module Hadolint.Rule.DL3051 (rule) where import qualified Data.Map as Map import qualified Data.Text as Text import Hadolint.Rule import Language.Docker.Syntax rule :: LabelSchema -> Rule args rule :: forall args. LabelSchema -> Rule args rule LabelSchema labelschema = [Rule args] -> Rule args forall a. Monoid a => [a] -> a mconcat ([Rule args] -> Rule args) -> [Rule args] -> Rule args forall a b. (a -> b) -> a -> b $ (Text -> Rule args) -> [Text] -> [Rule args] forall a b. (a -> b) -> [a] -> [b] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Text -> Rule args forall args. Text -> Rule args labelIsNotEmptyRule (LabelSchema -> [Text] forall k a. Map k a -> [k] Map.keys LabelSchema labelschema) {-# INLINEABLE rule #-} labelIsNotEmptyRule :: LabelName -> Rule args labelIsNotEmptyRule :: forall args. Text -> Rule args labelIsNotEmptyRule Text label = RuleCode -> DLSeverity -> Text -> (Instruction args -> Bool) -> Rule args forall args. RuleCode -> DLSeverity -> Text -> (Instruction args -> Bool) -> Rule args simpleRule RuleCode code DLSeverity severity Text message Instruction args -> Bool forall {args}. Instruction args -> Bool check where code :: RuleCode code = RuleCode "DL3051" severity :: DLSeverity severity = DLSeverity DLWarningC message :: Text message = Text "label `" Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text label Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text "` is empty." check :: Instruction args -> Bool check (Label Pairs pairs) = Pairs -> Bool forall a. [a] -> Bool forall (t :: * -> *) a. Foldable t => t a -> Bool null (Pairs -> Bool) -> Pairs -> Bool forall a b. (a -> b) -> a -> b $ Text -> Pairs -> Pairs getEmptyLabels Text label Pairs pairs check Instruction args _ = Bool True getEmptyLabels :: LabelName -> Pairs -> Pairs getEmptyLabels :: Text -> Pairs -> Pairs getEmptyLabels Text lbl Pairs prs = [(Text l, Text v) | (Text l, Text v) <- Pairs prs, Text l Text -> Text -> Bool forall a. Eq a => a -> a -> Bool == Text lbl, Text -> Bool Text.null Text v]