IG: clarify description

This commit is contained in:
Bas Leijdekkers
2019-03-08 11:32:41 +01:00
parent 5316bb28d3
commit afb39182bb
@@ -2,7 +2,19 @@
<body>
Reports assignment to, or modification of <b>for</b> statement parameters inside the <b>for</b> loop body.
While occasionally intended, this construct can be extremely confusing, and is often the result of a typo.
Assignments in plain <b>for</b> loops without an update statement are not reported.
<p>
Assignments in basic <b>for</b> loops without an update statement are not reported.
In these cases the assignment is probably intended and can't be easily moved to the update part of the <b>for</b> loop.
For example:
<pre><code>
<b>for</b> (<b>int</b> i = 0; i &lt; list.size(); ) {
<b>if</b> (element.equals(list.get(i))) {
list.remove(i);
} <b>else</b> {
i++; // modification of for loop parameter
}
}
</code></pre>
<!-- tooltip end -->
<p>