From efb64e0228c19ef7936446d3ca14a7d7a6e2540b Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sun, 28 Nov 2021 22:24:30 +0100 Subject: 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 --- lib/CheckMap.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/CheckMap.hs') 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 -- cgit v1.2.3