Code reviews are good. Reviewers find bugs in your code, point out inconsistencies, areas where you are misusing the Java language, deviations from good style, and so forth. The problem with code reviewers is they usually get tired after a half an hour or so of reviewing code, and the quality of the review drops off.

The program FindBugs is a bug pattern detector for java. FindBugs is just like a code reviewer that never gets tired. It scours through your code and looks for potential bugs and problems and gives you a report. Unlike a human code reviewer, FindBugs doesn't give you that self-satisfied smirk when it finds a bug like the human reviewer does.

In preparation for a major release of Sphinx-4, I ran FindBugs against our code base (about a 100K commented lines of code). I'd rather not say exactly how many bugs FindBugs reported. Suffice it to say that it was more than I expected. Constants that were not final, unused fields, inconsistent synchronization, all the types of flaws that a good, tireless code reviewer would find.

I was surprised and impressed by the types of bugs FindBugs can find. It has proven to be extremely useful in improving my code quality. I've added FindBugs to my set of must-use Java tools, next to ant and jfluid.

Comments:

If you like FindBugs, then I'd recommend using Checkstyle integrated with your IDE (I use Eclipse) or as a command line tool. Another invaluable tool in working with large code bases is Simian. Simian is a cut-n-paste/duplication detector and can be found at http://www.redhillconsulting.com.au/products/simian/ (Disclaimer: The author of Simian is a friend)

Posted by Jon Eaves on September 22, 2004 at 08:28 AM EDT #

And, as usual for just about every single cool new feature that people discover they now can't live without, this feature can be found built in to IDEA.

Posted by Anonymous on September 22, 2004 at 08:45 AM EDT #

Thanks, I just started using it as an Eclipse plugin today. Pretty useful for detecting silly mistakes.

Posted by Sahil on September 22, 2004 at 11:32 PM EDT #

Post a Comment:
Comments are closed for this entry.

This blog copyright 2010 by plamere