summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorstuebinm2021-11-28 15:03:49 +0100
committerstuebinm2021-11-28 15:03:49 +0100
commita683b00fa1bc506be76919f4f0b166e595ef7a5b (patch)
tree2eb92e2568480894db7559c03e2ec80d480465fa /lib
parentc6e6293bb3a93816a2dbc3e19ab48d8b4695b964 (diff)
parentf9c693bff9f29a939afaa1e666a411464541210c (diff)
Merge branch 'main' of git.cccv.de:hub/walint
Diffstat (limited to 'lib')
-rw-r--r--lib/CheckDir.hs27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs
index b1b5830..3901336 100644
--- a/lib/CheckDir.hs
+++ b/lib/CheckDir.hs
@@ -57,28 +57,33 @@ data MissingDep = MissingDep
, neededBy :: [FilePath]
} deriving (Generic, ToJSON)
+-- | Missing assets are the same thing as missing dependencies,
+-- but should not be confused (and also serialise differently
+-- to json)
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 <= maxObservedLevel
- where maxObservedLevel = maximum
- . map hintLevel
- . concatMap (keys . mapresultLayer)
- . elems
- . dirresultMaps
- $ res
-
-
-
+ && configMaxLintLevel config <= maximumLintLevel res
+
+-- | 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
instance ToJSON DirResult where
toJSON res = A.object
[ "missingDeps" .= dirresultDeps res
, "missingAssets" .= dirresultMissingAssets res
, "mapLints" .= dirresultMaps res
+ , "severity" .= maximumLintLevel res
]
instance ToJSON MissingAsset where