org.sonar.l10n.javascript.rules.javascript.S1994.html Maven / Gradle / Ivy
Why is this an issue?
It can be extremely confusing when a for
loop’s counter is incremented outside of its increment clause. In such cases, the increment
should be moved to the loop’s increment clause if at all possible.
Noncompliant code example
for (i = 0; i < 10; j++) { // Noncompliant
// ...
i++;
}
Compliant solution
for (i = 0; i < 10; i++, j++) {
// ...
}
Or
for (i = 0; i < 10; i++) {
// ...
j++;
}