Saturday, June 25, 2011

Find Bugs with FindBugs

FindBugs is a tool for a static analysis of Java code. It basically goes trough your programs (both .class and .java files) and searches for patterns of most common bugs. When you run it against your code you see a GUI with a listing of all found errors which you can browse trough according to a category or a severity.

The list of bugs that FindBugs can find is almost endless: starting from synchronization issues (eg: bug in access to a shared variable), performance (inefficient operations), ending on dead code and unclosed files. If your project has more than a 1000 lines I bet you’ll find something!

Two things have to be said frankly: not all bugs found will be severe enough that it would be wise to fix them – sometimes the code is too old or crappy to risk the change (well, whose fault is that?). Secondly, not all bugs can be found trough static analysis so an empty FireBugs report does not mean everything is fine. There are many complementary ways to improve the quality of the code (like UnitTests, code reviews) and static analysis is only one of them.

To summarize: FindBugs can find a lot of embarrassing stuff in your code that you probably really want to find. Its not a miracle cure, but for sure you’ll benefit a lot from it. And what is probably most important: it’ really easy in use (download, unpack, run) and IT’S FREE! Just go to Help -> Eclipse market place and search it and install it. Enjoy

No comments:

Post a Comment