From 887540e3bb4c2cfc63a142a573cc8161c5bc00d8 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sat, 25 Dec 2021 02:56:38 +0100 Subject: don't print doubled lints twice --- lib/CheckMap.hs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib/CheckMap.hs') diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index 51b4496..467fa26 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -30,8 +30,7 @@ import Properties (checkLayer, checkMap, checkTileset) import Tiled (Layer (layerLayers, layerName), LoadResult (..), Tiledmap (tiledmapLayers, tiledmapTilesets), - Tileset, loadTiledmap) -import TiledAbstract (HasName (..)) + loadTiledmap) import Types (Dep, Hint (Hint, hintLevel, hintMsg), Level (..), lintsToHints) import Util (PrettyPrint (prettyprint), prettyprint) @@ -40,9 +39,9 @@ import Util (PrettyPrint (prettyprint), prettyprint) -- | What this linter produces: lints for a single map data MapResult = MapResult - { mapresultLayer :: Map Hint [Layer] + { mapresultLayer :: Map Hint [Text] -- ^ lints that occurred in one or more layers - , mapresultTileset :: Map Hint [Tileset] + , mapresultTileset :: Map Hint [Text] -- ^ lints that occurred in one or more tilesets , mapresultDepends :: [Dep] -- ^ (external and local) dependencies of this map @@ -58,8 +57,8 @@ data MapResult = MapResult instance ToJSON MapResult where toJSON res = A.object - [ "layer" .= CollectedLints (fmap getName <$> mapresultLayer res) - , "tileset" .= CollectedLints (fmap getName <$> mapresultTileset res) + [ "layer" .= CollectedLints (mapresultLayer res) + , "tileset" .= CollectedLints (mapresultTileset res) , "general" .= mapresultGeneral res , "offers" .= mapresultProvides res ] @@ -178,7 +177,7 @@ instance PrettyPrint (Level, MapResult) where -- | pretty-prints a collection of Hints, printing each -- Hint only once, then a list of its occurences line-wrapped -- to fit onto a decent-sized terminal - prettyLints :: HasName a => (MapResult -> Map Hint [a]) -> [Text] + prettyLints :: (MapResult -> Map Hint [Text]) -> [Text] prettyLints getter = fmap (\(h, cs) -> prettyprint h <> "\n (in " @@ -188,7 +187,7 @@ instance PrettyPrint (Level, MapResult) where _ | l < 70 -> (l+2+T.length c, a <> ", " <> c) _ -> (6+T.length c, a <> ",\n " <> c) ) - (0, "") (fmap getName cs)) + (0, "") cs) <> ")\n") (toList . getter $ mapResult) -- cgit v1.2.3