module Hadolint.Rule.DL3019 (rule) where import Hadolint.Rule import Hadolint.Shell (ParsedShell) import qualified Hadolint.Shell as Shell import Language.Docker.Syntax rule :: Rule ParsedShell rule :: Rule ParsedShell rule = RuleCode -> DLSeverity -> Text -> (Instruction ParsedShell -> Bool) -> Rule ParsedShell forall args. RuleCode -> DLSeverity -> Text -> (Instruction args -> Bool) -> Rule args simpleRule RuleCode code DLSeverity severity Text message Instruction ParsedShell -> Bool check where code :: RuleCode code = RuleCode "DL3019" severity :: DLSeverity severity = DLSeverity DLInfoC message :: Text message = Text "Use the `--no-cache` switch to avoid the need to use `--update` and remove \ \`/var/cache/apk/*` when done installing packages" check :: Instruction ParsedShell -> Bool check (Run (RunArgs Arguments ParsedShell args RunFlags _)) = (ParsedShell -> Bool) -> Arguments ParsedShell -> Bool forall a b. (a -> b) -> Arguments a -> b foldArguments ((Command -> Bool) -> ParsedShell -> Bool Shell.noCommands Command -> Bool forgotCacheOption) Arguments ParsedShell args check Instruction ParsedShell _ = Bool True forgotCacheOption :: Command -> Bool forgotCacheOption Command cmd = Text -> [Text] -> Command -> Bool Shell.cmdHasArgs Text "apk" [Text "add"] Command cmd Bool -> Bool -> Bool && Bool -> Bool not (Text -> Command -> Bool Shell.hasFlag Text "no-cache" Command cmd) {-# INLINEABLE rule #-}