summaryrefslogtreecommitdiff
path: root/lib/CheckMap.hs
diff options
context:
space:
mode:
authorstuebinm2021-11-14 03:09:50 +0100
committerstuebinm2021-11-14 03:09:50 +0100
commit52b73711fc21e121267318677840a54fbe174b10 (patch)
treec6e65874b376ca5d0712930796908c3e4f6490d7 /lib/CheckMap.hs
parent24a0763b4b0a87b5abd488ebca67f4c5ff9b966d (diff)
Functional jitsiRoomAdminTag adjustment
also yet another typeclass™, because why not?
Diffstat (limited to 'lib/CheckMap.hs')
-rw-r--r--lib/CheckMap.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs
index 1b42854..962da22 100644
--- a/lib/CheckMap.hs
+++ b/lib/CheckMap.hs
@@ -21,6 +21,7 @@ import qualified Data.Vector as V
import GHC.Generics (Generic)
+import LintConfig (LintConfig')
import LintWriter (filterLintLevel, invertLintResult, lintToDep,
resultToAdjusted, resultToDeps,
resultToLints, resultToOffers, runLintWriter)
@@ -71,19 +72,19 @@ instance ToJSON CollectedLints where
-- | this module's raison d'être
-- Lints the map at `path`, and limits local links to at most `depth`
-- layers upwards in the file hierarchy
-loadAndLintMap :: FilePath -> Int -> IO (Maybe MapResult)
-loadAndLintMap path depth = loadTiledmap path <&> (\case
+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 $
path <> ": Fatal: " <> err
])
IOErr _ -> Nothing
Loaded waMap ->
- Just (runLinter waMap depth))
+ Just (runLinter config waMap depth))
-- | lint a loaded map
-runLinter :: Tiledmap -> Int -> MapResult
-runLinter tiledmap depth = MapResult
+runLinter :: LintConfig' -> Tiledmap -> Int -> MapResult
+runLinter config tiledmap depth = MapResult
{ mapresultLayer = invertThing layer
, mapresultTileset = invertThing tileset
, mapresultGeneral = resultToLints generalResult
@@ -96,10 +97,10 @@ runLinter tiledmap depth = MapResult
where
layer = checkThing tiledmapLayers checkLayer
tileset = checkThing tiledmapTilesets checkTileset
- generalResult = runLintWriter tiledmap depth checkMap
+ generalResult = runLintWriter config tiledmap depth checkMap
checkThing getter checker = V.toList . V.map runCheck $ getter tiledmap
- where runCheck thing = runLintWriter thing depth checker
+ where runCheck thing = runLintWriter config thing depth checker
-- | "inverts" a LintResult, i.e. groups it by lints instead of
-- layers / maps