Home | Eclipse plugins -> FindBugs
+Andrey | About

Eclipse ready

FindBugs SF project page plugin for Eclipse

(this is NOT a FindBugs home page)

This page is my personal page dedicated to the FindBugs Eclipse plugin. FindBugs is a project of The University of Maryland, but I'm also contributing to its Eclipse plugin, so I've decided to put here some quick info's.

Get the SF project page stuff

 

Binaries | Sources | Eclipse update sites | How to checkout and build | Open issues | Latest changes | FishEye

Feedback

Vote for FindBugs plugin at Eclipse Marketplace
or add MercurialEclipse to your stack at Ohloh
Support development of the plugin:

 

Short demo for FindBugsFindBugs Eclipse plugin (2.0.0 version)

I was asked to provide a demo for it, and so I've made a short (~15 minutes) video.
FindBugs Eclipse plugin (2.0.0 version) demo: watch on Google+ or watch on Youtube.
Enjoy :-)

 

News and noteworthy in FindBugs 1.3.7 - 1.3.8 Eclipse plugin

 

FindBugs plugin is now more consistent to the rest of Eclipse:

  • FindBugs preferences can be configured now per workspace or per project.

  • For new projects FindBugs follows Eclipse standards and uses workspace preferences until user decides to set custom project settings

Per default FindBugs plugin generates now less noise:

  • FindBugs plugin now disables EXPERIMENTAL, I18N, MALICIOUS_CODE and SECURITY bug categories
    reporting for new projects (can be changed in workspace settings, existing projects are not affected by this change).

  • FindBugs detectors was also tuned to generate less warnings for specific Eclipse related code (warnings for fields in Activator/NLS based classes).

The old Bug Details view is now gone and is replaced by the standard Eclipse Properties view:

  • If you've used FindBugs plugin before, Eclipse will report an error that the view can't be found anymore after installation of 1.3.8 plugin.
    This error is ok and will occur only once.

  • Standard Eclipse Properties view follows now selection in the Bug Explorer view and shows properties for selected element(s).
    This also works for selection of bugs in Java editor.

  • Properties view shows also bug pattern descriptions for selected bug patterns and bug counts summary for selected elements in Bug Explorer view.

Bug filtering is improved:

  • FindBugs plugin allows now filter files to be specified as absolute paths or relative to project/workspace.

  • Existing projects preferences are not affected by this change.

Bug navigation is improved:

  • Different cross-reference links are added to Java perspectives and views:
    Show In... -> Bug Explorer menu appears now in the context menu of Java elements,
    Show In... -> Package Explorer appears in the context menu of bugs.

  • Java perspectives has shortcuts to FindBugs perspective and vice-versa.

  • FindBugs warnings in the standard Problems view also have now additional context menus.

Analysis results presentation is improved:

  • Bug Explorer view received freely configurable grouping, ordering and filtering of bugs.

  • Last used grouping, ordering and filtering are remembered and restored after the Eclipse startup.

Miscellaneous:

  • FindBugs -> Save XML and FindBugs -> Load XML actions are added to the Java project context menu.
    This allows user to export/import analysis results as xml file.

  • Reporting bugs during analysis was refactored, which improves FindBugs plugin performance, especially during multi-project build.

  • FindBugs Eclipse plugins has now JUnit tests, contributed by Tomas Pollak.

 

Quick SF project page tour (based on 1.3.8 FindBugs Eclipse plugin)

 

1. Prepare Eclipse

We will start our tour with changing eclipse.ini file (see bug 265525). FindBugs needs much RAM, so we have to change default eclipse.ini:

-vmargs
-Xms40m
-Xmx200m

change to ->

-vmargs
-Xms100m
-Xmx900m



Install FindBugs from any one update site below:

http://findbugs.cs.umd.edu/eclipse (official releases)
http://findbugs.cs.umd.edu/eclipse-candidate (candidate releases and official releases)
http://findbugs.cs.umd.edu/eclipse-daily (all releases, including development ones)

 

2. Run SF project page analysis

FindBugs analysis can be started by right clicking Java project/package/class:

 

Starting FindBugs

 

