RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Find the Java Bugs That Pose a Threat with FindBugs : Page 2

FindBugs enables you to isolate and correct dangerous Java bugs. Its unique features separate it from the many static analysis tools in the Java world. Find out what makes FindBugs so special.

Using FindBugs
Figure 1. The FindBugs Graphical Tool: Use the default FindBugs graphical tool to review the issues that FindBugs raises.
Despite its power, FindBugs is easy to use. In fact, you can run it against your code in several ways. One way is to use the default FindBugs graphical tool, and review the issues that FindBugs raises (see Figure 1). This tool also lets you classify issues into categories such as "Should Fix" and "Mostly Harmless," and sort issues in various ways.

However, a more convenient way to use FindBugs is directly within your IDE. This way, FindBugs can analyze your code and isolate issues within your normal development environment, where you can fix them immediately.

Figure 2. Using FindBugs in Eclipse: FindBugs provides an Eclipse plugin that integrates FindBugs directly into your Eclipse environment.

To this end, FindBugs provides an Eclipse plugin that integrates FindBugs directly into your Eclipse environment (see Figure 2). You can install this plugin using the FindBugs Update site. Once installed, you can run the FindBugs analysis against your code using the "FindBugs" entry in the contextual menu.

Figure 3. Configuring FindBugs in Eclipse: You can fine-tune FindBugs behavior in the "FindBugs" entry in the "Project->Properties" window.

FindBugs issues are easy to see—just look for the red insect icon in the margin of the source code window. A nice touch is that the color of the insect indicates severity—the darker the red, the more severe the issue. You can pass the mouse over the issue to get a quick overview of the problem. You can also list FindBugs issues in the "Problems" view, or in one of the specialized FindBugs views. If you click on a particular FindBugs issue, Eclipse will open the FindBugs Details view, which contains the detailed description of the bug.

Once you become more familiar with FindBugs, you can fine-tune its behavior in the "FindBugs" entry in the "Project->Properties" window (see Figure 3). For example, you can configure FindBugs to run automatically or deactivate certain FindBugs rules if they don't suit your particular needs. The "Reporter Configuration" tab lets you filter out entire categories of rules, whereas the "Filter files" tab lets you filter out certain files or file sets from the FindBugs analysis.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date