Skip to content
Snippets Groups Projects
Commit 61e66f41 authored by stuebinm's avatar stuebinm
Browse files

add a severity attribute to the json output

parent 95323a5c
No related branches found
No related tags found
No related merge requests found
Pipeline #8485 passed
...@@ -57,28 +57,33 @@ data MissingDep = MissingDep ...@@ -57,28 +57,33 @@ data MissingDep = MissingDep
, neededBy :: [FilePath] , neededBy :: [FilePath]
} deriving (Generic, ToJSON) } 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 newtype MissingAsset = MissingAsset MissingDep
-- | given this config, should the result be considered to have failed?
resultIsFatal :: LintConfig' -> DirResult -> Bool resultIsFatal :: LintConfig' -> DirResult -> Bool
resultIsFatal config res = resultIsFatal config res =
not (null (dirresultMissingAssets res)) not (null (dirresultMissingAssets res))
&& configMaxLintLevel config <= maxObservedLevel && configMaxLintLevel config <= maximumLintLevel res
where maxObservedLevel = maximum
. map hintLevel -- | maximum lint level that was observed anywhere in any map.
. concatMap (keys . mapresultLayer) -- note that it really does go through all lints, so don't
. elems -- call it too often
. dirresultMaps maximumLintLevel :: DirResult -> Level
$ res maximumLintLevel = maximum
. map hintLevel
. concatMap (keys . mapresultLayer)
. elems
. dirresultMaps
instance ToJSON DirResult where instance ToJSON DirResult where
toJSON res = A.object toJSON res = A.object
[ "missingDeps" .= dirresultDeps res [ "missingDeps" .= dirresultDeps res
, "missingAssets" .= dirresultMissingAssets res , "missingAssets" .= dirresultMissingAssets res
, "mapLints" .= dirresultMaps res , "mapLints" .= dirresultMaps res
, "severity" .= maximumLintLevel res
] ]
instance ToJSON MissingAsset where instance ToJSON MissingAsset where
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment