diff options
Diffstat (limited to '')
-rw-r--r-- | lib/CheckDir.hs | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs index 3901336..d5ea440 100644 --- a/lib/CheckDir.hs +++ b/lib/CheckDir.hs @@ -64,25 +64,35 @@ newtype MissingAsset = MissingAsset MissingDep -- | given this config, should the result be considered to have failed? resultIsFatal :: LintConfig' -> DirResult -> Bool -resultIsFatal config res = - not (null (dirresultMissingAssets res)) - && configMaxLintLevel config <= maximumLintLevel res +resultIsFatal config res = maximumLintLevel res > configMaxLintLevel config -- | maximum lint level that was observed anywhere in any map. -- note that it really does go through all lints, so don't -- call it too often maximumLintLevel :: DirResult -> Level -maximumLintLevel = (\t -> if null t then Info else maximum t) - . map hintLevel - . concatMap (keys . mapresultLayer) - . elems - . dirresultMaps +maximumLintLevel res + | not (null (dirresultMissingAssets res)) = Fatal + | otherwise = + (\t -> if null t then Info else maximum t) + . map hintLevel + . concatMap (\map -> keys (mapresultLayer map) + <> keys (mapresultTileset map) + <> mapresultGeneral map + ) + . elems + . dirresultMaps + $ res + + instance ToJSON DirResult where - toJSON res = A.object - [ "missingDeps" .= dirresultDeps res - , "missingAssets" .= dirresultMissingAssets res - , "mapLints" .= dirresultMaps res + toJSON res = A.object [ + "result" .= A.object + [ "missingDeps" .= dirresultDeps res + , "missingAssets" .= dirresultMissingAssets res + , "mapLints" .= dirresultMaps res + ] + , "resultText" .= prettyprint (Suggestion, res) , "severity" .= maximumLintLevel res ] |