diff options
author | stuebinm | 2021-11-28 22:24:30 +0100 |
---|---|---|
committer | stuebinm | 2021-11-28 22:26:48 +0100 |
commit | efb64e0228c19ef7936446d3ca14a7d7a6e2540b (patch) | |
tree | b9988c843847ed19e1e9fce2f3072a318f489f81 /lib/CheckDir.hs | |
parent | a683b00fa1bc506be76919f4f0b166e595ef7a5b (diff) |
various fixes to bugs
Among them
- always set correct exit codes
- refuse to write out files if the out path already exists
- calculate the overall severity correctly
- slightly changed the json output schema
- also output the text output format in json
- make the default config.json suitable for a production environment
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 ] |