hadolint 2.9.2 → 2.9.3
raw patch · 7 files changed
+141/−8 lines, 7 filesdep ~language-dockerPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: language-docker
API changes (from Hackage documentation)
+ Hadolint.Formatter: Gnu :: OutputFormat
+ Hadolint.Formatter.Format: Gnu :: OutputFormat
+ Hadolint.Formatter.Gnu: printResults :: (VisualStream s, TraversableStream s, ShowErrorComponent e, Foldable f) => f (Result s e) -> IO ()
Files
- README.md +3/−3
- hadolint.cabal +6/−4
- src/Hadolint/Config/Commandline.hs +1/−1
- src/Hadolint/Formatter.hs +2/−0
- src/Hadolint/Formatter/Format.hs +3/−0
- src/Hadolint/Formatter/Gnu.hs +72/−0
- test/Hadolint/Formatter/GnuSpec.hs +54/−0
README.md view
@@ -150,7 +150,7 @@ -V,--verbose Enables verbose logging of hadolint's output to stderr -f,--format ARG The output format for the results [tty | json |- checkstyle | codeclimate | gitlab_codeclimate |+ checkstyle | codeclimate | gitlab_codeclimate | gnu | codacy | sonarqube | sarif] (default: tty) --error RULECODE Make the rule `RULECODE` have the level `error` --warning RULECODE Make the rule `RULECODE` have the level `warning`@@ -194,7 +194,7 @@ ```yaml failure-threshold: string # name of threshold level (error | warning | info | style | ignore | none)-format: string # Output format (tty | json | checkstyle | codeclimate | gitlab_codeclimate | codacy)+format: string # Output format (tty | json | checkstyle | codeclimate | gitlab_codeclimate | gnu | codacy) ignored: [string] # list of rules label-schema: # See Linting Labels below for specific label-schema details author: string # Your name@@ -291,7 +291,7 @@ NO_COLOR=1 # Set or unset. See https://no-color.org HADOLINT_NOFAIL=1 # Truthy value e.g. 1, true or yes HADOLINT_VERBOSE=1 # Truthy value e.g. 1, true or yes-HADOLINT_FORMAT=json # Output format (tty | json | checkstyle | codeclimate | gitlab_codeclimate | codacy | sarif )+HADOLINT_FORMAT=json # Output format (tty | json | checkstyle | codeclimate | gitlab_codeclimate | gnu | codacy | sarif ) HADOLINT_FAILURE_THRESHOLD=info # threshold level (error | warning | info | style | ignore | none) HADOLINT_OVERRIDE_ERROR=DL3010,DL3020 # comma separated list of rule codes HADOLINT_OVERRIDE_WARNING=DL3010,DL3020 # comma separated list of rule codes
hadolint.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: hadolint-version: 2.9.2+version: 2.9.3 synopsis: Dockerfile Linter JavaScript API description: A smarter Dockerfile linter that helps you build best practice Docker images. category: Development@@ -41,6 +41,7 @@ Hadolint.Formatter.Codacy Hadolint.Formatter.Codeclimate Hadolint.Formatter.Format+ Hadolint.Formatter.Gnu Hadolint.Formatter.Json Hadolint.Formatter.Sarif Hadolint.Formatter.SonarQube@@ -154,7 +155,7 @@ , foldl , gitrev >=1.3.1 , ilist- , language-docker >=10.4.2 && <11+ , language-docker >=10.4.3 && <11 , megaparsec >=9.0.0 , mtl , network-uri@@ -194,7 +195,7 @@ , containers , data-default , hadolint- , language-docker >=10.4.2 && <11+ , language-docker >=10.4.3 && <11 , megaparsec >=9.0.0 , optparse-applicative >=0.14.0 , prettyprinter >=1.7.0@@ -212,6 +213,7 @@ Hadolint.Config.ConfigurationSpec Hadolint.Config.EnvironmentSpec Hadolint.Config.SpecHook+ Hadolint.Formatter.GnuSpec Hadolint.Formatter.ParseErrorSpec Hadolint.Formatter.SarifSpec Hadolint.Formatter.TTYSpec@@ -315,7 +317,7 @@ , foldl , hadolint , hspec >=2.8.3- , language-docker >=10.4.2 && <11+ , language-docker >=10.4.3 && <11 , megaparsec >=9.0.0 , optparse-applicative >=0.14.0 , silently
src/Hadolint/Config/Commandline.hs view
@@ -137,7 +137,7 @@ <> short 'f' -- options for the output format <> help "The output format for the results [tty | json | checkstyle |\- \ codeclimate | gitlab_codeclimate | codacy | sonarqube |\+ \ codeclimate | gitlab_codeclimate | gnu | codacy | sonarqube |\ \ sarif] (default: tty)" <> completeWith [ "tty",
src/Hadolint/Formatter.hs view
@@ -12,6 +12,7 @@ import qualified Hadolint.Formatter.Checkstyle as FormatCheckstyle import qualified Hadolint.Formatter.Codacy as FormatCodacy import qualified Hadolint.Formatter.Codeclimate as FormatCodeclimate+import qualified Hadolint.Formatter.Gnu as FormatGnu import qualified Hadolint.Formatter.Json as FormatJson import qualified Hadolint.Formatter.Sarif as FormatSarif import qualified Hadolint.Formatter.SonarQube as FormatSonarQube@@ -31,6 +32,7 @@ Codacy -> FormatCodacy.printResults allResults CodeclimateJson -> FormatCodeclimate.printResults allResults GitlabCodeclimateJson -> FormatCodeclimate.printGitlabResults allResults+ Gnu -> FormatGnu.printResults allResults Json -> FormatJson.printResults allResults Sarif -> FormatSarif.printResults allResults SonarQube -> FormatSonarQube.printResults allResults
src/Hadolint/Formatter/Format.hs view
@@ -33,6 +33,7 @@ | TTY | CodeclimateJson | GitlabCodeclimateJson+ | Gnu | Checkstyle | Codacy | Sarif@@ -44,6 +45,7 @@ pretty TTY = "tty" pretty CodeclimateJson = "codeclimate" pretty GitlabCodeclimateJson = "gitlab_codeclimate"+ pretty Gnu = "gnu" pretty Checkstyle = "checkstyle" pretty Codacy = "codacy" pretty Sarif = "sarif"@@ -76,6 +78,7 @@ readMaybeOutputFormat "tty" = Just TTY readMaybeOutputFormat "codeclimate" = Just CodeclimateJson readMaybeOutputFormat "gitlab_codeclimate" = Just GitlabCodeclimateJson+readMaybeOutputFormat "gnu" = Just Gnu readMaybeOutputFormat "checkstyle" = Just Checkstyle readMaybeOutputFormat "codacy" = Just Codacy readMaybeOutputFormat "sarif" = Just Sarif
+ src/Hadolint/Formatter/Gnu.hs view
@@ -0,0 +1,72 @@+-- | Hadolint GNU Format Output+--+-- See https://www.gnu.org/prep/standards/html_node/Errors.html for reference.++module Hadolint.Formatter.Gnu+ ( printResults,+ )+where+++import Data.Text (Text, pack)+import Hadolint.Formatter.Format+import Hadolint.Rule (CheckFailure (..), RuleCode (..))+import Text.Megaparsec (TraversableStream)+import Text.Megaparsec.Error+import Text.Megaparsec.Stream (VisualStream)+import qualified Data.List.NonEmpty as NonEmpty+import qualified Data.Text.IO as TextIO+++printResults ::+ (VisualStream s, TraversableStream s, ShowErrorComponent e, Foldable f) =>+ f (Result s e) ->+ IO ()+printResults = mapM_ printResult+++printResult ::+ (VisualStream s, TraversableStream s, ShowErrorComponent e) =>+ Result s e ->+ IO ()+printResult (Result filename errors checks) =+ printErrors errors >> printChecks filename checks+++printErrors ::+ (VisualStream s, TraversableStream s, ShowErrorComponent e, Foldable f) =>+ f (ParseErrorBundle s e) ->+ IO ()+printErrors = mapM_ (TextIO.putStrLn . formatError)+++printChecks :: (Foldable f) => Text -> f CheckFailure -> IO ()+printChecks filename = mapM_ (TextIO.putStrLn . formatCheck filename)+++formatError ::+ (VisualStream s, TraversableStream s, ShowErrorComponent e) =>+ ParseErrorBundle s e ->+ Text+formatError err@(ParseErrorBundle e _) =+ pack $+ "hadolint:"+ <> stripNewlines+ ( errorPositionPretty err+ <> ": "+ <> parseErrorTextPretty (NonEmpty.head e)+ )+++formatCheck :: Text -> CheckFailure -> Text+formatCheck source (CheckFailure code severity message line) =+ "hadolint:"+ <> source+ <> ":"+ <> pack (show line)+ <> ": "+ <> unRuleCode code+ <> " "+ <> severityText severity+ <> ": "+ <> message
+ test/Hadolint/Formatter/GnuSpec.hs view
@@ -0,0 +1,54 @@+module Hadolint.Formatter.GnuSpec (spec) where+++import Helpers+import Hadolint+ ( CheckFailure (..),+ DLSeverity (..),+ OutputFormat (..),+ )+import Test.Hspec+++spec :: SpecWith ()+spec = do+ let ?noColor = False++ describe "Formatter: Gnu" $ do+ it "print empty results" $ do+ let checkFails = []+ expectation = ""+ assertFormatter Gnu checkFails expectation++ it "print one failed rule" $ do+ let checkFails =+ [ CheckFailure+ { code = "DL2001",+ severity = DLWarningC,+ message = "test",+ line = 1+ }+ ]+ expectation =+ "hadolint:<string>:1: DL2001 warning: test\n"+ assertFormatter Gnu checkFails expectation++ it "print multiple failed rules" $ do+ let checkFails =+ [ CheckFailure+ { code = "DL2001",+ severity = DLWarningC,+ message = "test",+ line = 1+ },+ CheckFailure+ { code = "DL2003",+ severity = DLInfoC,+ message = "test 2",+ line = 3+ }+ ]+ expectation =+ "hadolint:<string>:1: DL2001 warning: test\n\+ \hadolint:<string>:3: DL2003 info: test 2\n"+ assertFormatter Gnu checkFails expectation