mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-09 02:03:51 +08:00
Skip SC2214 if variable is modified in loop (fixes #2351)
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user