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