Skip SC2214 if variable is modified in loop (fixes #2351)

This commit is contained in:
Vidar Holen 2021-10-09 12:13:41 -07:00
parent 3aedda766d
commit c3aaa27540
3 changed files with 23 additions and 9 deletions

View file

@ -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