OLD | NEW |
1 <html><head> | 1 <html><head> |
2 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | 2 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
3 <title>Chapter 7. Using the FindBugs™ Eclipse plugin</title><
meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home"
href="index.html" title="FindBugs™ Manual"><link rel="up" href="index.htm
l" title="FindBugs™ Manual"><link rel="prev" href="anttask.html" title="Ch
apter 6. Using the FindBugs™ Ant task"><link rel="next" href="fi
lter.html" title="Chapter 8. Filter Files"></head><body bgcolor="white
" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navhea
der"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="
center">Chapter 7. Using the <span class="application">FindBugs</span>
™ Eclipse plugin</th></tr><tr><td width="20%" align="left"><a accesskey="p
" href="anttask.html">Prev</a> </td><th width="60%" align="center"> </
th><td width="20%" align="right"> <a accesskey="n" href="filter.html">Next<
/a></td></tr></table><hr></div><div class="chapter" title="Chapter 7.
Using the FindBugs™ Eclipse plugin"><div class="titlepage"><div><div><h2 c
lass="title"><a name="eclipse"></a>Chapter 7. Using the <span class="a
pplication">FindBugs</span>™ Eclipse plugin</h2></div></div></div><div cla
ss="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ecl
ipse.html#d0e1704">1. Requirements</a></span></dt><dt><span class="sect1"><a hre
f="eclipse.html#d0e1712">2. Installation</a></span></dt><dt><span class="sect1">
<a href="eclipse.html#d0e1759">3. Using the Plugin</a></span></dt><dt><span clas
s="sect1"><a href="eclipse.html#d0e1790">4. Extending the Eclipse Plugin (since
2.0.0)</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1843">5.
Troubleshooting</a></span></dt></dl></div><p> | 3 <title>Chapter 7. Using the FindBugs™ Eclipse plugin</title><
meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home"
href="index.html" title="FindBugs™ Manual"><link rel="up" href="index.htm
l" title="FindBugs™ Manual"><link rel="prev" href="anttask.html" title="Ch
apter 6. Using the FindBugs™ Ant task"><link rel="next" href="fi
lter.html" title="Chapter 8. Filter Files"></head><body bgcolor="white
" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navhea
der"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="
center">Chapter 7. Using the <span class="application">FindBugs</span>
™ Eclipse plugin</th></tr><tr><td width="20%" align="left"><a accesskey="p
" href="anttask.html">Prev</a> </td><th width="60%" align="center"> </
th><td width="20%" align="right"> <a accesskey="n" href="filter.html">Next<
/a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div>
<div><h1 class="title"><a name="eclipse"></a>Chapter 7. Using the <spa
n class="application">FindBugs</span>™ Eclipse plugin</h1></div></div></di
v><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span clas
s="sect1"><a href="eclipse.html#d0e1711">1. Requirements</a></span></dt><dt><spa
n class="sect1"><a href="eclipse.html#d0e1719">2. Installation</a></span></dt><d
t><span class="sect1"><a href="eclipse.html#d0e1766">3. Using the Plugin</a></sp
an></dt><dt><span class="sect1"><a href="eclipse.html#d0e1797">4. Extending the
Eclipse Plugin (since 2.0.0)</a></span></dt><dt><span class="sect1"><a href="ecl
ipse.html#d0e1850">5. Troubleshooting</a></span></dt></dl></div><p> |
4 The FindBugs Eclipse plugin allows <span class="application">FindBugs</span> to
be used within | 4 The FindBugs Eclipse plugin allows <span class="application">FindBugs</span> to
be used within |
5 the <a class="ulink" href="http://www.eclipse.org/" target="_top">Eclipse</a> ID
E. | 5 the <a class="ulink" href="http://www.eclipse.org/" target="_top">Eclipse</a> ID
E. |
6 The FindBugs Eclipse plugin was generously contributed by Peter Friese. | 6 The FindBugs Eclipse plugin was generously contributed by Peter Friese. |
7 Phil Crosby and Andrey Loskutov contributed major improvements | 7 Phil Crosby and Andrey Loskutov contributed major improvements |
8 to the plugin. | 8 to the plugin. |
9 </p><div class="sect1" title="1. Requirements"><div class="titlepage"><div>
<div><h2 class="title" style="clear: both"><a name="d0e1704"></a>1. Require
ments</h2></div></div></div><p> | 9 </p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style=
"clear: both"><a name="d0e1711"></a>1. Requirements</h2></div></div></div><
p> |
10 To use the <span class="application">FindBugs</span> Plugin for Eclipse, you nee
d Eclipse 3.3 or later, | 10 To use the <span class="application">FindBugs</span> Plugin for Eclipse, you nee
d Eclipse 3.3 or later, |
11 and JRE/JDK 1.5 or later. | 11 and JRE/JDK 1.5 or later. |
12 </p></div><div class="sect1" title="2. Installation"><div class="titlepage"
><div><div><h2 class="title" style="clear: both"><a name="d0e1712"></a>2. I
nstallation</h2></div></div></div><p> | 12 </p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title"
style="clear: both"><a name="d0e1719"></a>2. Installation</h2></div></div><
/div><p> |
13 We provide update sites that allow you to automatically install FindBugs into
Eclipse and also query and install updates. | 13 We provide update sites that allow you to automatically install FindBugs into
Eclipse and also query and install updates. |
14 There are three different update sites</p><div class="variablelist" title="Fin
dBugs 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.ed
u/eclipse/" target="_top">http://findbugs.cs.umd.edu/eclipse/</a></span></dt><dd
><p> | 14 There are three different update sites</p><div class="variablelist"><p class="
title"><b>FindBugs Eclipse update sites</b></p><dl class="variablelist"><dt><spa
n class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse/" targe
t="_top">http://findbugs.cs.umd.edu/eclipse/</a></span></dt><dd><p> |
15 Only provides official releases of FindBugs. | 15 Only provides official releases of FindBugs. |
16 </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-can
didate/</a></span></dt><dd><p> | 16 </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-can
didate/</a></span></dt><dd><p> |
17 Provides official releases and release candidates of FindBugs. | 17 Provides official releases and release candidates of FindBugs. |
18 </p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.c
s.umd.edu/eclipse-daily/" target="_top">http://findbugs.cs.umd.edu/eclipse-daily
/</a></span></dt><dd><p> | 18 </p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.c
s.umd.edu/eclipse-daily/" target="_top">http://findbugs.cs.umd.edu/eclipse-daily
/</a></span></dt><dd><p> |
19 Provides the daily build of FindBugs. No testing other than that it com
piles. | 19 Provides the daily build of FindBugs. No testing other than that it com
piles. |
20 </p></dd></dl></div><p>You can also manually | 20 </p></dd></dl></div><p>You can also manually |
21 download the plugin from the following link: | 21 download the plugin from the following link: |
22 <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.fi
ndbugs.plugin.eclipse_3.0.0.20140706.zip?download" target="_top">http://prdownlo
ads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_3.0.0.20140706.z
ip?download</a>. | 22 <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.fi
ndbugs.plugin.eclipse_3.0.1.20150306.zip?download" target="_top">http://prdownlo
ads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_3.0.1.20150306.z
ip?download</a>. |
23 Extract it in Eclipse's "plugins" subdirectory. | 23 Extract it in Eclipse's "plugins" subdirectory. |
24 (So <eclipse_install_dir>/plugins/edu.umd.cs.findbugs.plugin.eclipse_3.0.0
.20140706/findbugs.png | 24 (So <eclipse_install_dir>/plugins/edu.umd.cs.findbugs.plugin.eclipse_3.0.1
.20150306/findbugs.png |
25 should be the path to the <span class="application">FindBugs</span> logo.) | 25 should be the path to the <span class="application">FindBugs</span> logo.) |
26 | 26 |
27 </p><p> | 27 </p><p> |
28 Once the plugin is extracted, start Eclipse and choose | 28 Once the plugin is extracted, start Eclipse and choose |
29 <span class="guimenu">Help</span> → <span class="guimenuitem">About Eclips
e Platform</span> → <span class="guimenuitem">Plug-in Details</span>. | 29 <span class="guimenu">Help</span> → <span class="guimenuitem">About Eclips
e Platform</span> → <span class="guimenuitem">Plug-in Details</span>. |
30 You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project
". | 30 You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project
". |
31 </p></div><div class="sect1" title="3. Using the Plugin"><div class="titlep
age"><div><div><h2 class="title" style="clear: both"><a name="d0e1759"></a>3.&nb
sp;Using the Plugin</h2></div></div></div><p> | 31 </p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title"
style="clear: both"><a name="d0e1766"></a>3. Using the Plugin</h2></div></d
iv></div><p> |
32 To get started, right click on a Java project in Package Explorer, | 32 To get started, right click on a Java project in Package Explorer, |
33 and select the option labeled "Find Bugs". | 33 and select the option labeled "Find Bugs". |
34 <span class="application">FindBugs</span> will run, and problem markers (display
ed in source | 34 <span class="application">FindBugs</span> will run, and problem markers (display
ed in source |
35 windows, and also in the Eclipse Problems view) will point to | 35 windows, and also in the Eclipse Problems view) will point to |
36 locations in your code which have been identified as potential instances | 36 locations in your code which have been identified as potential instances |
37 of bug patterns. | 37 of bug patterns. |
38 </p><p> | 38 </p><p> |
39 You can also run <span class="application">FindBugs</span> on existing java arch
ives (jar, ear, zip, war etc). Simply | 39 You can also run <span class="application">FindBugs</span> on existing java arch
ives (jar, ear, zip, war etc). Simply |
40 create an empty Java project and attach archives to the project classpath. Havin
g that, you | 40 create an empty Java project and attach archives to the project classpath. Havin
g that, you |
41 can now right click the archive node in Package Explorer and select the option l
abeled | 41 can now right click the archive node in Package Explorer and select the option l
abeled |
42 "Find Bugs". If you additionally configure the source code locations for the bin
aries, | 42 "Find Bugs". If you additionally configure the source code locations for the bin
aries, |
43 <span class="application">FindBugs</span> will also link the generated warnings
to the right source files. | 43 <span class="application">FindBugs</span> will also link the generated warnings
to the right source files. |
44 </p><p> | 44 </p><p> |
45 You may customize how <span class="application">FindBugs</span> runs by opening
the Properties | 45 You may customize how <span class="application">FindBugs</span> runs by opening
the Properties |
46 dialog for a Java project, and choosing the "Findbugs" property page. | 46 dialog for a Java project, and choosing the "Findbugs" property page. |
47 Options you may choose include: | 47 Options you may choose include: |
48 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="li
stitem"><p> | 48 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: d
isc; "><li class="listitem"><p> |
49 Enable or disable the "Run FindBugs Automatically" checkbox. | 49 Enable or disable the "Run FindBugs Automatically" checkbox. |
50 When enabled, FindBugs will run every time you modify a Java class | 50 When enabled, FindBugs will run every time you modify a Java class |
51 within the project. | 51 within the project. |
52 </p></li><li class="listitem"><p> | 52 </p></li><li class="listitem"><p> |
53 Choose minimum warning priority and enabled bug categories. | 53 Choose minimum warning priority and enabled bug categories. |
54 These options will choose which warnings are shown. | 54 These options will choose which warnings are shown. |
55 For example, if you select the "Medium" warning priority, | 55 For example, if you select the "Medium" warning priority, |
56 only Medium and High priority warnings will be shown. | 56 only Medium and High priority warnings will be shown. |
57 Similarly, if you uncheck the "Style" checkbox, no warnings | 57 Similarly, if you uncheck the "Style" checkbox, no warnings |
58 in the Style category will be displayed. | 58 in the Style category will be displayed. |
59 </p></li><li class="listitem"><p> | 59 </p></li><li class="listitem"><p> |
60 Select detectors. The table allows you to select which detectors | 60 Select detectors. The table allows you to select which detectors |
61 you want to enable for your project. | 61 you want to enable for your project. |
62 </p></li></ul></div></div><div class="sect1" title="4. Extending the Ec
lipse Plugin (since 2.0.0)"><div class="titlepage"><div><div><h2 class="title" s
tyle="clear: both"><a name="d0e1790"></a>4. Extending the Eclipse Plugin (s
ince 2.0.0)</h2></div></div></div><p> | 62 </p></li></ul></div></div><div class="sect1"><div class="titlepage"><div><di
v><h2 class="title" style="clear: both"><a name="d0e1797"></a>4. Extending
the Eclipse Plugin (since 2.0.0)</h2></div></div></div><p> |
63 Eclipse plugin supports contribution of custom <span class="application">FindBug
s</span> detectors (see also | 63 Eclipse plugin supports contribution of custom <span class="application">FindBug
s</span> detectors (see also |
64 <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/findbugs/
src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a> | 64 <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/findbugs/
src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a> |
65 for more information). There are two ways to contribute custom plugins to the Ec
lipse: | 65 for more information). There are two ways to contribute custom plugins to the Ec
lipse: |
66 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="li
stitem"><p> | 66 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: d
isc; "><li class="listitem"><p> |
67 Existing standard <span class="application">FindBugs</span> detector package
s can be configured via | 67 Existing standard <span class="application">FindBugs</span> detector package
s can be configured via |
68 <span class="guimenu">Window</span> → <span class="guimenuitem">Prefer
ences</span> → <span class="guimenuitem">Java</span> → <span class="
guimenuitem">FindBugs</span> → <span class="guimenuitem">Misc. Settings</s
pan> → <span class="guimenuitem">Custom Detectors</span>. | 68 <span class="guimenu">Window</span> → <span class="guimenuitem">Prefer
ences</span> → <span class="guimenuitem">Java</span> → <span class="
guimenuitem">FindBugs</span> → <span class="guimenuitem">Misc. Settings</s
pan> → <span class="guimenuitem">Custom Detectors</span>. |
69 Simply specify there locations of any additional plugin libraries. | 69 Simply specify there locations of any additional plugin libraries. |
70 </p><p> | 70 </p><p> |
71 The benefit of this solution is that already existing detector packages can
be | 71 The benefit of this solution is that already existing detector packages can
be |
72 used "as is", and that you can quickly verify the quality of third party det
ectors. | 72 used "as is", and that you can quickly verify the quality of third party det
ectors. |
73 The drawback is that you have to apply this settings in each | 73 The drawback is that you have to apply this settings in each |
74 new Eclipse workspace, and this settings can't be shared between team member
s. | 74 new Eclipse workspace, and this settings can't be shared between team member
s. |
75 </p></li><li class="listitem"><p> | 75 </p></li><li class="listitem"><p> |
76 It is possible to contribute custom detectors via standard Eclipse extension
s mechanism. | 76 It is possible to contribute custom detectors via standard Eclipse extension
s mechanism. |
77 </p><p> | 77 </p><p> |
78 Please check the documentation of the | 78 Please check the documentation of the |
79 <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/eclip
sePlugin/schema/detectorPlugins.exsd" target="_top"> | 79 <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/eclip
sePlugin/schema/detectorPlugins.exsd" target="_top"> |
80 findBugsEclipsePlugin/schema/detectorPlugins.exsd</a> | 80 findBugsEclipsePlugin/schema/detectorPlugins.exsd</a> |
81 extension point how to update the plugin.xml. Existing <span class="applicat
ion">FindBugs</span> detector plugins can | 81 extension point how to update the plugin.xml. Existing <span class="applicat
ion">FindBugs</span> detector plugins can |
82 be easily "extended" to be full featured <span class="application">FindBugs<
/span> AND Eclipse detector plugins. | 82 be easily "extended" to be full featured <span class="application">FindBugs<
/span> AND Eclipse detector plugins. |
83 Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar
and | 83 Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar
and |
84 update your build scripts to not to override the MANIFEST.MF during the buil
d. | 84 update your build scripts to not to override the MANIFEST.MF during the buil
d. |
85 </p><p> | 85 </p><p> |
86 The benefit of this solution is that for given (shared) Eclipse installation | 86 The benefit of this solution is that for given (shared) Eclipse installation |
87 each team member has exactly same detectors set, and there is no need to con
figure | 87 each team member has exactly same detectors set, and there is no need to con
figure |
88 anything anymore. The (really small) precondition | 88 anything anymore. The (really small) precondition |
89 is that you have to convert your existing detectors package to the valid | 89 is that you have to convert your existing detectors package to the valid |
90 Eclipse plugin. You can do this even for third-party detector packages. | 90 Eclipse plugin. You can do this even for third-party detector packages. |
91 Another major differentiator is the ability to extend the default FindBugs | 91 Another major differentiator is the ability to extend the default FindBugs |
92 classpath at runtime with required third party libraries (see | 92 classpath at runtime with required third party libraries (see |
93 <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/findb
ugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a> | 93 <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/findb
ugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a> |
94 for more information). | 94 for more information). |
95 </p></li></ul></div></div><div class="sect1" title="5. Troubleshooting"
><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name=
"d0e1843"></a>5. Troubleshooting</h2></div></div></div><p> | 95 </p></li></ul></div></div><div class="sect1"><div class="titlepage"><div><di
v><h2 class="title" style="clear: both"><a name="d0e1850"></a>5. Troublesho
oting</h2></div></div></div><p> |
96 This section lists common problems with the plugin and (if known) how to resolve
them. | 96 This section lists common problems with the plugin and (if known) how to resolve
them. |
97 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="li
stitem"><p> | 97 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: d
isc; "><li class="listitem"><p> |
98 If you see OutOfMemory error dialogs after starting <span class="application
">FindBugs</span> analysis in Eclipse, | 98 If you see OutOfMemory error dialogs after starting <span class="application
">FindBugs</span> analysis in Eclipse, |
99 please increase JVM available memory: change eclipse.ini and add the lines b
elow | 99 please increase JVM available memory: change eclipse.ini and add the lines b
elow |
100 to the end of the file: | 100 to the end of the file: |
101 </p><pre class="programlisting"> | 101 </p><pre class="programlisting"> |
102 -vmargs | 102 -vmargs |
103 -Xmx1000m | 103 -Xmx1000m |
104 </pre><p> | 104 </pre><p> |
105 Important: the configuration arguments starting with the line "-vmargs" must | 105 Important: the configuration arguments starting with the line "-vmargs" must |
106 be last lines in the eclipse.ini file, and only one argument per line is all
owed! | 106 be last lines in the eclipse.ini file, and only one argument per line is all
owed! |
107 </p></li><li class="listitem"><p> | 107 </p></li><li class="listitem"><p> |
108 If you do not see any <span class="application">FindBugs</span> problem mark
ers (in your source | 108 If you do not see any <span class="application">FindBugs</span> problem mark
ers (in your source |
109 windows or in the Problems View), you may need to change your | 109 windows or in the Problems View), you may need to change your |
110 Problems View filter settings. See | 110 Problems View filter settings. See |
111 <a class="ulink" href="http://findbugs.sourceforge.net/FAQ.html#q7" target="
_top">http://findbugs.sourceforge.net/FAQ.html#q7</a> for more information. | 111 <a class="ulink" href="http://findbugs.sourceforge.net/FAQ.html#q7" target="
_top">http://findbugs.sourceforge.net/FAQ.html#q7</a> for more information. |
112 </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> </td><td width="20%" align="center"> </t
d><td width="40%" align="right"> <a accesskey="n" href="filter.html">Next</
a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 6. U
sing the <span class="application">FindBugs</span>™ <span class="applicati
on">Ant</span> task </td><td width="20%" align="center"><a accesskey="h" hr
ef="index.html">Home</a></td><td width="40%" align="right" valign="top"> Ch
apter 8. Filter Files</td></tr></table></div></body></html> | 112 </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> </td><td width="20%" align="center"> </t
d><td width="40%" align="right"> <a accesskey="n" href="filter.html">Next</
a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 6. U
sing the <span class="application">FindBugs</span>™ <span class="applicati
on">Ant</span> task </td><td width="20%" align="center"><a accesskey="h" hr
ef="index.html">Home</a></td><td width="40%" align="right" valign="top"> Ch
apter 8. Filter Files</td></tr></table></div></body></html> |
OLD | NEW |