You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following issues were found during the review of PR #385.
Describe the bug
While the sniff works well for the most common case of a variable being incremented/decremented in the third expression in the condition of a for loop, it does not take other possible operations involving variables into account, making it highly inaccurate for all but the most common case.
Code sample
for ($i = 0; $i < 20; $i++) {
for ($j = 0; $j < 20; $j = $i + 10) { // $i is not being written to, so is not being jumbled here.
}
}
$j = 0;
for ($i = 40; $i > 20; $i -= $j) { // $j is not being written to here ...for (; $j < 20; $j++) { // ... so $j is not being jumbled here.
}
}
To reproduce
Steps to reproduce the behavior:
Create a file called test.php with the code sample above...
Run phpcs test.php --standard=Generic --sniffs=Generic.CodeAnalysis.JumbledIncrementer
The following issues were found during the review of PR #385.
Describe the bug
While the sniff works well for the most common case of a variable being incremented/decremented in the third expression in the condition of a
for
loop, it does not take other possible operations involving variables into account, making it highly inaccurate for all but the most common case.Code sample
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs test.php --standard=Generic --sniffs=Generic.CodeAnalysis.JumbledIncrementer
Expected behavior
No warnings to be thrown when a variable seen in the third expression is not being written to.
Additional context
Here are some additional code samples for inspiration as each of these will also result in a false positive:
Please confirm:
master
branch of PHP_CodeSniffer.The text was updated successfully, but these errors were encountered: