mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-16 10:03:08 -07:00
Replace verbose checks with optional checks
This commit is contained in:
parent
58205a3573
commit
5fb1da6814
11 changed files with 229 additions and 74 deletions
|
@ -84,7 +84,8 @@ checkScript sys spec = do
|
|||
asFallbackShell = shellFromFilename $ csFilename spec,
|
||||
asCheckSourced = csCheckSourced spec,
|
||||
asExecutionMode = Executed,
|
||||
asTokenPositions = tokenPositions
|
||||
asTokenPositions = tokenPositions,
|
||||
asOptionalChecks = csOptionalChecks spec
|
||||
} where as = newAnalysisSpec root
|
||||
let analysisMessages =
|
||||
fromMaybe [] $
|
||||
|
@ -302,6 +303,14 @@ prop_sourcedFileUsesOriginalShellExtension = result == [2079]
|
|||
csCheckSourced = True
|
||||
}
|
||||
|
||||
prop_canEnableOptionalsWithSpec = result == [2244]
|
||||
where
|
||||
result = checkWithSpec [] emptyCheckSpec {
|
||||
csFilename = "file.sh",
|
||||
csScript = "#!/bin/sh\n[ \"$1\" ]",
|
||||
csOptionalChecks = ["avoid-nullary-conditions"]
|
||||
}
|
||||
|
||||
prop_optionIncludes1 =
|
||||
-- expect 2086, but not included, so nothing reported
|
||||
null $ checkOptionIncludes (Just [2080]) "#!/bin/sh\n var='a b'\n echo $var"
|
||||
|
@ -347,6 +356,12 @@ prop_brokenRcGetsWarning = result == [1134, 2086]
|
|||
csIgnoreRC = False
|
||||
}
|
||||
|
||||
prop_canEnableOptionalsWithRc = result == [2244]
|
||||
where
|
||||
result = checkWithRc "enable=avoid-nullary-conditions" emptyCheckSpec {
|
||||
csScript = "#!/bin/sh\n[ \"$1\" ]"
|
||||
}
|
||||
|
||||
prop_sourcePathRedirectsName = result == [2086]
|
||||
where
|
||||
f "dir/myscript" _ "lib" = return "foo/lib"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue