A few ago I decided to try out FindBugs, a plugin for Eclipse JDT. Here is its description on Eclipse Plugin Central:
[FindBugs] looks for instances of ‘bug patterns’—code instances that are likely to be errors.
I have seen enough of these tools to have downloaded it with skeptical expectations: code pattern analyzers are typically ridden with absurd anti‐pattern heuristics, nonsensical descriptions, bugs, and useless heavy‐weight features. I had it since my most recent plugin‐downloading spree but first tried it yesterday. I was impressed: it is possibly the best Eclipse plugin I have used. Note that FindBugs is both a standalone distribution and a plugin for Eclipse; I review both here:
- Its anti‐patterns really are anti‐patterns. Most of its detections were actual design flaws or questionable practices. So far its heuristics have incorrectly identified very little.
- It is highly configurable. It allows you to select anti‐patterns to check, filter files, choose ant‐patterns to show, and control re‐checking on rebuild.
- It is fast. Speed is atypical for code pattern analyzers. Because FindBugs also shows the analysis speed for each anti‐pattern, you can fine‐tune its speed.
- I have not encountered a bug yet. This may change, but it seems pretty solid. Note that I discount false positives (incorrect pattern matches) as bugs—that will always happen.
- Its anti‐patterns have descriptions. No—I am not joking. Each of its anti‐patterns has a description that is in valid English (!), explains the issue, and suggests solutions. I find that extremely useful in sorting issues from non‐issues and false positives.
The first time I ran FindBugs, I looked through the list and examined each code fragment. I had previously noticed some of the practice flaws it identified, but some were useful. But more than that: it actually identified three bugs, which I will signal in an SVN commit diff somewhere. The bottom line is that FindBugs actually finds bugs.
