module Hadolint.Rule.DL3010 (rule) where

import Data.Foldable (toList)
import qualified Data.Text as Text
import Hadolint.Rule
import Language.Docker.Syntax

rule :: Rule args
rule :: Rule args
rule = 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
"DL3010"
    severity :: DLSeverity
severity = DLSeverity
DLInfoC
    message :: Text
message = Text
"Use ADD for extracting archives into an image"
    check :: Instruction args -> Bool
check (Copy (CopyArgs NonEmpty SourcePath
srcs TargetPath
_ Chown
_ Chmod
_ CopySource
NoSource)) =
      [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and
        [ Bool -> Bool
not (Text
format Text -> Text -> Bool
`Text.isSuffixOf` Text
src)
          | SourcePath Text
src <- NonEmpty SourcePath -> [SourcePath]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty SourcePath
srcs,
            Text
format <- [Text]
archiveFileFormatExtensions
        ]
    check Instruction args
_ = Bool
True
{-# INLINEABLE rule #-}