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

@ -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 }) ) |])