SQUASH: --severity specifies *minimum* severity to be handled

Signed-off-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Martin Schwenke 2018-08-17 11:12:24 +10:00 committed by Vidar Holen
parent b16da4b242
commit 3fe11927bb
4 changed files with 8 additions and 8 deletions

View File

@ -58,7 +58,7 @@ not warn at all, as `ksh` supports decimals in arithmetic contexts.
**-S**\ *SEVERITY*,\ **--severity=***severity* **-S**\ *SEVERITY*,\ **--severity=***severity*
: Specify maximum severity of errors to consider. Valid values are *error*, : Specify minimum severity of errors to consider. Valid values are *error*,
*warning*, *info* and *style*. The default is *style*. *warning*, *info* and *style*. The default is *style*.
**-s**\ *shell*,\ **--shell=***shell* **-s**\ *shell*,\ **--shell=***shell*

View File

@ -68,7 +68,7 @@ data Options = Options {
checkSpec :: CheckSpec, checkSpec :: CheckSpec,
externalSources :: Bool, externalSources :: Bool,
formatterOptions :: FormatterOptions, formatterOptions :: FormatterOptions,
maxSeverity :: Severity minSeverity :: Severity
} }
defaultOptions = Options { defaultOptions = Options {
@ -77,7 +77,7 @@ defaultOptions = Options {
formatterOptions = FormatterOptions { formatterOptions = FormatterOptions {
foColorOption = ColorAuto foColorOption = ColorAuto
}, },
maxSeverity = StyleC minSeverity = StyleC
} }
usageHeader = "Usage: shellcheck [OPTIONS...] FILES..." usageHeader = "Usage: shellcheck [OPTIONS...] FILES..."
@ -97,7 +97,7 @@ options = [
"Specify dialect (sh, bash, dash, ksh)", "Specify dialect (sh, bash, dash, ksh)",
Option "S" ["severity"] Option "S" ["severity"]
(ReqArg (Flag "severity") "SEVERITY") (ReqArg (Flag "severity") "SEVERITY")
"Maximum severity of errors to consider (error, warning, info, style)", "Minimum severity of errors to consider (error, warning, info, style)",
Option "V" ["version"] Option "V" ["version"]
(NoArg $ Flag "version" "true") "Print version information", (NoArg $ Flag "version" "true") "Print version information",
Option "x" ["external-sources"] Option "x" ["external-sources"]
@ -282,7 +282,7 @@ parseOption flag options =
Flag "severity" severity -> Flag "severity" severity ->
return options { return options {
checkSpec = (checkSpec options) { checkSpec = (checkSpec options) {
csMaxSeverity = parseSeverityOption severity csMinSeverity = parseSeverityOption severity
} }
} }

View File

@ -68,7 +68,7 @@ checkScript sys spec = do
(parseMessages ++ map translator analysisMessages) (parseMessages ++ map translator analysisMessages)
shouldInclude (PositionedComment _ _ (Comment severity code _)) = shouldInclude (PositionedComment _ _ (Comment severity code _)) =
severity <= csMaxSeverity spec && severity <= csMinSeverity spec &&
code `notElem` csExcludedWarnings spec code `notElem` csExcludedWarnings spec
sortMessages = sortBy (comparing order) sortMessages = sortBy (comparing order)

View File

@ -36,7 +36,7 @@ data CheckSpec = CheckSpec {
csCheckSourced :: Bool, csCheckSourced :: Bool,
csExcludedWarnings :: [Integer], csExcludedWarnings :: [Integer],
csShellTypeOverride :: Maybe Shell, csShellTypeOverride :: Maybe Shell,
csMaxSeverity :: Severity csMinSeverity :: Severity
} deriving (Show, Eq) } deriving (Show, Eq)
data CheckResult = CheckResult { data CheckResult = CheckResult {
@ -51,7 +51,7 @@ emptyCheckSpec = CheckSpec {
csCheckSourced = False, csCheckSourced = False,
csExcludedWarnings = [], csExcludedWarnings = [],
csShellTypeOverride = Nothing, csShellTypeOverride = Nothing,
csMaxSeverity = StyleC csMinSeverity = StyleC
} }
newParseSpec :: ParseSpec newParseSpec :: ParseSpec