Skip to content
Snippets Groups Projects
Commit 7b76bada authored by stuebinm's avatar stuebinm
Browse files

correct recognision of entrypoints in sublayers

also, the recursive check layer function slowly approaches something
like readability!
parent 53f71bca
Branches
No related tags found
No related merge requests found
...@@ -61,6 +61,7 @@ instance ToJSON MapResult where ...@@ -61,6 +61,7 @@ instance ToJSON MapResult where
[ "layer" .= CollectedLints (fmap getName <$> mapresultLayer res) [ "layer" .= CollectedLints (fmap getName <$> mapresultLayer res)
, "tileset" .= CollectedLints (fmap getName <$> mapresultTileset res) , "tileset" .= CollectedLints (fmap getName <$> mapresultTileset res)
, "general" .= mapresultGeneral res , "general" .= mapresultGeneral res
, "offers" .= mapresultProvides res
] ]
newtype CollectedLints = CollectedLints (Map Hint [Text]) newtype CollectedLints = CollectedLints (Map Hint [Text])
...@@ -143,22 +144,26 @@ checkLayerRec config depth layers = ...@@ -143,22 +144,26 @@ checkLayerRec config depth layers =
(runLintWriter config parent depth checkLayer,[]) (runLintWriter config parent depth checkLayer,[])
-- this is a group layer. Fun! -- this is a group layer. Fun!
Just sublayers -> Just sublayers ->
let (parentResult, subresults)
-- before linting, append the group's top-level name to that of sublayers where
results = take (length sublayers) -- Lintresults for sublayers with adjusted names
$ checkLayerRec config depth $ sublayers subresults :: [LintResult Layer]
<&> \l -> l { layerName = layerName parent <> "/" <> layerName l } subresults =
-- get the original sublayer names take (length sublayers)
names = fmap layerName sublayers . fmap (fmap (\l -> l { layerName = layerName parent <> "/" <> layerName l } ))
-- pass the adjusted sublayers on to linting the parent layer, $ subresults'
-- but restore the actual names of sublayers
result = runLintWriter config -- Lintresults for sublayers and subsublayers etc.
(parent { layerLayers = Just subresults' =
$ zipWith (\n l -> (resultToAdjusted l) { layerName = n }) checkLayerRec config depth
names results $ sublayers
}
) depth checkLayer -- lintresult for the parent layer
in (result,results) parentResult = runLintWriter config parentAdjusted depth (checkLayer)
-- the parent layer with adjusted sublayers
parentAdjusted =
parent { layerLayers = Just (fmap resultToAdjusted subresults') }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
{-# LANGUAGE DeriveFunctor #-}
{-# OPTIONS_GHC -Wno-missing-signatures #-} {-# OPTIONS_GHC -Wno-missing-signatures #-}
-- | a monad that collects warnings, outputs, etc, -- | a monad that collects warnings, outputs, etc,
...@@ -67,6 +68,7 @@ type LintWriter' ctxt res = ...@@ -67,6 +68,7 @@ type LintWriter' ctxt res =
-- | it already collected. -- | it already collected.
newtype LinterState ctxt = LinterState newtype LinterState ctxt = LinterState
{ fromLinterState :: ([Lint], ctxt)} { fromLinterState :: ([Lint], ctxt)}
deriving Functor
-- | The result of running a linter: an adjusted context, and a list of lints. -- | The result of running a linter: an adjusted context, and a list of lints.
-- | This is actually just a type synonym of LinterState, but kept seperately -- | This is actually just a type synonym of LinterState, but kept seperately
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment