From 7e9941bf90644120b3627d0f0f66204fed9efb2a Mon Sep 17 00:00:00 2001 From: stuebinm Date: Mon, 4 Apr 2022 00:10:56 +0200 Subject: linter: collect content warnings --- lib/LintWriter.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/LintWriter.hs') diff --git a/lib/LintWriter.hs b/lib/LintWriter.hs index bf2eb3e..87bad02 100644 --- a/lib/LintWriter.hs +++ b/lib/LintWriter.hs @@ -40,7 +40,7 @@ module LintWriter , lintConfig -- * adjust the linter's context , adjust - ) where + ,offersCWs,resultToCWs) where import Universum @@ -122,6 +122,11 @@ resultToBadges (LinterState a) = mapMaybe lintToBadge $ fst a where lintToBadge (Badge badge) = Just badge lintToBadge _ = Nothing +resultToCWs :: LintResult a -> [Text] +resultToCWs (LinterState a) = fold $ mapMaybe lintToCW $ fst a + where lintToCW = \case (CW cw) -> Just cw; _ -> Nothing + + -- | convert a lint result into a flat list of lints resultToLints :: LintResult a -> [Lint] resultToLints (LinterState res) = fst res @@ -152,6 +157,8 @@ offersEntrypoint text = tell' $ Offers text offersBadge :: Badge -> LintWriter a offersBadge badge = tell' $ Badge badge +offersCWs :: [Text] -> LintWriter a +offersCWs = tell' . CW -- | get the context as it was initially, without any modifications -- cgit v1.2.3