Project

Profile

Help

FindBugs

Added by Anonymous almost 14 years ago

Legacy ID: #8394639 Legacy Poster: Andriy Gerasika (andriy_gerasika)

Hello, Michael, what do you think about running FindBugs static analysis tool on Saxon code? Judging from "//noinspection" comments I guess you are already running some tool, but FindBugs is way more extensive. I was myself running PMD/Checkstyle/IntelliJ IDEA statical analysis, and have found FindBugs is the best. It is able to spot bugs other tools cannot, and amount of false-positives is near zero. For example, FindBugs suggest that entrySet() iterator should be used instead of keySet() in class net.sf.saxon.query.QueryModule, method getNamespaceResolver(): ... for (Iterator iter = userDeclaredNamespaces.keySet().iterator(); iter.hasNext();) { String prefix = (String)iter.next(); String uri = (String)userDeclaredNamespaces.get(prefix); nscodes[used++] = namePool.getNamespaceCode(prefix, uri); } ... or typo in net.sf.saxon.Query, line 695: if (!("1.0".equals(value) | "1.1".equals(value))) { I am not saying Saxon code is bad, actually it is the best I have seen, just hoping FindBugs will allow you to squeeze little bit more performance/catch more bugs early. Thank You Kind Regards, Andriy Gerasika


Replies (2)

RE: FindBugs - Added by Anonymous almost 14 years ago

Legacy ID: #8395356 Legacy Poster: Michael Kay (mhkay)

I develop Saxon under IntelliJ; I've customized the code inspections it does a little bit, but in most areas I use the defaults, and I find this serves me very well in identifying where I haven't used good coding practices. Occasionally I explore some of the inspections that aren't enabled by default. I did run FindBugs once, but the output was too voluminous to analyze easily, so I tend to stick with what IntelliJ detects. I'll take a look at the two examples you've cited. It's worth remembering that Saxon 9.2 was the first release that was able to depend on Java 1.5 features - all previous releases ran with Java 1.4 or earlier, and of course it hasn't been possible to exploit Java 1.5 in all places where it might be advantageous. There are a also a few areas of code that I know are not as thoroughly tested as they should be, and where it's therefore prudent to adopt an approach of "if it ain't broke, don't fix it".

RE: FindBugs - Added by Anonymous almost 14 years ago

Legacy ID: #8407188 Legacy Poster: Michael Kay (mhkay)

Thanks for the suggestion; I've now run Saxon through FindBugs and it was a very productive exercise. Very few false alarms, and quite a few things that the default inspections in IntelliJ don't catch.

    (1-2/2)

    Please register to reply