manual.xml revision 489a0ec7301a86af8497d24748336db09ca278da
1<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> 2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 3 "file:/etc/docbook/docbookx.dtd" [ 4<!ENTITY FindBugs "<application>FindBugs</application>"> 5<!ENTITY Ant "<application>Ant</application>"> 6<!ENTITY Saxon "<application>Saxon</application>"> 7<!ENTITY FBHome "<replaceable>$FINDBUGS_HOME</replaceable>"> 8<!ENTITY FBHomeWin "<replaceable>%FINDBUGS_HOME%</replaceable>"> 9<!ENTITY nbsp " "> 10]> 11 12<book lang="en" id="findbugs-manual"> 13 14<bookinfo> 15<title>&FindBugs;™ Manual</title> 16 17<authorgroup> 18 <author> 19 <firstname>David</firstname> 20 <othername>H.</othername> 21 <surname>Hovemeyer</surname> 22 </author> 23 <author> 24 <firstname>William</firstname> 25 <othername>W.</othername> 26 <surname>Pugh</surname> 27 </author> 28</authorgroup> 29 30<copyright> 31 <year>2003 - 2012</year> 32 <holder>University of Maryland</holder> 33</copyright> 34 35<legalnotice> 36<para> 37This manual is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. 38To view a copy of this license, visit 39<ulink url="http://creativecommons.org/licenses/by-nc-sa/1.0/">http://creativecommons.org/licenses/by-nc-sa/1.0/</ulink> 40or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. 41</para> 42<para> 43The name FindBugs and the FindBugs logo are trademarked by the University of Maryland. 44</para> 45</legalnotice> 46 47<edition>2.0.2</edition> 48 49<pubdate>21:04:38 EST, 25 February, 2013</pubdate> 50 51</bookinfo> 52 53<!-- 54 ************************************************************************** 55 Introduction 56 ************************************************************************** 57--> 58 59<chapter id="introduction"> 60<title>Introduction</title> 61 62<para> &FindBugs;™ is a program to find bugs in Java programs. It looks for instances 63of "bug patterns" --- code instances that are likely to be errors.</para> 64 65<para> This document describes version 2.0.2 of &FindBugs;.We 66are very interested in getting your feedback on &FindBugs;. Please visit 67the <ulink url="http://findbugs.sourceforge.net">&FindBugs; web page</ulink> for 68the latest information on &FindBugs;, contact information, and support resources such 69as information about the &FindBugs; mailing lists.</para> 70 71<sect1> 72<title>Requirements</title> 73<para> To use &FindBugs;, you need a runtime environment compatible with 74<ulink url="http://java.sun.com/j2se">Java 2 Standard Edition</ulink>, version 1.5 or later. 75&FindBugs; is platform independent, and is known to run on GNU/Linux, Windows, and 76MacOS X platforms.</para> 77 78<para>You should have at least 512 MB of memory to use &FindBugs;. 79To analyze very large projects, more memory may be needed.</para> 80</sect1> 81 82</chapter> 83 84<!-- 85 ************************************************************************** 86 Installing FindBugs 87 ************************************************************************** 88--> 89 90<chapter id="installing"> 91<title>Installing &FindBugs;™</title> 92 93<para> 94This chapter explains how to install &FindBugs;. 95</para> 96 97<sect1> 98<title>Extracting the Distribution</title> 99 100<para> 101The easiest way to install &FindBugs; is to download a binary distribution. 102Binary distributions are available in 103<ulink url="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.2.tar.gz?download">gzipped tar format</ulink> and 104<ulink url="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.2.zip?download">zip format</ulink>. 105Once you have downloaded a binary distribution, extract it into a directory of your choice. 106</para> 107 108<para> 109Extracting a gzipped tar format distribution: 110<screen> 111<prompt>$ </prompt><command>gunzip -c findbugs-2.0.2.tar.gz | tar xvf -</command> 112</screen> 113</para> 114 115<para> 116Extracting a zip format distribution: 117<screen> 118<prompt>C:\Software></prompt><command>unzip findbugs-2.0.2.zip</command> 119</screen> 120</para> 121 122<para> 123Usually, extracting a binary distribution will create a directory ending in 124<filename class="directory">findbugs-2.0.2</filename>. For example, if you extracted 125the binary distribution from the <filename class="directory">C:\Software</filename> 126directory, then the &FindBugs; software will be extracted into the directory 127<filename class="directory">C:\Software\findbugs-2.0.2</filename>. 128This directory is the &FindBugs; home directory. We'll refer to it as 129&FBHome; (or &FBHomeWin; for Windows) throughout this manual. 130</para> 131</sect1> 132 133</chapter> 134 135<!-- 136 ************************************************************************** 137 Compiling FindBugs from Source 138 ************************************************************************** 139--> 140 141<chapter id="building"> 142<title>Building &FindBugs;™ from Source</title> 143 144<para> 145This chapter describes how to build &FindBugs; from source code. Unless you are 146interesting in modifying &FindBugs;, you will probably want to skip to the 147<link linkend="running">next chapter</link>. 148</para> 149 150<sect1> 151<title>Prerequisites</title> 152 153<para> 154To compile &FindBugs; from source, you will need the following: 155<itemizedlist> 156 <listitem> 157 <para> 158 The <ulink url="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.2-source.zip?download" 159 >&FindBugs; source distribution</ulink> 160 </para> 161 </listitem> 162 <listitem> 163 <para> 164 <ulink url="http://java.sun.com/j2se/">JDK 1.5.0 or later</ulink> 165 </para> 166 </listitem> 167 <listitem> 168 <para> 169 <ulink url="http://ant.apache.org/">Apache &Ant;</ulink>, version 1.6.3 or later 170 </para> 171 </listitem> 172</itemizedlist> 173</para> 174 175<warning> 176 <para> 177 The version of &Ant; included as <filename>/usr/bin/ant</filename> on 178 Redhat Linux systems will <emphasis>not</emphasis> work for compiling 179 &FindBugs;. We recommend you install a binary distribution of &Ant; 180 downloaded from the <ulink url="http://ant.apache.org/">&Ant; website</ulink>. 181 Make sure that when you run &Ant; your <replaceable>JAVA_HOME</replaceable> 182 environment variable points to the directory in which you installed 183 JDK 1.5 (or later). 184 </para> 185</warning> 186 187<para> 188If you want to be able to generate formatted versions of the &FindBugs; documentation, 189you will also need the following software: 190<itemizedlist> 191 <listitem> 192 <para> 193 The <ulink url="http://docbook.sourceforge.net/projects/xsl/index.html">DocBook XSL Stylesheets</ulink>. 194 These are required to convert the &FindBugs; manual into HTML format. 195 </para> 196 </listitem> 197 <listitem> 198 <para> 199 The <ulink url="http://saxon.sourceforge.net/">&Saxon; XSLT Processor</ulink>. 200 (Also required for converting the &FindBugs; manual to HTML.) 201 </para> 202 </listitem> 203<!-- 204 <listitem> 205 <para> 206 </para> 207 </listitem> 208--> 209</itemizedlist> 210</para> 211 212</sect1> 213 214<sect1> 215<title>Extracting the Source Distribution</title> 216<para> 217After you download the source distribution, you'll need to extract it into 218a working directory. A typical command to do this is: 219 220<screen> 221<prompt>$ </prompt><command>unzip findbugs-2.0.2-source.zip</command> 222</screen> 223 224</para> 225</sect1> 226 227<sect1> 228<title>Modifying <filename>local.properties</filename></title> 229<para> 230If you intend to build the FindBugs documentation, 231you will need to modify the <filename>local.properties</filename> file 232used by the <ulink url="http://ant.apache.org/">&Ant;</ulink> 233<filename>build.xml</filename> file to build &FindBugs;. 234If you do not want to build the FindBugs documentation, then you 235can ignore this file. 236</para> 237 238<para> 239The <filename>local.properties</filename> overrides definitions 240in the <filename>build.properties</filename> file. 241The <filename>build.properties</filename> file looks something like this: 242<programlisting> 243<![CDATA[ 244# User Configuration: 245# This section must be modified to reflect your system. 246 247local.software.home =/export/home/daveho/linux 248 249# Set this to the directory containing the DocBook Modular XSL Stylesheets 250# from http://docbook.sourceforge.net/projects/xsl/ 251 252xsl.stylesheet.home =${local.software.home}/docbook/docbook-xsl-1.71.1 253 254# Set this to the directory where Saxon (http://saxon.sourceforge.net/) 255# is installed. 256 257saxon.home =${local.software.home}/java/saxon-6.5.5 258]]> 259</programlisting> 260</para> 261 262<para> 263The <varname>xsl.stylesheet.home</varname> property specifies the full 264path to the directory where you have installed the 265<ulink url="http://docbook.sourceforge.net/projects/xsl/">DocBook Modular XSL 266Stylesheets</ulink>. You only need to specify this property if you will be 267generating the &FindBugs; documentation. 268</para> 269 270<para> 271The <varname>saxon.home</varname> property is the full path to the 272directory where you installed the <ulink url="http://saxon.sourceforge.net/">&Saxon; XSLT Processor</ulink>. 273You only need to specify this property if you will be 274generating the &FindBugs; documentation. 275</para> 276 277</sect1> 278 279<sect1> 280<title>Running &Ant;</title> 281 282<para> 283Once you have extracted the source distribution, 284made sure that &Ant; is installed, 285modified <filename>build.properties</filename> (optional), 286and configured the tools (such as &Saxon;), 287you are ready to build &FindBugs;. Invoking &Ant; is a simple matter 288of running the command 289<screen> 290<prompt>$ </prompt><command>ant <replaceable>target</replaceable></command> 291</screen> 292where <replaceable>target</replaceable> is one of the following: 293<variablelist> 294 <varlistentry> 295 <term><command>build</command></term> 296 <listitem> 297 <para> 298 This target compiles the code for &FindBugs;. It is the default target. 299 </para> 300 </listitem> 301 </varlistentry> 302 303 <varlistentry> 304 <term><command>docs</command></term> 305 <listitem> 306 <para> 307 This target formats the documentation. (It also compiles some of 308 the source code as a side-effect.) 309 </para> 310 </listitem> 311 </varlistentry> 312 313 <varlistentry> 314 <term><command>runjunit</command></term> 315 <listitem> 316 <para> 317 This target compiles and runs the internal JUnit tests included 318 in &FindBugs;. It will print an error message if any unit 319 tests fail. 320 </para> 321 </listitem> 322 </varlistentry> 323 324 <varlistentry> 325 <term><command>bindist</command></term> 326 <listitem> 327 <para> 328 Builds a binary distribution of &FindBugs;. 329 The target creates both <filename>.zip</filename> and 330 <filename>.tar.gz</filename> archives. 331 </para> 332 </listitem> 333 </varlistentry> 334</variablelist> 335</para> 336 337<para> 338After running an &Ant; command, you should see output similar to 339the following (after some other messages regarding the tasks that 340&Ant; is running): 341<screen> 342<computeroutput> 343BUILD SUCCESSFUL 344Total time: 17 seconds 345</computeroutput> 346</screen> 347</para> 348 349</sect1> 350 351<sect1> 352<title>Running &FindBugs;™ from a source directory</title> 353<para> 354The &Ant; build script for &FindBugs; is written such that after 355building the <command>build</command> target, the working directory 356is set up just like a binary distribution. So, the information about 357running &FindBugs; in <xref linkend="running" /> 358applies to source distributions, too. 359</para> 360</sect1> 361 362</chapter> 363 364 365<!-- 366 ************************************************************************** 367 Running FindBugs 368 ************************************************************************** 369--> 370 371<chapter id="running"> 372<title>Running &FindBugs;™</title> 373 374<para> 375&FindBugs; has two user interfaces: a graphical user interface (GUI) and a 376command line user interface. This chapter describes 377how to run each of these user interfaces. 378</para> 379 380 <warning> 381 <para> 382 This chapter is in the process of being re-written. 383 The rewrite is not complete yet. 384 </para> 385 </warning> 386 387<!-- 388<sect1> 389<title>Executing the &FindBugs;™ GUI</title> 390</sect1> 391--> 392 393<sect1> 394 <title>Quick Start</title> 395 <para> 396 If you are running &FindBugs; on a Windows system, 397 double-click on the file <filename>&FBHomeWin;\lib\findbugs.jar</filename> to start the &FindBugs; GUI. 398 </para> 399 400 <para> 401 On a Unix, Linux, or Mac OS X system, run the <filename>&FBHome;/bin/findbugs</filename> 402 script, or run the command <screen> 403<command>java -jar &FBHome;/lib/findbugs.jar</command></screen> 404 to run the &FindBugs; GUI. 405 </para> 406 407 <para> 408 Refer to <xref linkend="gui"/> for information on how to use the GUI. 409 </para> 410</sect1> 411 412<sect1> 413 414 <title>Executing &FindBugs;</title> 415 416 <para> 417 This section describes how to invoke the &FindBugs; program. 418 There are two ways to invoke &FindBugs;: directly, or using a 419 wrapper script. 420 </para> 421 422 423 <sect2 id="directInvocation"> 424 <title>Direct invocation of &FindBugs;</title> 425 426 <para> 427 The preferred method of running &FindBugs; is to directly execute 428 <filename>&FBHome;/lib/findbugs.jar</filename> using the <command>-jar</command> 429 command line switch of the JVM (<command>java</command>) executable. 430 (Versions of &FindBugs; prior to 1.3.5 required a wrapper script 431 to invoke &FindBugs;.) 432 </para> 433 434 <para> 435 The general syntax of invoking &FindBugs; directly is the following: 436<screen> 437 <command>java <replaceable>[JVM arguments]</replaceable> -jar &FBHome;/lib/findbugs.jar <replaceable>options...</replaceable></command> 438</screen> 439 </para> 440 441<!-- 442 <para> 443 By default, executing <filename>findbugs.jar</filename> runs the 444 &FindBugs; graphical user interface (GUI). On windows systems, 445 you can double-click on <filename>findbugs.jar</filename> to launch 446 the GUI. From a command line, the command 447 <screen> 448java -jar <replaceable>&FBHome;</replaceable>/lib/findbugs.jar</screen> 449 will launch the GUI. 450 </para> 451--> 452 453 <sect3 id="chooseUI"> 454 <title>Choosing the User Interface</title> 455 456 <para> 457 The first command line option chooses the &FindBugs; user interface to execute. 458 Possible values are: 459 </para> 460 <itemizedlist> 461 <listitem> 462 <para> 463 <command>-gui</command>: runs the graphical user interface (GUI) 464 </para> 465 </listitem> 466 467 <listitem> 468 <para> 469 <command>-textui</command>: runs the command line user interface 470 </para> 471 </listitem> 472 473 <listitem> 474 <para> 475 <command>-version</command>: displays the &FindBugs; version number 476 </para> 477 </listitem> 478 479 <listitem> 480 <para> 481 <command>-help</command>: displays help information for the 482 &FindBugs; command line user interface 483 </para> 484 </listitem> 485 486 <listitem> 487 <para> 488 <command>-gui1</command>: executes the original (obsolete) 489 &FindBugs; graphical user interface 490 </para> 491 </listitem> 492 </itemizedlist> 493 494 </sect3> 495 496 <sect3 id="jvmArgs"> 497 <title>Java Virtual Machine (JVM) arguments</title> 498 499 <para> 500 Several Java Virtual Machine arguments are useful when invoking 501 &FindBugs;. 502 </para> 503 504 <variablelist> 505 <varlistentry> 506 <term><command>-Xmx<replaceable>NN</replaceable>m</command></term> 507 <listitem> 508 <para> 509 Set the maximum Java heap size to <replaceable>NN</replaceable> 510 megabytes. &FindBugs; generally requires a large amount of 511 memory. For a very large project, using 1500 megabytes 512 is not unusual. 513 </para> 514 </listitem> 515 </varlistentry> 516 517 <varlistentry> 518 <term><command>-D<replaceable>name</replaceable>=<replaceable>value</replaceable></command></term> 519 <listitem> 520 <para> 521 Set a Java system property. For example, you might use the 522 argument <command>-Duser.language=ja</command> to display 523 GUI messages in Japanese. 524 </para> 525 </listitem> 526 </varlistentry> 527 528 <!-- 529 <varlistentry> 530 <term></term> 531 <listitem> 532 <para> 533 </para> 534 </listitem> 535 </varlistentry> 536 --> 537 </variablelist> 538 </sect3> 539 540 </sect2> 541 542 <sect2 id="wrapperScript"> 543 <title>Invocation of &FindBugs; using a wrapper script</title> 544 545 <para> 546 Another way to run &FindBugs; is to use a wrapper script. 547 </para> 548 549<para> 550On Unix-like systems, use the following command to invoke the wrapper script: 551<screen> 552<prompt>$ </prompt><command>&FBHome;/bin/findbugs <replaceable>options...</replaceable></command> 553</screen> 554</para> 555 556<para> 557On Windows systems, the command to invoke the wrapper script is 558<screen> 559<prompt>C:\My Directory></prompt><command>&FBHomeWin;\bin\findbugs.bat <replaceable>options...</replaceable></command> 560</screen> 561</para> 562 563<para> 564On both Unix-like and Windows systems, you can simply add the <filename><replaceable>$FINDBUGS_HOME</replaceable>/bin</filename> 565directory to your <filename>PATH</filename> environment variable and then invoke 566FindBugs using the <command>findbugs</command> command. 567</para> 568 569 <sect3 id="wrapperOptions"> 570 <title>Wrapper script command line options</title> 571 <para>The &FindBugs; wrapper scripts support the following command-line options. 572 Note that these command line options are <emphasis>not</emphasis> handled by 573 the &FindBugs; program per se; rather, they are handled by the wrapper 574 script. 575 </para> 576 <variablelist> 577 <varlistentry> 578 <term><command>-jvmArgs <replaceable>args</replaceable></command></term> 579 <listitem> 580 <para> 581 Specifies arguments to pass to the JVM. For example, you might want 582 to set a JVM property: 583<screen> 584<prompt>$ </prompt><command>findbugs -textui -jvmArgs "-Duser.language=ja" <replaceable>myApp.jar</replaceable></command> 585</screen> 586 </para> 587 </listitem> 588 </varlistentry> 589 590 <varlistentry> 591 <term><command>-javahome <replaceable>directory</replaceable></command></term> 592 <listitem> 593 <para> 594 Specifies the directory containing the JRE (Java Runtime Environment) to 595 use to execute &FindBugs;. 596 </para> 597 </listitem> 598 </varlistentry> 599 600 <varlistentry> 601 <term><command>-maxHeap <replaceable>size</replaceable></command></term> 602 <listitem> 603 <para> 604 Specifies the maximum Java heap size in megabytes. The default is 256. 605 More memory may be required to analyze very large programs or libraries. 606 </para> 607 </listitem> 608 </varlistentry> 609 610 <varlistentry> 611 <term><command>-debug</command></term> 612 <listitem> 613 <para> 614 Prints a trace of detectors run and classes analyzed to standard output. 615 Useful for troubleshooting unexpected analysis failures. 616 </para> 617 </listitem> 618 </varlistentry> 619 620 <varlistentry> 621 <term><command>-property</command> <replaceable>name=value</replaceable></term> 622 <listitem> 623 <para> 624 This option sets a system property. &FindBugs; uses system properties 625 to configure analysis options. See <xref linkend="analysisprops"/>. 626 You can use this option multiple times in order to set multiple properties. 627 Note: In most versions of Windows, the <replaceable>name=value</replaceable> 628 string must be in quotes. 629 </para> 630 </listitem> 631 </varlistentry> 632 633 </variablelist> 634 635 </sect3> 636 637</sect2> 638 639</sect1> 640 641<sect1 id="commandLineOptions"> 642<title>Command-line Options</title> 643 644<!-- 645<para> 646 647There are two ways to invoke &FindBugs;. The first invokes the the Graphical User Interface (GUI): 648 649<screen> 650<prompt>$ </prompt><command>findbugs <replaceable>[standard options]</replaceable> <replaceable>[GUI options]</replaceable></command> 651</screen> 652 653The second invokes the Command Line Interface (Text UI): 654 655<screen> 656<prompt>$ </prompt><command>findbugs -textui <replaceable>[standard options]</replaceable> <replaceable>[Text UI options]</replaceable></command> 657</screen> 658</para> 659--> 660 661<para> 662 This section describes the command line options supported by &FindBugs;. 663 These command line options may be used when invoking &FindBugs; directly, 664 or when using a wrapper script. 665</para> 666 667<sect2> 668<title>Common command-line options</title> 669 670<para> 671These options may be used with both the GUI and command-line interfaces. 672</para> 673 674<variablelist> 675 676 <varlistentry> 677 <term><command>-effort:min</command></term> 678 <listitem> 679 <para> 680 This option disables analyses that increase precision but also 681 increase memory consumption. You may want to try this option if 682 you find that &FindBugs; runs out of memory, or takes an unusually 683 long time to complete its analysis. 684 </para> 685 </listitem> 686 </varlistentry> 687 688 689 <varlistentry> 690 <term><command>-effort:max</command></term> 691 <listitem> 692 <para> 693 Enable analyses which increase precision and find more bugs, but which 694 may require more memory and take more time to complete. 695 </para> 696 </listitem> 697 </varlistentry> 698 699 <varlistentry> 700 <term><command>-project</command> <replaceable>project</replaceable></term> 701 <listitem> 702 <para> 703 Specify a project to be analyzed. The project file you specify should 704 be one that was created using the GUI interface. It will typically end 705 in the extension <filename>.fb</filename> or <filename>.fbp</filename>. 706 </para> 707 </listitem> 708 </varlistentry> 709 710 <!-- 711 <varlistentry> 712 <term><command></command></term> 713 <listitem> 714 <para> 715 716 </para> 717 </listitem> 718 </varlistentry> 719 --> 720 721</variablelist> 722 723</sect2> 724 725<sect2> 726<title>GUI Options</title> 727 728<para> 729These options are only accepted by the Graphical User Interface. 730 731<variablelist> 732 <varlistentry> 733 <term><command>-look:</command><replaceable>plastic|gtk|native</replaceable></term> 734 <listitem> 735 <para> 736 Set Swing look and feel. 737 </para> 738 </listitem> 739 </varlistentry> 740 741</variablelist> 742</para> 743</sect2> 744 745<sect2> 746<title>Text UI Options</title> 747 748<para> 749These options are only accepted by the Text User Interface. 750</para> 751 752<variablelist> 753 <varlistentry> 754 <term><command>-sortByClass</command></term> 755 <listitem> 756 <para> 757 Sort reported bug instances by class name. 758 </para> 759 </listitem> 760 </varlistentry> 761 762 <varlistentry> 763 <term><command >-include</command> <replaceable>filterFile.xml</replaceable></term> 764 <listitem> 765 <para> 766 Only report bug instances that match the filter specified by <replaceable>filterFile.xml</replaceable>. 767 See <xref linkend="filter" />. 768 </para> 769 </listitem> 770 </varlistentry> 771 772 <varlistentry> 773 <term><command >-exclude</command> <replaceable>filterFile.xml</replaceable></term> 774 <listitem> 775 <para> 776 Report all bug instances except those matching the filter specified by <replaceable>filterFile.xml</replaceable>. 777 See <xref linkend="filter" />. 778 </para> 779 </listitem> 780 </varlistentry> 781 782 <varlistentry> 783 <term><command>-onlyAnalyze</command> <replaceable>com.foobar.MyClass,com.foobar.mypkg.*</replaceable></term> 784 <listitem> 785 <para> 786 Restrict analysis to find bugs to given comma-separated list of 787 classes and packages. 788 Unlike filtering, this option avoids running analysis on 789 classes and packages that are not explicitly matched: 790 for large projects, this may greatly reduce the amount of time 791 needed to run the analysis. (However, some detectors may produce 792 inaccurate results if they aren't run on the entire application.) 793 Classes should be specified using their full classnames (including 794 package), and packages should be specified in the same way 795 they would in a Java <literal>import</literal> statement to 796 import all classes in the package (i.e., add <literal>.*</literal> 797 to the full name of the package). 798 Replace <literal>.*</literal> with <literal>.-</literal> to also 799 analyze all subpackages. 800 </para> 801 </listitem> 802 </varlistentry> 803 804 <varlistentry> 805 <term><command>-low</command></term> 806 <listitem> 807 <para> 808 Report all bugs. 809 </para> 810 </listitem> 811 </varlistentry> 812 813 <varlistentry> 814 <term><command>-medium</command></term> 815 <listitem> 816 <para> 817 Report medium and high priority bugs. This is the default setting. 818 </para> 819 </listitem> 820 </varlistentry> 821 822 <varlistentry> 823 <term><command>-high</command></term> 824 <listitem> 825 <para> 826 Report only high priority bugs. 827 </para> 828 </listitem> 829 </varlistentry> 830 831 <varlistentry> 832 <term><command>-relaxed</command></term> 833 <listitem> 834 <para> 835 Relaxed reporting mode. For many detectors, this option 836 suppresses the heuristics used to avoid reporting false positives. 837 </para> 838 </listitem> 839 </varlistentry> 840 841 <varlistentry> 842 <term><command>-xml</command></term> 843 <listitem> 844 <para> 845 Produce the bug reports as XML. The XML data produced may be 846 viewed in the GUI at a later time. You may also specify this 847 option as <command>-xml:withMessages</command>; when this variant 848 of the option is used, the XML output will contain human-readable 849 messages describing the warnings contained in the file. 850 XML files generated this way are easy to transform into reports. 851 </para> 852 </listitem> 853 </varlistentry> 854 855 <varlistentry> 856 <term><command>-html</command></term> 857 <listitem> 858 <para> 859 Generate HTML output. By default, &FindBugs; will use the <filename>default.xsl</filename> 860 <ulink url="http://www.w3.org/TR/xslt">XSLT</ulink> 861 stylesheet to generate the HTML: you can find this file in <filename>findbugs.jar</filename>, 862 or in the &FindBugs; source or binary distributions. Variants of this option include 863 <command>-html:plain.xsl</command>, <command>-html:fancy.xsl</command> and <command>-html:fancy-hist.xsl</command>. 864 The <filename>plain.xsl</filename> stylesheet does not use Javascript or DOM, 865 and may work better with older web browsers, or for printing. The <filename>fancy.xsl</filename> 866 stylesheet uses DOM and Javascript for navigation and CSS for 867 visual presentation. The <command>fancy-hist.xsl</command> an evolution of <command>fancy.xsl</command> stylesheet. 868 It makes an extensive use of DOM and Javascript for dynamically filtering the lists of bugs. 869 </para> 870 871 <para> 872 If you want to specify your own 873 XSLT stylesheet to perform the transformation to HTML, specify the option as 874 <command>-html:<replaceable>myStylesheet.xsl</replaceable></command>, 875 where <replaceable>myStylesheet.xsl</replaceable> is the filename of the 876 stylesheet you want to use. 877 </para> 878 </listitem> 879 </varlistentry> 880 881 <varlistentry> 882 <term><command>-emacs</command></term> 883 <listitem> 884 <para> 885 Produce the bug reports in Emacs format. 886 </para> 887 </listitem> 888 </varlistentry> 889 890 <varlistentry> 891 <term><command>-xdocs</command></term> 892 <listitem> 893 <para> 894 Produce the bug reports in xdoc XML format for use with Apache Maven. 895 </para> 896 </listitem> 897 </varlistentry> 898 899 <varlistentry> 900 <term><command>-output</command> <replaceable>filename</replaceable></term> 901 <listitem> 902 <para> 903 Produce the output in the specified file. 904 </para> 905 </listitem> 906 </varlistentry> 907 908 <varlistentry> 909 <term><command>-outputFile</command> <replaceable>filename</replaceable></term> 910 <listitem> 911 <para> 912 This argument is deprecated. Use <command>-output</command> instead. 913 </para> 914 </listitem> 915 </varlistentry> 916 917 <varlistentry> 918 <term><command>-nested</command><replaceable>[:true|false]</replaceable></term> 919 <listitem> 920 <para> 921 This option enables or disables scanning of nested jar and zip files found in 922 the list of files and directories to be analyzed. 923 By default, scanning of nested jar/zip files is enabled. 924 To disable it, add <command>-nested:false</command> to the command line 925 arguments. 926 </para> 927 </listitem> 928 </varlistentry> 929 930 <varlistentry> 931 <term><command>-auxclasspath</command> <replaceable>classpath</replaceable></term> 932 <listitem> 933 <para> 934 Set the auxiliary classpath for analysis. This classpath should include all 935 jar files and directories containing classes that are part of the program 936 being analyzed but you do not want to have analyzed for bugs. 937 </para> 938 </listitem> 939 </varlistentry> 940 941<!-- 942 <varlistentry> 943 <term><command></command> <replaceable></replaceable></term> 944 <listitem> 945 <para> 946 </para> 947 </listitem> 948 </varlistentry> 949--> 950 951</variablelist> 952 953</sect2> 954</sect1> 955 956 957</chapter> 958 959<chapter id="gui"> 960 <title>Using the &FindBugs; GUI</title> 961 962 <para> 963 This chapter describes how to use the &FindBugs; graphical user interface (GUI). 964 </para> 965 966<sect1> 967<title>Creating a Project</title> 968<para> 969After you have started &FindBugs; using the <command>findbugs</command> command, 970choose the <menuchoice><guimenu>File</guimenu><guimenuitem>New Project</guimenuitem></menuchoice> 971menu item. You will see a dialog which looks like this: 972<mediaobject> 973<imageobject> 974<imagedata fileref="project-dialog.png" /> 975</imageobject> 976</mediaobject> 977</para> 978 979<para> 980Use the "Add" button next to "Classpath to analyze" to select a Java archive 981file (zip, jar, ear, or war file) or directory containing java classes to analyze for bugs. You may add multiple 982archives/directories. 983</para> 984 985<para> 986You can also add the source directories which contain 987the source code for the Java archives you are analyzing. This will enable 988&FindBugs; to highlight the source code which contains a possible error. 989The source directories you add should be the roots of the Java 990package hierarchy. For example, if your application is contained in the 991<varname>org.foobar.myapp</varname> package, you should add the 992parent directory of the <filename class="directory">org</filename> directory 993to the source directory list for the project. 994</para> 995 996<para> 997Another optional step is to add additional Jar files or directories as 998"Auxiliary classpath locations" entries. You should do this if the archives and directories you are analyzing 999have references to other classes which are not included in the analyzed 1000archives/directories and are not in the standard runtime classpath. Some of the bug 1001pattern detectors in &FindBugs; make use of class hierarchy information, 1002so you will get more accurate results if the entire class hierarchy is 1003available which &FindBugs; performs its analysis. 1004</para> 1005 1006</sect1> 1007 1008<sect1> 1009<title>Running the Analysis</title> 1010<para> 1011Once you have added all of the archives, directories, and source directories, 1012click the "Analyze" button to analyze the classes contained in the 1013Jar files. Note that for a very large program on an older computer, 1014this may take quite a while (tens of minutes). A recent computer with 1015ample memory will typically be able to analyze a large program in only a 1016few minutes. 1017</para> 1018</sect1> 1019 1020<sect1> 1021<title>Browsing Results</title> 1022 1023<para> 1024When the analysis completes, you will see a screen like the following: 1025<mediaobject> 1026 <imageobject> 1027 <imagedata fileref="example-details.png" /> 1028 </imageobject> 1029</mediaobject> 1030</para> 1031 1032<para> 1033The upper left-hand pane of the window shows the bug tree; this is a hierarchical 1034representation of all of the potential bugs detected in the analyzed 1035Jar files. 1036</para> 1037 1038<para> 1039When you select a particular bug instance in the top pane, you will 1040see a description of the bug in the "Details" tab of the bottom pane. 1041In addition, the source code pane on the upper-right will show the 1042program source code where the potential bug occurs, if source is available. 1043In the above example, the bug is a stream object that is not closed. The 1044source code window highlights the line where the stream object is created. 1045</para> 1046 1047<para> 1048You may add a textual annotations to bug instances. To do so, type them 1049into the text box just below the hierarchical view. You can type any 1050information which you would like to record. When you load and save bug 1051results files, the annotations are preserved. 1052</para> 1053 1054</sect1> 1055 1056<sect1> 1057<title>Saving and Opening</title> 1058 1059<para> 1060You may use the <menuchoice><guimenu>File</guimenu><guimenuitem>Save as...</guimenuitem></menuchoice> 1061menu option to save your work. To save your work, including the jar 1062file lists you specified and all bug results, choose 1063"FindBugs analysis results (.xml)" from the drop-down list in the 1064"Save as..." dialog. There are also options for saving just the jar 1065file lists ("FindBugs project file (.fbp)") or just the results 1066("FindBugs analysis file (.fba)"). 1067A saved file may be loaded with the 1068<menuchoice><guimenu>File</guimenu><guimenuitem>Open...</guimenuitem></menuchoice> 1069menu option. 1070</para> 1071 1072</sect1> 1073 1074<!-- 1075<sect1 id="textui"> 1076<title>Using the &FindBugs;™ Command Line Interface</title> 1077 1078<para> 1079The &FindBugs; Command Line Interface (or Text UI) can be used to 1080analyze an application for bugs non-interactively. Each bug instance will be 1081reported on a single line. All output is written to the standard output file descriptor. 1082<xref linkend="filter" /> explains how bug reports may be filtered in order 1083to get only the output you're interested in. 1084</para> 1085 1086<para> 1087See <xref linkend="commandLineOptions" /> for a description of how to invoke the 1088Command Line Interface. 1089</para> 1090</sect1> 1091--> 1092 1093</chapter> 1094 1095<!-- 1096 ************************************************************************** 1097 Using the FindBugs Ant task 1098 ************************************************************************** 1099--> 1100 1101<chapter id="anttask"> 1102<title>Using the &FindBugs;™ &Ant; task</title> 1103 1104<para> 1105This chapter describes how to integrate &FindBugs; into a build script 1106for <ulink url="http://ant.apache.org/">&Ant;</ulink>, which is a popular Java build 1107and deployment tool. Using the &FindBugs; &Ant; task, your build script can 1108automatically run &FindBugs; on your Java code. 1109</para> 1110 1111<para> 1112The &Ant; task was generously contributed by Mike Fagan. 1113</para> 1114 1115<sect1> 1116<title>Installing the &Ant; task</title> 1117 1118<para> 1119To install the &Ant; task, simply copy <filename>&FBHome;/lib/findbugs-ant.jar</filename> 1120into the <filename>lib</filename> subdirectory of your &Ant; installation. 1121 1122<note> 1123<para>It is strongly recommended that you use the &Ant; task with the version 1124of &FindBugs; it was included with. We do not guarantee that the &Ant; task Jar file 1125will work with any version of &FindBugs; other than the one it was included with.</para> 1126</note> 1127</para> 1128 1129</sect1> 1130 1131<sect1> 1132<title>Modifying build.xml</title> 1133 1134<para> 1135To incorporate &FindBugs; into <filename>build.xml</filename> (the build script 1136for &Ant;), you first need to add a task definition. This should appear as follows: 1137 1138<screen> 1139 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/> 1140</screen> 1141 1142The task definition specifies that when a <literal>findbugs</literal> element is 1143seen in <filename>build.xml</filename>, it should use the indicated class to execute the task. 1144</para> 1145 1146<para> 1147After you have added the task definition, you can define a target 1148which uses the <literal>findbugs</literal> task. Here is an example 1149which could be added to the <filename>build.xml</filename> for the 1150Apache <ulink url="http://jakarta.apache.org/bcel/">BCEL</ulink> library. 1151 1152<screen> 1153 <property name="findbugs.home" value="/export/home/daveho/work/findbugs" /> 1154 1155 <target name="findbugs" depends="jar"> 1156 <findbugs home="${findbugs.home}" 1157 output="xml" 1158 outputFile="bcel-fb.xml" > 1159 <auxClasspath path="${basedir}/lib/Regex.jar" /> 1160 <sourcePath path="${basedir}/src/java" /> 1161 <class location="${basedir}/bin/bcel.jar" /> 1162 </findbugs> 1163 </target> 1164</screen> 1165 1166The <literal>findbugs</literal> element must have the <literal>home</literal> 1167attribute set to the directory in which &FindBugs; is installed; in other words, 1168&FBHome;. See <xref linkend="installing" />. 1169</para> 1170 1171<para> 1172This target will execute &FindBugs; on <filename>bcel.jar</filename>, which is the 1173Jar file produced by BCEL's build script. (By making it depend on the "jar" 1174target, we ensure that the library is fully compiled before running &FindBugs; on it.) 1175The output of &FindBugs; will be saved in XML format to a file called 1176<filename>bcel-fb.xml</filename>. 1177An auxiliary Jar file, <filename>Regex.jar</filename>, is added to the aux classpath, 1178because it is referenced by the main BCEL library. A source path is specified 1179so that the saved bug data will have accurate references to the BCEL source code. 1180</para> 1181</sect1> 1182 1183<sect1> 1184<title>Executing the task</title> 1185 1186<para> 1187Here is an example of invoking &Ant; from the command line, using the <literal>findbugs</literal> 1188target defined above. 1189 1190<screen> 1191 <prompt>[daveho@noir]$</prompt> <command>ant findbugs</command> 1192 Buildfile: build.xml 1193 1194 init: 1195 1196 compile: 1197 1198 examples: 1199 1200 jar: 1201 1202 findbugs: 1203 [findbugs] Running FindBugs... 1204 [findbugs] Bugs were found 1205 [findbugs] Output saved to bcel-fb.xml 1206 1207 BUILD SUCCESSFUL 1208 Total time: 35 seconds 1209</screen> 1210 1211In this case, because we saved the bug results in an XML file, we can 1212use the &FindBugs; GUI to view the results; see <xref linkend="running"/>. 1213</para> 1214 1215</sect1> 1216 1217<sect1> 1218<title>Parameters</title> 1219 1220<para>This section describes the parameters that may be specified when 1221using the &FindBugs; task. 1222 1223<variablelist> 1224 1225 <varlistentry> 1226 <term><literal>class</literal></term> 1227 <listitem> 1228 <para> 1229 A optional nested element specifying which classes to analyze. The <literal>class</literal> 1230 element must specify a <literal>location</literal> attribute which names the 1231 archive file (jar, zip, etc.), directory, or class file to be analyzed. Multiple <literal>class</literal> 1232 elements may be specified as children of a single <literal>findbugs</literal> element. 1233 </para> 1234 <para>In addition to or instead of specifying a <literal>class</literal> element, 1235 the &FindBugs; task can contain one or more <literal>fileset</literal> element(s) that 1236 specify files to be analyzed. 1237 For example, you might use a fileset to specify that all of the jar files in a directory 1238 should be analyzed. 1239 </para> 1240 </listitem> 1241 </varlistentry> 1242 1243 <varlistentry> 1244 <term><literal>auxClasspath</literal></term> 1245 <listitem> 1246 <para> 1247 An optional nested element which specifies a classpath (Jar files or directories) 1248 containing classes used by the analyzed library or application, but which 1249 you don't want to analyze. It is specified the same way as 1250 &Ant;'s <literal>classpath</literal> element for the Java task. 1251 </para> 1252 </listitem> 1253 </varlistentry> 1254 1255 <varlistentry> 1256 <term><literal>sourcePath</literal></term> 1257 <listitem> 1258 <para> 1259 An optional nested element which specifies a source directory path 1260 containing source files used to compile the Java code being analyzed. 1261 By specifying a source path, any generated XML bug output will have 1262 complete source information, which allows later viewing in the 1263 GUI. 1264 </para> 1265 </listitem> 1266 </varlistentry> 1267 1268 <varlistentry> 1269 <term><literal>home</literal></term> 1270 <listitem> 1271 <para> 1272 A required attribute. 1273 It must be set to the name of the directory where &FindBugs; is installed. 1274 </para> 1275 </listitem> 1276 </varlistentry> 1277 1278 <varlistentry> 1279 <term><literal>quietErrors</literal></term> 1280 <listitem> 1281 <para> 1282 An optional boolean attribute. 1283 If true, reports of serious analysis errors and missing classes will 1284 be suppressed in the &FindBugs; output. Default is false. 1285 </para> 1286 </listitem> 1287 </varlistentry> 1288 1289 <varlistentry> 1290 <term><literal>reportLevel</literal></term> 1291 <listitem> 1292 <para> 1293 An optional attribute. It specifies 1294 the confidence/priority threshold for reporting issues. If set to "low", confidence is not used to filter bugs. 1295 If set to "medium" (the default), low confidence issues are supressed. 1296 If set to "high", only high confidence bugs are reported. 1297 </para> 1298 </listitem> 1299 </varlistentry> 1300 1301 <varlistentry> 1302 <term><literal>output</literal></term> 1303 <listitem> 1304 <para> 1305 Optional attribute. 1306 It specifies the output format. If set to "xml" (the default), output 1307 is in XML format. 1308 If set to "xml:withMessages", output is in XML format augmented with 1309 human-readable messages. (You should use this format if you plan 1310 to generate a report using an XSL stylesheet.) 1311 If set to "html", output is in HTML formatted (default stylesheet is default.xsl). 1312 If set to "text", output is in ad-hoc text format. 1313 If set to "emacs", output is in <ulink url="http://www.gnu.org/software/emacs/">Emacs</ulink> error message format. 1314 If set to "xdocs", output is xdoc XML for use with Apache Maven. 1315 </para> 1316 </listitem> 1317 </varlistentry> 1318 <varlistentry> 1319 <term><literal>stylesheet</literal></term> 1320 <listitem> 1321 <para> 1322 Optional attribute. 1323 It specifies the stylesheet to use to generate html output when the output is set to html. 1324 Stylesheets included in the FindBugs distribution include default.xsl, fancy.xsl, fancy-hist.xsl, plain.xsl, and summary.xsl. 1325 The default value, if no stylesheet attribute is provided, is default.xsl. 1326 1327 </para> 1328 </listitem> 1329 </varlistentry> 1330 1331 <varlistentry> 1332 <term><literal>sort</literal></term> 1333 <listitem> 1334 <para> 1335 Optional attribute. If the <literal>output</literal> attribute 1336 is set to "text", then the <literal>sort</literal> attribute specifies 1337 whether or not reported bugs are sorted by class. Default is true. 1338 </para> 1339 </listitem> 1340 </varlistentry> 1341 1342 <varlistentry> 1343 <term><literal>outputFile</literal></term> 1344 <listitem> 1345 <para> 1346 Optional attribute. If specified, names the output file in which the 1347 &FindBugs; output will be saved. By default, the output is displayed 1348 directly by &Ant;. 1349 </para> 1350 </listitem> 1351 </varlistentry> 1352 1353 <varlistentry> 1354 <term><literal>debug</literal></term> 1355 <listitem> 1356 <para> 1357 Optional boolean attribute. If set to true, &FindBugs; prints diagnostic 1358 information about which classes are being analyzed, and which bug pattern 1359 detectors are being run. Default is false. 1360 </para> 1361 </listitem> 1362 </varlistentry> 1363 1364 <varlistentry> 1365 <term><literal>effort</literal></term> 1366 <listitem> 1367 <para> 1368 Set the analysis effort level. The value specified should be 1369 one of <literal>min</literal>, <literal>default</literal>, 1370 or <literal>max</literal>. See <xref linkend="commandLineOptions"/> 1371 for more information about setting the analysis level. 1372 </para> 1373 </listitem> 1374 </varlistentry> 1375 1376 <varlistentry> 1377 <term><literal>conserveSpace</literal></term> 1378 <listitem> 1379 <para>Synonym for effort="min".</para> 1380 </listitem> 1381 </varlistentry> 1382 1383 <varlistentry> 1384 <term><literal>workHard</literal></term> 1385 <listitem> 1386 <para>Synonym for effort="max".</para> 1387 </listitem> 1388 </varlistentry> 1389 1390 <varlistentry> 1391 <term><literal>visitors</literal></term> 1392 <listitem> 1393 <para> 1394 Optional attribute. It specifies a comma-separated list of bug detectors 1395 which should be run. The bug detectors are specified by their class names, 1396 without any package qualification. By default, all detectors which are 1397 not disabled by default are run. 1398 </para> 1399 </listitem> 1400 </varlistentry> 1401 1402 <varlistentry> 1403 <term><literal>omitVisitors</literal></term> 1404 <listitem> 1405 <para> 1406 Optional attribute. It is like the <literal>visitors</literal> attribute, 1407 except it specifies detectors which will <emphasis>not</emphasis> be run. 1408 </para> 1409 </listitem> 1410 </varlistentry> 1411 1412 <varlistentry> 1413 <term><literal>excludeFilter</literal></term> 1414 <listitem> 1415 <para> 1416 Optional attribute. It specifies the filename of a filter specifying bugs 1417 to exclude from being reported. See <xref linkend="filter" />. 1418 </para> 1419 </listitem> 1420 </varlistentry> 1421 1422 <varlistentry> 1423 <term><literal>includeFilter</literal></term> 1424 <listitem> 1425 <para> 1426 Optional attribute. It specifies the filename of a filter specifying 1427 which bugs are reported. See <xref linkend="filter" />. 1428 </para> 1429 </listitem> 1430 </varlistentry> 1431 1432 <varlistentry> 1433 <term><literal>projectFile</literal></term> 1434 <listitem> 1435 <para> 1436 Optional attribute. It specifies the name of a project file. 1437 Project files are created by the &FindBugs; GUI, and specify classes, 1438 aux classpath entries, and source directories. By naming a project, 1439 you don't need to specify any <literal>class</literal> elements, 1440 nor do you need to specify <literal>auxClasspath</literal> or 1441 <literal>sourcePath</literal> attributes. 1442 See <xref linkend="running"/> for how to create a project. 1443 </para> 1444 </listitem> 1445 </varlistentry> 1446 1447 <varlistentry> 1448 <term><literal>jvmargs</literal></term> 1449 <listitem> 1450 <para> 1451 Optional attribute. It specifies any arguments that should be passed 1452 to the Java virtual machine used to run &FindBugs;. You may need to 1453 use this attribute to specify flags to increase the amount of memory 1454 the JVM may use if you are analyzing a very large program. 1455 </para> 1456 </listitem> 1457 </varlistentry> 1458 1459 <varlistentry> 1460 <term><literal>systemProperty</literal></term> 1461 <listitem> 1462 <para> 1463 Optional nested element. If specified, defines a system property. 1464 The <literal>name</literal> attribute specifies the name of the 1465 system property, and the <literal>value</literal> attribute specifies 1466 the value of the system property. 1467 </para> 1468 </listitem> 1469 </varlistentry> 1470 1471 <varlistentry> 1472 <term><literal>timeout</literal></term> 1473 <listitem> 1474 <para> 1475 Optional attribute. It specifies the amount of time, in milliseconds, 1476 that the Java process executing &FindBugs; may run before it is 1477 assumed to be hung and is terminated. The default is 600,000 1478 milliseconds, which is ten minutes. Note that for very large 1479 programs, &FindBugs; may require more than ten minutes to complete its 1480 analysis. 1481 </para> 1482 </listitem> 1483 </varlistentry> 1484 1485 <varlistentry> 1486 <term><literal>failOnError</literal></term> 1487 <listitem> 1488 <para> 1489 Optional boolean attribute. Whether to abort the build process if there is an 1490 error running &FindBugs;. Defaults to "false" 1491 </para> 1492 </listitem> 1493 </varlistentry> 1494 1495 <varlistentry> 1496 <term><literal>errorProperty</literal></term> 1497 <listitem> 1498 <para> 1499 Optional attribute which specifies the name of a property that 1500 will be set to "true" if an error occurs while running &FindBugs;. 1501 </para> 1502 </listitem> 1503 </varlistentry> 1504 1505 <varlistentry> 1506 <term><literal>warningsProperty</literal></term> 1507 <listitem> 1508 <para> 1509 Optional attribute which specifies the name of a property 1510 that will be set to "true" if any warnings are reported by 1511 &FindBugs; on the analyzed program. 1512 </para> 1513 </listitem> 1514 </varlistentry> 1515 1516</variablelist> 1517 1518 1519</para> 1520 1521<!-- 1522 1523--> 1524 1525</sect1> 1526 1527</chapter> 1528 1529<!-- 1530 ************************************************************************** 1531 Using the FindBugs Eclipse plugin 1532 ************************************************************************** 1533--> 1534 1535<chapter id="eclipse"> 1536<title>Using the &FindBugs;™ Eclipse plugin</title> 1537 1538<para> 1539The FindBugs Eclipse plugin allows &FindBugs; to be used within 1540the <ulink url="http://www.eclipse.org/">Eclipse</ulink> IDE. 1541The FindBugs Eclipse plugin was generously contributed by Peter Friese. 1542Phil Crosby and Andrei Loskutov contributed major improvements 1543to the plugin. 1544</para> 1545 1546<sect1> 1547<title>Requirements</title> 1548 1549<para> 1550To use the &FindBugs; Plugin for Eclipse, you need Eclipse 3.3 or later, 1551and JRE/JDK 1.5 or later. 1552</para> 1553 1554</sect1> 1555 1556<sect1> 1557<title>Installation</title> 1558 1559<para> 1560 We provide update sites that allow you to automatically install FindBugs into Eclipse and also query and install updates. 1561 There are three different update sites</para> 1562 1563 <variablelist><title>FindBugs Eclipse update sites</title> 1564 <varlistentry><term><ulink url="http://findbugs.cs.umd.edu/eclipse/">http://findbugs.cs.umd.edu/eclipse/</ulink></term> 1565 1566 <listitem> 1567 <para> 1568 Only provides official releases of FindBugs. 1569 </para> 1570 </listitem> 1571 </varlistentry> 1572 1573 <varlistentry><term><ulink url="http://findbugs.cs.umd.edu/eclipse-candidate/">http://findbugs.cs.umd.edu/eclipse-candidate/</ulink></term> 1574 1575 <listitem> 1576 <para> 1577 Provides official releases and release candidates of FindBugs. 1578 </para> 1579 </listitem> 1580 </varlistentry> 1581 1582 <varlistentry><term><ulink url="http://findbugs.cs.umd.edu/eclipse-daily/">http://findbugs.cs.umd.edu/eclipse-daily/</ulink></term> 1583 1584 <listitem> 1585 <para> 1586 Provides the daily build of FindBugs. No testing other than that it compiles. 1587 </para> 1588 </listitem> 1589 </varlistentry> 1590 </variablelist> 1591 1592<para>You can also manually 1593download the plugin from the following link: 1594<ulink url="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.2.20130225.zip?download" 1595>http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.2.20130225.zip?download</ulink>. 1596Extract it in Eclipse's "plugins" subdirectory. 1597(So <eclipse_install_dir>/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.2.20130225/findbugs.png 1598should be the path to the &FindBugs; logo.) 1599 1600</para> 1601 1602<para> 1603Once the plugin is extracted, start Eclipse and choose 1604<menuchoice> 1605 <guimenu>Help</guimenu> 1606 <guimenuitem>About Eclipse Platform</guimenuitem> 1607 <guimenuitem>Plug-in Details</guimenuitem> 1608</menuchoice>. 1609You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project". 1610</para> 1611</sect1> 1612 1613<sect1> 1614<title>Using the Plugin</title> 1615 1616<para> 1617To get started, right click on a Java project in Package Explorer, 1618and select the option labeled "Find Bugs". 1619&FindBugs; will run, and problem markers (displayed in source 1620windows, and also in the Eclipse Problems view) will point to 1621locations in your code which have been identified as potential instances 1622of bug patterns. 1623</para> 1624<para> 1625You can also run &FindBugs; on existing java archives (jar, ear, zip, war etc). Simply 1626create an empty Java project and attach archives to the project classpath. Having that, you 1627can now right click the archive node in Package Explorer and select the option labeled 1628"Find Bugs". If you additionally configure the source code locations for the binaries, 1629&FindBugs; will also link the generated warnings to the right source files. 1630</para> 1631<para> 1632You may customize how &FindBugs; runs by opening the Properties 1633dialog for a Java project, and choosing the "Findbugs" property page. 1634Options you may choose include: 1635</para> 1636 1637<itemizedlist> 1638 <listitem> 1639 <para> 1640 Enable or disable the "Run FindBugs Automatically" checkbox. 1641 When enabled, FindBugs will run every time you modify a Java class 1642 within the project. 1643 </para> 1644 </listitem> 1645 1646 <listitem> 1647 <para> 1648 Choose minimum warning priority and enabled bug categories. 1649 These options will choose which warnings are shown. 1650 For example, if you select the "Medium" warning priority, 1651 only Medium and High priority warnings will be shown. 1652 Similarly, if you uncheck the "Style" checkbox, no warnings 1653 in the Style category will be displayed. 1654 </para> 1655 </listitem> 1656 1657 <listitem> 1658 <para> 1659 Select detectors. The table allows you to select which detectors 1660 you want to enable for your project. 1661 </para> 1662 </listitem> 1663</itemizedlist> 1664 1665</sect1> 1666 1667<sect1> 1668<title>Extending the Eclipse Plugin (since 2.0.0)</title> 1669<para> 1670Eclipse plugin supports contribution of custom &FindBugs; detectors (see also 1671<ulink url="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt">AddingDetectors.txt</ulink> 1672for more information). There are two ways to contribute custom plugins to the Eclipse: 1673</para> 1674<itemizedlist> 1675 <listitem> 1676 <para> 1677 Existing standard &FindBugs; detector packages can be configured via 1678 <menuchoice> 1679 <guimenu>Window</guimenu> 1680 <guimenuitem>Preferences</guimenuitem> 1681 <guimenuitem>Java</guimenuitem> 1682 <guimenuitem>&FindBugs;</guimenuitem> 1683 <guimenuitem>Misc. Settings</guimenuitem> 1684 <guimenuitem>Custom Detectors</guimenuitem> 1685 </menuchoice>. 1686 Simply specify there locations of any additional plugin libraries. 1687 </para> 1688 1689 <para> 1690 The benefit of this solution is that already existing detector packages can be 1691 used "as is", and that you can quickly verify the quality of third party detectors. 1692 The drawback is that you have to apply this settings in each 1693 new Eclipse workspace, and this settings can't be shared between team members. 1694 </para> 1695 </listitem> 1696 1697 <listitem> 1698 <para> 1699 It is possible to contribute custom detectors via standard Eclipse extensions mechanism. 1700 </para> 1701 1702 <para> 1703 Please check the documentation of the 1704 <ulink url="http://code.google.com/p/findbugs/source/browse/trunk/eclipsePlugin/schema/detectorPlugins.exsd"> 1705 findBugsEclipsePlugin/schema/detectorPlugins.exsd</ulink> 1706 extension point how to update the plugin.xml. Existing &FindBugs; detector plugins can 1707 be easily "extended" to be full featured &FindBugs; AND Eclipse detector plugins. 1708 Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and 1709 update your build scripts to not to override the MANIFEST.MF during the build. 1710 </para> 1711 1712 <para> 1713 The benefit of this solution is that for given (shared) Eclipse installation 1714 each team member has exactly same detectors set, and there is no need to configure 1715 anything anymore. The (really small) precondition 1716 is that you have to convert your existing detectors package to the valid 1717 Eclipse plugin. You can do this even for third-party detector packages. 1718 Another major differentiator is the ability to extend the default FindBugs 1719 classpath at runtime with required third party libraries (see 1720 <ulink url="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt">AddingDetectors.txt</ulink> 1721 for more information). 1722 </para> 1723 </listitem> 1724 1725</itemizedlist> 1726 1727</sect1> 1728 1729<sect1> 1730<title>Troubleshooting</title> 1731 1732<para> 1733This section lists common problems with the plugin and (if known) how to resolve them. 1734</para> 1735 1736<itemizedlist> 1737 <listitem> 1738 <para> 1739 If you see OutOfMemory error dialogs after starting &FindBugs; analysis in Eclipse, 1740 please increase JVM available memory: change eclipse.ini and add the lines below 1741 to the end of the file: 1742 <programlisting> 1743 -vmargs 1744 -Xmx1000m 1745 </programlisting> 1746 Important: the configuration arguments starting with the line "-vmargs" must 1747 be last lines in the eclipse.ini file, and only one argument per line is allowed! 1748 </para> 1749 </listitem> 1750 <listitem> 1751 <para> 1752 If you do not see any &FindBugs; problem markers (in your source 1753 windows or in the Problems View), you may need to change your 1754 Problems View filter settings. See 1755 <ulink url="http://findbugs.sourceforge.net/FAQ.html#q7">http://findbugs.sourceforge.net/FAQ.html#q7</ulink> for more information. 1756 </para> 1757 </listitem> 1758 1759</itemizedlist> 1760 1761</sect1> 1762 1763 1764</chapter> 1765 1766 1767<!-- 1768 ************************************************************************** 1769 Filter files 1770 ************************************************************************** 1771--> 1772 1773<chapter id="filter"> 1774<title>Filter Files</title> 1775 1776<para> 1777Filter files may be used to include or exclude bug reports for particular classes 1778and methods. This chapter explains how to use filter files. 1779 1780<note> 1781<title>Planned Features</title> 1782<para> 1783 Filters are currently only supported by the Command Line interface. 1784 Eventually, filter support will be added to the GUI. 1785</para> 1786</note> 1787</para> 1788 1789 1790<sect1> 1791<title>Introduction to Filter Files</title> 1792 1793<para> 1794Conceptually, a filter matches bug instances against a set of criteria. 1795By defining a filter, you can select bug instances for special treatment; 1796for example, to exclude or include them in a report. 1797</para> 1798 1799<para> 1800A filter file is an <ulink url="http://www.w3.org/XML/">XML</ulink> document with a top-level <literal>FindBugsFilter</literal> element 1801which has some number of <literal>Match</literal> elements as children. Each <literal>Match</literal> 1802element represents a predicate which is applied to generated bug instances. 1803Usually, a filter will be used to exclude bug instances. For example: 1804 1805<screen> 1806<prompt>$ </prompt><command>findbugs -textui -exclude <replaceable>myExcludeFilter.xml</replaceable> <replaceable>myApp.jar</replaceable></command> 1807</screen> 1808 1809However, a filter could also be used to select bug instances to specifically 1810report: 1811 1812<screen> 1813<prompt>$ </prompt><command>findbugs -textui -include <replaceable>myIncludeFilter.xml</replaceable> <replaceable>myApp.jar</replaceable></command> 1814</screen> 1815</para> 1816 1817<para> 1818<literal>Match</literal> elements contain children, which are conjuncts of the predicate. 1819In other words, each of the children must be true for the predicate to be true. 1820</para> 1821 1822</sect1> 1823 1824<sect1> 1825<title>Types of Match clauses</title> 1826 1827<variablelist> 1828 <varlistentry> 1829 <term><literal><Bug></literal></term> 1830 <listitem><para> 1831 This element specifies a particular bug pattern or patterns to match. 1832 The <literal>pattern</literal> attribute is a comma-separated list of 1833 bug pattern types. You can find the bug pattern types for particular 1834 warnings by looking at the output produced by the <command>-xml</command> 1835 output option (the <literal>type</literal> attribute of <literal>BugInstance</literal> 1836 elements), or from the <ulink url="/bugDescriptions.html">bug 1837 descriptions document</ulink>. 1838 </para><para> 1839 For more coarse-grained matching, use <literal>code</literal> attribute. It takes 1840 a comma-separated list of bug abbreviations. For most-coarse grained matching use 1841 <literal>category</literal> attriute, that takes a comma separated list of bug category names: 1842 <literal>CORRECTNESS</literal>, <literal>MT_CORRECTNESS</literal>, 1843 <literal>BAD_PRACTICICE</literal>, <literal>PERFORMANCE</literal>, <literal>STYLE</literal>. 1844 </para><para> 1845 If more than one of the attributes mentioned above are specified on the same 1846 <literal><Bug></literal> element, all bug patterns that match either one of specified 1847 pattern names, or abreviations, or categories will be matched. 1848 </para><para> 1849 As a backwards compatibility measure, <literal><BugPattern></literal> and 1850 <literal><BugCode></literal> elements may be used instead of 1851 <literal><Bug></literal> element. Each of these uses a 1852 <literal>name</literal> attribute for specifying accepted values list. Support for these 1853 elements may be removed in a future release. 1854 </para></listitem> 1855 </varlistentry> 1856 1857 <varlistentry> 1858 <term><literal><Confidence></literal></term> 1859 <listitem> 1860 <para> 1861 This element matches warnings with a particular bug confidence. 1862 The <literal>value</literal> attribute should be an integer value: 1863 1 to match high-confidence warnings, 2 to match normal-confidence warnings, 1864 or 3 to match low-confidence warnings. <Confidence> replaced 1865 <Priority> in 2.0.0 release. 1866 </para> 1867 </listitem> 1868 </varlistentry> 1869 1870 <varlistentry> 1871 <term><literal><Priority></literal></term> 1872 <listitem> 1873 <para> 1874 Same as <literal><Confidence></literal>, exists for backward compatibility. 1875 </para> 1876 </listitem> 1877 </varlistentry> 1878 1879 <varlistentry> 1880 <term><literal><Rank></literal></term> 1881 <listitem> 1882 <para> 1883 This element matches warnings with a particular bug rank. 1884 The <literal>value</literal> attribute should be an integer value 1885 between 1 and 20, where 1 to 4 are scariest, 5 to 9 scary, 10 to 14 troubling, 1886 and 15 to 20 of concern bugs. 1887 </para> 1888 </listitem> 1889 </varlistentry> 1890 1891 <varlistentry> 1892 <term><literal><Package></literal></term> 1893 <listitem> 1894 <para> 1895 This element matches warnings associated with classes within the package specified 1896 using <literal>name</literal> attribute. Nested packages are not included (along the 1897 lines of Java import statement). However matching multiple packages can be achieved 1898 easily using regex name match. 1899 </para> 1900 </listitem> 1901 </varlistentry> 1902 1903 <varlistentry> 1904 <term><literal><Class></literal></term> 1905 <listitem> 1906 <para> 1907 This element matches warnings associated with a particular class. The 1908 <literal>name</literal> attribute is used to specify the exact or regex match pattern 1909 for the class name. 1910 </para> 1911 1912 <para> 1913 As a backward compatibility measure, instead of element of this type, you can use 1914 <literal>class</literal> attribute on a <literal>Match</literal> element to specify 1915 exact an class name or <literal>classregex</literal> attribute to specify a regular 1916 expression to match the class name against. 1917 </para> 1918 1919 <para> 1920 If the <literal>Match</literal> element contains neither a <literal>Class</literal> element, 1921 nor a <literal>class</literal> / <literal>classregex</literal> attribute, the predicate will apply 1922 to all classes. Such predicate is likely to match more bug instances than you want, unless it is 1923 refined further down with apropriate method or field predicates. 1924 </para> 1925 </listitem> 1926 </varlistentry> 1927 1928 <varlistentry> 1929 <term><literal><Method></literal></term> 1930 1931 <listitem><para>This element specifies a method. The <literal>name</literal> is used to specify 1932 the exact or regex match pattern for the method name. 1933 The <literal>params</literal> attribute is a comma-separated list 1934 of the types of the method's parameters. The <literal>returns</literal> attribute is 1935 the method's return type. In <literal>params</literal> and <literal>returns</literal>, class names 1936 must be fully qualified. (E.g., "java.lang.String" instead of just 1937 "String".) If one of the latter attributes is specified the other is required for creating a method signature. 1938 Note that you can provide either <literal>name</literal> attribute or <literal>params</literal> 1939 and <literal>returns</literal> attributes or all three of them. This way you can provide various kinds of 1940 name and signature based matches. 1941 </para></listitem> 1942 </varlistentry> 1943 1944 <varlistentry> 1945 <term><literal><Field></literal></term> 1946 1947 <listitem><para>This element specifies a field. The <literal>name</literal> attribute is is used to specify 1948 the exact or regex match pattern for the field name. You can also filter fields according to their signature - 1949 use <literal>type</literal> attribute to specify fully qualified type of the field. You can specify eiter or both 1950 of these attributes in order to perform name / signature based matches. 1951 </para></listitem> 1952 </varlistentry> 1953 1954 <varlistentry> 1955 <term><literal><Local></literal></term> 1956 1957 <listitem><para>This element specifies a local variable. The <literal>name</literal> attribute is is used to specify 1958 the exact or regex match pattern for the local variable name. Local variables are variables defined within a method. 1959 </para></listitem> 1960 </varlistentry> 1961 1962 <varlistentry> 1963 <term><literal><Or></literal></term> 1964 <listitem><para> 1965 This element combines <literal>Match</literal> clauses as disjuncts. I.e., you can put two 1966 <literal>Method</literal> elements in an <literal>Or</literal> clause in order to match either method. 1967 </para></listitem> 1968 </varlistentry> 1969 <varlistentry> 1970 <term><literal><And></literal></term> 1971 <listitem><para> 1972 This element combines <literal>Match</literal> clauses which both must evaluate to true. I.e., you can put 1973 <literal>Bug</literal> and <literal>Priority</literal> elements in an <literal>And</literal> clause in order 1974 to match specific bugs with given priority only. 1975 </para></listitem> 1976 </varlistentry> 1977 <varlistentry> 1978 <term><literal><Not></literal></term> 1979 <listitem><para> 1980 This element inverts the included child <literal>Match</literal>. I.e., you can put a 1981 <literal>Bug</literal> element in a <literal>Not</literal> clause in order to match any bug 1982 excluding the given one. 1983 </para></listitem> 1984 </varlistentry> 1985</variablelist> 1986 1987</sect1> 1988 1989<sect1> 1990<title>Java element name matching</title> 1991 1992<para> 1993If the <literal>name</literal> attribute of <literal>Class</literal>, <literal>Method</literal> or 1994<literal>Field</literal> starts with the ~ character the rest of attribute content is interpreted as 1995a Java regular expression that is matched against the names of the Java element in question. 1996</para> 1997 1998<para> 1999Note that the pattern is matched against whole element name and therefore .* clauses need to be used 2000at pattern beginning and/or end to perform substring matching. 2001</para> 2002 2003<para> 2004See <ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html"><literal>java.util.regex.Pattern</literal></ulink> 2005documentation for pattern syntax. 2006</para> 2007</sect1> 2008 2009<sect1> 2010<title>Caveats</title> 2011 2012<para> 2013<literal>Match</literal> clauses can only match information that is actually contained in the 2014bug instances. Every bug instance has a class, so in general, excluding 2015bugs by class will work. 2016</para> 2017 2018<para> 2019Some bug instances have two (or more) classes. For example, the DE (dropped exception) 2020bugs report both the class containing the method where the dropped exception 2021happens, and the class which represents the type of the dropped exception. 2022Only the <emphasis>first</emphasis> (primary) class is matched against <literal>Match</literal> clauses. 2023So, for example, if you want to suppress IC (initialization circularity) 2024reports for classes "com.foobar.A" and "com.foobar.B", you would use 2025two <literal>Match</literal> clauses: 2026 2027<programlisting> 2028 <Match> 2029 <Class name="com.foobar.A" /> 2030 <Bug code="IC" /> 2031 </Match> 2032 2033 <Match> 2034 <Class name="com.foobar.B" /> 2035 <Bug code="IC" /> 2036 </Match> 2037</programlisting> 2038 2039By explicitly matching both classes, you ensure that the IC bug instance will be 2040matched regardless of which class involved in the circularity happens to be 2041listed first in the bug instance. (Of course, this approach might accidentally 2042supress circularities involving "com.foobar.A" or "com.foobar.B" and a third 2043class.) 2044</para> 2045 2046<para> 2047Many kinds of bugs report what method they occur in. For those bug instances, 2048you can put <literal>Method</literal> clauses in the <literal>Match</literal> element and they should work 2049as expected. 2050</para> 2051 2052</sect1> 2053 2054<sect1> 2055<title>Examples</title> 2056 2057<para> 2058 1. Match all bug reports for a class. 2059 2060<programlisting> 2061<![CDATA[ 2062 <Match> 2063 <Class name="com.foobar.MyClass" /> 2064 </Match> 2065]]> 2066</programlisting> 2067 2068</para> 2069 2070<para> 2071 2. Match certain tests from a class by specifying their abbreviations. 2072<programlisting> 2073<![CDATA[ 2074 <Match> 2075 <Class name="com.foobar.MyClass"/ > 2076 <Bug code="DE,UrF,SIC" /> 2077 </Match> 2078]]> 2079</programlisting> 2080</para> 2081 2082<para> 2083 3. Match certain tests from all classes by specifying their abbreviations. 2084 2085<programlisting> 2086<![CDATA[ 2087 <Match> 2088 <Bug code="DE,UrF,SIC" /> 2089 </Match> 2090]]> 2091</programlisting> 2092</para> 2093 2094<para> 2095 4. Match certain tests from all classes by specifying their category. 2096 2097<programlisting> 2098<![CDATA[ 2099 <Match> 2100 <Bug category="PERFORMANCE" /> 2101 </Match> 2102]]> 2103</programlisting> 2104</para> 2105 2106<para> 2107 5. Match bug types from specified methods of a class by their abbreviations. 2108 2109<programlisting> 2110<![CDATA[ 2111 <Match> 2112 <Class name="com.foobar.MyClass" /> 2113 <Or> 2114 <Method name="frob" params="int,java.lang.String" returns="void" /> 2115 <Method name="blat" params="" returns="boolean" /> 2116 </Or> 2117 <Bug code="DC" /> 2118 </Match> 2119]]> 2120</programlisting> 2121</para> 2122 2123<para> 2124 6. Match a particular bug pattern in a particular method. 2125 2126<programlisting> 2127<![CDATA[ 2128 <!-- A method with an open stream false positive. --> 2129 <Match> 2130 <Class name="com.foobar.MyClass" /> 2131 <Method name="writeDataToFile" /> 2132 <Bug pattern="OS_OPEN_STREAM" /> 2133 </Match> 2134]]> 2135</programlisting> 2136</para> 2137 2138<para> 2139 7. Match a particular bug pattern with a given priority in a particular method. 2140 2141<programlisting> 2142<![CDATA[ 2143 <!-- A method with a dead local store false positive (medium priority). --> 2144 <Match> 2145 <Class name="com.foobar.MyClass" /> 2146 <Method name="someMethod" /> 2147 <Bug pattern="DLS_DEAD_LOCAL_STORE" /> 2148 <Priority value="2" /> 2149 </Match> 2150]]> 2151</programlisting> 2152</para> 2153 2154<para> 2155 8. Match minor bugs introduced by AspectJ compiler (you are probably not interested in these unless 2156 you are an AspectJ developer). 2157 2158<programlisting> 2159<![CDATA[ 2160 <Match> 2161 <Class name="~.*\$AjcClosure\d+" /> 2162 <Bug pattern="DLS_DEAD_LOCAL_STORE" /> 2163 <Method name="run" /> 2164 </Match> 2165 <Match> 2166 <Bug pattern="UUF_UNUSED_FIELD" /> 2167 <Field name="~ajc\$.*" /> 2168 </Match> 2169]]> 2170</programlisting> 2171</para> 2172 2173<para> 2174 9. Match bugs in specific parts of the code base 2175 2176<programlisting> 2177<![CDATA[ 2178 <!-- match unused fields warnings in Messages classes in all packages --> 2179 <Match> 2180 <Class name="~.*\.Messages" /> 2181 <Bug code="UUF" /> 2182 </Match> 2183 <!-- match mutable statics warnings in all internal packages --> 2184 <Match> 2185 <Package name="~.*\.internal" /> 2186 <Bug code="MS" /> 2187 </Match> 2188 <!-- match anonymoous inner classes warnings in ui package hierarchy --> 2189 <Match> 2190 <Package name="~com\.foobar\.fooproject\.ui.*" /> 2191 <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" /> 2192 </Match> 2193]]> 2194</programlisting> 2195</para> 2196 2197<para> 2198 10. Match bugs on fields or methods with specific signatures 2199<programlisting> 2200<![CDATA[ 2201 <!-- match System.exit(...) usage warnings in void main(String[]) methods in all classes --> 2202 <Match> 2203 <Method returns="void" name="main" params="java.lang.String[]" /> 2204 <Bug pattern="DM_EXIT" /> 2205 </Match> 2206 <!-- match UuF warnings on fields of type com.foobar.DebugInfo on all classes --> 2207 <Match> 2208 <Field type="com.foobar.DebugInfo" /> 2209 <Bug code="UuF" /> 2210 </Match> 2211]]> 2212</programlisting> 2213</para> 2214 2215 2216<para> 2217 11. Match bugs using the Not filter operator 2218<programlisting> 2219<![CDATA[ 2220<!-- ignore all bugs in test classes, except for those bugs specifically relating to JUnit tests --> 2221<!-- i.e. filter bug if ( classIsJUnitTest && ! bugIsRelatedToJUnit ) --> 2222<Match> 2223 <!-- the Match filter is equivalent to a logical 'And' --> 2224 2225 <Class name="~.*\.*Test" /> 2226 <!-- test classes are suffixed by 'Test' --> 2227 2228 <Not> 2229 <Bug code="IJU" /> <!-- 'IJU' is the code for bugs related to JUnit test code --> 2230 </Not> 2231</Match> 2232]]> 2233</programlisting> 2234</para> 2235 2236</sect1> 2237 2238<sect1> 2239<title>Complete Example</title> 2240 2241<programlisting> 2242<![CDATA[ 2243<FindBugsFilter> 2244 <Match> 2245 <Class name="com.foobar.ClassNotToBeAnalyzed" /> 2246 </Match> 2247 2248 <Match> 2249 <Class name="com.foobar.ClassWithSomeBugsMatched" /> 2250 <Bug code="DE,UrF,SIC" /> 2251 </Match> 2252 2253 <!-- Match all XYZ violations. --> 2254 <Match> 2255 <Bug code="XYZ" /> 2256 </Match> 2257 2258 <!-- Match all doublecheck violations in these methods of "AnotherClass". --> 2259 <Match> 2260 <Class name="com.foobar.AnotherClass" /> 2261 <Or> 2262 <Method name="nonOverloadedMethod" /> 2263 <Method name="frob" params="int,java.lang.String" returns="void" /> 2264 <Method name="blat" params="" returns="boolean" /> 2265 </Or> 2266 <Bug code="DC" /> 2267 </Match> 2268 2269 <!-- A method with a dead local store false positive (medium priority). --> 2270 <Match> 2271 <Class name="com.foobar.MyClass" /> 2272 <Method name="someMethod" /> 2273 <Bug pattern="DLS_DEAD_LOCAL_STORE" /> 2274 <Priority value="2" /> 2275 </Match> 2276 2277 <!-- All bugs in test classes, except for JUnit-specific bugs --> 2278 <Match> 2279 <Class name="~.*\.*Test" /> 2280 <Not> 2281 <Bug code="IJU" /> 2282 </Not> 2283 </Match> 2284 2285</FindBugsFilter> 2286]]> 2287</programlisting> 2288 2289</sect1> 2290 2291 2292</chapter> 2293 2294 2295<!-- 2296 ************************************************************************** 2297 Analysis properties 2298 ************************************************************************** 2299--> 2300 2301<chapter id="analysisprops"> 2302<title>Analysis Properties</title> 2303 2304<para> 2305&FindBugs; allows several aspects of the analyses it performs to be 2306customized. System properties are used to configure these options. 2307This chapter describes the configurable analysis options. 2308</para> 2309 2310<para> 2311The analysis options have two main purposes. First, they allow you 2312to inform &FindBugs; about the meaning of methods in your application, 2313so that it can produce more accurate results, or produce fewer 2314false warnings. Second, they allow you to configure the precision 2315of the analysis performed. Reducing analysis precision can save 2316memory and analysis time, at the expense of missing some real bugs, 2317or producing more false warnings. 2318</para> 2319 2320<para> 2321The analysis options are set using the <command>-property</command> 2322command line option. For example: 2323<screen> 2324<prompt>$ </prompt><command>findbugs -textui -property "cfg.noprune=true" <replaceable>myApp.jar</replaceable></command> 2325</screen> 2326</para> 2327 2328<para> 2329The list of configurable analysis properties is shown in 2330<xref linkend="analysisproptable"/>. 2331</para> 2332 2333<table id="analysisproptable"> 2334<title>Configurable Analysis Properties</title> 2335<tgroup cols="3" align="left"> 2336 <thead> 2337 <row> 2338 <entry>Property Name</entry> 2339 <entry>Value</entry> 2340 <entry>Meaning</entry> 2341 </row> 2342 </thead> 2343 <tbody> 2344<!-- 2345 <row> 2346 <entry>cfg.noprune</entry> 2347 <entry>true or false</entry> 2348 <entry>If true, infeasible exception edges are not pruned from 2349 the control flow graphs of analyzed methods. This option 2350 increases the speed of the analysis (by about 20%-30%), 2351 but causes some detectors to produce more false warnings.</entry> 2352 </row> 2353--> 2354 <row> 2355 <entry>findbugs.assertionmethods</entry> 2356 <entry>Comma-separated list of fully qualified method names: 2357 e.g., "com.foo.MyClass.checkAssertion"</entry> 2358 <entry>This property specifies the names of methods that are used 2359 to check program assertions. Specifying these methods allows 2360 the null pointer dereference bug detector to avoid reporting 2361 false warnings for values which are checked by assertion 2362 methods.</entry> 2363 </row> 2364 <row> 2365 <entry>findbugs.de.comment</entry> 2366 <entry>true or false</entry> 2367 <entry>If true, the DroppedException detector scans source code 2368 for empty catch blocks for a comment, and if one is found, does 2369 not report a warning.</entry> 2370 </row> 2371 <row> 2372 <entry>findbugs.maskedfields.locals</entry> 2373 <entry>true or false</entry> 2374 <entry>If true, emit low priority warnings for local variables 2375 which obscure fields. Default is false.</entry> 2376 </row> 2377 <row> 2378 <entry>findbugs.nullderef.assumensp</entry> 2379 <entry>true or false</entry> 2380 <entry>not used 2381 (intention: If true, the null dereference detector assumes that any 2382 reference value returned from a method or passed to a method 2383 in a parameter might be null. Default is false. Note that 2384 enabling this property will very likely cause a large number 2385 of false warnings to be produced.)</entry> 2386 </row> 2387 <row> 2388 <entry>findbugs.refcomp.reportAll</entry> 2389 <entry>true or false</entry> 2390 <entry>If true, all suspicious reference comparisons 2391 using the == and != operators are reported. If false, 2392 only one such warning is issued per method. Default 2393 is false.</entry> 2394 </row> 2395 <row> 2396 <entry>findbugs.sf.comment</entry> 2397 <entry>true or false</entry> 2398 <entry>If true, the SwitchFallthrough detector will only report 2399 warnings for cases where the source code does not have a comment 2400 containing the words "fall" or "nobreak". (An accurate source 2401 path must be used for this feature to work correctly.) 2402 This helps find cases where the switch fallthrough is likely 2403 to be unintentional.</entry> 2404 </row> 2405<!-- see others at src/doc/manual/sysprops.html 2406 <row> 2407 <entry></entry> 2408 <entry></entry> 2409 <entry></entry> 2410 </row> 2411--> 2412 </tbody> 2413</tgroup> 2414</table> 2415 2416</chapter> 2417 2418<!-- 2419 ************************************************************************** 2420 Annotations 2421 *************************************************************************** 2422--> 2423 2424<chapter id="annotations"> 2425<title>Annotations</title> 2426 2427<para> 2428&FindBugs; supports several annotations to express the developer's intent 2429so that FindBugs can issue warnings more appropriately. You need to use 2430Java 5 to use annotations, and must place the annotations.jar and jsr305.jar 2431files in the classpath while compiling your program. 2432</para> 2433 2434<variablelist> 2435 <varlistentry> 2436 <term><command>edu.umd.cs.findbugs.annotations.CheckForNull</command></term> 2437 <listitem> 2438<command>[Target]</command> Field, Method, Parameter 2439 </listitem> 2440 <listitem> 2441 <para> 2442The annotated element might be null, and uses of the element should check for null. 2443When this annotation is applied to a method it applies to the method return value. 2444 </para> 2445 </listitem> 2446 </varlistentry> 2447 2448 <varlistentry> 2449 <term><command>edu.umd.cs.findbugs.annotations.CheckReturnValue</command></term> 2450 <listitem> 2451 <command>[Target]</command> Method, Constructor 2452 </listitem> 2453 <listitem> 2454 <variablelist> 2455 <varlistentry> 2456 <term><command>[Parameter]</command></term> 2457 <listitem> 2458 <para> 2459 <command>priority:</command>The priority of the warning (HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. 2460 </para> 2461 </listitem> 2462 <listitem> 2463 <para> 2464 <command>explanation:</command>A textual explaination of why the return value should be checked. Default value:"". 2465 </para> 2466 </listitem> 2467 </varlistentry> 2468 </variablelist> 2469 </listitem> 2470 <listitem> 2471 <para> 2472This annotation is used to denote a method whose return value should always be checked after invoking the method. 2473 </para> 2474 </listitem> 2475 </varlistentry> 2476 2477 <varlistentry> 2478 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotation</command></term> 2479 <listitem> 2480 <command>[Target]</command> Type, Package 2481 </listitem> 2482 <listitem> 2483 <variablelist> 2484 <varlistentry> 2485 <term><command>[Parameter]</command></term> 2486 <listitem> 2487 <para> 2488 <command>value:</command>Annotation class objects. More than one class can be specified. 2489 </para> 2490 </listitem> 2491 <listitem> 2492 <para> 2493 <command>priority:</command>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. 2494 </para> 2495 </listitem> 2496 </varlistentry> 2497 </variablelist> 2498 </listitem> 2499 <listitem> 2500 <para> 2501Indicates that all members of the class or package should be annotated with the default 2502value of the supplied annotation classes. This would be used for behavior annotations 2503such as @NonNull, @CheckForNull, or @CheckReturnValue. In particular, you can use 2504@DefaultAnnotation(NonNull.class) on a class or package, and then use @Nullable only 2505on those parameters, methods or fields that you want to allow to be null. 2506 </para> 2507 </listitem> 2508 </varlistentry> 2509 2510 <varlistentry> 2511 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotationForFields</command></term> 2512 <listitem> 2513 <command>[Target]</command> Type, Package 2514 </listitem> 2515 <listitem> 2516 <variablelist> 2517 <varlistentry> 2518 <term><command>[Parameter]</command></term> 2519 <listitem> 2520 <para> 2521 <command>value:</command>Annotation class objects. More than one class can be specified. 2522 </para> 2523 </listitem> 2524 <listitem> 2525 <para> 2526 <command>priority:</command>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. 2527 </para> 2528 </listitem> 2529 </varlistentry> 2530 </variablelist> 2531 </listitem> 2532 <listitem> 2533 <para> 2534This is same as the DefaultAnnotation except it only applys to fields. 2535 </para> 2536 </listitem> 2537 </varlistentry> 2538 2539 <varlistentry> 2540 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotationForMethods</command></term> 2541 <listitem> 2542 <command>[Target]</command> Type, Package 2543 </listitem> 2544 <listitem> 2545 <variablelist> 2546 <varlistentry> 2547 <term><command>[Parameter]</command></term> 2548 <listitem> 2549 <para> 2550 <command>value:</command>Annotation class objects. More than one class can be specified. 2551 </para> 2552 </listitem> 2553 <listitem> 2554 <para> 2555 <command>priority:</command>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. 2556 </para> 2557 </listitem> 2558 </varlistentry> 2559 </variablelist> 2560 </listitem> 2561 <listitem> 2562 <para> 2563This is same as the DefaultAnnotation except it only applys to methods. 2564 </para> 2565 </listitem> 2566 </varlistentry> 2567 2568 <varlistentry> 2569 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters</command></term> 2570 <listitem> 2571 <command>[Target]</command> Type, Package 2572 </listitem> 2573 <listitem> 2574 <variablelist> 2575 <varlistentry> 2576 <term><command>[Parameter]</command></term> 2577 <listitem> 2578 <para> 2579 <command>value:</command>Annotation class objects. More than one class can be specified. 2580 </para> 2581 </listitem> 2582 <listitem> 2583 <para> 2584 <command>priority:</command>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. 2585 </para> 2586 </listitem> 2587 </varlistentry> 2588 </variablelist> 2589 </listitem> 2590 <listitem> 2591 <para> 2592This is same as the DefaultAnnotation except it only applys to method parameters. 2593 </para> 2594 </listitem> 2595 </varlistentry> 2596 2597 <varlistentry> 2598 <term><command>edu.umd.cs.findbugs.annotations.NonNull</command></term> 2599 <listitem> 2600 <command>[Target]</command> Field, Method, Parameter 2601 </listitem> 2602 <listitem> 2603 <para> 2604The annotated element must not be null. 2605Annotated fields must not be null after construction has completed. Annotated methods must have non-null return values. 2606 </para> 2607 </listitem> 2608 </varlistentry> 2609 2610 <varlistentry> 2611 <term><command>edu.umd.cs.findbugs.annotations.Nullable</command></term> 2612 <listitem> 2613 <command>[Target]</command> Field, Method, Parameter 2614 </listitem> 2615 <listitem> 2616 <para> 2617The annotated element could be null under some circumstances. In general, this means 2618developers will have to read the documentation to determine when a null value is 2619acceptable and whether it is neccessary to check for a null value. FindBugs will 2620treat the annotated items as though they had no annotation. 2621 </para> 2622 <para> 2623In pratice this annotation is useful only for overriding an overarching NonNull 2624annotation. 2625 </para> 2626 </listitem> 2627 </varlistentry> 2628 2629 <varlistentry> 2630 <term><command>edu.umd.cs.findbugs.annotations.OverrideMustInvoke</command></term> 2631 <listitem> 2632 <command>[Target]</command> Method 2633 </listitem> 2634 <listitem> 2635 <variablelist> 2636 <varlistentry> 2637 <term><command>[Parameter]</command></term> 2638 <listitem> 2639 <para> 2640 <command>value:</command>Specify when the super invocation should be 2641 performed (FIRST, ANYTIME, LAST). Default value:ANYTIME. 2642 </para> 2643 </listitem> 2644 </varlistentry> 2645 </variablelist> 2646 </listitem> 2647 <listitem> 2648 <para> 2649Used to annotate a method that, if overridden, must (or should) be invoke super 2650in the overriding method. Examples of such methods include finalize() and clone(). 2651The argument to the method indicates when the super invocation should occur: 2652at any time, at the beginning of the overriding method, or at the end of the overriding method. 2653(This anotation is not implmemented in FindBugs as of September 8, 2006). 2654 </para> 2655 </listitem> 2656 </varlistentry> 2657 2658 <varlistentry> 2659 <term><command>edu.umd.cs.findbugs.annotations.PossiblyNull</command></term> 2660 <listitem> 2661 <para> 2662This annotation is deprecated. Use CheckForNull instead. 2663 </para> 2664 </listitem> 2665 </varlistentry> 2666 2667 <varlistentry> 2668 <term><command>edu.umd.cs.findbugs.annotations.SuppressWarnings</command></term> 2669 <listitem> 2670 <command>[Target]</command> Type, Field, Method, Parameter, Constructor, Package 2671 </listitem> 2672 <listitem> 2673 <variablelist> 2674 <varlistentry> 2675 <term><command>[Parameter]</command></term> 2676 <listitem> 2677 <para> 2678 <command>value:</command>The name of the warning. More than one name can be specified. 2679 </para> 2680 </listitem> 2681 <listitem> 2682 <para> 2683 <command>justification:</command>Reason why the warning should be ignored. Default value:"". 2684 </para> 2685 </listitem> 2686 </varlistentry> 2687 </variablelist> 2688 </listitem> 2689 <listitem> 2690 <para> 2691The set of warnings that are to be suppressed by the compiler in the annotated element. 2692Duplicate names are permitted. The second and successive occurrences of a name are ignored. 2693The presence of unrecognized warning names is <emphasis>not</emphasis> an error: Compilers 2694must ignore any warning names they do not recognize. They are, however, free to emit a 2695warning if an annotation contains an unrecognized warning name. Compiler vendors should 2696document the warning names they support in conjunction with this annotation type. They 2697are encouraged to cooperate to ensure that the same names work across multiple compilers. 2698 </para> 2699 </listitem> 2700 </varlistentry> 2701 2702 <varlistentry> 2703 <term><command>edu.umd.cs.findbugs.annotations.UnknownNullness</command></term> 2704 <listitem> 2705 <command>[Target]</command> Field, Method, Parameter 2706 </listitem> 2707 <listitem> 2708 <para> 2709Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. 2710 </para> 2711 </listitem> 2712 </varlistentry> 2713 2714 <varlistentry> 2715 <term><command>edu.umd.cs.findbugs.annotations.UnknownNullness</command></term> 2716 <listitem> 2717 <command>[Target]</command> Field, Method, Parameter 2718 </listitem> 2719 <listitem> 2720 <para> 2721Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. 2722 </para> 2723 </listitem> 2724 </varlistentry> 2725</variablelist> 2726 2727<para> 2728 &FindBugs; also supports the following annotations: 2729<itemizedlist> 2730 <listitem>net.jcip.annotations.GuardedBy</listitem> 2731 <listitem>net.jcip.annotations.Immutable</listitem> 2732 <listitem>net.jcip.annotations.NotThreadSafe</listitem> 2733 <listitem>net.jcip.annotations.ThreadSafe</listitem> 2734</itemizedlist> 2735</para> 2736<para> 2737You can refer the JCIP annotation <ulink url="http://jcip.net/annotations/doc/index.html"> 2738API documentation</ulink> at <ulink url="http://jcip.net/">Java Concurrency in Practice</ulink>. 2739</para> 2740</chapter> 2741 2742<!-- 2743 ************************************************************************** 2744 Using rejarForAnalysis 2745 ************************************************************************** 2746--> 2747 2748<chapter id="rejarForAnalysis"> 2749<title>Using rejarForAnalysis</title> 2750 2751<para> 2752If your project consists of many jarfiles or the jarfiles are scattered 2753over many directories, you may wish to use the <command>rejarForAnalysis 2754</command> script to make 2755FindBugs invocation easier. The script collects many jarfiles and combines them 2756into a single, large jarfile that can then be easily passed to FindBugs for 2757analysis. This can be particularly useful in combination with the 'find' command 2758on unix systems; e.g. <command>find . -name '*.jar' | xargs rejarForAnalysis 2759</command>. 2760</para> 2761 2762<para> 2763The <command>rejarForAnalysis</command> script 2764can also be used to split a very large project up into a set of jarfiles with 2765the project classfiles evenly divided between them. This is useful when running 2766FindBugs on the entire project is not practical due to time or memory consumption. 2767Instead of running FindBugs on the entire project, you may use <command> 2768rejarForAnalysis</command> build one large, all-inclusive jarfile 2769containing all classes, invoke <command>rejarForAnalysis</command> 2770again to split the project into multiple jarfiles, then run FindBugs 2771on each divided jarfiles in turn, specifying the the all-inclusive jarfile in 2772the <command>-auxclasspath</command>. 2773</para> 2774 2775<para> 2776These are the options accepted by the <command>rejarForAnalysis</command> script: 2777</para> 2778 2779<variablelist> 2780 <varlistentry> 2781 <term><command>-maxAge</command> <replaceable>days</replaceable></term> 2782 <listitem> 2783 <para> 2784 Maximum age in days (ignore jar files older than this). 2785 </para> 2786 </listitem> 2787 </varlistentry> 2788 <varlistentry> 2789 <term><command>-inputFileList</command> <replaceable>filename</replaceable></term> 2790 <listitem> 2791 <para> 2792 Text file containing names of jar files. 2793 </para> 2794 </listitem> 2795 </varlistentry> 2796 <varlistentry> 2797 <term><command>-maxClasses</command> <replaceable>num</replaceable></term> 2798 <listitem> 2799 <para> 2800 Maximum number of classes per analysis*.jar file. 2801 </para> 2802 </listitem> 2803 </varlistentry> 2804 <varlistentry> 2805 <term><command>-prefix</command> <replaceable>class name prefix</replaceable></term> 2806 <listitem> 2807 <para> 2808 Prefix of class names that should be analyzed (e.g., edu.umd.cs.). 2809 </para> 2810 </listitem> 2811 </varlistentry> 2812</variablelist> 2813</chapter> 2814 2815<!-- 2816 ************************************************************************** 2817 Data mining 2818 ************************************************************************** 2819--> 2820 2821<chapter id="datamining"> 2822 <title>Data mining of bugs with &FindBugs;™</title> 2823 2824<para> 2825FindBugs incorporates an ability to perform sophisticated queries on bug 2826databases and track warnings across multiple versions of code being 2827studied, allowing you to do things such as seeing when a bug was first introduced, examining 2828just the warnings that have been introduced since the last release, or graphing the number 2829of infinite recursive loops in your code over time.</para> 2830 2831<para> 2832These techniques all depend upon the XML format used by FindBugs for storing warnings. 2833These XML files usually contain just the warnings from one particular analysis run, but 2834they can also store the results from analyzing a sequence of software builds or versions. 2835 </para> 2836 2837<para> 2838Any FindBugs XML bug database contains a version name and timestamp. 2839FindBugs tries to compute a timestamp from the timestamps of the files that 2840are analyzed (e.g., the timestamp is intended to be the time the class files 2841were generated, not analyzed). Each bug database also contains a version name. 2842Both the version name and timestamp can be set manually using the 2843<command>setBugDatabaseInfo</command> (<xref linkend="setBugDatabaseInfo" />) command. 2844 </para> 2845 2846<para>A multiversion bug database assigns a sequence number to each version of 2847the analyzed code. These sequence numbers are simply successive integers, 2848starting at 0 (e.g., a bug database for 4 versions of the code will contain 2849versions 0..3). The bug database will also record the name and timestamp for 2850each version. The <command>filterBugs</command> command allows you to refer 2851to a version by sequence number, name or timestamp.</para> 2852 2853<para> 2854You can take a sequence (or pair) of single version bug databases and create 2855from them a multiversion bug database, or combine a multiversion bug database 2856with a sequence of later single-version bug databases.</para> 2857 2858<para> 2859Some of these commands can be invoked as ant tasks. See below for specifics 2860on how to invoke them and what attributes and arguments they take. All of 2861the examples assume that the <literal>findbugs.lib</literal> 2862<literal>refid</literal> is set correctly. Here is one way to set it: 2863</para> 2864 2865<programlisting> 2866<![CDATA[ 2867 <!-- findbugs task definition --> 2868 <property name="findbugs.home" value="/your/path/to/findbugs" /> 2869 <path id="findbugs.lib"> 2870 <fileset dir="${findbugs.home}/lib"> 2871 <include name="findbugs-ant.jar"/> 2872 </fileset> 2873 </path> 2874]]> 2875</programlisting> 2876 2877 <sect1 id="commands"> 2878 <title>Commands</title> 2879 2880 <para> 2881All tools for FindBugs data mining are can be invoked from the command line, 2882and some of the more useful tools can also be invoked from an 2883ant build file.</para> 2884 2885<para> 2886Briefly, the command-line tools are:</para> 2887 2888 <variablelist> 2889 <varlistentry> 2890 <term><command><link linkend="unionBugs">unionBugs</link></command></term> 2891 <listitem> 2892 <para> 2893 combine the results from separate analysis of disjoint 2894 classes 2895 </para> 2896 </listitem> 2897 </varlistentry> 2898 <varlistentry> 2899 <term><command><link linkend="computeBugHistory">computeBugHistory</link></command></term> 2900 <listitem> 2901 <para>Merge bug warnings from multiple versions of 2902 analyzed code into 2903 a single multiversion bug database. This can either be used 2904 to add more versions to an existing multiversion database, 2905 or to create a multiversion database from a sequence of single version 2906 bug warning databases.</para> 2907 </listitem> 2908 </varlistentry> 2909 <varlistentry> 2910 <term><command><link linkend="setBugDatabaseInfo">setBugDatabaseInfo</link></command></term> 2911 <listitem> 2912 <para>Set information such as the revision name or 2913timestamp in an XML bug database</para> 2914 </listitem> 2915 </varlistentry> 2916 <varlistentry> 2917 <term><command><link linkend="listBugDatabaseInfo">listBugDatabaseInfo</link></command></term> 2918 <listitem> 2919 <para>List information such as the revision name and 2920timestamp for a list of XML bug databases</para> 2921 </listitem> 2922 </varlistentry> 2923 <varlistentry> 2924 <term><command><link linkend="filterBugs">filterBugs</link></command></term> 2925 <listitem> 2926 <para>Select a subset of a bug database</para> 2927 </listitem> 2928 </varlistentry> 2929 <varlistentry> 2930 <term><command><link linkend="mineBugHistory">mineBugHistory</link></command></term> 2931 <listitem> 2932 <para>Generate a tabular listing of the number of warnings in each 2933 version of a multiversion bug database</para> 2934 </listitem> 2935 </varlistentry> 2936 <varlistentry> 2937 <term><command><link linkend="defectDensity">defectDensity</link></command></term> 2938 <listitem> 2939 <para>List information about defect density 2940 (warnings per 1000 NCSS) 2941 for the entire project and each class and package</para> 2942 </listitem> 2943 </varlistentry> 2944 <varlistentry> 2945 <term><command><link linkend="convertXmlToText">convertXmlToText</link></command></term> 2946 <listitem> 2947 <para>Convert bug warnings in XML format to 2948 a textual one-line-per-bug format, or to HTML</para> 2949 </listitem> 2950 </varlistentry> 2951 </variablelist> 2952 2953 2954 <sect2 id="unionBugs"> 2955 <title>unionBugs</title> 2956 2957 <para> 2958 If you have, for example, separately analyzing each jar file used in an application, 2959 you can use this command to combine the separately generated xml bug warning files into 2960 a single file containing all of the warnings.</para> 2961 2962 <para>Do <emphasis>not</emphasis> use this command to combine results from analyzing different versions of the same 2963 file; use <command>computeBugHistory</command> instead.</para> 2964 2965 <para>Specify the xml files on the command line. The result is sent to standard output.</para> 2966 </sect2> 2967 2968 <sect2 id="computeBugHistory"> 2969 <title>computeBugHistory</title> 2970 2971<para>Use this command to generate a bug database containing information from different builds or versions 2972of software you are analyzing. 2973History is taken from the first file provided as input; any following 2974files should be single version bug databases (if they contain history, the history in those 2975files will be ignored).</para> 2976<para>By default, output is written to the standard output. 2977</para> 2978 2979<para>This functionality may also can be accessed from ant. 2980First create a taskdef for <command>computeBugHistory</command> in your 2981build file: 2982</para> 2983 2984<programlisting> 2985<![CDATA[ 2986<taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask"> 2987 <classpath refid="findbugs.lib" /> 2988</taskdef> 2989]]> 2990</programlisting> 2991 2992<para>Attributes for this ant task are listed in the following table. 2993To specify input files, nest them inside with a 2994<literal><datafile></literal> element. For example: 2995</para> 2996 2997<programlisting> 2998<![CDATA[ 2999<computeBugHistory home="${findbugs.home}" ...> 3000 <datafile name="analyze1.xml"/> 3001 <datafile name="analyze2.xml"/> 3002</computeBugHistory> 3003]]> 3004</programlisting> 3005 3006 <table id="computeBugHistoryTable"> 3007 <title>Options for computeBugHistory command</title> 3008 <tgroup cols="3" align="left"> 3009 <thead> 3010 <row> 3011 <entry>Command-line option</entry> 3012 <entry>Ant attribute</entry> 3013 <entry>Meaning</entry> 3014 </row> 3015 </thead> 3016 <tbody> 3017<row><entry>-output <file></entry> <entry>output="<file>"</entry> <entry>save output in the named file (may also be an input file)</entry></row> 3018<row><entry>-overrideRevisionNames[:truth]</entry> <entry>overrideRevisionNames="[true|false]"</entry><entry>override revision names for each version with names computed from the filenames</entry></row> 3019<row><entry>-noPackageMoves[:truth]</entry> <entry>noPackageMoves="[true|false]"</entry><entry>if a class has moved to another package, treat warnings in that class as seperate</entry></row> 3020<row><entry>-preciseMatch[:truth]</entry> <entry>preciseMatch="[true|false]"</entry><entry>require bug patterns to match precisely</entry></row> 3021<row><entry>-precisePriorityMatch[:truth]</entry> <entry>precisePriorityMatch="[true|false]"</entry><entry>consider two warnings as the same only if priorities match exactly</entry></row> 3022<row><entry>-quiet[:truth]</entry> <entry>quiet="[true|false]"</entry><entry>don't generate any output to standard out unless there is an error</entry></row> 3023<row><entry>-withMessages[:truth]</entry> <entry>withMessages="[true|false]"</entry><entry>include human-readable messages describing the warnings in XML output</entry></row> 3024 </tbody> 3025 </tgroup> 3026 </table> 3027 3028 </sect2> 3029 <sect2 id="filterBugs"> 3030 <title>filterBugs</title> 3031<para>This command is used to select a subset of warnings from a FindBugs XML warning file 3032and write the selected subset to a new FindBugs warning file.</para> 3033<para> 3034This command takes a sequence of options, and either zero, one or two 3035filenames of findbugs xml bug files on the command line.</para> 3036<para>If no file names are provided, the command reads from standard input 3037and writes to standard output. If one file name is provided, 3038it reads from the file and writes to standard output. 3039If two file names are provided, it reads from the first and writes the output 3040to the second file name.</para> 3041 3042<para>This functionality may also can be accessed from ant. 3043First create a taskdef for <command>filterBugs</command> in your 3044build file: 3045</para> 3046 3047<programlisting> 3048<![CDATA[ 3049<taskdef name="filterBugs" classname="edu.umd.cs.findbugs.anttask.FilterBugsTask"> 3050 <classpath refid="findbugs.lib" /> 3051</taskdef> 3052]]> 3053</programlisting> 3054 3055<para>Attributes for this ant task are listed in the following table. 3056To specify an input file either use the input attribute or nest it inside 3057the ant call with a <literal><datafile></literal> element. For example: 3058</para> 3059 3060<programlisting> 3061<![CDATA[ 3062<filterBugs home="${findbugs.home}" ...> 3063 <datafile name="analyze.xml"/> 3064</filterBugs> 3065]]> 3066</programlisting> 3067 3068 <table id="filterOptionsTable"> 3069 <title>Options for filterBugs command</title> 3070 <tgroup cols="3" align="left"> 3071 <thead> 3072 <row> 3073 <entry>Command-line option</entry> 3074 <entry>Ant attribute</entry> 3075 <entry>Meaning</entry> 3076 </row> 3077 </thead> 3078 <tbody> 3079<row><entry></entry> <entry>input="<file>"</entry> <entry>use file as input</entry></row> 3080<row><entry></entry> <entry>output="<file>"</entry> <entry>output results to file</entry></row> 3081<row><entry>-not</entry> <entry>not="[true|false]"</entry> <entry>reverse (all) switches for the filter</entry></row> 3082<row><entry>-withSource[:truth]</entry> <entry>withSource="[true|false]"</entry> <entry>only warnings for switch source is available</entry></row> 3083<row><entry>-exclude <filter file></entry><entry>exclude="<filter file>"</entry> <entry>exclude bugs matching given filter</entry></row> 3084<row><entry>-include <filter file></entry><entry>include="<filter file>"</entry> <entry>include only bugs matching given filter</entry></row> 3085<row><entry>-annotation <text></entry> <entry>annotation="<text>"</entry> <entry>allow only warnings containing this text in a manual annotation</entry></row> 3086<row><entry>-after <when></entry> <entry>after="<when>"</entry> <entry>allow only warnings that first occurred after this version</entry></row> 3087<row><entry>-before <when></entry> <entry>before="<when>"</entry> <entry>allow only warnings that first occurred before this version</entry></row> 3088<row><entry>-first <when></entry> <entry>first="<when>"</entry> <entry>allow only warnings that first occurred in this version</entry></row> 3089<row><entry>-last <when></entry> <entry>last="<when>"</entry> <entry>allow only warnings that last occurred in this version</entry></row> 3090<row><entry>-fixed <when></entry> <entry>fixed="<when>"</entry> <entry>allow only warnings that last occurred in the previous version (clobbers <option>-last</option>)</entry></row> 3091<row><entry>-present <when></entry> <entry>present="<when>"</entry> <entry>allow only warnings present in this version</entry></row> 3092<row><entry>-absent <when></entry> <entry>absent="<when>"</entry> <entry>allow only warnings absent in this version</entry></row> 3093<row><entry>-active[:truth]</entry> <entry>active="[true|false]"</entry> <entry>allow only warnings alive in the last sequence number</entry></row> 3094<row><entry>-introducedByChange[:truth]</entry> <entry>introducedByChange="[true|false]"</entry><entry>allow only warnings introduced by a change of an existing class</entry></row> 3095<row><entry>-removedByChange[:truth]</entry> <entry>removedByChange="[true|false]"</entry> <entry>allow only warnings removed by a change of a persisting class</entry></row> 3096<row><entry>-newCode[:truth]</entry> <entry>newCode="[true|false]"</entry> <entry>allow only warnings introduced by the addition of a new class</entry></row> 3097<row><entry>-removedCode[:truth]</entry> <entry>removedCode="[true|false]"</entry> <entry>allow only warnings removed by removal of a class</entry></row> 3098<row><entry>-priority <level></entry> <entry>priority="<level>"</entry> <entry>allow only warnings with this priority or higher</entry></row> 3099<row><entry>-maxRank <rank></entry> <entry>rank="[1..20]"</entry> <entry>allow only warnings with this rank or lower</entry></row> 3100<row><entry>-class <pattern></entry> <entry>class="<class>"</entry> <entry>allow only bugs whose primary class name matches this pattern</entry></row> 3101<row><entry>-bugPattern <pattern></entry> <entry>bugPattern="<pattern>"</entry> <entry>allow only bugs whose type matches this pattern</entry></row> 3102<row><entry>-category <category></entry> <entry>category="<category>"</entry> <entry>allow only warnings with a category that starts with this string</entry></row> 3103<row><entry>-designation <designation></entry> <entry>designation="<designation>"</entry> <entry>allow only warnings with this designation (e.g., -designation SHOULD_FIX)</entry></row> 3104<row><entry>-withMessages[:truth] </entry> <entry>withMessages="[true|false]"</entry> <entry>the generated XML should contain textual messages</entry></row> 3105 </tbody> 3106 </tgroup> 3107 </table> 3108 3109 </sect2> 3110 3111 <sect2 id="mineBugHistory"> 3112 <title>mineBugHistory</title> 3113<para>This command generates a table containing counts of the numbers of warnings 3114in each version of a multiversion bug database.</para> 3115 3116 3117<para>This functionality may also can be accessed from ant. 3118First create a taskdef for <command>mineBugHistory</command> in your 3119build file: 3120</para> 3121 3122<programlisting> 3123<![CDATA[ 3124<taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask"> 3125 <classpath refid="findbugs.lib" /> 3126</taskdef> 3127]]> 3128</programlisting> 3129 3130<para>Attributes for this ant task are listed in the following table. 3131To specify an input file either use the <literal>input</literal> 3132attribute or nest it inside the ant call with a 3133<literal><datafile></literal> element. For example: 3134</para> 3135 3136<programlisting> 3137<![CDATA[ 3138<mineBugHistory home="${findbugs.home}" ...> 3139 <datafile name="analyze.xml"/> 3140</mineBugHistory> 3141]]> 3142</programlisting> 3143 3144 <table id="mineBugHistoryOptionsTable"> 3145 <title>Options for mineBugHistory command</title> 3146 <tgroup cols="3" align="left"> 3147 <thead> 3148 <row> 3149 <entry>Command-line option</entry> 3150 <entry>Ant attribute</entry> 3151 <entry>Meaning</entry> 3152 </row> 3153 </thead> 3154 <tbody> 3155<row><entry></entry> <entry>input="<file>"</entry> <entry>use file as input</entry></row> 3156<row><entry></entry> <entry>output="<file>"</entry> <entry>write output to file</entry></row> 3157<row><entry>-formatDates</entry> <entry>formatDates="[true|false]"</entry> <entry>render dates in textual form</entry></row> 3158<row><entry>-noTabs</entry> <entry>noTabs="[true|false]"</entry> <entry>delimit columns with groups of spaces instead of tabs (see below)</entry></row> 3159<row><entry>-summary</entry> <entry>summary="[true|false]"</entry> <entry>output terse summary of changes over the last ten entries</entry></row> 3160 </tbody> 3161 </tgroup> 3162 </table> 3163 3164 <para> 3165 The <option>-noTabs</option> output can be easier to read from a shell 3166 with a fixed-width font. 3167 Because numeric columns are right-justified, spaces may precede the 3168 first column value. This option also causes <option>-formatDates</option> 3169 to render dates in terser format without embedded whitespace. 3170 </para> 3171 3172 <para>The table is a tab-separated (barring <option>-noTabs</option>) 3173 table with the following columns:</para> 3174 3175 <table id="mineBugHistoryColumns"> 3176 <title>Columns in mineBugHistory output</title> 3177 <tgroup cols="2" align="left"> 3178 <thead> 3179 <row> 3180 <entry>Title</entry> 3181 <entry>Meaning</entry> 3182 </row> 3183 </thead> 3184 <tbody> 3185 <row><entry>seq</entry><entry>Sequence number (successive integers, starting at 0)</entry></row> 3186 <row><entry>version</entry><entry>Version name</entry></row> 3187 <row><entry>time</entry><entry>Release timestamp</entry></row> 3188 <row><entry>classes</entry><entry>Number of classes analyzed</entry></row> 3189 <row><entry>NCSS</entry><entry>Non Commenting Source Statements</entry></row> 3190 <row><entry>added</entry><entry>Count of new warnings for a class that existed in the previous version</entry></row> 3191 <row><entry>newCode</entry><entry>Count of new warnings for a class that did not exist in the previous version</entry></row> 3192 <row><entry>fixed</entry><entry>Count of warnings removed from a class that remains in the current version</entry></row> 3193 <row><entry>removed</entry><entry>Count of warnings in the previous version for a class that is not present in the current version</entry></row> 3194 <row><entry>retained</entry><entry>Count of warnings that were in both the previous and current version</entry></row> 3195 <row><entry>dead</entry><entry>Warnings that were present in earlier versions but in neither the current version or the immediately preceeding version</entry></row> 3196 <row><entry>active</entry><entry>Total warnings present in the current version</entry></row> 3197 </tbody> 3198 </tgroup> 3199 </table> 3200 </sect2> 3201 3202 <sect2 id="defectDensity"> 3203 <title>defectDensity</title> 3204<para> 3205This command lists information about defect density (warnings per 1000 NCSS) for the entire project and each class and package. 3206It can either be invoked with no files specified on the command line (in which case it reads from standard input) 3207or with one file specified on the command line.</para> 3208<para>It generates a table with the following columns, and with one 3209row for the entire project, and one row for each package or class that contains at least 32104 warnings.</para> 3211 <table id="defectDensityColumns"> 3212 <title>Columns in defectDensity output</title> 3213 <tgroup cols="2" align="left"> 3214 <thead> 3215 <row> 3216 <entry>Title</entry> 3217 <entry>Meaning</entry> 3218 </row> 3219 </thead> 3220 <tbody> 3221 <row><entry>kind</entry><entry>project, package or class</entry></row> 3222 <row><entry>name</entry><entry>The name of the project, package or class</entry></row> 3223 <row><entry>density</entry><entry>Number of warnings generated per 1000 lines of NCSS.</entry></row> 3224 <row><entry>bugs</entry><entry>Number of warnings</entry></row> 3225 <row><entry>NCSS</entry><entry>Calculated number of NCSS</entry></row> 3226 </tbody> 3227 </tgroup> 3228 </table> 3229 </sect2> 3230 3231 <sect2 id="convertXmlToText"> 3232 <title>convertXmlToText</title> 3233 3234 <para> 3235 This command converts a warning collection in XML format to a text 3236 format with one line per warning, or to HTML. 3237 </para> 3238 3239<para>This functionality may also can be accessed from ant. 3240First create a taskdef for <command>convertXmlToText</command> in your 3241build file: 3242</para> 3243 3244<programlisting> 3245<![CDATA[ 3246<taskdef name="convertXmlToText" classname="edu.umd.cs.findbugs.anttask.ConvertXmlToTextTask"> 3247 <classpath refid="findbugs.lib" /> 3248</taskdef> 3249]]> 3250</programlisting> 3251 3252<para>Attributes for this ant task are listed in the following table.</para> 3253 3254 <table id="convertXmlToTextTable"> 3255 <title>Options for convertXmlToText command</title> 3256 <tgroup cols="3" align="left"> 3257 <thead> 3258 <row> 3259 <entry>Command-line option</entry> 3260 <entry>Ant attribute</entry> 3261 <entry>Meaning</entry> 3262 </row> 3263 </thead> 3264 <tbody> 3265<row><entry></entry> <entry>input="<filename>"</entry> <entry>use file as input</entry></row> 3266<row><entry></entry> <entry>output="<filename>"</entry> <entry>output results to file</entry></row> 3267<row><entry>-longBugCodes</entry> <entry>longBugCodes="[true|false]"</entry> <entry>use the full bug pattern code instead of two-letter abbreviation</entry></row> 3268<row><entry></entry> <entry>format="text"</entry> <entry>generate plain text output with one bug per line (command-line default)</entry></row> 3269<row><entry>-html[:stylesheet]</entry> <entry>format="html:<stylesheet>"</entry> <entry>generate output with specified stylesheet (see below), or default.xsl if unspecified</entry></row> 3270 </tbody> 3271 </tgroup> 3272 </table> 3273 3274 <para> 3275 You may specify plain.xsl, default.xsl, fancy.xsl, fancy-hist.xsl, 3276 or your own XSL stylesheet for the -html/format option. 3277 Despite the name of this option, you may specify 3278 a stylesheet that emits something other than html. 3279 When applying a stylesheet other than those included 3280 with FindBugs (listed above), the -html/format option should be used 3281 with a path or URL to the stylesheet. 3282 </para> 3283 </sect2> 3284 3285 <sect2 id="setBugDatabaseInfo"> 3286 <title>setBugDatabaseInfo</title> 3287 3288 <para> 3289 This command sets meta-information in a specified warning collection. 3290 It takes the following options: 3291 </para> 3292 3293<para>This functionality may also can be accessed from ant. 3294First create a taskdef for <command>setBugDatabaseInfo</command> in your 3295build file: 3296</para> 3297 3298<programlisting> 3299<![CDATA[ 3300<taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask"> 3301 <classpath refid="findbugs.lib" /> 3302</taskdef> 3303]]> 3304</programlisting> 3305 3306<para>Attributes for this ant task are listed in the following table. 3307To specify an input file either use the <literal>input</literal> 3308attribute or nest it inside the ant call with a 3309<literal><datafile></literal> element. For example: 3310</para> 3311 3312<programlisting> 3313<![CDATA[ 3314<setBugDatabaseInfo home="${findbugs.home}" ...> 3315 <datafile name="analyze.xml"/> 3316</setBugDatabaseInfo> 3317]]> 3318</programlisting> 3319 3320 <table id="setBugDatabaseInfoOptions"> 3321 <title>setBugDatabaseInfo Options</title> 3322 <tgroup cols="3" align="left"> 3323 <thead> 3324 <row> 3325 <entry>Command-line option</entry> 3326 <entry>Ant attribute</entry> 3327 <entry>Meaning</entry> 3328 </row> 3329 </thead> 3330 <tbody> 3331 <row><entry></entry> <entry>input="<file>"</entry> <entry>use file as input</entry></row> 3332 <row><entry></entry> <entry>output="<file>"</entry> <entry>write output to file</entry></row> 3333 <row><entry>-name <name></entry> <entry>name="<name>"</entry> <entry>set name for (last) revision</entry></row> 3334 <row><entry>-timestamp <when></entry> <entry>timestamp="<when>"</entry> <entry>set timestamp for (last) revision</entry></row> 3335 <row><entry>-source <directory></entry> <entry>source="<directory>"</entry> <entry>add specified directory to the source search path</entry></row> 3336 <row><entry>-findSource <directory></entry> <entry>findSource="<directory>"</entry> <entry>find and add all relevant source directions contained within specified directory</entry></row> 3337 <row><entry>-suppress <filter file></entry> <entry>suppress="<filter file>"</entry> <entry>suppress warnings matched by this file (replaces previous suppressions)</entry></row> 3338 <row><entry>-withMessages</entry> <entry>withMessages="[true|false]"</entry> <entry>add textual messages to XML</entry></row> 3339 <row><entry>-resetSource</entry> <entry>resetSource="[true|false]"</entry> <entry>remove all source search paths</entry></row> 3340 </tbody> 3341 </tgroup> 3342 </table> 3343 </sect2> 3344 3345 <sect2 id="listBugDatabaseInfo"> 3346 <title>listBugDatabaseInfo</title> 3347 3348 <para>This command takes a list of zero or more xml bug database filenames on the command line. 3349If zero file names are provided, it reads from standard input and does not generate 3350a table header.</para> 3351 3352<para>There is only one option: <option>-formatDates</option> renders dates 3353 in textual form. 3354 </para> 3355 3356<para>The output is a table one row per bug database and the following columns:</para> 3357 <table id="listBugDatabaseInfoColumns"> 3358 <title>listBugDatabaseInfo Columns</title> 3359 <tgroup cols="2" align="left"> 3360 <thead> 3361 <row> 3362 <entry>Column</entry> 3363 <entry>Meaning</entry> 3364 </row> 3365 </thead> 3366 <tbody> 3367 <row><entry>version</entry><entry>version name</entry></row> 3368 <row><entry>time</entry><entry>Release timestamp</entry></row> 3369 <row><entry>classes</entry><entry>Number of classes analyzed</entry></row> 3370 <row><entry>NCSS</entry><entry>Non Commenting Source Statements analyzed</entry></row> 3371 <row><entry>total</entry><entry>Total number of warnings of all kinds</entry></row> 3372 <row><entry>high</entry><entry>Total number of high priority warnings of all kinds</entry></row> 3373 <row><entry>medium</entry><entry>Total number of medium/normal priority warnings of all kinds</entry></row> 3374 <row><entry>low</entry><entry>Total number of low priority warnings of all kinds</entry></row> 3375 <row><entry>filename</entry><entry>filename of database</entry></row> 3376<!-- 3377 <row><entry></entry><entry></entry></row> 3378 <row><entry></entry><entry></entry></row> 3379 <row><entry></entry><entry></entry></row> 3380 <row><entry></entry><entry></entry></row> 3381 <row><entry></entry><entry></entry></row> 3382 <row><entry></entry><entry></entry></row> 3383--> 3384 </tbody> 3385 </tgroup> 3386 </table> 3387 3388 </sect2> 3389 3390 </sect1> 3391 3392 <sect1 id="examples"> 3393 <title>Examples</title> 3394<sect2 id="unixscriptsexamples"> 3395 <title>Mining history using proveded shell scrips</title> 3396<para>In all of the following, the commands are given in a directory that contains 3397directories jdk1.6.0-b12, jdk1.6.0-b13, ..., jdk1.6.0-b60.</para> 3398 3399<para>You can use the command:</para> 3400<screen> 3401computeBugHistory jdk1.6.0-b* | filterBugs -bugPattern IL_ | mineBugHistory -formatDates 3402</screen> 3403<para>to generate the following output:</para> 3404 3405<screen> 3406seq version time classes NCSS added newCode fixed removed retained dead active 34070 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 4 0 0 0 0 4 34081 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 4 0 4 34092 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 0 0 2 0 2 0 2 34103 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 0 0 1 0 1 2 1 34114 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 0 0 1 3 1 34125 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 0 0 1 3 1 34136 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1 3 1 34147 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 0 0 1 3 1 34158 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1 3 1 34169 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 0 0 1 3 1 341710 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 0 0 0 0 1 3 1 341811 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1 3 1 341912 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 0 0 0 0 1 3 1 342013 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1 3 1 342114 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1 3 1 342215 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 0 0 0 0 1 3 1 342316 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 0 0 0 0 1 3 1 342417 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1 3 2 342518 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 0 0 0 2 3 2 342619 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 2 3 2 342720 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 0 0 0 2 3 2 342821 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 0 0 0 0 2 3 2 342922 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 0 1 0 0 2 3 3 343023 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 0 2 0 0 3 3 5 343124 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 5 3 5 343225 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 0 0 0 0 5 3 5 343326 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 0 0 0 0 5 3 5 343427 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 5 3 5 343528 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 0 0 1 0 4 3 4 343629 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 0 0 0 0 4 4 4 343730 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 0 0 1 0 3 4 3 343831 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 3 5 3 343932 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 0 0 0 0 3 5 3 344033 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 1 0 0 0 3 5 4 344134 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 0 0 0 0 4 5 4 344235 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 0 0 4 5 4 344336 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 0 0 1 0 3 5 3 344437 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 3 6 3 344538 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 0 0 0 0 3 6 3 344639 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 0 0 0 0 3 6 3 344740 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 3 6 3 344841 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 0 0 0 3 6 3 344942 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 0 0 0 0 3 6 3 345043 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 3 6 3 3451</screen> 3452 3453<para> 3454We could also generate that information directly, without creating an intermediate db.xml file, using the command 3455</para> 3456 3457<screen> 3458computeBugHistory jdk1.6.0-b*/jre/lib/rt.xml | filterBugs -bugPattern IL_ db.xml | mineBugHistory -formatDates 3459</screen> 3460 3461<para>We can then use that information to display a graph showing the number of infinite recursive loops 3462found by FindBugs in each build of Sun's JDK1.6.0. The blue area indicates the number of infinite 3463recursive loops in that build, the red area above it indicates the number of infinite recursive loops that existed 3464in some previous version but not in the current version (thus, the combined height of the red and blue areas 3465is guaranteed to never decrease, and goes up whenever a new infinite recursive loop bug is introduced). The height 3466of the red area is computed as the sum of the fixed, removed and dead values for each version. 3467The reductions in builds 13 and 14 came after Sun was notified about the bugs found by FindBugs in the JDK. 3468 </para> 3469<mediaobject> 3470<imageobject> 3471<imagedata fileref="infiniteRecursiveLoops.png" /> 3472</imageobject> 3473</mediaobject> 3474 3475<para> 3476Given the db.xml file that contains the results for all the jdk1.6.0 builds, the following command will show the history of high and medium priority correctness warnings: 3477</para> 3478 3479<screen> 3480filterBugs -priority M -category C db.xml | mineBugHistory -formatDates 3481</screen> 3482 3483<para> 3484generating the table: 3485</para> 3486 3487<screen> 3488seq version time classes NCSS added newCode fixed removed retained dead active 34890 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 1075 0 0 0 0 1075 34901 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 1075 0 1075 34912 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 3 0 6 0 1069 0 1072 34923 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 2 1 3 0 1069 6 1072 34934 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 1 0 1071 9 1071 34945 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 1 0 1070 10 1070 34956 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1070 11 1070 34967 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 1 0 1069 11 1069 34978 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1069 12 1069 34989 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 2 1 1066 12 1066 349910 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 1 0 1 1 1064 15 1065 350011 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1065 17 1065 350112 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 3 0 8 26 1031 17 1034 350213 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1034 51 1034 350314 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1034 51 1034 350415 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 1 1 0 1 1033 51 1035 350516 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 3 0 2 1 1032 52 1035 350617 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1035 55 1036 350718 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 36 2 0 1034 55 1070 350819 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 1070 57 1070 350920 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 1 1 0 1069 57 1070 351021 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 1 7 2 6 1062 58 1070 351122 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 6 39 5 0 1065 66 1110 351223 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 7 147 11 0 1099 71 1253 351324 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 1253 82 1253 351425 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 3 0 1 2 1250 82 1253 351526 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 5 11 15 8 1230 85 1246 351627 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 1246 108 1246 351728 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 19 0 2 0 1244 108 1263 351829 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 13 1 1 32 1230 110 1244 351930 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 163 8 7 20 1217 143 1388 352031 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 1388 170 1388 352132 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 1 11 1 0 1387 170 1399 352233 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 19 27 16 7 1376 171 1422 352334 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 1 15 3 0 1419 194 1435 352435 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 1 1 1433 197 1433 352536 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 13 12 16 20 1397 199 1422 352637 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 1422 235 1422 352738 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 1 4 7 0 1415 235 1420 352839 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 6 8 37 0 1383 242 1397 352940 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 1397 279 1397 353041 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 1 1 0 1396 279 1397 353142 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 6 0 5 0 1392 280 1398 353243 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 1398 285 1398 353344 jdk1.6.0-b61 "Thu Nov 17 01:58:42 EST 2005" 16202 971134 2 0 4 0 1394 285 1396 3534</screen> 3535</sect2> 3536 3537<sect2 id="incrementalhistory"> 3538 <title>Incremental history maintenance</title> 3539 3540<para> 3541If db.xml contains the results of running findbugs over builds b12 - b60, we can update db.xml to include the results of analyzing b61 with the commands: 3542</para> 3543<screen> 3544computeBugHistory -output db.xml db.xml jdk1.6.0-b61/jre/lib/rt.xml 3545</screen> 3546</sect2> 3547 3548 </sect1> 3549 3550 <sect1 id="antexample"> 3551 <title>Ant example</title> 3552<para> 3553Here is a complete ant script example for both running findbugs and running a chain of data-mining tools afterward: 3554</para> 3555<screen> 3556<![CDATA[ 3557<project name="analyze_asm_util" default="findbugs"> 3558 <!-- findbugs task definition --> 3559 <property name="findbugs.home" value="/Users/ben/Documents/workspace/findbugs/findbugs" /> 3560 <property name="jvmargs" value="-server -Xss1m -Xmx800m -Duser.language=en -Duser.region=EN -Dfindbugs.home=${findbugs.home}" /> 3561 3562 <path id="findbugs.lib"> 3563 <fileset dir="${findbugs.home}/lib"> 3564 <include name="findbugs-ant.jar"/> 3565 </fileset> 3566 </path> 3567 3568 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"> 3569 <classpath refid="findbugs.lib" /> 3570 </taskdef> 3571 3572 <taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask"> 3573 <classpath refid="findbugs.lib" /> 3574 </taskdef> 3575 3576 <taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask"> 3577 <classpath refid="findbugs.lib" /> 3578 </taskdef> 3579 3580 <taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask"> 3581 <classpath refid="findbugs.lib" /> 3582 </taskdef> 3583 3584 <!-- findbugs task definition --> 3585 <target name="findbugs"> 3586 <antcall target="analyze" /> 3587 <antcall target="mine" /> 3588 </target> 3589 3590 <!-- analyze task --> 3591 <target name="analyze"> 3592 <!-- run findbugs against asm-util --> 3593 <findbugs home="${findbugs.home}" 3594 output="xml:withMessages" 3595 timeout="90000000" 3596 reportLevel="experimental" 3597 workHard="true" 3598 effort="max" 3599 adjustExperimental="true" 3600 jvmargs="${jvmargs}" 3601 failOnError="true" 3602 outputFile="out.xml" 3603 projectName="Findbugs" 3604 debug="false"> 3605 <class location="asm-util-3.0.jar" /> 3606 </findbugs> 3607 </target> 3608 3609 <target name="mine"> 3610 3611 <!-- Set info to the latest analysis --> 3612 <setBugDatabaseInfo home="${findbugs.home}" 3613 withMessages="true" 3614 name="asm-util-3.0.jar" 3615 input="out.xml" 3616 output="out-rel.xml"/> 3617 3618 <!-- Checking if history file already exists (out-hist.xml) --> 3619 <condition property="mining.historyfile.available"> 3620 <available file="out-hist.xml"/> 3621 </condition> 3622 <condition property="mining.historyfile.notavailable"> 3623 <not> 3624 <available file="out-hist.xml"/> 3625 </not> 3626 </condition> 3627 3628 <!-- this target is executed if the history file do not exist (first run) --> 3629 <antcall target="history-init"> 3630 <param name="data.file" value="out-rel.xml" /> 3631 <param name="hist.file" value="out-hist.xml" /> 3632 </antcall> 3633 <!-- else this one is executed --> 3634 <antcall target="history"> 3635 <param name="data.file" value="out-rel.xml" /> 3636 <param name="hist.file" value="out-hist.xml" /> 3637 <param name="hist.summary.file" value="out-hist.txt" /> 3638 </antcall> 3639 </target> 3640 3641 <!-- Initializing history file --> 3642 <target name="history-init" if="mining.historyfile.notavailable"> 3643 <copy file="${data.file}" tofile="${hist.file}" /> 3644 </target> 3645 3646 <!-- Computing bug history --> 3647 <target name="history" if="mining.historyfile.available"> 3648 <!-- Merging ${data.file} into ${hist.file} --> 3649 <computeBugHistory home="${findbugs.home}" 3650 withMessages="true" 3651 output="${hist.file}"> 3652 <dataFile name="${hist.file}"/> 3653 <dataFile name="${data.file}"/> 3654 </computeBugHistory> 3655 3656 <!-- Compute history into ${hist.summary.file} --> 3657 <mineBugHistory home="${findbugs.home}" 3658 formatDates="true" 3659 noTabs="true" 3660 input="${hist.file}" 3661 output="${hist.summary.file}"/> 3662 </target> 3663 3664</project> 3665]]> 3666</screen> 3667 </sect1> 3668</chapter> 3669 3670 3671<!-- 3672 ************************************************************************** 3673 License 3674 ************************************************************************** 3675--> 3676 3677<chapter id="license"> 3678<title>License</title> 3679 3680<para> 3681The name FindBugs and the FindBugs logo is trademarked by the University 3682of Maryland. 3683FindBugs is free software distributed under the terms of the 3684<ulink url="http://www.gnu.org/licenses/lgpl.html">Lesser GNU Public License</ulink>. 3685You should have received a copy of the license in the file <filename>LICENSE.txt</filename> 3686in the &FindBugs; distribution. 3687</para> 3688 3689<para> 3690You can find the latest version of FindBugs, along with its source code, from the 3691<ulink url="http://findbugs.sourceforge.net">FindBugs web page</ulink>. 3692</para> 3693 3694</chapter> 3695 3696 3697<!-- 3698 ************************************************************************** 3699 Acknowledgments 3700 ************************************************************************** 3701--> 3702<chapter id="acknowledgments"> 3703<title>Acknowledgments</title> 3704 3705<sect1> 3706<title>Contributors</title> 3707 3708<para>&FindBugs; was originally written by Bill Pugh (<email>pugh@cs.umd.edu</email>). 3709David Hovemeyer (<email>daveho@cs.umd.edu</email>) implemented some of the 3710detectors, added the Swing GUI, and is a co-maintainer.</para> 3711 3712<para>Mike Fagan (<email>mfagan@tde.com</email>) contributed the &Ant; build script, 3713the &Ant; task, and several enhancements and bug fixes to the GUI.</para> 3714 3715<para>Germano Leichsenring contributed Japanese translations of the bug 3716summaries.</para> 3717 3718<para>David Li contributed the Emacs bug report format.</para> 3719 3720<para>Peter D. Stout contributed recursive detection of Class-Path 3721attributes in analyzed Jar files, German translations of 3722text used in the Swing GUI, and other fixes.</para> 3723 3724<para>Peter Friese wrote the &FindBugs; Eclipse plugin.</para> 3725 3726<para>Rohan Lloyd contributed several Mac OS X enhancements, 3727bug detector improvements, 3728and maintains the Fink package for &FindBugs;.</para> 3729 3730<para>Hiroshi Okugawa translated the &FindBugs; manual and 3731more of the bug summaries into Japanese.</para> 3732 3733<para>Phil Crosby enhanced the Eclipse plugin to add a view 3734to display the bug details.</para> 3735 3736<para>Dave Brosius fixed a number of bugs, added user preferences 3737to the Swing GUI, improved several bug detectors, and 3738contributed the string concatenation detector.</para> 3739 3740<para>Thomas Klaeger contributed a number of bug fixes and 3741bug detector improvements.</para> 3742 3743<para>Andrei Loskutov made a number of improvements to the 3744Eclipse plugin.</para> 3745 3746<para>Brian Goetz contributed a major refactoring of the 3747visitor classes to improve readability and understandability.</para> 3748 3749<para> Pete Angstadt fixed several problems in the Swing GUI.</para> 3750 3751<para>Francis Lalonde provided a task resource file for the 3752FindBugs Ant task.</para> 3753 3754<para>Garvin LeClaire contributed support for output in 3755Xdocs format, for use by Maven.</para> 3756 3757<para>Holger Stenzhorn contributed improved German translations of items 3758in the Swing GUI.</para> 3759 3760<para>Juha Knuutila contributed Finnish translations of items 3761in the Swing GUI.</para> 3762 3763<para>Tanel Lebedev contributed Estonian translations of items 3764in the Swing GUI.</para> 3765 3766<para>Hanai Shisei (ruimo) contributed full Japanese translations of 3767bug messages, and text used in the Swing GUI.</para> 3768 3769<para>David Cotton contributed Fresh translations for bug 3770messages and for the Swing GUI.</para> 3771 3772<para>Michael Tamm contributed support for the "errorProperty" attribute 3773in the Ant task.</para> 3774 3775<para>Thomas Kuehne improved the German translation of the Swing GUI.</para> 3776 3777<para>Len Trigg improved source file support for the Emacs output mode.</para> 3778 3779<para>Greg Bentz provided a fix for the hashcode/equals detector.</para> 3780 3781<para>K. Hashimoto contributed internationalization fixes and several other 3782 bug fixes.</para> 3783 3784<para> 3785 Glenn Boysko contributed support for ignoring specified local 3786 variables in the dead local store detector. 3787</para> 3788 3789<para> 3790 Jay Dunning contributed a detector to find equality comparisons 3791 of floating-point values, and overhauled the analysis summary 3792 report and its representation in the saved XML format. 3793</para> 3794 3795<para> 3796 Olivier Parent contributed updated French translations for bug descriptions and 3797 Swing GUI. 3798</para> 3799 3800<para> 3801 Chris Nappin contributed the <filename>plain.xsl</filename> 3802 stylesheet. 3803</para> 3804 3805<para> 3806 Etienne Giraudy contributed the <filename>fancy.xsl</filename> and <filename>fancy-hist.xsl</filename> 3807 stylesheets, and made improvements to the <command>-xml:withMessages</command> 3808 option. 3809</para> 3810 3811<para> 3812 Takashi Okamoto fixed bugs in the project preferences dialog 3813 in the Eclipse plugin, and contributed to its internationalization and localization. 3814</para> 3815 3816<para>Thomas Einwaller fixed bugs in the project preferences dialog in the Eclipse plugin.</para> 3817 3818<para>Jeff Knox contributed support for the warningsProperty attribute 3819in the Ant task.</para> 3820 3821<para>Peter Hendriks extended the Eclipse plugin preferences, 3822and fixed a bug related to renaming the Eclipse plugin ID.</para> 3823 3824<para>Mark McKay contributed an Ant task to launch the findbugs frame.</para> 3825 3826<para>Dieter von Holten (dvholten) contributed 3827some German improvements to findbugs_de.properties.</para> 3828 3829 3830<para>If you have contributed to &FindBugs;, but aren't mentioned above, 3831please send email to <email>findbugs@cs.umd.edu</email> (and also accept 3832our humble apologies).</para> 3833 3834</sect1> 3835 3836<sect1> 3837<title>Software Used</title> 3838 3839<para>&FindBugs; uses several open-source software packages, without which its 3840development would have been much more difficult.</para> 3841 3842<sect2> 3843<title>BCEL</title> 3844<para>&FindBugs; includes software developed by the Apache Software Foundation 3845(<ulink url="http://www.apache.org/">http://www.apache.org/</ulink>). 3846Specifically, it uses the <ulink url="http://jakarta.apache.org/bcel/">Byte Code 3847Engineering Library</ulink>.</para> 3848</sect2> 3849 3850<sect2> 3851<title>ASM</title> 3852<para>&FindBugs; uses the <ulink url="http://asm.objectweb.org/">ASM</ulink> 3853bytecode framework, which is distributed under the following license:</para> 3854 3855<blockquote> 3856<para> 3857Copyright (c) 2000-2005 INRIA, France Telecom 3858All rights reserved. 3859</para> 3860 3861<para> 3862Redistribution and use in source and binary forms, with or without 3863modification, are permitted provided that the following conditions 3864are met: 3865</para> 3866 3867<orderedlist numeration="arabic"> 3868 <listitem><para> 3869 Redistributions of source code must retain the above copyright 3870 notice, this list of conditions and the following disclaimer. 3871 </para></listitem> 3872 <listitem><para> 3873 Redistributions in binary form must reproduce the above copyright 3874 notice, this list of conditions and the following disclaimer in the 3875 documentation and/or other materials provided with the distribution. 3876 </para></listitem> 3877 <listitem><para> 3878 Neither the name of the copyright holders nor the names of its 3879 contributors may be used to endorse or promote products derived from 3880 this software without specific prior written permission. 3881 </para></listitem> 3882</orderedlist> 3883 3884<para> 3885THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 3886AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 3887IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 3888ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 3889LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 3890CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 3891SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 3892INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3893CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3894ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 3895THE POSSIBILITY OF SUCH DAMAGE. 3896</para> 3897</blockquote> 3898</sect2> 3899 3900<sect2> 3901<title>DOM4J</title> 3902<para>&FindBugs; uses <ulink url="http://dom4j.org">DOM4J</ulink>, which is 3903distributed under the following license:</para> 3904 3905<blockquote> 3906<para> 3907Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 3908</para> 3909 3910<para> 3911Redistribution and use of this software and associated documentation 3912("Software"), with or without modification, are permitted provided that 3913the following conditions are met: 3914</para> 3915 3916<orderedlist numeration="arabic"> 3917 <listitem><para> 3918 Redistributions of source code must retain copyright statements and 3919 notices. Redistributions must also contain a copy of this document. 3920 </para></listitem> 3921 <listitem><para> 3922 Redistributions in binary form must reproduce the above copyright 3923 notice, this list of conditions and the following disclaimer in the 3924 documentation and/or other materials provided with the distribution. 3925 </para></listitem> 3926 <listitem><para> 3927 The name "DOM4J" must not be used to endorse or promote products 3928 derived from this Software without prior written permission 3929 of MetaStuff, Ltd. For written permission, please contact 3930 <email>dom4j-info@metastuff.com</email>. 3931 </para></listitem> 3932 <listitem><para> 3933 Products derived from this Software may not be called "DOM4J" nor may 3934 "DOM4J" appear in their names without prior written permission of 3935 MetaStuff, Ltd. DOM4J is a registered trademark of MetaStuff, Ltd. 3936 </para></listitem> 3937 <listitem><para> 3938 Due credit should be given to the DOM4J Project (<ulink url="http://dom4j.org/">http://dom4j.org/</ulink>). 3939 </para></listitem> 3940</orderedlist> 3941 3942<para> 3943THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' 3944AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 3945THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 3946PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS 3947CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 3948EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 3949PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 3950PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 3951LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 3952NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 3953SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3954</para> 3955</blockquote> 3956 3957</sect2> 3958 3959</sect1> 3960 3961</chapter> 3962 3963 3964</book> 3965