While googling for help, I came across PMD and thought to give it a try.
The plugin works nicely and is easy to set up and run.
But after running it over my source file, I was disappointed, because it mostly was a different incarnation of checkstyle. It was telling me that some variable names were too short, others too long bla bla bla.
But it did not find the real problem of the following code snippet:
Object o1 = getBla(..);
Object o2 = getBla(..);
if (o1==null && o2 !=null) {
// do something
}
else {
if (!o1.equals(o2)) // something else
}
PMD complains that o1 and o2 are too short that is all, but does not detect the NPE when o1 and o2 are both null.
Ok, this might be too tricky. Lets try something simpler:
Object o = null;
System.out.println("below is a NPE");
o.equals(null);
Even here, PMD only complains about the short variable name, but doesn't find the NPE.
I am sure, that a tool like PMD can help a lot in improving code quality, but is basically useless for bug hunting.
And for my need to convert the findbugs output into a html page, I wrote an extremly simple xslt stylesheet.
No comments:
Post a Comment