summaryrefslogtreecommitdiff
path: root/tools/findbugs/doc/manual/eclipse.html
blob: 52ac8e9caaa5ae504c5604c7deb9024e3a9c58fa (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Chapter&nbsp;7.&nbsp;Using the FindBugs&#8482; Eclipse plugin</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="anttask.html" title="Chapter&nbsp;6.&nbsp;Using the FindBugs&#8482; Ant task"><link rel="next" href="filter.html" title="Chapter&nbsp;8.&nbsp;Filter Files"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;7.&nbsp;Using the <span class="application">FindBugs</span>&#8482; Eclipse plugin</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="anttask.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="filter.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;7.&nbsp;Using the FindBugs&#8482; Eclipse plugin"><div class="titlepage"><div><div><h2 class="title"><a name="eclipse"></a>Chapter&nbsp;7.&nbsp;Using the <span class="application">FindBugs</span>&#8482; Eclipse plugin</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="eclipse.html#d0e1662">1. Requirements</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1670">2. Installation</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1717">3. Using the Plugin</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1748">4. Extending the Eclipse Plugin (since 2.0.0)</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1802">5. Troubleshooting</a></span></dt></dl></div><p>
The FindBugs Eclipse plugin allows <span class="application">FindBugs</span> to be used within
the <a class="ulink" href="http://www.eclipse.org/" target="_top">Eclipse</a> IDE.
The FindBugs Eclipse plugin was generously contributed by Peter Friese.
Phil Crosby and Andrei Loskutov contributed major improvements
to the plugin.
</p><div class="sect1" title="1.&nbsp;Requirements"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1662"></a>1.&nbsp;Requirements</h2></div></div></div><p>
To use the <span class="application">FindBugs</span> Plugin for Eclipse, you need Eclipse 3.3 or later,
and JRE/JDK 1.5 or later.
</p></div><div class="sect1" title="2.&nbsp;Installation"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1670"></a>2.&nbsp;Installation</h2></div></div></div><p>
  We provide update sites that allow you to automatically install FindBugs into Eclipse and also query and install updates.
  There are three different update sites</p><div class="variablelist" title="FindBugs Eclipse update sites"><p class="title"><b>FindBugs Eclipse update sites</b></p><dl><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse/" target="_top">http://findbugs.cs.umd.edu/eclipse/</a></span></dt><dd><p>
       Only provides official releases of FindBugs.
      </p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-candidate/" target="_top">http://findbugs.cs.umd.edu/eclipse-candidate/</a></span></dt><dd><p>
          Provides official releases and release candidates of FindBugs.
        </p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-daily/" target="_top">http://findbugs.cs.umd.edu/eclipse-daily/</a></span></dt><dd><p>
         Provides the daily build of FindBugs. No testing other than that it compiles.
        </p></dd></dl></div><p>You can also manually
download the plugin from the following link:
<a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download" target="_top">http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download</a>.
Extract it in Eclipse's "plugins" subdirectory.
(So &lt;eclipse_install_dir&gt;/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png
should be the path to the <span class="application">FindBugs</span> logo.)

</p><p>
Once the plugin is extracted, start Eclipse and choose
<span class="guimenu">Help</span> &#8594; <span class="guimenuitem">About Eclipse Platform</span> &#8594; <span class="guimenuitem">Plug-in Details</span>.
You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project".
</p></div><div class="sect1" title="3.&nbsp;Using the Plugin"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1717"></a>3.&nbsp;Using the Plugin</h2></div></div></div><p>
To get started, right click on a Java project in Package Explorer,
and select the option labeled "Find Bugs".
<span class="application">FindBugs</span> 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.
</p><p>
You can also run <span class="application">FindBugs</span> 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,
<span class="application">FindBugs</span> will also link the generated warnings to the right source files.
</p><p>
You may customize how <span class="application">FindBugs</span> runs by opening the Properties
dialog for a Java project, and choosing the "Findbugs" property page.
Options you may choose include:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
    Enable or disable the "Run FindBugs Automatically" checkbox.
    When enabled, FindBugs will run every time you modify a Java class
    within the project.
    </p></li><li class="listitem"><p>
    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.
    </p></li><li class="listitem"><p>
    Select detectors.  The table allows you to select which detectors
    you want to enable for your project.
    </p></li></ul></div></div><div class="sect1" title="4.&nbsp;Extending the Eclipse Plugin (since 2.0.0)"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1748"></a>4.&nbsp;Extending the Eclipse Plugin (since 2.0.0)</h2></div></div></div><p>
Eclipse plugin supports contribution of custom <span class="application">FindBugs</span> detectors (see also
<a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a>
for more information). There are two ways to contribute custom plugins to the Eclipse:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
    Existing standard <span class="application">FindBugs</span> detector packages can be configured via
    <span class="guimenu">Window</span> &#8594; <span class="guimenuitem">Preferences</span> &#8594; <span class="guimenuitem">Java</span> &#8594; <span class="guimenuitem"><span class="application">FindBugs</span></span> &#8594; <span class="guimenuitem">Misc. Settings</span> &#8594; <span class="guimenuitem">Custom Detectors</span>.
    Simply specify there locations of any additional plugin libraries.
    </p><p>
    The benefit of this solution is that already existing detector packages can be
    used "as is", and that you can quickly verify the quality of third party detectors.
    The drawback is that you have to apply this settings in each
    new Eclipse workspace, and this settings can't be shared between team members.
    </p></li><li class="listitem"><p>
    It is possible to contribute custom detectors via standard Eclipse extensions mechanism.
    </p><p>
    Please check the documentation of the
    <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/eclipsePlugin/schema/detectorPlugins.exsd" target="_top">
    findBugsEclipsePlugin/schema/detectorPlugins.exsd</a>
    extension point how to update the plugin.xml. Existing <span class="application">FindBugs</span> detector plugins can
    be easily "extended" to be full featured <span class="application">FindBugs</span> AND Eclipse detector plugins.
    Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and
    update your build scripts to not to override the MANIFEST.MF during the build.
    </p><p>
    The benefit of this solution is that for given (shared) Eclipse installation
    each team member has exactly same detectors set, and there is no need to configure
    anything anymore. The (really small) precondition
    is that you have to convert your existing detectors package to the valid
    Eclipse plugin. You can do this even for third-party detector packages.
    Another major differentiator is the ability to extend the default FindBugs
    classpath at runtime with required third party libraries (see
    <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a>
    for more information).
    </p></li></ul></div></div><div class="sect1" title="5.&nbsp;Troubleshooting"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1802"></a>5.&nbsp;Troubleshooting</h2></div></div></div><p>
This section lists common problems with the plugin and (if known) how to resolve them.
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
    If you see OutOfMemory error dialogs after starting <span class="application">FindBugs</span> analysis in Eclipse,
    please increase JVM available memory: change eclipse.ini and add the lines below
    to the end of the file:
    </p><pre class="programlisting">
    -vmargs
    -Xmx1000m
    </pre><p>
    Important: the configuration arguments starting with the line "-vmargs" must
    be last lines in the eclipse.ini file, and only one argument per line is allowed!
    </p></li><li class="listitem"><p>
    If you do not see any <span class="application">FindBugs</span> problem markers (in your source
    windows or in the Problems View), you may need to change your
    Problems View filter settings.  See
    <a class="ulink" href="http://findbugs.sourceforge.net/FAQ.html#q7" target="_top">http://findbugs.sourceforge.net/FAQ.html#q7</a> for more information.
    </p></li></ul></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="anttask.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="filter.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;6.&nbsp;Using the <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> task&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;8.&nbsp;Filter Files</td></tr></table></div></body></html>