Affects PMD Version: 6.0.0
Rule: ForLoopCanBeForeach
Description: The rule should report loops that are iterated on this if possible. For now it considers neither this.iterator() nor just iterator(). Followup on #800
Code Sample demonstrating the issue:
import java.util.Iterator;
class Foo<T> implements Iterable<T> {
@Override
public Iterator<T> iterator() {
return null;
}
private void fofo() {
for (Iterator<T> it = iterator(); it.hasNext();) {
T item = it.next();
}
for (Iterator<T> it = this.iterator(); it.hasNext();) {
T item = it.next();
}
}
}
Running PMD through: CLI
Affects PMD Version: 6.0.0
Rule: ForLoopCanBeForeach
Description: The rule should report loops that are iterated on this if possible. For now it considers neither this.iterator() nor just iterator(). Followup on #800
Code Sample demonstrating the issue:
Running PMD through: CLI