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