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/CheckMap.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/CheckMap.hs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index 5d50f3f..8a2ad7e 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -32,8 +32,8 @@ import Tiled2 (HasName (getName), LoadResult (..), Tiledmap (tiledmapLayers, tiledmapTilesets), Tileset, loadTiledmap) -import Types (Dep, Hint (hintLevel, hintMsg), Level (..), - Lint (..), hint) +import Types (Dep, Hint (Hint, hintLevel, hintMsg), + Level (..), Lint (..), hint, lintsToHints) import Util (PrettyPrint (prettyprint), prettyprint) @@ -50,7 +50,7 @@ data MapResult = MapResult -- ^ entrypoints provided by this map (needed for dependency checking) , mapresultAdjusted :: Maybe Tiledmap -- ^ the loaded map, with adjustments by the linter - , mapresultGeneral :: [Lint] + , mapresultGeneral :: [Hint] -- ^ general-purpose lints that didn't fit anywhere else } deriving (Generic) @@ -78,7 +78,7 @@ instance ToJSON CollectedLints where loadAndLintMap :: LintConfig' -> FilePath -> Int -> IO (Maybe MapResult) loadAndLintMap config path depth = loadTiledmap path <&> (\case DecodeErr err -> Just (MapResult mempty mempty mempty mempty Nothing - [ hint Fatal . T.pack $ + [ Hint Fatal . T.pack $ path <> ": Fatal: " <> err ]) IOErr _ -> Nothing @@ -90,7 +90,7 @@ runLinter :: LintConfig' -> Tiledmap -> Int -> MapResult runLinter config tiledmap depth = MapResult { mapresultLayer = invertThing layer , mapresultTileset = invertThing tileset - , mapresultGeneral = resultToLints generalResult + , mapresultGeneral = lintsToHints $ resultToLints generalResult , mapresultDepends = mapMaybe lintToDep (resultToLints generalResult) <> concatMap resultToDeps layer <> concatMap resultToDeps tileset @@ -187,5 +187,4 @@ instance PrettyPrint (Level, MapResult) where prettyGeneral :: [Text] prettyGeneral = map ((<> "\n") . prettyprint) - . filterLintLevel level $ mapresultGeneral mapResult |