Monday, 21 March 2016

How to use FindBugs plugin in eclipse ?


Installation

Update sites
It allow you to automatically install FindBugs into Eclipse and also query and install updates.
http://findbugs.cs.umd.edu/eclipse (Only providesofficial releases of FindBugs)
1.    In eclipse, Click on Help - Software Update - Find andInstall...
2.    Choose the Search for new features to install option, and click Next.
3.    Click New Remote Site.
4.    Enter "Findbugs" into the Name field and URL : http://findbugs.cs.umd.edu/eclipse
5.    Click the checkbox next to it to select it, and click Finish.
       You should see FindBugs Feature under Select features to install.
       ( You may have to click on one or two triangles to make it visible in the tree.)
       Select the checkbox next to it and click next.
6.    Select the I accept option to accept the license and click Next.
7.    Make sure the location is correct where you're installing it.
       The default ( your workspace ) should be fine. Click Finish.
8.    The plugin is not digitally signed. Go ahead and install it anyway.
9.    Click Yes to make Eclipse restart itself.

Manually download the plugin
Extract it in Eclipse's "plugins" subdirectory.



Using the Plugin
To get started, right click on a Java project in Package Explorer, and select the option labeled "Find Bugs".
FindBugs will run, and problem markers (displayed in source windows, and also in the Eclipse Problems view) will point to locations in your code which have been identified as potential instances of bug patterns.

Switch to FindBugs perspective, which opens Bugexplorer having all bug list and bug info views.

You can also run FindBugs on existing java archives (jar, ear, zip, war etc).
Simply create an empty Java project and attach archives to the project classpath. Having that, you can now right click the archive node in Package Explorer and select the option labeled "Find Bugs".
If you additionally configure the source code locations for the binaries, FindBugs will also link the generated warnings to the right source files.

Property setting for FindBug
You may customize how FindBugs runs by opening the Properties dialog for a Java project, and choosing the "Findbugs" property page. Options you may choose include : 
Enable or disable the "Run FindBugs Automatically" checkbox. When enabled ,FindBugs will run every time you modify a Java class within the project.
Choose minimum warning priority and enabled bug categories. These options will choose which warnings are shown. For example, if you select the "Medium" warning priority, only Medium and High priority warnings will be shown.
Similarly, if you uncheck the "Style" checkbox, no warnings in the Style category will be displayed.
Select detectors. The table allows you to select which detectors you want to enable for your project.


Bug description
Please find bug description link, which could be identified by FindBug :


Troubleshooting
Problem 1.
If you see OutOfMemory error dialogs after starting FindBugs analysis in Eclipse, please increase JVM available memory.
Change eclipse.ini and add the lines below to the end of the file :
-vmargs
-Xmx1000m
Important: the configurationarguments starting with the line "-vmargs" must be last lines in the eclipse.ini file, and only one argument per line is allowed.

Problem 2.
If you do not see any FindBugs problem markers (in your source windows or in the Problems View), you may need to change your Problems View filter settings.
See http://findbugs.sourceforge.net/FAQ.html#q7 for more information.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.