mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-13 16:43:20 -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
|
@ -1005,6 +1005,23 @@ isUnmodifiedParameterExpansion t =
|
|||
in getBracedReference str == str
|
||||
_ -> False
|
||||
|
||||
isTrueAssignmentSource c =
|
||||
case c of
|
||||
DataString SourceChecked -> False
|
||||
DataString SourceDeclaration -> False
|
||||
DataArray SourceChecked -> False
|
||||
DataArray SourceDeclaration -> False
|
||||
_ -> True
|
||||
|
||||
modifiesVariable params token name =
|
||||
or $ map check flow
|
||||
where
|
||||
flow = getVariableFlow params token
|
||||
check t =
|
||||
case t of
|
||||
Assignment (_, _, n, source) -> isTrueAssignmentSource source && n == name
|
||||
_ -> False
|
||||
|
||||
|
||||
return []
|
||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue