module Hadolint.Rule.DL3024 (rule) where import qualified Data.Set as Set import Hadolint.Rule import Language.Docker.Syntax rule :: Rule args rule :: Rule args rule = (Linenumber -> State (Set Text) -> Instruction args -> State (Set Text)) -> State (Set Text) -> Rule args forall a args. (Linenumber -> State a -> Instruction args -> State a) -> State a -> Rule args customRule Linenumber -> State (Set Text) -> Instruction args -> State (Set Text) forall args. Linenumber -> State (Set Text) -> Instruction args -> State (Set Text) check (Set Text -> State (Set Text) forall a. a -> State a emptyState Set Text forall a. Set a Set.empty) where code :: RuleCode code = RuleCode "DL3024" severity :: DLSeverity severity = DLSeverity DLErrorC message :: Text message = Text "FROM aliases (stage names) must be unique" check :: Linenumber -> State (Set Text) -> Instruction args -> State (Set Text) check Linenumber line State (Set Text) st (From BaseImage {$sel:alias:BaseImage :: BaseImage -> Maybe ImageAlias alias = Just (ImageAlias Text als)}) = let newState :: State (Set Text) newState = State (Set Text) st State (Set Text) -> (State (Set Text) -> State (Set Text)) -> State (Set Text) forall a b. a -> (a -> b) -> b |> (Set Text -> Set Text) -> State (Set Text) -> State (Set Text) forall a. (a -> a) -> State a -> State a modify (Text -> Set Text -> Set Text forall a. Ord a => a -> Set a -> Set a Set.insert Text als) in if Text -> Set Text -> Bool forall a. Ord a => a -> Set a -> Bool Set.member Text als (State (Set Text) -> Set Text forall a. State a -> a state State (Set Text) st) then State (Set Text) newState State (Set Text) -> (State (Set Text) -> State (Set Text)) -> State (Set Text) forall a b. a -> (a -> b) -> b |> CheckFailure -> State (Set Text) -> State (Set Text) forall a. CheckFailure -> State a -> State a addFail CheckFailure :: RuleCode -> DLSeverity -> Text -> Linenumber -> CheckFailure CheckFailure {Linenumber Text RuleCode DLSeverity line :: Linenumber message :: Text severity :: DLSeverity code :: RuleCode line :: Linenumber message :: Text severity :: DLSeverity code :: RuleCode ..} else State (Set Text) newState check Linenumber _ State (Set Text) st Instruction args _ = State (Set Text) st {-# INLINEABLE rule #-}