Rule:
UnusedPrivateMethod
Rule set:
Unused Code
Generates the following incorrect warnings for the following code:
Avoid unused private methods such as 'badA(A)'
Avoid unused private methods such as 'badX(Exception)'
public class C {
private void badA(A a) {}
private void badX(Exception e) {}
private void goodA(A a) {}
private void goodN(A a) {}
private void goodO(Object o) {}
public void bad() {
B b = null;
badA(b);
badA(new B());
badX(new X());
goodA(new A());
goodN(null);
goodO(new A());
}
}
class A {}
class B extends A {}
class X extends Exception {}
I couldn't reproduce your problem.
Are you using already the "auxclasspath" option? (e.g. for ant see http://pmd.sourceforge.net/pmd-5.2.1/usage/ant-task.html)
How do you start pmd? (commandline, ant, ...)
Could please check the attached test case in bug-1278.zip?
Thanks,
Andreas
Last edit: Andreas Dangel 2014-11-14
I assume, this is just caused by missing auxclasspath option.
While fixing [#1276], I've changed the behavior of PMD if no auxclasspath is configured. In this case, there might be some false negatives (such as [#1226]) in this rule, but much less false positives.
So, I'm closing this issue as "obsolete".
Related
Issues:
#1226Issues:
#1276Last edit: Andreas Dangel 2014-11-15
Sorry, I missed the emails about your comments.
I am using EasyPMD 6.0 in NetBeans, with a Java free-form project.
Do you know how to set the auxclasspath for that? If not, I will ask the creator of EasyPMD.
Thanks.
It looks like you can configure "Additional classpath" URLs for EasyPMD - which should configure the auxclasspath.