Recently I have realised that often in posts on this blog I tend to mention the FindBugs tool. Therefore today some words about it.
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!

3 Comments until now
I just ran FindBugs on some source code I had for work and was very impressed with what was found. This just became a staple in my dev tool set.
[...] time ago I wrote a post about FindBugs – a powerful tool for static code analysis in Java. Today I want to tell you [...]
Man, try PMD – it is another great tool for static analysis and it has a plugin for IDEs too.
Add your Comment!