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