Fix minor details in new Bats support
This commit is contained in:
parent
c97cb8cf54
commit
e1fe9be7af
|
@ -1,6 +1,7 @@
|
||||||
## Since previous release
|
## Since previous release
|
||||||
### Added
|
### Added
|
||||||
- Preliminary support for fix suggestions
|
- Preliminary support for fix suggestions
|
||||||
|
- Files containing Bats tests can now be checked
|
||||||
- SC2246: Warn if a shebang's interpreter ends with /
|
- SC2246: Warn if a shebang's interpreter ends with /
|
||||||
- SC2245: Warn that Ksh ignores all but the first glob result in `[`
|
- SC2245: Warn that Ksh ignores all but the first glob result in `[`
|
||||||
- SC2243/SC2244: Suggest using explicit -n for `[ $foo ]`
|
- SC2243/SC2244: Suggest using explicit -n for `[ $foo ]`
|
||||||
|
|
|
@ -351,6 +351,14 @@ isOnlyRedirection t =
|
||||||
|
|
||||||
isFunction t = case t of T_Function {} -> True; _ -> False
|
isFunction t = case t of T_Function {} -> True; _ -> False
|
||||||
|
|
||||||
|
-- Bats tests are functions for the purpose of 'local' and such
|
||||||
|
isFunctionLike t =
|
||||||
|
case t of
|
||||||
|
T_Function {} -> True
|
||||||
|
T_BatsTest {} -> True
|
||||||
|
_ -> False
|
||||||
|
|
||||||
|
|
||||||
isBraceExpansion t = case t of T_BraceExpansion {} -> True; _ -> False
|
isBraceExpansion t = case t of T_BraceExpansion {} -> True; _ -> False
|
||||||
|
|
||||||
-- Get the lists of commands from tokens that contain them, such as
|
-- Get the lists of commands from tokens that contain them, such as
|
||||||
|
|
|
@ -52,6 +52,7 @@ shellFromFilename filename = foldl mplus Nothing candidates
|
||||||
where
|
where
|
||||||
shellExtensions = [(".ksh", Ksh)
|
shellExtensions = [(".ksh", Ksh)
|
||||||
,(".bash", Bash)
|
,(".bash", Bash)
|
||||||
|
,(".bats", Bash)
|
||||||
,(".dash", Dash)]
|
,(".dash", Dash)]
|
||||||
-- The `.sh` is too generic to determine the shell:
|
-- The `.sh` is too generic to determine the shell:
|
||||||
-- We fallback to Bash in this case and emit SC2148 if there is no shebang
|
-- We fallback to Bash in this case and emit SC2148 if there is no shebang
|
||||||
|
|
|
@ -770,7 +770,7 @@ prop_checkLocalScope2 = verifyNot checkLocalScope "f() { local foo=3; }"
|
||||||
checkLocalScope = CommandCheck (Exactly "local") $ \t ->
|
checkLocalScope = CommandCheck (Exactly "local") $ \t ->
|
||||||
whenShell [Bash, Dash] $ do -- Ksh allows it, Sh doesn't support local
|
whenShell [Bash, Dash] $ do -- Ksh allows it, Sh doesn't support local
|
||||||
path <- getPathM t
|
path <- getPathM t
|
||||||
unless (any isFunction path) $
|
unless (any isFunctionLike path) $
|
||||||
err (getId $ getCommandTokenOrThis t) 2168 "'local' is only valid in functions."
|
err (getId $ getCommandTokenOrThis t) 2168 "'local' is only valid in functions."
|
||||||
|
|
||||||
prop_checkDeprecatedTempfile1 = verify checkDeprecatedTempfile "var=$(tempfile)"
|
prop_checkDeprecatedTempfile1 = verify checkDeprecatedTempfile "var=$(tempfile)"
|
||||||
|
|
Loading…
Reference in New Issue