FindBugs

In a recent internal email James Gosling mentioned a cool Java software project called FindBugs written by Bill Pugh of the University of Maryland. FindBugs is a program which looks for bugs in Java code. Yesterday I downloaded it and tried it out on the Java Accessibility Helper, a Java application that I maintain.

Installing it basically consisted of unpacking the compressed tarball. When I ran it on the Helper I initially got the following summary:

        Summary Analysis Generated at:
        Wed, 23 Mar 2005 10:43:00 -0800

  Type Checked    Count    Bugs    Percentage
  -------------------------------------------
  Outer Classes   129      313     242.64%
  Inner Classes   256       63     24.61%
  Interfaces       35        0     0.00%
  -------------------------------------------
  Total           420      370     88.10%

  12 Packages Analyzed

Ouch! In going through the bugs found, I'm confused on exactly how it gets this number. I went and fixed up 82 different problems that it found, and then by adding up the total left in the "By Bug Type" category, I reckon there are 77 left. So that's a total of 159. I then clicked on Settings->Configure Detectors and checked all the bug types and it only found four more bugs. I need to investigate this further to find out what's going on here.

I then got curious on whether the number of bugs reported against the Helper was typical. I decided to try it on the latest version of FreeTTS, a freely available text-to-speech synthesizer, which is written by three guys who I have a great deal of respect for. Here's the results:

        Summary Analysis Generated at: 
        Thu, 24 Mar 2005 08:40:31 -0800

  Type Checked   Count   Bugs   Percentage
  ----------------------------------------
  Outer Classes  160     154    96.25%
  Inner Classes   69       9    13.04%
  Interfaces      48       0     0.00%
  ----------------------------------------
  Total          277     162    58.48%

  19 Packages Analyzed

Ah, I feel a bit better now. Even though I'm not the original author of the Helper code, I had been through it and fixed up several thing prior to the FindBugs testing. It was a little disconcerting to see FindBugs reporting so many problems, but it appears that it's good at finding bugs that the Java programmers might not know about.

To summarise, FindBugs is a great piece of software. I encourage you to run it over your Java code and see what it reports.

[]

Comments:

Post a Comment:
Comments are closed for this entry.
About

user12607856

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today