module Hadolint
  ( module Hadolint.Lint,
    module Hadolint.Process,
    module Hadolint.Config,
    Result (..),
    OutputFormat (..),
    shallSkipErrorStatus,
    printResults,
  )
where

import Data.Text (Text)
import Hadolint.Config
import qualified Hadolint.Formatter.Checkstyle
import qualified Hadolint.Formatter.Codacy
import qualified Hadolint.Formatter.Codeclimate
import Hadolint.Formatter.Format (Result (..))
import qualified Hadolint.Formatter.Json
import qualified Hadolint.Formatter.TTY
import Hadolint.Lint
import Hadolint.Process
import Language.Docker.Parser (DockerfileError)

data OutputFormat
  = Json
  | TTY
  | CodeclimateJson
  | GitlabCodeclimateJson
  | Checkstyle
  | Codacy
  deriving (Int -> OutputFormat -> ShowS
[OutputFormat] -> ShowS
OutputFormat -> String
(Int -> OutputFormat -> ShowS)
-> (OutputFormat -> String)
-> ([OutputFormat] -> ShowS)
-> Show OutputFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputFormat] -> ShowS
$cshowList :: [OutputFormat] -> ShowS
show :: OutputFormat -> String
$cshow :: OutputFormat -> String
showsPrec :: Int -> OutputFormat -> ShowS
$cshowsPrec :: Int -> OutputFormat -> ShowS
Show, OutputFormat -> OutputFormat -> Bool
(OutputFormat -> OutputFormat -> Bool)
-> (OutputFormat -> OutputFormat -> Bool) -> Eq OutputFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputFormat -> OutputFormat -> Bool
$c/= :: OutputFormat -> OutputFormat -> Bool
== :: OutputFormat -> OutputFormat -> Bool
$c== :: OutputFormat -> OutputFormat -> Bool
Eq)

shallSkipErrorStatus :: OutputFormat -> Bool
shallSkipErrorStatus :: OutputFormat -> Bool
shallSkipErrorStatus OutputFormat
format = OutputFormat
format OutputFormat -> [OutputFormat] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [OutputFormat
CodeclimateJson, OutputFormat
Codacy]

printResults :: Foldable f => OutputFormat -> Bool -> f (Result Text DockerfileError) -> IO ()
printResults :: OutputFormat -> Bool -> f (Result Text DockerfileError) -> IO ()
printResults OutputFormat
format Bool
nocolor f (Result Text DockerfileError)
allResults =
  case OutputFormat
format of
    OutputFormat
TTY -> f (Result Text DockerfileError) -> Bool -> IO ()
forall s e (f :: * -> *).
(VisualStream s, TraversableStream s, ShowErrorComponent e,
 Foldable f) =>
f (Result s e) -> Bool -> IO ()
Hadolint.Formatter.TTY.printResults f (Result Text DockerfileError)
allResults Bool
nocolor
    OutputFormat
Json -> f (Result Text DockerfileError) -> IO ()
forall s e (f :: * -> *).
(VisualStream s, TraversableStream s, ShowErrorComponent e,
 Foldable f) =>
f (Result s e) -> IO ()
Hadolint.Formatter.Json.printResults f (Result Text DockerfileError)
allResults
    OutputFormat
Checkstyle -> f (Result Text DockerfileError) -> IO ()
forall (f :: * -> *) s e.
(Foldable f, VisualStream s, TraversableStream s,
 ShowErrorComponent e) =>
f (Result s e) -> IO ()
Hadolint.Formatter.Checkstyle.printResults f (Result Text DockerfileError)
allResults
    OutputFormat
CodeclimateJson -> f (Result Text DockerfileError) -> IO ()
forall s e (f :: * -> *).
(VisualStream s, TraversableStream s, ShowErrorComponent e,
 Foldable f) =>
f (Result s e) -> IO ()
Hadolint.Formatter.Codeclimate.printResults f (Result Text DockerfileError)
allResults
    OutputFormat
GitlabCodeclimateJson -> f (Result Text DockerfileError) -> IO ()
forall (f :: * -> *) s e.
(Foldable f, VisualStream s, TraversableStream s,
 ShowErrorComponent e) =>
f (Result s e) -> IO ()
Hadolint.Formatter.Codeclimate.printGitlabResults f (Result Text DockerfileError)
allResults
    OutputFormat
Codacy -> f (Result Text DockerfileError) -> IO ()
forall (f :: * -> *) s e.
(Foldable f, VisualStream s, TraversableStream s,
 ShowErrorComponent e) =>
f (Result s e) -> IO ()
Hadolint.Formatter.Codacy.printResults f (Result Text DockerfileError)
allResults