diff options
author | stuebinm | 2021-09-20 22:30:22 +0200 |
---|---|---|
committer | stuebinm | 2021-09-20 22:30:22 +0200 |
commit | 42df3cf0eb0c5877ac3320994cadec07619bcd6b (patch) | |
tree | cbe11c6cc138ab5a303ec9ba4105dfd00df243f1 /lib/CheckMap.hs | |
parent | 9a8d793f8f08fd5674bc6a917278ee7251bac56f (diff) |
typechecking for path depths!
This now checks if relative paths are still inside the repository, as a
general safety mechanism to stop the linter from accidentally reading
other things, as well as a nice hint for users.
Diffstat (limited to '')
-rw-r--r-- | lib/CheckMap.hs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index b32bad6..3966988 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -16,7 +16,7 @@ import qualified Data.Text as T import qualified Data.Vector as V import GHC.Generics (Generic) -import LintWriter (LayerContext (..), LintResult (..), LintWriter, +import LintWriter (LintResult (..), LintWriter, askContext, lintToDep, resultToDeps, resultToLints, runLintWriter) import Properties (checkLayerProperty, checkMap) @@ -29,7 +29,7 @@ import Util (PrettyPrint (prettyprint), prettyprint) -- | What this linter produces: lints for a single map data MapResult a = MapResult - { mapresultLayer :: Maybe (Map Text (LintResult LayerContext)) + { mapresultLayer :: Maybe (Map Text (LintResult Layer)) , mapresultGeneral :: [Lint] , mapresultDepends :: [Dep] } deriving (Generic, ToJSON) @@ -59,20 +59,21 @@ runLinter tiledmap = MapResult <> mapMaybe lintToDep generalLints } where - layerMap :: Map Text (LintResult LayerContext) + layerMap :: Map Text (LintResult Layer) layerMap = fromList layer layer = V.toList . V.map runCheck $ tiledmapLayers tiledmap - where runCheck l = (layerName l, runLintWriter (LayerContext ()) (checkLayer l)) + where runCheck l = (layerName l, runLintWriter l 0 checkLayer) -- lints collected from properties generalLints = - resultToLints $ runLintWriter () (checkMap tiledmap) + resultToLints $ runLintWriter tiledmap 0 checkMap -- | collect lints on a single map layer -checkLayer :: Layer -> LintWriter LayerContext -checkLayer layer = - mapM_ (checkLayerProperty layer) (layerProperties layer) +checkLayer :: LintWriter Layer +checkLayer = do + layer <- askContext + mapM_ checkLayerProperty (layerProperties layer) -- human-readable lint output, e.g. for consoles instance PrettyPrint a => PrettyPrint (MapResult a) where |