Info on JMRI:
Development tools
Structure
Functional Info
Techniques and Standards
How To
Background Info

JMRI: Static Analysis with FindBugs

FindBugs is a tool that can examine code to find possible problems. It does a "static analysis", looking through the code to find certain "known bad ideas": Things that are likely to cause occasional/intermittent problems, poor performance, etc. Because those kinds of problems are hard to find with tests, finding them by inspection is often the only realistic approach. Having a tool that can do those inspections automatically, so that they can be done every time something is changed, keeps the code from slowly getting worse and worse without anybody noticing until it's too late.

For more information on FindBugs, see the FindBugs home page.

Simon White added FindBugs support to our Ant-based build chain during the development of JMRI 2.5.5. His note on this follows.

As per feature request 1716873, I've added an ant task to run Findbugs. This will produce a report in HTML in the same location as the JMRI jar (i.e. the top level project dir). Note the new task first runs ant dist because FindBugs examines the jmri.jar file.

To run the task:

On my old machine this takes about 20 minutes but your mileage may vary.

Note that in the build.xml I have set the maximum memory -Xmx setting for the findbugs task to 1024m. If your system has more memory, boosting this may speed things up.

Running this on JMRI 2.5.4 produced the following:

Bad practice Warnings164
Correctness Warnings77
Experimental Warnings7
Malicious code vulnerability Warnings221
Multithreaded correctness Warnings90
Performance Warnings459
Dodgy Warnings304
Total1322

Note I've only been able to test this on windows (my Linux box is much slower and I don't have access to a Mac), and the aux classpath I've had to specify for findbugs doesn't include the java jars used my the Mac (they broke findbugs on the PC) so a seperate solution for Macs might be needed.