summaryrefslogtreecommitdiff
path: root/lib/CheckDir.hs
diff options
context:
space:
mode:
authorstuebinm2021-12-29 04:49:46 +0100
committerstuebinm2021-12-29 04:56:19 +0100
commit0419aa9918723c8b74252bf6ff1a2162c2f3a89a (patch)
tree6c793ecd95e1653024f4cb73675ab2a400c7221c /lib/CheckDir.hs
parent436a7dbb734f58a254bed6c9d28908033b537bf8 (diff)
maps, maps, and yet more maps
don't add maps to the result if their lint result looks the same as that of another list, just say it happened several times instead (this leads to a rather confusing Eq instance for MapResult which implements a very simple surface-level equality — perhaps change that later)
Diffstat (limited to '')
-rw-r--r--lib/CheckDir.hs20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs
index 59c6f2f..cb4f886 100644
--- a/lib/CheckDir.hs
+++ b/lib/CheckDir.hs
@@ -14,8 +14,10 @@ import Control.Monad (void)
import Control.Monad.Extra (mapMaybeM)
import Data.Aeson (ToJSON, (.=))
import qualified Data.Aeson as A
+import Data.Bifunctor (first)
import Data.Foldable (fold)
import Data.Functor ((<&>))
+import Data.List (partition)
import Data.Map (Map, elems, keys)
import qualified Data.Map as M
import Data.Map.Strict (mapKeys, mapWithKey, (\\))
@@ -34,7 +36,7 @@ import System.FilePath.Posix (takeDirectory)
import Text.Dot (Dot, showDot)
import Types (Dep (Local, LocalMap), Hint (Hint),
Level (..), hintLevel)
-import Util (PrettyPrint (prettyprint))
+import Util (PrettyPrint (prettyprint), ellipsis)
-- based on the startling observation that Data.Map has lower complexity
@@ -97,13 +99,25 @@ instance ToJSON DirResult where
"result" .= A.object
[ "missingDeps" .= dirresultDeps res
, "missingAssets" .= dirresultMissingAssets res
- , "mapLints" .= dirresultMaps res
- , "exitGraph" .= showDot (dirresultGraph res)
+ -- some repos have auto-generated maps which are basically all the
+ -- same; aggregate those to reduce output size
+ , "mapLints" .= (M.fromList
+ . fmap (first (ellipsis 6))
+ . foldr aggregateSameResults []
+ . M.toList
+ $ dirresultMaps res)
+ -- unused in the hub, temporarily removed to make the output smaller
+ -- , "exitGraph" .= showDot (dirresultGraph res)
]
, "severity" .= maximumLintLevel res
, "mapInfo" .= fmap (\tm -> A.object [ "badges" .= mapresultBadges tm ])
(dirresultMaps res)
]
+ where
+ aggregateSameResults (path,res) acc =
+ case partition (\(_,res') -> res == res') acc of
+ ([],_) -> ([T.pack path], res):acc
+ ((paths,_):_,acc') -> (T.pack path:paths, res) : acc'
instance ToJSON MissingAsset where
toJSON (MissingAsset md) = A.object