Note: if you have a multi-core workstation, you can select multiple Java projects and run FindBugs analysis in parallel.
FindBugs will use all available cores to run analysis in parallel, which works very well for big workspaces with many projects.

 

3. Show SF project page analysis results

After FindBugs analysis is done, results are available in Bug Explorer view and also shown as label decorations for the project/package/file.
To enable such decorations go to Window->Preferences->General-Appearance->Label Decorations:

 

Label decorations

 

4. Examine SF project page analysis results

You can jump from the Package Explorer directly to the related bugs in Bug Explorer by selecting interesting Java element and opening Show In menu.
Bug Explorer
view shows up with all the bugs selected which are related to the selected java element:

 

Show In... Bug Explorer

 

Another possibility is to switch perspective: Window->Open Perspective->FindBugs or via "Ctrl+3 -> FindBugs":

 

FindBugs perspective

 

Eclipse Properties view follows selection in the Bug Explorer view and shows properties for selected element(s).
In case there are more information available, it uses additional tabs. For example, each bug instance has it's own annotations tab:

 

Properties view

 

It is also possible to select multiple elements in the Bug Explorer view.
In this case, Properties view will show summary of bugs reported for the current selection:

 

Properties view

 

Elements selected in the Bug Explorer view can be copied to clipboard and then used for review sheets etc:

 

Copy selection

 

5. Customize SF project page results presentation

Ok, now we know how to find and export our bugs, but what if there are too many of them?

Bug Explorer view allows flexible filtering and grouping of reported bugs. Let's look how it works:

  1. First, we select bug pattern which we think isn't relevant for us.

  2. Right click on it shows "Toggle Filter" menu.

  3. Select one of two toggle actions:

    • "This Specific Bug Pattern" action will toggle on/off only one, specific bug pattern

    • "Bug Pattern Type" action will toggle the whole group of patterns on/off
      (selected bug pattern group will be shown empty and in different color):


Bug filters

 

It is of course possible to revert the filtering by using same "Toggle Filter" command again on filtered elements.

Filters configured in the Bug Explorer view are remembered automatically and applied each time view is opened again.
It is also possible to configure ALL available bug patterns and bug pattern types (even not yet reported for the project) and define a custom filter set:

 

Configure filters

 

Bug Filter Configuration dialog allows to configure ALL available bug pattern types and included bug patterns.
A description is shown for selected pattern type/pattern:

 

Filter configuration

 

Filter configuration

 

Another filtering feature supported by Bug Explorer view is standard Eclipse Working Sets:

 

Working Sets

 

Per default, bugs in Bug Explorer view are ordered first by project and then by bug pattern, but this group order can be easily changed:

 

Group ordering

 

Beside 6 predefined grouping orders, we can change group visibility and sort order by selecting Group By... view menu.
Bug Group Configuration
dialog opens:

 

Custom group selection

 

6. Configure SF project page analysis settings

Last but not least, FindBugs analysis preferences are also configurable.

  • Since 1.3.8 Eclipse plugin version, FindBugs preferences can be configured per workspace or per project.

  • 1.3.8 plugin version changes the way how FindBugs is configured for new projects: now it follows Eclipse standards and uses workspace preferences.

  • Of course if user decides to use custom project settings, it is still possible.

 

Workspace settings

 

FindBugs preference page has three tabs which control different aspects of FindBugs plugin behavior.

On the first tab FindBugs detector enablement can be changed.

  • This is the most important tab for tuning FindBugs analysis performance. In general enabling more detectors leads to longer analysis time.

  • Depending on the project nature, not all detectors must be enabled.

  • For example, if project contains Swing UI code, catching cross site scripting issues does not make much sense, so it is ok to disable CrossSiteScripting detector, etc.

 

Detectors tab

 

Second tab allows to customize bug reporter settings for all analyzed classes in the project.

This tab is important to control how much "noise" FindBugs should generate.

 

reporters tab

 

Third tab is dedicated to advanced reporter settings.

  • Here you can specify (xml) filter files for fine-grained reporter configuration.

  • Filter files allows to include or exclude bug reports for particular classes and methods.

  • In the future FindBugs Eclipse plugin might have more convenient way to define and configure filters rules from the UI.

  • More on filters in FindBugs manual...

 

Filters tab

Last changed at: 25.03.12 15:11