False +: UnusedPrivateMethod and for-each loop
A source code analyzer
Brought to you by:
adangel,
juansotuyo
I'm using PMD 4.1 through maven-pmd-plugin version 2.4, but I can't see this problem mentioned in the bugfix list for PMD 4.2.
If a private method is used in a for-each loop, the UnusedPrivateMethod rule generates a false positive. Here's an example:
public class UnusedPrivateMethodFalsePositiveExample {
UnusedPrivateMethodFalsePositiveExample[] foos;
public void foo() {
for (UnusedPrivateMethodFalsePositiveExample foo : foos) {
foo.falsePositive();
}
}
private void falsePositive() {
}
UnusedPrivateMethod reports the method falsePositive() isn't used, but clearly it is in the for-each loop.