mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-11 15:46:26 -07:00
Skip SC2214 if variable is modified in loop (fixes #2351)
This commit is contained in:
parent
3aedda766d
commit
c3aaa27540
3 changed files with 23 additions and 9 deletions
|
@ -1957,17 +1957,9 @@ subshellAssignmentCheck params t =
|
|||
|
||||
findSubshelled [] _ _ = return ()
|
||||
findSubshelled (Assignment x@(_, _, str, data_):rest) scopes@((reason,scope):restscope) deadVars =
|
||||
if isTrueAssignment data_
|
||||
if isTrueAssignmentSource data_
|
||||
then findSubshelled rest ((reason, x:scope):restscope) $ Map.insert str Alive deadVars
|
||||
else findSubshelled rest scopes deadVars
|
||||
where
|
||||
isTrueAssignment c =
|
||||
case c of
|
||||
DataString SourceChecked -> False
|
||||
DataString SourceDeclaration -> False
|
||||
DataArray SourceChecked -> False
|
||||
DataArray SourceDeclaration -> False
|
||||
_ -> True
|
||||
|
||||
findSubshelled (Reference (_, readToken, str):rest) scopes deadVars = do
|
||||
unless (shouldIgnore str) $ case Map.findWithDefault Alive str deadVars of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue