diff --git a/.classpath b/.classpath index 33f0fd2..87680be 100644 --- a/.classpath +++ b/.classpath @@ -1,11 +1,11 @@ - - - + + + - + @@ -15,7 +15,7 @@ - + @@ -26,18 +26,21 @@ - - + + - + - - + + - + + + + diff --git a/.project b/.project index a8d2927..d68fad5 100644 --- a/.project +++ b/.project @@ -6,7 +6,17 @@ + com.cenqua.clover.core.prejavabuilder + + + + org.eclipse.jdt.core.javabuilder + + + + + com.cenqua.clover.core.postjavabuilder @@ -29,6 +39,7 @@ org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature + com.cenqua.clover.core.clovernature edu.umd.cs.findbugs.plugin.eclipse.findbugsNature diff --git a/.settings/edu.umd.cs.findbugs.core.prefs b/.settings/edu.umd.cs.findbugs.core.prefs index d33a0f8..a06a096 100644 --- a/.settings/edu.umd.cs.findbugs.core.prefs +++ b/.settings/edu.umd.cs.findbugs.core.prefs @@ -1,5 +1,5 @@ #FindBugs User Preferences -#Thu Aug 25 18:56:29 EDT 2011 +#Thu Nov 07 08:16:06 EST 2013 cloud_id=edu.umd.cs.findbugs.cloud.appengine.findbugs-cloud detectorAbnormalFinallyBlockReturn=AbnormalFinallyBlockReturn|true detectorAbstractClassEmptyMethods=AbstractClassEmptyMethods|true @@ -23,6 +23,7 @@ detectorCheckCalls=CheckCalls|false detectorCheckExpectedWarnings=CheckExpectedWarnings|false detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true +detectorCheckRelaxingNullnessAnnotation=CheckRelaxingNullnessAnnotation|true detectorCheckTypeQualifiers=CheckTypeQualifiers|true detectorCloneIdiom=CloneIdiom|true detectorComparatorIdiom=ComparatorIdiom|true @@ -123,6 +124,7 @@ detectorInheritanceTypeChecking=InheritanceTypeChecking|true detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true detectorInitializationChain=InitializationChain|true +detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true detectorInstantiateStaticClass=InstantiateStaticClass|true detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true detectorInvalidJUnitTest=InvalidJUnitTest|true @@ -254,6 +256,6 @@ detector_threshold=2 effort=default excludefilter0=findbugsExclude.xml|true -filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,I18N,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|15 -filter_settings_neg=MALICIOUS_CODE,NOISE,EXPERIMENTAL| +filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,I18N,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|15 +filter_settings_neg=MALICIOUS_CODE,NOISE| run_at_full_build=false diff --git a/.settings/edu.umd.cs.findbugs.plugin.eclipse.prefs b/.settings/edu.umd.cs.findbugs.plugin.eclipse.prefs index 7d29871..74b9fa6 100644 --- a/.settings/edu.umd.cs.findbugs.plugin.eclipse.prefs +++ b/.settings/edu.umd.cs.findbugs.plugin.eclipse.prefs @@ -1,3 +1,3 @@ -#Fri Jun 03 22:22:24 CEST 2011 eclipse.preferences.version=1 +edu.umd.cs.findbugs.plugin.eclipse.findbugsMarkerOfConcern=Info runAnalysisAsExtraJob=true diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index d12752f..bcd62eb 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -19,6 +19,7 @@ org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault @@ -32,7 +33,7 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=disabled +org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error @@ -57,12 +58,12 @@ org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private -org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning @@ -71,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=no_tag org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled @@ -83,6 +84,7 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning @@ -100,11 +102,12 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled @@ -129,6 +132,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.5 diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs index 7bd896d..c68fe73 100644 --- a/.settings/org.eclipse.jdt.ui.prefs +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -29,7 +29,7 @@ sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=true +sp_cleanup.make_variable_declarations_final=false sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true sp_cleanup.on_save_use_additional_actions=true @@ -41,8 +41,8 @@ sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_trailing_whitespaces_all=false +sp_cleanup.remove_trailing_whitespaces_ignore_empty=true sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false sp_cleanup.remove_unused_imports=true diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index ee15745..1ccf4f9 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -12,10 +12,17 @@ lib/asm-3.3.jar, lib/asm-tree-3.3.jar, lib/asm-commons-3.3.jar, - lib/jaxen-1.1.1.jar, + lib/jaxen-1.1.6.jar, lib/jFormatString.jar, - lib/commons-lang-2.4.jar, - lib/jsr305.jar + lib/commons-lang-2.6.jar, + lib/jsr305.jar, + lib/ant.jar, + lib/asm-analysis-3.3.jar, + lib/asm-util-3.3.jar, + lib/asm-xml-3.3.jar, + lib/jcip-annotations.jar, + lib/jdepend-2.9.jar, + lib/yjp-controller-api-redist.jar Bundle-Localization: plugin Export-Package: edu.umd.cs.findbugs, edu.umd.cs.findbugs.annotations, @@ -37,6 +44,7 @@ edu.umd.cs.findbugs.ba.type, edu.umd.cs.findbugs.ba.vna, edu.umd.cs.findbugs.bcel, + edu.umd.cs.findbugs.bcel.generic, edu.umd.cs.findbugs.bugReporter, edu.umd.cs.findbugs.charsets, edu.umd.cs.findbugs.classfile, @@ -89,5 +97,4 @@ org.objectweb.asm.commons, org.objectweb.asm.signature, org.objectweb.asm.tree -Require-Bundle: org.apache.ant Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/build-lib/README.txt b/build-lib/README.txt new file mode 100644 index 0000000..7cb0eb6 --- /dev/null +++ b/build-lib/README.txt @@ -0,0 +1 @@ +This is a folder for jars required for BUILDING, not dependencies of FindBugs itself! \ No newline at end of file diff --git a/build.properties b/build.properties index 953c24b..27f21f8 100644 --- a/build.properties +++ b/build.properties @@ -7,8 +7,6 @@ src/junit/,\ src/gui/,\ etc -local.software.home =/fs/pugh/pugh -#local.software.home =/user/daveho/local # Set this to the directory containing the DocBook Modular XSL Stylesheets # from http://docbook.sourceforge.net/projects/xsl/ @@ -37,11 +35,8 @@ # Eclipse plugin. eclipse.home =${local.software.home}/java/eclipse-2.1.3 -java14.rt =/export/home/pugh/work/j2sdk1.4.0/jre/lib/rt.jar - dblatex.img.fix=while(<>){s,([A-Za-z-]*\.png\}),manual/\1,g;print;} -#/export/home/pugh/JSR305-ri/build/classes pluginsSrc.dir=../plugins/ serverSrc.dir=../server/ diff --git a/build.xml b/build.xml index 89b95a6..0981cc5 100644 --- a/build.xml +++ b/build.xml @@ -50,6 +50,7 @@ + @@ -66,10 +67,10 @@ - + - + @@ -81,12 +82,10 @@ - - - - - - + + + + @@ -132,16 +131,33 @@ - + - + + + + + + + + + @@ -356,10 +372,10 @@ - + - + @@ -543,6 +559,24 @@ /> + + + + + + + + + + + @@ -557,7 +591,7 @@ timeout="1800000" outputFile="${build.dir}/findbugscheckAll.xml" > - + @@ -584,7 +618,7 @@ timeout="1800000" outputFile="${build.dir}/findbugscheck.xml" > - + @@ -651,7 +685,7 @@ - + Running JUnit test cases for FindBugs... @@ -681,6 +715,7 @@ + @@ -721,19 +756,19 @@ - + ${svnrnum} - + - + @@ -827,7 +862,7 @@ output="${bugdesc.output}"> - + @@ -856,8 +891,10 @@ + + @@ -998,9 +1035,9 @@ - + - + @@ -1183,7 +1220,7 @@ - + ${svnant.home} @@ -1191,7 +1228,8 @@ - + + + sourcepath="src/java:src/gui:src/antTask" splitindex="true" use="true" version="true"> @@ -1277,7 +1315,7 @@ packagenames="edu.umd.cs.findbugs.annotations" doctitle="FindBugs Annotation Documentation" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar= "false" notree="false" - sourcepath="src/gui" splitindex="true" use="true" version="true"/> + sourcepath="src/java:src/gui:src/antTask" splitindex="true" use="true" version="true"/> diff --git a/design/architecture/mkdep.pl b/design/architecture/mkdep.pl old file mode 100755 new file mode 100644 index 7724235..7724235 100644 diff --git a/doc/AddingDetectors.txt b/doc/AddingDetectors.txt new file mode 100644 index 0000000..131e690 --- /dev/null +++ b/doc/AddingDetectors.txt @@ -0,0 +1,237 @@ +Adding Detectors to FindBugs +May 12, 2003 +Updated June 6, 2003 (detector meta-information, cleanups) + +=============== +1. Introduction +=============== + +FindBugs uses a plugin-based approach to adding detectors. +This makes it easy for users to add their own detectors alongside +the ones that come built in. + +Basic idea: FindBugs has some Jar files in a "plugins" directory. +At startup, each of those jar files is checked for a "findbugs.xml" +file. That XML file registers instances of Detectors, as well +as particular "bug patterns" that the detector reports. + +Additionally to the findbugs.xml, bugrank.txt and messages.xml files are +required for each FindBugs detector plugin. + +At startup, FindBugs loads all plugin Jar files. At analysis time, +all detectors named in the findbugs.xml files from those plugins +are instantiated and applied to analyzed class files. + +In order to format reported BugInstances as text for display, +a messages file is loaded from the plugin. In order to support multiple +language translations, a locale search is performed in a manner +similar to the handling of resource bundles. For example, if the +locale is "pt_BR", then the files + + messages_pt_BR.xml + messages_pt.xml + messages.xml + +are tried, in that order. + +The "findbugs.xml" and "messages.xml" files used by the standard FindBugs +bug pattern detectors (coreplugin.jar) can be found in the "etc" directory +of the findbugs source distribution. Both files must be UTF-8 encoded. + + +============================ +2. Example findbugs.xml file +============================ + + + + + + + + + + + + + + + +====================================== +3. Meaning of elements in findbugs.xml +====================================== + + a collection of and elements. + Each plugin Jar file can (and usually will) provide multiple detectors + and define multiple bug patterns. + + specifies a class which implements the edu.umd.cs.findbugs.Detector + interface and has a constructor that takes a single parameter of type + edu.umd.cs.findbugs.BugReporter. This element has three possible attributes: + + 1. The required "class" attribute specifies the Detector class. + + 2. The optional "disabled" attribute, if set to "true", means + that by default, the detector will be disabled at runtime. + This is useful for detectors that aren't quite ready for prime time. + + 3. The required "speed" attribute supplies a value to be shown in the + "Settings->Configure Detectors" dialog. It gives the user an idea of + how expensive the analysis will be to perform. The value of this + attribute should be one of "fast", "moderate", or "slow". + + specifies a kind of bug that will be reported. + It has three required attributes: + + 1. "type" is a unique code identifying the bug. Only one BugPattern + can have a a particular type. + + 2. "abbrev" is a short alphanumeric code for the bug. + Note that multiple BugPatterns can use the same abbreviation + if they are related. (See the BugCode element in messages.xml). + + 3. "category" can be one of categories defined in the core plugin's messages.xml: + + CORRECTNESS - code that was probably not what the developer intended + BAD_PRACTICE - violations of recommended and essential coding practice + STYLE - code that is confusing, anomalous, or written in a way that that leads itself to errors + MT_CORRECTNESS - multithreaded correctness issues + MALICIOUS_CODE - a potential vulnerability if exposed to malicious code + PERFORMANCE - a performance issue + I18N - internationalization and locale + + or you may create your own category, in which case you should define + it in a element in _your_ messages.xml file. + +============================ +4. Example messages.xml file +============================ + + + + +
+ This detector looks for JSR-166 locks that are not released on all paths + out of a method. Because it performs dataflow analysis, it is fairly slow. + ]]> +
+
+ + + + + Lock not released on all paths out of method + + {1} does not release lock on all paths out of method + +
+ A JSR-166 lock acquired in this method is not released on all paths + out of the method. This could result in a deadlock if another thread + tries to acquire the lock. Generally, you should use a finally + block to ensure that acquired locks are always released. + ]]> +
+
+ + + + Unreleased locks + + + +
+ + +====================================== +5. Meaning of elements in messages.xml +====================================== + + is the top level element + + elements optionally describe any categories you + may have created for your bug patterns. You can skip these if + you are using only the categories defined by the core plugin. + + The child element has a brief (a word or three) + description of the category. The child element + is typically a single capital latter. The optional
+ child element may describe it in more detail (but no markup). + + holds meta-information about a Detector in the plugin. + The required "class" attribute specifies the Detector class. + Detector elements much have the following child elements: + + The
child element has a brief HTML description of the Detector. + It should have HTML markup that would be valid in a BODY element. + It should be specified in a CDATA section so that the HTML + tags are not misinterpreted as XML. + + holds all of the human-readable messages for the bug pattern + identified by the "type" attribute. The type corresponds to the + type attribute of the BugPattern elements described in findbugs.xml. + BugPattern elements must have the following child elements: + + this is used for when "View->Full Descriptions" + is turned off in the GUI, and it's also used as the title for + descriptions in the Details window. + + this is used for when "View->Full Descriptions" + is turned on in the GUI, and for output using the command line UI. + The placeholders in the long description ({0}, {1}, etc.) + refer to BugAnnotations attached to the BugInstances reported by + the detector for this bug pattern. You may also use constructs + like {1.name} or {1.returnType}. + +
this is the descriptive text to be used in the Details + window. It consists of HTML markup to appear in the BODY element of an HTML + document. It should be specified in a CDATA section so that the HTML + tags are not misinterpreted as XML. + + is the text which describes the common characteristic of all + of the BugPatterns which share an abbreviation. In the example above, + the abbreviation "UL" is for bugs in which a lock is not released. + The text of a BugCode element is shown for tree nodes in the GUI + which group bug instances by "bug type". + +====================================== +6. Meaning of elements in bugrank.txt +====================================== + +For the detailed and up to date information, please read the javadoc of the +edu.umd.cs.findbugs.BugRanker class. + +============================================ +7. Using 3rd party libraries in the detector +============================================ + +FindBugs plugins may extend the default FindBugs classpath and use custom 3rd party +libraries during the analysis. This libraries must be part of standard jar class path +specified via "ClassPath" attribute in the META-INF/MANIFEST.MF file. + +====================================== +8. Adding detectors to Eclipse plugin +====================================== + +Since version 2.0.0 Eclipse plugin allows to configure or contribute custom detectors. + +7.1. It is possible to contribute custom detectors via standard Eclipse extensions mechanism. +Please check the documentation of the "findBugsEclipsePlugin/schema/detectorPlugins.exsd" +extension point how to update the plugin.xml. Existing FindBugs detector plugins can +be easily "extended" to be full featured FindBugs & Eclipse detector plugins. +Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and +update your build scripts to not to override the MANIFEST.MF during the build. + +7.2 It is possible to configure custom detectors via Eclipse workspace preferences. +Go to "Window->Preferences->Java->FindBugs->Misc. Settings->Custom Detectors" +and specify there locations of any additional plugin libraries. + +7.3 Plugins contributed via standard Eclipse extensions mechanism (see 7.1) +may extend the default FindBugs classpath and use custom libraries during the analysis. +This libraries must be part of standard Eclipse plugin dependencies specified via +either "Require-Bundle" or "Bundle-ClassPath" attributes in the MANIFEST.MF file. +In case custom detectors need access to this custom libraries at runtime, an +extra line must be added to the MANIFEST.MF (without quotation marks): +"Eclipse-RegisterBuddy: edu.umd.cs.findbugs.plugin.eclipse". + diff --git a/doc/Changes.html b/doc/Changes.html new file mode 100644 index 0000000..21b4551 --- /dev/null +++ b/doc/Changes.html @@ -0,0 +1,2810 @@ + + + +FindBugs Change Log + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FindBugs
 
Docs and Info
FindBugs 2.0
Demo and data
Users and supporters
FindBugs blog
Fact sheet
Manual
Manual(ja/日本語)
FAQ
Bug descriptions
Mailing lists
Documents and Publications
Links
 
Downloads
 
FindBugs Swag
 
Development
Open bugs
Reporting bugs
Contributing
Dev team
API [no frames]
Change log
SF project page
Browse source
Latest code changes
+
+ + +

FindBugs Change Log, Version 2.0.3

+ +

FindBugs Change Log, Version 2.0.2

+ +
    +
  • Fix false positions for NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR + - fixing Bug3547559, + Bug3555408, + Bug3580266 + and Bug3587164. + + +
  • +
  • Fix false positives for SF_SWITCH_NO_DEFAULT +
  • Inline access methods for private fields, + fixing false positive in Bug3484713. + +
  • Type qualifier annotations, including nullness + annotations, are now ignored on vararg parameters (including + default and inherited annotations), awaiting JSR308. +
  • Defined new bug pattern to give better explanations of + issues involving strict type qualifiers TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED +
  • Adjusted analysis of type qualifiers, now giving warnings + where a computed value is used in a place where a value with a + strict type qualifier is required. +
  • Complain about missing classes only if they are + encountered while analyzing application classes; ignore missing + classes that are encounted while analyzing classes loaded from the + auxclasspath. Fix for Bug3588379 +
  • Fixed false positive null pointer warning coming from + synthetic bridge methods, fixing Bug3589328 +
  • In general, suppress warnings in synthetic methods. +
  • Fix some false positives involving GC_UNRELATED_TYPES + on classes that extend generic collection classes. + +
  • +
  • Combine multiple identical warnings about + DM_DEFAULT_ENCODING + that occur in the same method, + simplifying issue triage. + +
  • Changes by Andrey Loskutov +
      +
    • fixed job scheduling errors in 3.8/4.2 Eclipse bug + report +
    • more realistic progress bar updates for jobs +
    • added nullness annotations for some common Eclipse API + methods known to usually return null values +
    • Added support for org.eclipse.jdt.annotation.Nullable, + NonNull and NonNullByDefault annotations (introduced with + Eclipse 3.8/4.2)
    • +
    +
  • Documentation improvements +
  • lots + of other small changes +
+

FindBugs Change Log, Version 2.0.1

+ + + +

FindBugs Change Log, Version 2.0.0

+ +

Changes since version 1.3.8

+ + +

Changes since version 1.3.8

+ + +

Changes since version 1.3.7

+
    +
  • Primarily another small bugfix release.
  • +
  • FindBugs base: +
      +
    • New Reports: +
        +
      • SF_SWITCH_NO_DEFAULT: missing default case in switch + statement.
      • +
      • SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW: + value ignored when switch fallthrough leads to thrown + exception.
      • +
      • INT_VACUOUS_BIT_OPERATION: bit operations that don't + do any meaningful work.
      • +
      • FB_UNEXPECTED_WARNING: warning generated that + conflicts with @NoWarning FindBugs annotation.
      • +
      • FB_MISSING_EXPECTED_WARNING: warning not generated + despite presence of @ExpectedWarning FindBugs annotation.
      • +
      • NOISE category: intended for use in data mining + experiments. +
          +
        • NOISE_NULL_DEREFERENCE: fake null point dereference + warning.
        • +
        • NOISE_METHOD_CALL: fake method call warning.
        • +
        • NOISE_FIELD_REFERENCE: fake field dereference + warning.
        • +
        • NOISE_OPERATION: fake operation warning.
        • +
        +
      • +
      +
    • +
    • Other: + +
    • +
    • Fixes: +
        +
      • [ 2317842 ] Highlighting broken in Windows
      • +
      • [ 2515908 ] check for oddness should track sign of + argument
      • +
      • [ 2487936 ] "L B GC" false pos cast from + Map.Entry.getKey() to Map.get()
      • +
      • [ 2528264 ] Ant tasks not compatible with Ant 1.7.1
      • +
      • [ 2539590 ] SF_SWITCH_FALLTHROUGH wrong message + reported
      • +
      • [ 2020066 ] Bug history displayed in fancy-hist.xsl is + incorrect
      • +
      • [ 2545098 ] Invalid character in analysis results file
      • +
      • [ 2492673 ] Plugin sites should specify "requires + Eclipse 3.3 or newer"
      • +
      • [ 2588044 ] a tiny typing error
      • +
      • [ 2589048 ] Documentation for convertXmlToText + insufficient
      • +
      • [ 2638739 ] NullPointerException when building
      • +
      +
    • +
    • Patches: +
        +
      • [ 2538184 ] Make BugCollection implement + Iterable<BugInstance> (thanks to Tomas Pollak)
      • +
      • [ 2249771 ] Add Maven2 Findbugs plugin link to the + Links page (thanks to Garvin Leclaire)
      • +
      • [ 2609526 ] Japanese manual update (thanks to K. + Hashimoto)
      • +
      • [ 2119482 ] CheckBcel checks for nonexistent classes + (thanks to Jerry James)
      • +
      +
    • +
    +
  • +
  • FindBugs Eclipse plugin: +
      +
    • Major feature enhancements (thanks to Andrey Loskutov). + See this + overview for more information. +
    • +
    • Major test improvements (thanks to Tomas Pollak).
    • +
    • Fixes: +
        +
      • [ 2532365 ] Compiler warning
      • +
      • [ 2522989 ] Fix filter files selection
      • +
      • [ 2504068 ] NullPointerException
      • +
      • [ 2640849 ] NPE in Eclipse plugin 1.3.7 and Eclipse + 3.5 M5
      • +
      +
    • +
    • Patches: +
        +
      • [ 2143140 ] Unchecked conversion fixes for Eclipse + plugin (thanks to Jerry James) +
      +
    • +
    +
  • +
+ +

Changes since version 1.3.6

+
    +
  • Overall, a small bugfix release. +
  • New detection of accidental vacuous/useless calls to + EasyMock methods, and of generic signatures that proclaim the use + of unhashable classes in ways that require that they be hashed. +
  • Eliminate some false positives where we were warning about + a useless call (e.g., comparing two incompatible types for + equality), but the only thing the code was doing with the result + was passing it to assertFalse. +
  • Japanese localization and manual by K.Hashimoto. (Thanks!) + +
  • Added -exclude and -outputDir command line options to + rejarForAnalysis +
  • Extended -adjustPriorities option to FindBugs analysis + textui so that you can modify the priorities of individual bug + patterns as well as visitors, and also completely suppress + individual bug patterns or visitors. +
      +
    • e.g., -adjustPriority + MS_SHOULD_BE_FINAL=suppress,MS_PKGPROTECT=suppress,EI_EXPOSE_REP=suppress,EI_EXPOSE_REP2=suppress,PZLA_PREFER_ZERO_LENGTH_ARRAYS=raise + +
    +
+ + +

Changes since version 1.3.5

+
    +
  • Added fairly exhaustive static analysis of uses of format + strings, checking for missing or extra arguements, invalid format + specifiers, or mismatched format specifiers and arguments (e.g, + passing a String value for a %d format specifier). The logic for + doing so is derived from Sun's java.util.Formatter class, and + available separately from FindBugs as part of the jFormatString + project. +
  • More tuning of the unsatisfied obligation detector. Since + this detector is still rather noisy and an unfinished research + project, I've moved the generated issues to a new category: + EXPERIMENTAL. +
  • Added check for BIT_ADD_OF_SIGNED_BYTE; + similar to BIT_IOR_OF_SIGNED_BYTE, + except that addition is being used to combine shifted signed + bytes. +
  • Changed detection of EI_EXPOSE_REP2, so we only report it + if the value stored is guaranteed to be the same value that was + passed in as a parameter. +
  • Added EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS, + a warning when an equals method checks to see if an operand is an + instance of a class not compatible with itself. For example, if + the Foo class checks to see if the argument is an instance of + String. This is either a questionable design decision or a coding + mistake. +
  • Added DMI_INVOKING_HASHCODE_ON_ARRAY, + which checks for invoking hashCode() on an array, + which returns a hash code that ignores the contents of the array. + +
  • Added checks for using x.removeAll(x) to + rather than x.clear() to clear an array. +
  • Add checks for calls such as x.contains(x), x.remove(x) + and x.containsAll(x). +
  • Improvements to Eclipse plugin (thanks to Andrey + Loskutov): +
      +
    • Report separate markers for each occurrence of an issue + that appears multiple times in a method +
    • fine tuning for reported markers: add only one marker + for fields, add marker on right position +
    • link bugs selected in bug explorer view to the opened + editor and vice versa +
    • select bugs selected in editor ruler in the opened bug + explorer view +
    • consistent abbreviations used in both bug explorer and + bug details view +
    • added "Expand All" button to the bug explorer view +
    • added "Go Into/Go Up" buttons to the bug explorer view +
    • added "Copy to clipboard" menu/functionality to the + details view list widget +
    • fix for CNF exception if loading the backup solution for + broken browser widget +
    +
+ + + +

Changes since version 1.3.4

+
    +
  • Analysis about 15% faster +
  • 38 + bugs closed
  • +
  • New defect warnings: +
      +
    • calls to methods that always throw + UnsupportedOperationException (DMI_UNSUPPORTED_METHOD) +
    • repeated conditional tests (e.g., if (x + < 0 || x < 0) ...) (RpC_REPEATED_CONDITIONAL_TEST) +
    • Complete rewrite of detector for format string problems. + More accurate, finds more problems, generates more descriptive + reports, several different bug pattern + (VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED, + VA_FORMAT_STRING_ILLEGAL, VA_FORMAT_STRING_MISSING_ARGUMENT, + VA_FORMAT_STRING_BAD_ARGUMENT, + VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT) +
    • Fairly complete implementation of JSR-305 custom type + qualifier analysis (no support for custom validators yet). + (TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK + TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK + TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK) +
    • New detector for unsatisfied obligations such forgetting + to close a file (OBL_UNSATISFIED_OBLIGATION). +
    • Warning when a parameter is marked as nullable, but is + always dereferenced. + (NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE) +
    • Separate warning for dereference the result of readLine + (NP_DEREFERENCE_OF_READLINE_VALUE) +
    +
  • When XML is generated with messages, the project stats now + include <FileStat> elements. For each source file, this + gives the path for the file, the total number of warnings for that + file, and a bugHash for the file. While the instanceHash for a bug + is intended to be version invariant (ignoring line numbers, etc), + the bugHash for a file is intended to reflect all the information + about the warnings in that file. The intended use case is that if + the bugHash for a file is the same in two analysis runs, then nothing + has changed about any of the warnings reported for that file + between the two analysis runs. +
  • More merging of similar issues within a method. For + example, if the result of readLine() is dereferences multiple + times within a method, it will be reported as a single warning + with occurrences at multiple source lines. +
+

Changes since version 1.3.3

+ +
    +
  • FindBugs base +
      +
    • New Reports: +
        +
      • EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC: equals method + overrides equals in superclass and may not be symmetric
      • +
      • EQ_ALWAYS_TRUE: equals method always returns true
      • +
      • EQ_ALWAYS_FALSE: equals method always returns false
      • +
      • EQ_COMPARING_CLASS_NAMES: equals method compares class + names rather than class objects
      • +
      • EQ_UNUSUAL: Unusual equals method
      • +
      • EQ_GETCLASS_AND_CLASS_CONSTANT: equals method fails + for subtypes
      • +
      • SE_READ_RESOLVE_IS_STATIC: The readResolve method must + not be declared as a static method.
      • +
      • SE_PRIVATE_READ_RESOLVE_NOT_INHERITED: private + readResolve method not inherited by subclasses
      • +
      • MSF_MUTABLE_SERVLET_FIELD: Mutable servlet field
      • +
      • XSS_REQUEST_PARAMETER_TO_SEND_ERROR: Servlet reflected + cross site scripting vulnerability
      • +
      • SKIPPED_CLASS_TOO_BIG: Class too big for analysis
      • +
      +
    • +
    • Other: +
        +
      • Value-number analysis now more space-efficient
      • +
      • Enhancements to reduce memory overhead when analyzing + very large classes
      • +
      • Now skips very large classes that would otherwise take + too much time and memory to analyze
      • +
      • Infrastructure for tracking effectively-constant/ + effectively-final fields
      • +
      • Added more cweids
      • +
      • Enhanced taint tracking for taint-based detectors
      • +
      • Ignore doomed calls to equals if result is used as an + argument to assertFalse
      • +
      • EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC handles compareTo
      • +
      • Priority tweak for ICAST_INTEGER_MULTIPLY_CAST_TO_LONG + (only low priority if multiplying by 1000)
      • +
      • Improved tracking of fields across method calls
      • +
      +
    • +
    • Fixes: +
        +
      • [ 1941450 ] DLS_DEAD_LOCAL_STORE not reported
      • +
      • [ 1953323 ] Omitted break statement in + SynchronizeAndNullCheckField
      • +
      • [ 1942620 ] Source Directories selection dialog + interface confusion (partial)
      • +
      • [ 1948275 ] Unhelpful "Load of known null"
      • +
      • [ 1933922 ] MWM error in findbugs
      • +
      • [ 1934772 ] 1.3.3 appears to rely on JDK 1.6, JNLP + still specifies 1.5
      • +
      • [ 1933945 ] -loadbugs doesn't work
      • +
      • Fixed problems for class names starting with '$'
      • +
      • Fixed bugs and incomplete handling of annotations in + VersionInsensitiveBugComparator
      • +
      +
    • +
    • Patches: +
        +
      • [ 1955106 ] Javadoc fixes
      • +
      • [ 1951930 ] Superfluous import statements (thanks to + Jerry James)
      • +
      • [ 1951907 ] Missing @Deprecated annotations (thanks to + Jerry James)
      • +
      • [ 1951876 ] Infonode Docking Windows compile fix + (thanks to Jerry James)
      • +
      • [ 1936055 ] bugfix for findbugs.de.comment not working + (thanks to Peter Fokkinga) +
      +
    • +
    +
  • FindBugs BlueJ plugin +
      +
    • Updated to use FindBugs 1.3.4 (first new release since + 1.1.3)
    • +
    +
  • +
+ +

Changes since version 1.3.2

+ +
    +
  • FindBugs base +
      +
    • New Detectors: +
        +
      • FieldItemSummary: Produces summary information for + what is stored into fields
      • +
      • SynchronizeOnClassLiteralNotGetClass: Look for code + that synchronizes on the results of getClass rather than on + class literals
      • +
      • SynchronizingOnContentsOfFieldToProtectField: This + detector looks for code that seems to be synchronizing on a + field in order to guard updates of that field
      • +
      +
    • +
    • New BugCode: +
        +
      • HRS: HTTP Response splitting vulnerability
      • +
      • WL: Possible locking on wrong object
      • +
      +
    • +
    • New Reports: +
        +
      • DMI_CONSTANT_DB_PASSWORD: This code creates a database + connect using a hard coded, constant password
      • +
      • HRS_REQUEST_PARAMETER_TO_COOKIE: HTTP cookie formed + from untrusted input
      • +
      • HRS_REQUEST_PARAMETER_TO_HTTP_HEADER: HTTP parameter + directly written to HTTP header output
      • +
      • CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE: Class defines + clone() but doesn't implement Cloneable
      • +
      • DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE: Synchronization + on boxed primitive could lead to deadlock
      • +
      • DL_SYNCHRONIZATION_ON_BOOLEAN: Synchronization on + Boolean could lead to deadlock
      • +
      • ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD: + Synchronization on field in futile attempt to guard that field +
      • +
      • DLS_DEAD_LOCAL_STORE_IN_RETURN: Useless assignment in + return statement
      • +
      • WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL: + Synchronization on getClass rather than class literal
      • +
      +
    • +
    • Other: +
        +
      • Many enhancements to cross-site scripting detector and + its documentation
      • +
      • Enhanced switch fall through handling
      • +
      • Enhanced unread field handling (look for IF_ACMPEQ and + IF_ACMPNE)
      • +
      • Clarified documentation for @Nullable in manual
      • +
      • Fewer DeadLocalStore false positives
      • +
      • Fewer UnreadField false positives
      • +
      • Fewer StaticCalendarDetector false positives
      • +
      • Performance fix for slow file system IO e.g. Clearcase + repositories (thanks, Andrei!)
      • +
      • Other, general performance enhancements (thanks, + Andrei!)
      • +
      • Enhancements for using FindBugs scripts with MKS on + Windows (thanks, Kelly O'Hair!)
      • +
      • Noted in the manual that jsr305.jar must be present + for annotations to compile
      • +
      • Added and fine-tuned default-nullness annotations
      • +
      • More CWE IDs added
      • +
      • Check and warning for unexpected BCEL version in + classpath
      • +
      +
    • +
    • Fixes: +
        +
      • Bug fix to handling of local variable tables in BCEL
      • +
      • Refined documentation for + MTIA_SUSPECT_STRUTS_INSTANCE_FIELD
      • +
      • [ 1927295 ] NPE when called on project root
      • +
      • [ 1926405 ] Incorrect dead store warning
      • +
      • [ 1926409 ] Incorrect redundant nullcheck warning
      • +
      • [ 1926389 ] Wrong line number printed/highlighted in + bug
      • +
      • [ 1927040 ] typo in bug description
      • +
      • [ 1926263 ] Minor glitch in HTML output
      • +
      • [ 1926240 ] Minor error in standard options in manual
      • +
      • [ 1926236 ] Minor bug in installation section of + manual
      • +
      • [ 1925539 ] ZIP is default file system code base
      • +
      • [ 1894701 ] Livelock / memory leak in + ObjectTypeFactory (thanks, Andrei!)
      • +
      • [ 1867491 ] Doesn't reload annotations after code + changes in IDE (thanks, Andrei!)
      • +
      • [ 1921399 ] -project option not supported
      • +
      • [ 1913834 ] "Dead" store to variable with method call
      • +
      • [ 1917352 ] H B se:...field in serializable class
      • +
      • [ 1911617 ] CloneIdiom relies on + getNameConstantOperand for INSTANCEOF
      • +
      • [ 1911620 ] False +: DLS predecrement before return
      • +
      • [ 1871376 ] False negative: non-serializable Map field
      • +
      • [ 1871051 ] non standard clone() method
      • +
      • [ 1908854 ] Error in TestASM
      • +
      • [ 1907539 ] 22 minor errors in bug checker + documentation
      • +
      • [ 1897323 ] EJB implementation class false positives
      • +
      • [ 1899648 ] Crash on startup on Vista with Java + 1.6.0_04
      • +
      +
    • +
    +
  • +
  • FindBugs Eclipse plugin (change log by Andrey Loskutov) +
      +
    • new feature: export basic FindBugs numbers for projects + via File->Export->Java->BugCounts (Andrey Loskutov)
    • +
    • new feature: jobs for different projects will be run in + parallel per default if running on a multi-core PC + ("fb.allowParallelBuild" system property not used anymore) + (Andrey Loskutov)
    • +
    • fixed performance slowdown in the multi-threaded build, + caused by workspace operation locks during assigning marker + attributes (Andrey Loskutov)
    • +
    +
  • +
+ +

Changes since version 1.3.1

+ +
    +
  • FindBugs base +
      +
    • New Bug Category: +
        +
      • SECURITY (Abbrev: S), A use of untrusted input in a + way that could create a remotely exploitable security + vulnerability
      • +
      +
    • +
    • New Detectors: +
        +
      • CrossSiteScripting: This detector looks for + obvious/blatant cases of cross site scripting vulnerabilities
      • +
      +
    • +
    • New BugCode: +
        +
      • XSS: Cross site scripting
      • +
      +
    • +
    • New Reports: +
        +
      • XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER: HTTP + parameter directly written to Servlet output, giving XSS + vulnerability
      • +
      • XSS_REQUEST_PARAMETER_TO_JSP_WRITER: HTTP parameter + directly written to JSP output, giving XSS vulnerability
      • +
      • EQ_OTHER_USE_OBJECT: equals() method defined that + doesn't override Object.equals(Object)
      • +
      • EQ_OTHER_NO_OBJECT: equals() method inherits rather + than overrides equals(Object)
      • +
      • NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE: Possible + null pointer dereference on path that might be infeasible
      • +
      +
    • +
    • Other: +
        +
      • Added -noClassOk command-line parameter to + command-line and ant interfaces; when -noClassOk is specified + and no classfiles are given, FindBugs will print a warning + message and output a well- formed file with no warnings
      • +
      • Fewer false positives for null pointer bugs
      • +
      • Suppress dead-local-store false positives in .jsp code
      • +
      • Type fixes in warning messages
      • +
      • Better warning message for NP_NULL_ON_SOME_PATH
      • +
      • "WMI" bug code description renamed from "Wrong Map + Iterator" to "Inefficient Map Iterator"
      • +
      +
    • +
    • Fixes: +
        +
      • [ 1893048 ] FindBugs confused by a findbugs.xml file
      • +
      • [ 1878528 ] XSL xforms don't support history features
      • +
      • [ 1876584 ] two default.xsl flaws
      • +
      • [ 1874856 ] Format string bug detector doesn't handle + special operators
      • +
      • [ 1872645 ] computeBugHistory - + java.lang.IllegalArgumentException
      • +
      • [ 1872237 ] Ant task fails when no .class files
      • +
      • [ 1868670 ] Filters: include AND exclude don't allowed
      • +
      • [ 1868666 ] check-for-oddness reported, but array + length can never be negative
      • +
      • [ 1866108 ] SetBugDatabaseInfoTask strips dir from + output filename
      • +
      • [ 1866021 ] MineBugHistoryTask strips dir of output + filename
      • +
      • [ 1865265 ] code doesn't handle + StringBuffer.append([CII) right
      • +
      • [ 1864793 ] Warning when casting a null reference + compared to a String
      • +
      • [ 1863376 ] Typo in manual chap 8: Filter Files
      • +
      • [ 1862705 ] Transient fields that default to null
      • +
      • [ 1842545 ] DLS on catch variable (with priority + tweaking)
      • +
      • [ 1816258 ] false positive BC_IMPOSSIBLE_CAST
      • +
      • [ 1551732 ] Get erroneous DLS with while loop
      • +
      +
    • +
    +
  • +
  • FindBugs Eclipse plugin (change log by Andrey Loskutov) +
      +
    • new feature: added Bug explorer view (replacing Bug tree + view), based on Common Navigator framework (Andrey Loskutov)
    • +
    • bug 1873860 fixed: empty projects are no longer shown in + Bug tree view (Andrey Loskutov)
    • +
    • new feature: bug counts decorators for projects, folders + and files (has to be activated via Preferences -> general + -> appearance -> label decorations)(Andrey Loskutov)
    • +
    • patch 1746499: better icons (Alessandro Nistico)
    • +
    • patch 1893685: Find bug actions on change sets bug + (Alessandro Nistico)
    • +
    • fixed bug 1855384: Bug configuration is broken in + Eclipse (Andrey Loskutov)
    • +
    • refactored FindBugs properties page (Andrey Loskutov)
    • +
    • refactored FindBugs worker/builder/run action (Andrey + Loskutov)
    • +
    • FB detects now only bugs from classes on project's + classpath (no double work on duplicated class files) (Andrey + Loskutov)
    • +
    • fixed bug introduced by the bad patch for 1867951: FB + cannot be executed incrementally on a folder of file (Andrey + Loskutov)
    • +
    • fixed job rule: now jobs for different projects may run + in parallel if running on a multi-core PC and + "fb.allowParallelBuild" system property is set to true (Andrey + Loskutov)
    • +
    • fixed FB auto-build not started if .fbprefs or + .classpath was changed (Andrey Loskutov)
    • +
    • fixed not reporting bugs on secondary types (classes + defined in java files with different name) (Andrey Loskutov)
    • +
    +
  • +
+ +

Changes since version 1.3.0

+
    +
  • New Reports +
      +
    • VA_FORMAT_STRING_ARG_MISMATCH: A format-string method + with a variable number of arguments is called, but the number of + arguments passed does not match with the number of % + placeholders in the format string. This is probably not what the + author intended. +
    • IO_APPENDING_TO_OBJECT_OUTPUT_STREAM: This code opens a + file in append mode and that wraps the result in an object + output stream. This won't allow you to append to an existing + object output stream stored in a file. If you want to be able to + append to an object output stream, you need to keep the object + output stream open. The only situation in which opening a file + in append mode and the writing an object output stream could + work is if on reading the file you plan to open it in random + access mode and seek to the byte offset where the append + started. +
    • NP_BOOLEAN_RETURN_NULL: A method that returns either + Boolean.TRUE, Boolean.FALSE or null is an accident waiting to + happen. This method can be invoked as though it returned a value + of type boolean, and the compiler will insert automatic unboxing + of the Boolean value. If a null value is returned, this will + result in a NullPointerException. +
    +
  • +
  • Changes to Existing Reports +
      +
    • RV_DONT_JUST_NULL_CHECK_READLINE: CORRECTNESS -> + STYLE
    • +
    • DMI_INVOKING_TOSTRING_ON_ARRAY: Long description + mentions array name whenever possible
    • +
    +
  • +
  • Fixes: +
      +
    • Updated manual to mention that Java 1.5 is now a + requirement for running FindBugs +
    • Applied patch 1840206 fixing issue "Ant task does not + work when presetdef is used" - thanks to phejl +
    • Applied patch 1778690 fixing issue "Ant task: tolerate + but complain about invalid auxClasspath" - thanks to David + Schmidt +
    • Applied patch 1852125 adding a Chinese-language GUI + bundle props file - thanks to fifi +
    • Applied patch 1845903 adding ability to load XML results + with the Eclipse plugin - thanks to Alex Mont +
    • Fixed issue 1844671 - "FP for "reversed" null check in + catch for stream close" +
    • Fixed issue 1836050 - "-onlyAnalyze broken" +
    • Fixed issue 1853011 - "Typo: Field names should start + with aN lower case letter" +
    • Fixed issue 1844181 - "JNLP file does not contain all + necessary JARs" +
    • Fixed issue 1840245 - "xxxException class does not + derive from Exception" +
    • Fixed issue 1840277 - "[M D EC] Typo in bug + documentation" +
    • Fixed issue 1782447 - "OutOfMemoryError if i activate + Findbugs on my project" +
    • Fixed issue 1830576 - "[regression] keySet/entrySet + false positive" +
    +
  • +
  • Other: +
      +
    • New bug code: "IO" (for + IO_APPENDING_TO_OBJECT_OUTPUT_STREAM)
    • +
    • Added "-onlyMostRecent" option for computeBugHistory + script/ant task +
    • More explicit language in + RV_RETURN_VALUE_IGNORED_BAD_PRACTICE messages +
    • Modified ResourceValueAnalysis to correctly identify + null == X or null != X as a null check (for issue 1844671) +
    • Modified DMI_HARDCODED_ABSOLUTE_FILENAME logic in + DumbMethodInvocations to ignore files from /etc or /dev and + increase priority of files from /home +
    • Better bug details for infinite loop warnings +
    • Modified unread-fields detector to reduce false + positives from reflective fields +
    • build.xml "classes" target now builds all sources in one + step +
    +
  • +
+ +

Changes since version 1.2.1

+
    +
  • New Detectors and Reports +
      +
    • SynchronizationOnSharedBuiltinConstant +
        +
      • DL_SYNCHRONIZATION_ON_SHARED_CONSTANT: The code + synchronizes on a shared primitive constant, such as an + interned String. Such constants are interned and shared across + all other classes loaded by the JVM. Thus, this could be + locking on something that other code might also be locking. + This could result in very strange and hard to diagnose + blocking and deadlock behavior. See http://www.javalobby.org/java/forums/t96352.html + and http://jira.codehaus.org/browse/JETTY-352. + +
      +
    • +
    • OverridingEqualsNotSymmetrical +
        +
      • EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC: Looks for equals + methods that override equals methods in a superclass where the + equivalence relationship might not be symmetrical. +
      +
    • +
    • CheckTypeQualifiers +
        +
      • TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED: A value + specified as carrying a type qualifier annotation is consumed + in a location or locations requiring that the value not carry + that annotation. More precisely, a value annotated with a type + qualifier specifying when=ALWAYS is guaranteed to reach a use + or uses where the same type qualifier specifies when=NEVER.
      • +
      • TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED: A value + specified as not carrying a type qualifier annotation is + guaranteed to be consumed in a location or locations requiring + that the value does carry that annotation. More precisely, a + value annotated with a type qualifier specifying when=NEVER is + guaranteed to reach a use or uses where the same type + qualifier specifies when=ALWAYS.
      • +
      • TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK: A value + that might not carry a type qualifier annotation reaches a use + which requires that annotation.
      • +
      • TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK: A value + which might carry a type qualifier annotation reaches a use + which forbids values carrying that annotation.
      • +
      +
    • +
    +
  • +
  • New Reports (existing detectors) +
      +
    • FindHEmismatch +
        +
      • EQ_DOESNT_OVERRIDE_EQUALS: This class extends a class + that defines an equals method and adds fields, but doesn't + define an equals method itself. Thus, equality on instances of + this class will ignore the identity of the subclass and the + added fields. Be sure this is what is intended, and that you + don't need to override the equals method. Even if you don't + need to override the equals method, consider overriding it + anyway to document the fact that the equals method for the + subclass just return the result of invoking super.equals(o).
      • +
      +
    • +
    • Naming +
        +
      • NM_WRONG_PACKAGE, NM_WRONG_PACKAGE_INTENTIONAL: The + method in the subclass doesn't override a similar method in a + superclass because the type of a parameter doesn't exactly + match the type of the corresponding parameter in the + superclass.
      • +
      • NM_SAME_SIMPLE_NAME_AS_SUPERCLASS: This class has a + simple name that is identical to that of its superclass, + except that its superclass is in a different package (e.g., alpha.Foo + extends beta.Foo). This can be exceptionally + confusing, create lots of situations in which you have to look + at import statements to resolve references and creates many + opportunities to accidently define methods that do not + override methods in their superclasses. +
      • +
      • NM_SAME_SIMPLE_NAME_AS_INTERFACE: This class/interface + has a simple name that is identical to that of an + implemented/extended interface, except that the interface is + in a different package (e.g., alpha.Foo extends beta.Foo). + This can be exceptionally confusing, create lots of situations + in which you have to look at import statements to resolve + references and creates many opportunities to accidently define + methods that do not override methods in their superclasses. +
      • +
      +
    • FindRefComparison +
        +
      • EC_UNRELATED_TYPES_USING_POINTER_EQUALITY: This method + uses using pointer equality to compare two references that + seem to be of different types. The result of this comparison + will always be false at runtime.
      • +
      +
    • +
    • IncompatMask +
        +
      • BIT_SIGNED_CHECK, BIT_SIGNED_CHECK_HIGH_BIT: This + method compares an expression such as ((event.detail + & SWT.SELECTED) > 0). Using bit arithmetic and then + comparing with the greater than operator can lead to + unexpected results (of course depending on the value of + SWT.SELECTED). If SWT.SELECTED is a negative number, this is a + candidate for a bug. Even when SWT.SELECTED is not negative, + it seems good practice to use '!= 0' instead of '> 0'. +
      • +
      +
    • +
    • LazyInit +
        +
      • LI_LAZY_INIT_UPDATE_STATIC: This method contains an + unsynchronized lazy initialization of a static field. After + the field is set, the object stored into that location is + further accessed. The setting of the field is visible to other + threads as soon as it is set. If the further accesses in the + method that set the field serve to initialize the object, then + you have a very serious multithreading bug, unless + something else prevents any other thread from accessing the + stored object until it is fully initialized. +
      • +
      +
    • +
    • FindDeadLocalStores +
        +
      • DLS_DEAD_STORE_OF_CLASS_LITERAL: This instruction + assigns a class literal to a variable and then never uses it. + The + behavior of this differs in Java 1.4 and in Java 5. In Java + 1.4 and earlier, a reference to Foo.class would + force the static initializer for Foo to be + executed, if it has not been executed already. In Java 5 and + later, it does not. See Sun's article + on Java SE compatibility for more details and examples, and + suggestions on how to force class initialization in Java 5. +
      • +
      +
    • +
    • MethodReturnCheck +
        +
      • RV_RETURN_VALUE_IGNORED_BAD_PRACTICE: This method + returns a value that is not checked. The return value should + be checked since it can indication an unusual or unexpected + function execution. For example, the File.delete() + method returns false if the file could not be successfully + deleted (rather than throwing an Exception). If you don't + check the result, you won't notice if the method invocation + signals unexpected behavior by returning an atypical return + value. +
      • +
      • RV_EXCEPTION_NOT_THROWN: This code creates an + exception (or error) object, but doesn't do anything with it. +
      • +
      +
    • +
    +
  • +
  • Changes to Existing Reports +
      +
    • NS_NON_SHORT_CIRCUIT: BAD_PRACTICE -> STYLE
    • +
    • NS_DANGEROUS_NON_SHORT_CIRCUIT: CORRECTNESS -> STYLE
    • +
    • RC_REF_COMPARISON: CORRECTNESS -> BAD_PRACTICE
    • +
    +
  • +
  • GUI Changes +
      +
    • Added importing and exporting of bug filters
    • +
    • Better handling of failed analysis runs
    • +
    • Added "-look" parameter for selecting look-and-feel
    • +
    • Fixed incorrect package filtering
    • +
    • Fixed issue where "synchronized" was not + syntax-highlighted
    • +
    +
  • +
  • Ant-task Changes +
      +
    • Refactored common ant-task code to AbstractFindBugsTask
    • +
    • Added tasks for computeBugHistory, convertXmlToText, + filterBugs, mineBugHistory, setBugDatabaseInfo
    • +
    +
  • +
  • Manual +
      +
    • Updates to GUI section, including new screenshots
    • +
    • Added description of rejarForAnalysis
    • +
    • Revamp of data-mining section
    • +
    +
  • +
  • Other Major +
      +
    • Internal restructuring for lower memory overhead
    • +
    +
  • +
  • Other Minor +
      +
    • Fixed typo: was STCAL_STATIC_SIMPLE_DATA_FORMAT_INSTANCE + now STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE
    • +
    • -outputFile parameter became -output
    • +
    • More sensitivity and specificity inLazyInit detector
    • +
    • More sensitivity and specificity in Naming detector
    • +
    • More sensitivity and specificity in UnreadFields + detector
    • +
    • More sensitivity in FindNullDeref detector
    • +
    • More sensitivity in FindBadCast2 detector
    • +
    • More specificity in FindReturnRef detector
    • +
    • Many other tweaks and bug fixes
    • +
    +
  • +
+ +

Changes since version 1.2.0

+
    +
  • Bug fixes: +
      +
    • Fix + bug + with detectors that were requested to be disabled but were + enabled due to requirements of other detectors.
    • +
    • Fix bugs in incremental analysis within Eclipse plugin
    • +
    • Fix some analysis errors
    • +
    • Fix some threading bugs in GUI2
    • +
    • Report version as version when it was compiled, not when + it was run
    • +
    • Copy analysis time stamp when filtering or transforming + analysis files.
    • +
    +
  • Enabled StaticCalendarDetector
  • +
  • Reworked GUI2 to use standard FindBugs filters +
      +
    • Allow a suppression filter to be stored in a project and + persisted to the XML representation of a project.
    • +
    +
  • + +
  • Move away from old GUI2 save format (a directory + containing an xml file and another file containing serialized + filters).
  • +
  • Support/recommend use of two new file extensions/formats: +
    +
    .fba - FindBugs Analysis File
    +
    Exactly the same as an existing bug collection file + stored in XML format, but using a distinct file extension to + make it easier to figure out which xml files contain FindBugs + results.
    +
    .fbp - FindBugs Project File
    +
    Contains just the information needed to run FindBugs and + display the results (e.g., the files to be analyzed, the + auxiliary class path and the location of source files) +
    +
  • +
+

Changes since version 1.1.3

+
    +
  • Added -xml:withAbridgedMessages option to generate xml + containing shorter messages. The messages will be shorted by doing + things like eliding package names, and leaving off the source line + from the LongMessage. These messages are appropriate if being used + in a context where the non-message components of the bug + annotations will be used to provide more information (e.g., + clicking on the message for a MethodAnnotation will display the + source for the method). +
      +
    • FindBugsDisplayFeatures.setAbridgedMessages(true) can be + used to generate abridged messages when FindBugs is being + accessed directly (not via generated XML) from a GUI or IDE.
    • +
    +
  • In null pointer analysis, try to be better about always + showing two locations: where it is known null and where it is + dereferenced. +
  • Interprocedural analysis of which methods return nonnull + values +
  • Use method calls to select order in which classes are + analyzed, and order in which methods are analyzed, to improve + interprocedural analysis results. +
  • Significant improvements in memory footprint, memory + allocation and CPU utilization (20-30% reduction in all three) +
  • Added a project name, to provide better descriptions in + the HTML output. +
  • Added new bug pattern: Casting to char, or bit masking + with nonnegative value, and then checking to see if the result is + negative. +
  • Stopped reporting transient fields of classes not marked + as serializable. Transient is used by other persistence + frameworks. +
  • Improvements to detector for SQL injection (Thanks to Matt Hargett for his + contributions +
  • Changed open/save options in GUI2 to not distinguish + between FindBugs projects and saved FindBugs analysis results. +
  • Improvements to detection of serious non-short-circuit + evaluation. +
  • Updated Japanese localization (thanks to Ruimo Uno) +
  • Eclipse plugin changes: +
      +
    • Created Bug User Annotations and Bug Tree Views +
    • Use different icons for different bug priorities +
    • Provide more information in Bug Details view +
    +
+ +

Changes since version 1.1.2:

+
    +
  • Fixed broken Ant task +
  • Added running ant task to smoke test +
  • Added validating xml and html output to smoke test +
  • Fixed some (but not all) issues with html output + validation +
  • Added check for x.equals(x) and x.compareTo(x) +
  • Various bug fixes +
+

Changes since version 1.1.1:

+
    +
  • Added check for infinite iterative loops
  • +
  • Added check for use of incompatible types in a collection + (e.g., checking to see if a Set<String> contains a + StringBuffer).
  • +
  • Added check for invocations of equals or hashCode on a + URL, which, surprising + many people, requires DNS resolution. +
  • +
  • Added check for classes that define compareTo but not + equals; such classes can exhibit some anomalous behavior (e.g., + they are treated differently by PriorityQueues in Java 5 and Java + 6).
  • +
  • Added a check for useless self operations (e.g., x < x + or x ^ x).
  • +
  • Fixed a data race that could cause the GUI to fail on + startup
  • +
  • Partial internationalization of the new GUI
  • +
  • Fix bug in "Redo analysis" option of new GUI
  • +
  • Tuning to reduce false positives
  • +
  • Fixed a bug in null pointer analysis that was generating + false positive null pointer warnings on exception paths. Fixing + this bug eliminates about 1/4 of the warnings on null pointer + exceptions on exception paths.
  • +
  • Fixed a bug in the processing of phi nodes for fields in + the null pointer analysis
  • +
  • Applied contributed patch that provides more quick fixes + in Eclipse plugin.
  • +
  • Fixed a number of bugs in the Eclipse auto update sites, + and in the way date qualifiers were being used in the Eclipse + plugin. You may need to manually disable your existing version of + the plugin and download the 1.1.2 from the update site to get the + automatic update function working correctly. The Eclipse update + sites are described at http://findbugs.cs.umd.edu/eclipse/. + +
  • +
  • Fixed progress bar in Eclipse plugin
  • +
  • A number of other bug fixes.
  • +
+ +

Changes since version 1.1.0:

+
    +
  • less scanning of classes not on the analysis path (This + was causing some performance problems.)
  • +
  • no unread field warnings for fields annotated with + javax.persistent or javax.ejb3
  • +
  • Eclipse plugin +
      +
    • bug annotation info displayed in Bug Details tab
    • +
    • .fbwarnings data file now stored in .metadata (not in + the project itself)
    • +
    +
  • +
  • new SE_BAD_FIELD_INNER_CLASS pattern
  • +
  • updates to Japanese translation (ruimo)
  • +
  • fix some internal slashed/dotted path confusion
  • +
  • other minor improvements
  • +
+ +

Changes since version 1.0.0:

+ +
    +
  • Overall, the change from FindBugs 1.0.0 to FindBugs 1.1.0 + has been a big change. We've done a lot of work in a lot of areas, + and aren't even going to try to enumerate all the changes.
  • +
  • We spent a lot of time reviewing the results generated by + FindBugs for open source and commercial code bases, and made a + number of changes, small and large, to minimize the number of + false positives. Our primary focus for this was warnings reported + as high and medium priority correctness warnings. Our internal + evaluation is that we produce very few high/medium priority + correctness warnings where the analysis is actually wrong, and + that more than 75% of the high/medium priority correctness + warnings correspond to real coding defects that need addressing in + the source code. The remaining 25% are largely cases such as a + branch or statement that if taken would lead to an error, but in + fact is a dead branch or statement that can never be taken. Such + coding is confusing and hard to maintain, so it should arguably be + fixed, but it is unlikely to actually result in an error during + execution. Thus, some might classify those warnings as false + positives.
  • +
  • We've substantially improved the analysis for errors that + could result in null pointer dereferences. Overall, our experience + has been that these changes have roughly doubled the number of + null pointer errors we detect, without increasing the number of + false positives (in fact, our false positive rate has gone down). + The improvements are due to four factors: +
      +
    • By default, we now do some interprocedural analysis to + determine methods that unconditionally dereference their + parameters.
    • +
    • FindBugs also comes with a model of which JDK methods + unconditionally dereference their parameters.
    • +
    • We do limited tracking of fields, so that we can detect + null values stored in fields that lead to exceptions.
    • +
    • We implemented a new analysis technique to find + guaranteed dereferences. Consider the following example:
      public int f(Object x, boolean b) {
      +  int result = 0;
      +  if (x == null) result++;
      +  else result--;
      +  // at this point, we know x is null on a simple path
      +  if (b) {
      +    // at this point, x is only null on a complex path
      +    // we don't know if the path in which x is null and b is true is feasible
      +    return result + x.hashCode();
      +    }
      +  else {
      +    // at this point, x is only null on a complex path
      +    // we don't know if the path in which x is null and b is false is feasible
      +    return result - x.hashCode();
      +    }
      +
      + +

      + FindBugs 1.0 used forward dataflow analysis to determine + whether each value is definitely null, null on a simple path, + possible null on a complex path, or definitely nonnull. Thus, + at the statement where + result + is decremented, we know that + x + is definitely null, and at the point before + if (b) + , we know that + x + is null on a simple path. If + x + were to be dereferenced here, we would generate a warning, + because if the else branch of the + if (x == null) + were ever taken, a null pointer exception would result. +

      + +

      + However, in both the then and else branches of the + if (b) + statement, + x + is only null on a complex path that may be infeasible. It might + be that the program logic is such that if + x + is null, then + b + is never true, so generating a warning about the dereference in + the then clause might be a false positive. We could try to + analyze the program to determine whether it is possible for + x + to be null and + b + to be true, but that can be a hard analysis problem. +

      + +

      + However, + x + is dereferenced in both the then and else branches of + the + if (b) + statement. So at the point immediately before + if (b) + , we know that + x + is null on a simple path and that + x + is guaranteed to be dereferenced on all paths from this point + forward. FindBugs 1.1 performs a backwards data flow analysis + to determine the values that are guaranteed to be dereferenced, + and will generate a warning in this case. +

      +
    • +
    +

    + The following screen shot of our new GUI shows an example of this + analysis, as well as showing off our new GUI and points out a + limitation of our current plugins for Eclipse and NetBeans. The + screen shot shows a null pointer bug in HelpDisplay.java. The + test for + href!=null + on line 78 suggests that + href + could be null. If it is, then + href + will be dereferenced on either line 87 or on line 90, generating + a NPE. Note that our analysis here also understands that passing + href + to + URLEncoder.encode + will deference it, and thus treats line 87 as a dereference, even + though + href + is not actually dereferenced at that line. Within our new GUI, + all of these locations are highlighted and listed in the summary + panel. In the original GUI (and in HTML output) we list all of + the locations, but only the primary location is highlighted by + the original GUI. In the Eclipse and NetBeans plugins, only the + primary location is displayed; fixing this is on our todo list + (contributions welcome). +

    +

    + + + +

    + +
  • +
  • Preliminary support for detectors using the frameworks + other than BCEL, such as the ASM + bytecode framework. You may experiment with writing ASM-based + detectors, but beware the API may still change (which could + possibly also affect BCEL-based detectors). In general, we've + started trying to move away from a deep dependence on BCEL, but + that change is only partially complete. Probably best to just + avoid this until we complete more work on this. This change is + only visible to FindBugs plugin developers, and shouldn't be + visible to FindBugs users. +
  • +
  • +

    Bug categories (CORRECTNESS, MT_CORRECTNESS, etc.) are no + longer hard-coded, but rather defined in xml files associated + with plugins, including the core plugin which defines the + standard categories. Third-party plugins can define their own + categories.

    +
  • +
  • +

    Several bug patterns have been moved from CORRECTNESS and + STYLE into a new category, BAD_PRACTICE. The English localization + of STYLE has changed from "Style" to "Dodgy."

    +

    In general, we've worked very hard to limit CORRECTNESS + bugs to be real programming errors and sins of commission. We + have reclassified as BAD_PRACTICE a number of bad design + practices that result in overly fragile code, such as defining an + equals method that doesn't accept null or defining class with a + equals method that inherits hashCode from class Object.

    +

    In general, our guidelines for deciding whether a bug + should be classified as CORRECTNESS, BAD_PRACTICE or STYLE are:

    +
    +
    CORRECTNESS
    +
    A problem that we can recognize with high confidence and + is an issue that we believe almost all developers would want to + examine and address. We recommend that software teams review all + high and medium priority warnings in their entire code base.
    +
    BAD_PRACTICE
    +
    A problem that we can recognize with high confidence and + represents a clear violation of recommended and standard coding + practice. We believe each software team should decide which bad + practices identified by FindBugs it wants to prohibit in the + team's coding standard, and take action to remedy violations of + those coding standards.
    +
    STYLE
    +
    These are places where something strange or dodgy is + going on, such as a dead store to a local variable. Typically, + less than half of these represent actionable programming + defects. Reviewing these warnings in any code under active + development is probably a good idea, but reviewing all such + warnings in your entire code base might be appropriate only in + some situations. Individual or team programming styles can + substantially influence the effectiveness of each of these + warnings (e.g., you might have a coding practice or style in + your group that confuses one of the detectors into generating a + lot of STYLE warnings); you will likely want to selectively + suppress or report the STYLE warnings that are effective for + your group.
    +
    +
  • +
  • Released a preliminary version of a new GUI (known + internally as GUI2 -- not very creative, huh?)
  • +
  • Provided standard ways to mark user designations of bug + warnings (e.g., as NOT_A_BUG or SHOULD_FIX). The internal logic + now records this, it is represented in the XML file, and GUI2 + allows the designations to be applied (along with free-form user + annotations about each warning). The user designations and + annotations are not yet supported by the Eclipse plugin, but we + clearly want to support it in Eclipse shortly.
  • +
  • Added a check for a bad comparison with a signed byte with + a value not in the range -128..127. For example:
    boolean find200(byte b[]) {
    +  for(int i = 0; i < b.length; i++) if (b[i] == 200) return i;
    +  return -1;
    +}
    +
    +
  • +
  • Added a checking for testing if a value is equal to + Double.NaN (no value is equal to NaN, not even NaN).
  • +
  • Added a check for using a class with an equals method but + no hashCode method in a hashed data structure.
  • +
  • Added check for uncallable method of an anonymous inner + class. For example, in the following code, it is impossible to + invoke the initalValue method (because the name is misspelled and + as a result is doesn't override a method in ThreadLocal).
    private static ThreadLocal serialNum = new ThreadLocal() {
    +         protected synchronized Object initalValue() {
    +             return new Integer(nextSerialNum++);
    +         }
    +     };
    +
    +
  • +
  • Added check for a dead local store caused by a switch + statement fall through
  • +
  • Added check for computing the absolute value of a random + 32 bit integer or of a hashcode. This is broken because + Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE , and thus + result of calling Math.abs, which is expected to be nonnegative, + will in fact be negative one time out of 2 32 , which + will invariably be the time your boss is demoing the software to + your customers. + +
  • +
  • More careful resolution of inherited methods and fields. + Some of the shortcuts we were taking in FindBugs 1.0.0 were + leading to inaccurate results, and it was fairly easy to address + this by making the analysis more accurate.
  • +
  • Overall, analysis times are about 1.6 times longer in + FindBugs 1.1.0 than in FindBugs 1.0.0. This is because we have + enabled substantial additional analysis at the default effort + level (the actual analysis engine is significantly faster than in + FindBugs 1.0). On a recent AMD Athlon processor, analyzing + JDK1.6.0 (about 1 million lines of code) requires about 15 minutes + of wall clock time.
  • +
  • Provided class and script (printClass) to print classfile + in the human readable format produced by BCEL
  • +
  • Provided -findSource option to setBugDatabaseInfo
  • +
+ + +

Changes since version 0.9.7:

+ +
    +
  • fix ObjectTypeFactory bug that was suppressing some bugs
  • +
  • opcode stack may determine definite zeros on some paths
  • +
  • opcode stack can track some constant string concatenations + (dbrosius)
  • +
  • default effort performs iterative opcode analysis (but min + effort does not)
  • +
  • default heap size upped to 384m
  • +
  • schema for XML output available: bugcollection.xsd
  • +
  • fixed some internal confusion between dotted and slashed + class names
  • +
  • New detectors +
      +
    • CheckImmutableAnnotation.java: checks JCIP annotations
    • +
    +
  • +
  • Updated detectors +
      +
    • BadRegEx.java: understands Pattern.LITERAL, warns about + "."
    • +
    • FindUnreleasedLock.java: fewer false positives
    • +
    • DumbMethods.java: check for vacuous comparisons to + MAX_INTEGER or MIN_INTEGER, fix bugs detecting + DM_NEXTINT_VIA_NEXTDOUBLE
    • +
    • FindPuzzlers.java: detect n%2==1, detect + toString() on array types +
    • +
    • FindInconsistentSync2.java: detects IS_FIELD_NOT_GUARDED +
    • +
    • MethodReturnCheck.java: add check for discarded newly + constructed values, increase priority of some ignored + constructed exceptions, better handling of bytecode compiled by + Eclipse
    • +
    • FindEmptySynchronizedBlock.java: better handling of + bytecode compiled by Eclipse
    • +
    • DoInsideDoPrivileged.java: warn if call to setAccessible + isn't in doPriviledged, don't report private methods
    • +
    • LoadOfKnownNullValue.java: fix bug that was reporting + false positives on finally blocks +
    • +
    • CheckReturnAnnotationDatabase.java: better checks for + unstarted threads
    • +
    • ConfusionBetweenInheritedAndOuterMethod.java: fewer + false positives, fixed a package-handling bug
    • +
    • BadResultSetAccess.java: separate bug pattern for + PreparedStatements, BRZA category folded into + SQL category +
    • +
    • FindDeadLocalStores.java, FindBadCast2.java, + DumbMethods.java, RuntimeExceptionCapture.java: coalesce similar + bugs within a method into a single bug instance with multiple + source lines
    • +
    +
  • +
  • Eclipse plugin +
      +
    • plugin ID changed from de.tobject.findbugs to edu.umd.cs.findbugs.plugin.eclipse +
    • +
    • support for findbugs eclipse auto-update site
    • +
    +
  • +
  • Updated test case files +
      +
    • BadRegEx.java
    • +
    • JSR166.java
    • +
    • ConcurrentModificationBug.java
    • +
    • DeadStore.java
    • +
    • InstanceOf.java
    • +
    • LoadKnownNull.java
    • +
    • NeedsToCheckReturnValue.java
    • +
    • BadResultSetAccessTest.java
    • +
    • DeadStore.java
    • +
    • TestNonNull2.java
    • +
    • TestImmutable.java
    • +
    • TestGuardedBy.java
    • +
    • BadRandomInt.java
    • +
    • six test cases added to new TigerTraps + directory +
    • +
    +
  • +
  • fix bug that was generating duplicate uids
  • +
  • fix bug with -onlyAnalyze some.package.* on + jdk1.4 +
  • +
  • fix regression bug in + DismantleByteCode.getRefConstantOperand()
  • +
  • fix some minor bugs with the Swing GUI
  • +
  • reordered some bugInstances so that source line + annotations come last
  • +
  • removed references to unused java system properties
  • +
  • French translation updates (David Cotton)
  • +
  • Japanese translation updates (Hanai Shisei)
  • +
  • content cleanup for findbugs.xml and messages.xml
  • +
  • references to cvs hostname updated to + findbugs.cvs.sourceforge.net
  • +
  • documented xdoc output options, new + mineBugHistory/computeBugHistory options
  • +
+ +

Changes since version 0.9.6:

+ +
    +
  • performance improvements
  • +
  • ObjectType instances are cached to reduce memory footprint +
  • +
  • for performance and memory reasons stateless detectors are + no longer cloned, must clear their own state between .class files +
  • +
  • fixed bug in bytecode-set lookup for methods (was causing + bad results for IS2, perhaps others)
  • +
  • fix some OpcodeStack bugs with integer and long + operations, perform iterative analysis when effort is max +
  • +
  • HTML output includes LongMessage text again (regression in + 0.95 - 0.96)
  • +
  • New detectors +
      +
    • CalledMethods.java: builds a list of invoked methods for + other detectors to consult (non-reporting)
    • +
    • UncallableMethodOfAnonymousClass.java: detect anonymous + inner classes that define methods that are probably intended to + but do not override methods in a superclass.
    • +
    +
  • +
  • Updated detectors +
      +
    • FindFieldSelfAssignment.java: recognize separate fields + with the same name (one from superclass)
    • +
    • FindLocalSelfAssignment2.java: handles backward branches + better (Dave Brosius)
    • +
    • FindBadCast2.java: BC_NULL_INSTANCEOF changed to + NP_NULL_INSTANCEOF
    • +
    • FindPuzzlers.java: eliminate false positive on setDate() + (Dave Brosius)
    • +
    +
  • +
  • Eclipse plugin +
      +
    • fix serious threading bug
    • +
    • preferences for Filters and effort (Peter Hendriks)
    • +
    • French localization (David Cotton)
    • +
    • fix bug when reporting inner classes (Peter Friese)
    • +
    +
  • +
  • Updated test case files +
      +
    • Mwn.java (Carl Burke/Dave Brosius)
    • +
    • DumbMethodInvocations.java (Anto paul/Dave Brosius)
    • + +
    +
  • +
  • XML output includes garbage collection duration
  • +
  • French messages updated (David Cotton)
  • +
  • Swing GUI shows file name after Load Bugs command
  • +
  • Ant task to launch the findbugs frame (Mark McKay)
  • +
  • miscellaneous code cleanup
  • +
+ +

Changes since version 0.9.5:

+ +
    +
  • Updated detectors +
      +
    • FindNullDeref.java: respect NonNull and CheckForNull + field annotations
    • +
    • SerializableIdiom.java: detect non-private readObject + and writeObject methods
    • +
    • FindRefComparison.java: smarter array comparison + detection
    • +
    • IsNullValueAnalysis.java: detect null + instanceof +
    • +
    • FindLocalSelfAssignment2.java: suppress some false + positives (Dave Brosius)
    • +
    • FindUnreleasedLock.java: don't waste time processing + classes that don't refer to java.util.concurrent.locks
    • +
    • MutableStaticFields.java: report the source line (Dave + Brosius)
    • +
    • SwitchFallthrough.java: better handling of System.exit() + (Dave Brosius)
    • +
    • MultithreadedInstanceAccess.java: better handling of + Servlet.init() (Dave Brosius)
    • +
    • ConfusionBetweenInheritedAndOuterMethod.java: now + enabled
    • +
    +
  • +
  • Eclipse plugin +
      +
    • background processing (Peter Friese)
    • +
    • internationalization, Japanese localization (Takashi + Okamoto)
    • +
    +
  • +
  • findbugs -onlyAnalyze option now works on windows + platforms +
  • +
  • mineBugHistory -noTabs option for better + alignment of output columns +
  • +
  • filterBugs -fixed option (also: will now + recognize the most recent version string) +
  • +
  • XML output includes running time and memory usage data
  • +
  • miscellaneous minor corrections to the manual
  • +
  • better bytecode analysis of the iinc instruction +
  • +
  • fix bug in null pointer analysis
  • +
  • improved catch block heuristics
  • +
  • some type analysis tweaks
  • +
  • Bug priority changes +
      +
    • DumbMethodInvocations.java: decrease priority of + hard-coded /tmp filenames +
    • +
    • ComparatorIdiom.java: decrease priority of + non-serializable anonymous comparators
    • +
    • FindSqlInjection.java: decrease priority of appending a + constant or a static
    • +
    +
  • +
  • Updated bug explanations +
      +
    • NM_VERY_CONFUSING (Dave Brosius)
    • +
    +
  • +
  • Updated test case files +
      +
    • BadStoreOfNonSerializableObject.java
    • +
    • BadRandomInt.java
    • +
    • TestFieldAnnotations.java
    • +
    • UseInitCause.java
    • +
    • SqlInjection.java
    • +
    • ArrayEquality.java
    • +
    • BadIntegerOperations.java
    • +
    • Pilhuhn.java
    • +
    • InstanceOf.java
    • +
    • SwitchFallthrough.java (Dave Brosius)
    • +
    +
  • +
  • fix URL decoding bug when running under Java Web Start + (Dave Brosius)
  • +
  • distribution includes project.xml file for + NetBeans +
  • +
+ +

Changes since version 0.9.4:

+
    +
  • New detectors +
      +
    • VarArgsProblems.java
    • +
    • FindSqlInjection.java: now enabled
    • +
    • ComparatorIdiom.java: comparators usually implement + serializable
    • +
    • Naming.java: detect methods not overridden due to + eponymously typed args from different packages
    • +
    +
  • +
  • Updated detectors +
      +
    • SwitchFallthrough.java: surpress some false positives
    • +
    • DuplicateBranches.java: surpress some false positives
    • +
    • IteratorIdioms.java: surpress some false positives
    • +
    • FindHEmismatch.java: surpress some false positives
    • +
    • QuestionableBooleanAssignment.java: finds more cases of + if (b=true) ilk +
    • +
    • DumbMethods.java: detect int remainder by 1, delayed gc + errors
    • +
    • SerializableIdiom.java: detect store of nonserializable + object into field of serializable class
    • +
    • FindNullDeref.java: fix potential exception
    • +
    • IsNullValue.java: fix potential exception
    • +
    • MultithreadedInstanceAccess.java: fix potential + exception
    • +
    • PreferZeroLengthArrays.java: flag the method, not the + line
    • +
    +
  • +
  • Remove some inadvertent dependencies on JDK 1.5
  • +
  • Sort order should be more consistent
  • +
  • XML output changes +
      +
    • Option to sort XML bug output
    • +
    • Now contains instance IDs
    • +
    • uid no longer missing (was causing problems with fancy + HTML output)
    • +
    • Typo fixed
    • +
    +
  • +
  • Internal changes to track source files, -sourceInfo + option +
  • +
  • Bug matching: first try exact bug pattern matching, option + to compare priorities, option to disable package moves
  • +
  • Architecture documentation in design/architecture +
  • +
  • Test cases move into their own CVS project
  • +
  • Don't report warnings that occur outside the analyzed + classes
  • +
  • Fixes to the build.xml files
  • +
  • Better handling of @CheckReturnValue and @CheckForNull + annotations (also, some additional methods searched for check + return value and check for null)
  • +
  • Fixed some stream-closing bugs (one by z-fb-user/Dave + Brosius) +
  • +
  • Bug priority changes +
      +
    • increase priority of ignoring return value of + java.sql.Connection methods
    • +
    • increase priority of comparing classes like Integer + using == +
    • +
    • decrease priority of IT_NO_SUCH_ELEMENT if we see any + call to next() +
    • +
    • tweak priority of NM_METHOD_CONSTRUCTOR_CONFUSION
    • +
    • decrease priority of RV_RETURN_VALUE_IGNORED for an + inherited annotation that doesn't return same type as class
    • +
    +
  • +
  • Updated bug explanations +
      +
    • RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE
    • +
    • DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED
    • +
    • IMA_INEFFICIENT_MEMBER_ACCESS (Dave Brosius)
    • +
    • some Japanese improvements to messages_ja.xml ( ruimo) +
    • +
    • some German improvements to findbugs_de.properties (Dave + Brosius, dvholten) +
    • +
    +
  • +
  • Updated test case files +
      +
    • BadIntegerOperations.java
    • +
    • SecondKaboom.java
    • +
    • OpenDatabase.java (Dave Brosius)
    • +
    • FindOpenStream.java (Dave Brosius)
    • +
    • BadRandomInt.java
    • +
    +
  • +
  • Source-lines info maintained for methods (handy for + abstract and native methods)
  • +
  • Remove surrounding opcodes from source line annotations
  • +
  • Better error when can't read file
  • +
  • Swing GUI: removed console pane from FindBugsFrame, fix + missing classes bug
  • +
  • Fixes to OpcodeStack.java
  • +
  • Detectors may attach a custom value to an OpcodeStack.Item + (Dave Brosius)
  • +
  • Filter.java: ability to add text messages to XML output, + fix bug with -withMessages +
  • +
  • SourceInfoMap supports ranges of source lines
  • +
  • Ant task supports the timestampNow attribute +
  • +
+ +

Changes since version 0.9.3:

+
    +
  • Substantial rework of datamining code
  • +
  • Removed bogus warnings about await on things other than + Condition not being in a loop
  • +
  • Fixed bug in OpcodeStack handling of dup2 of long/double + values
  • +
  • Don't report array types as missing classes
  • +
  • Adjustment of some warnings on ignored return values
  • +
  • Added thread safety annotations from Java Concurrency in + Practice (no detectors written for these yet)
  • +
  • Added annotation for methods that, if overridden, should + be invoked by overriding methods via a call to super
  • +
  • Updated -html:fancy.xsl (Etienne Giraudy)
  • +
+ +

Note: there was no version 0.9.2

+ +

Changes since version 0.9.1:

+
    + +
  • Embellish USM to find abstract methods that implement an + interface method (Dave Brosius)
  • +
  • New detector to find stores of literal booleans inside if + or while expressions (Dave Brosius)
  • +
  • New style detector to find final classes that declare + protected fields (Dave Brosius)
  • +
  • New detector to find subclass methods that simply forward, + verbatim, to the super class (Dave Brosius)
  • +
  • Detector to find instances where code is attempting to + write an object out via an implementation of DataOutput, but the + object is not guaranteed to be Serializable (Jon Christiansen, + Bill Pugh)
  • + + +
  • Large (35%) analysis speedup (Bill Pugh)
  • +
  • Add line numbers to Swing GUI code panel (Dave Brosius)
  • +
  • Added effort options to Swing GUI (Dave Brosius)
  • +
  • Add ability to specify bugs file to open from command line + for GUI version, through -loadbugs (Phillip Martin)
  • +
  • New stylesheet for generating HTML: use option -html:plain.xsl + (Chris Nappin) +
  • +
  • New stylesheet for generating HTML: use option -html:fancy.xsl + (Etienne Giraudy) +
  • +
  • Updated Japanese bug message translations (Shisei Hanai)
  • + + +
  • XHTML compliance fixes for bug details (Etienne Giraudy)
  • +
  • Various detector fixes (Shisei Hanai)
  • +
  • Fixed bugs in the project preferences dialog int the + Eclipse plugin (Takashi Okamoto, Thomas Einwaller)
  • +
  • Lowered priority of analysis thread in Swing GUI (David + Hovemeyer, suggested by Shisei Hanai and Jeffrey W. Badorek)
  • +
  • Fixed EclipsePlugin to correctly pick up auxclasspath + entries (Jon Christiansen)
  • +
+ +

Changes since version 0.9.0:

+
    +
  • Fixed dependence on JRE 1.5: all features should work on + JRE 1.4 again
  • +
  • Fixed -effort command line option handling for Swing GUI
  • +
  • Fixed conserveSpace and workHard attributes int Ant task
  • +
  • Added support for effort attribute in Ant task
  • +
+ +

Changes since version 0.8.8:

+
    + +
  • XMLFactoryBypass detector to find direct allocation of xml + class implementations (Dave Brosius)
  • +
  • InefficientMemberAccess detector to find accesses to + owning class private members (Dave Brosius)
  • +
  • DuplicateBranches detector checks switch statements too + (Dave Brosius)
  • + + +
  • FindBugs available from findbugs.sourceforge.net as Java + Web Start application (Dave Brosius)
  • +
  • Updated Japanese bug message translations (Shisei Hanai)
  • +
  • Improved bug detail message for covariant equals() (Shisei + Hanai)
  • +
  • Modeling of instanceof checks is now enabled by default, + making the bad cast detector much more useful (Bill Pugh, David + Hovemeyer)
  • +
  • Support for detector ordering constraints in plugin + descriptor (David Hovemeyer)
  • +
  • Simpler option to control analysis effort: -effort: value, + where value is one of min , + default , or max (David Hovemeyer) +
  • +
  • Using -effort:max, FindNullDeref checks for null arguments + passed to methods which dereference them unconditionally (David + Hovemeyer)
  • +
  • FindNullDeref checks @Null and @NonNull annotations for + parameters and return values (David Hovemeyer)
  • + + +
+ +

Changes since version 0.8.7:

+ +
    + +
  • New detector to find duplicate code in if/else statements + (Dave Brosius)
  • +
  • Look for calls to wait() on Condition objects (David + Hovemeyer)
  • +
  • Look for java.util.concurrent.Lock objects not released on + every path out of method (David Hovemeyer)
  • +
  • Look for calls to Thread.sleep() with a lock held (David + Hovemeyer)
  • +
  • More accurate detection of impossible casts (Bill Pugh, + David Hovemeyer)
  • + + +
  • Saved XML now contains project statistics (Jay Dunning)
  • +
  • Filter files can select by bug pattern type and warning + priority (David Hovemeyer)
  • + + +
  • Restored some files inadvertently omitted from previous + release (Rohan Lloyd, David Hovemeyer)
  • +
  • Make sure detectors requiring JDK 1.5 runtime classes are + only executed if those classes are available (David Hovemeyer)
  • +
  • Don't display analysis error dialog unless there is really + an error (David Hovemeyer)
  • +
  • Updated and expanded French translations of bug patterns + and Swing GUI (Olivier Parent)
  • +
  • Fixed invalid character encoding in German Swing GUI + translation (Olivier Parent)
  • +
  • Fix locale used for date format in project stats (K. + Hashimoto)
  • +
  • Fixed LongDescription elements in xml:withMessages output + format (K. Hashimoto)
  • +
+ +

Changes since version 0.8.6:

+ +
    + +
  • Extend Naming detector to look for classes that are named + XXXException but that are not Exceptions (Dave Brosius)
  • +
  • New detector to find classes that expose semaphores in the + public implementation through the 'this' reference. (Dave Brosius) +
  • +
  • New Style detector to find Struts Action/Servlet derived + classes that reference instance member variable not in + synchronized blocks. (Dave Brosius)
  • +
  • New Style detector to find classes that declare + implementation of interfaces that are already implemented by super + classes (Dave Brosius)
  • +
  • New Style detector to find circular dependencies between + classes (Dave Brosius)
  • +
  • New Style detector to find unnecessary math on constants + (Dave Brosius)
  • +
  • New detector to find equality comparisons using floating + point math (Jay Dunning)
  • +
  • New faster detector to find local self assignments (Bill + Pugh)
  • +
  • New detector to find infinite recursive loops (Bill Pugh) +
  • +
  • New detector to find for loops with an incorrect increment + (Bill Pugh)
  • +
  • New detector to find suspicious uses of + BufferedReader.readLine() and String.indexOf() (Bill Pugh)
  • +
  • New detector to find suspicious integer to double casts + (David Hovemeyer, Bill Pugh)
  • +
  • New detector to find invalid regular expression patterns + (Bill Pugh)
  • +
  • New detector to find Bloch/Gafter Java puzzlers (Bill + Pugh)
  • + + +
  • New system property to suppress reporting of DLS based on + local variable name (Glenn Boysko)
  • +
  • Enhancements to configuration dialog in Eclipse plugin, + allow for saving enabled detectors in Eclipse projects (Phil + Crosby)
  • +
  • Sortable columns in detector dialog (Dave Brosius)
  • +
  • New tab in gui for showing bugs grouped by category (Dave + Brosius)
  • +
  • Improved German translation of Swing GUI (Thomas Kuehne)
  • +
  • Improved source file reporting in Emacs output format (Len + Trigg)
  • +
  • Improvements to redundant null comparison detector (Bill + Pugh)
  • +
  • Localization of run analysis and analysis error dialogs in + Swing GUI (K. Hashimoto)
  • + + +
  • Don't scan equals methods in FindHEMismatch if code is + native (Greg Bentz)
  • +
  • French translation fixes (David Cotton)
  • +
  • Internationalization report fixes (K. Hashimoto)
  • +
  • Japanese translations updates (SHISEI Hanai)
  • +
+ +

Changes since version 0.8.5:

+
    + +
  • New detector to find catch blocks that may inadvertently + catch runtime exceptions (Brian Goetz)
  • +
  • New detector to find objects that are instantiated based + on classes that only have static methods and fields, using the + synthesized constructor (Dave Brosius)
  • +
  • New detector to find calls to Thread.interrupted() in a + non static context, and especially with non currentThread() + threads (Dave Brosius)
  • +
  • New detector to find calls to equals() methods that use + Object's version. (Dave Brosius)
  • +
  • New detector to find Applets that call methods in the + constructor refering to the AppletStub (Dave Brosius)
  • +
  • New detector to find some cases of infinite recursion + (Bill Pugh)
  • +
  • New detector to find dead stores to local variables (David + Hovemeyer, Bill Pugh)
  • +
  • Extend Dumb Method detector for toUpperCase(), + toLowerCase() without a locale, new Integer(1).toString(), new + XXX().getClass(), and new Thread() without a run implementation + (Dave Brosius) +
  • +
  • Ant task supports "errorProperty" attribute, which sets an + Ant property to "true" if an error occurs running FindBugs + (Michael Tamm)
  • +
  • Eclipse plugin allows filtering of warnings by bug + category, priority (David Hovemeyer)
  • +
  • Swing GUI allows filtering of warnings by bug category + (David Hovemeyer)
  • +
  • Ability to annotate methods using Java 1.5 annotations + that suppress FindBugs warnings (Bill Pugh)
  • +
  • New -adjustExperimental for lowering priority of + BugPatterns that are experimental (Dave Brosius)
  • +
  • Allow for command line options 'files' using the @ symbol + (David Hovemeyer)
  • +
  • New -adjustPriority command line option to for adjusting + bug priorites (David Hovemeyer)
  • +
  • Added an Edit menu (cut/copy/paste) to Swing GUI (Dave + Brosius)
  • +
  • French translation supplied (David Cotton) +
  • +
+ +

Changes since version 0.8.4:

+
    + +
  • New detector for volatile references to arrays (Bill Pugh) +
  • +
  • New detector to find instanceof usage where inheritance + can be determined statically (Dave Brosius)
  • +
  • New detector to find ResultSet.getXXX updateXXX calls + using index 0 (Dave Brosius)
  • +
  • New detector to find empty zip or jar entries (Bill Pugh) + + +
  • +
  • HTML output generation using built-in XSLT stylesheet or + user-defined stylesheet (David Hovemeyer)
  • +
  • Allow URLs to be specified to analyze zip/jar files, local + directories, and single classfiles (David Hovemeyer)
  • +
  • New command line option -onlyAnalyze restricts analysis to + selected classes and packages without reducing accuracy (David + Hovemeyer)
  • +
  • Allow Swing GUI to show source code in jar files on + Windows systems (Dave Brosius) +
  • +
  • Fix the Switch Fall Thru detector (Dave Brosius, David + Hovemeyer, Bill Pugh)
  • +
  • MacOS GUI fixes (Rohan Lloyd)
  • +
  • Fix false positive in BOA in case where method is + correctly and 'incorrectly' overridden (Dave Brosius)
  • +
  • Fixed memory blowup when analyzing methods which access a + large number of fields (David Hovemeyer)
  • +
+ +

Changes since version 0.8.3:

+
    +
  • Initial and preliminary localization of the Swing + GUI.  Translations by: +
      +
    • German - Peter D. Stout, Holger Stenzhorn
    • +
    • Finnish - Juha Knuutila
    • +
    • Estonian - Tanel Lebedev
    • +
    • Japanese - Hanai Shisei
    • +
    +
  • +
  • Eliminated debug print statements inadvertently left + enabled
  • +
  • Reverted some changes in the open stream detector: this + should fix some false positives that were introduced in the + previous release
  • +
  • Fixed a couple missing class reports
  • +
+ +

Changes since version 0.8.2:

+
    + + +
  • New detector to find improperly overridden GUI Adapter + classes (Dave Brosius)
  • +
  • New detector to find improperly setup JUnit TestCases + (Dave Brosius)
  • +
  • New detector to find variables that mask class level + fields (Dave Brosius)
  • +
  • New detector to find comparisons of values computed with + bitwise operators that always yield the same result (Tom Truscott) +
  • +
  • New detector to find unsafe getClass().getResource() calls + (Bill Pugh)
  • +
  • New detector to find GUI changes not in GUI thread but in + static main (Bill Pugh)
  • +
  • New detector to find calls to Collection.toArray() with + zero-length array argument; it is more efficient to pass an array + the size of the collection, which can be populated and returned as + the result (Dave Brosius) +
  • +
  • Better suppression of false warnings in various detectors + (Bill Pugh, David Hovemeyer)
  • +
  • Enhancement to ReadReturnShouldBeChecked detector for + skip() (Dave Brosius)
  • +
  • Enhancement to DumbMethods detector (Dave Brosius)
  • +
  • Open stream detector does not report wrappers of streams + passed as method parameters (David Hovemeyer) +
  • +
  • Cancel confirmation dialog in Swing GUI (Pete Angstadt)
  • +
  • Better relative path saving in Project file (Dave Brosius) +
  • +
  • Detector Priority in GUI is now saved in prefs file (Dave + Brosius)
  • +
  • Controls in GUI to reorder source and classpath entries, + and ability to flip between Project details and bugs pages (Dave + Brosius)
  • +
  • In Swing GUI, analysis error dialog supports "Select All" + and "Copy" operations for easy generation of error reports (Dave + Brosius)
  • +
  • Complete translation of bug descriptions and messages into + Japanese (Hanai Shisei) +
  • +
  • Fixed bug in DroppedException detector (Dave Brosius) +
  • +
  • The source distribution defaults to using JDK 1.5 javac to + compile, but support for compiling with JSR-14 prototype is still + supported
  • +
+ +

Changes since version 0.8.1:

+
    +
  • Fixed a critical ClassCastException bug (triggered if the + -workHard option was used, and an exception type was merged with + an array type during type inference)
  • +
+ +

Changes since version 0.8.0:

+
    +
  • Disabled SwitchFallthrough detector to work around + NullPointerExceptions
  • +
  • Added some additional false positive suppression + heuristics
  • +
+ +

Also, two contributors to the 0.8.0 release were + inadvertently left out of the credits:

+
    +
  • Pete Angstadt fixed several problems in the Swing GUI
  • +
  • Francis Lalonde provided a task resource file for the + FindBugs Ant task
  • +
+ +

Changes since version 0.7.4:

+
    +
  • New detector to look for uses of "+" operator to + concatenate String objects in a loop (Dave Brosius)
  • +
  • Reference comparison detector looks for places where the + argument passed to the equals(Object) method isn't the same type + as the receiver object
  • +
  • Better suppression of false warnings in many detectors
  • +
  • Many improvements to Eclipse plugin (Andrey Loskutov, + Peter Friese)
  • +
  • Fixed problem with building Eclipse plugin on Windows + (Thomas Klaeger)
  • +
  • Open stream detector looks for unclosed PreparedStatement + objects (Thomas Klaeger, Rohan Lloyd)
  • +
  • Fix for open stream detector: it wasn't detecting close() + methods called through an invokeinterface instruction (Thomas + Klaeger)
  • +
  • Refactoring of visitor classes to enforce use of accessors + for visited class features (Brian Goetz)
  • +
+ +

Changes since version 0.7.3:

+
    +
  • Experimental modification of open stream detector to look + for non-escaping JDBC resources (connections and statements) that + aren't closed on all paths out of method
  • +
  • Eclipse plugin fixed so it compiles and runs on Eclipse + 2.1.x (Peter Friese)
  • +
  • Option to Swing GUI and command line to generate project + file using relative paths for archives, source directories, and + aux classpath entries (Dave Brosius)
  • +
  • Improvements to findbugs.bat script for launching FindBugs + on Windows (Dave Brosius)
  • +
  • Updated Japanese message translations (Hiroshi Okugawa)
  • +
  • Uncalled private methods are now reported as low priority, + unless they have the same name as another method in the class + (which is more likely to indicate an actual bug)
  • +
  • Added some missing data in the bug messages XML files
  • +
  • Fixed some problems building from source on Windows + systems
  • +
  • Various minor bug fixes
  • +
+ +

Changes since version 0.7.2:

+
    +
  • Enhanced Eclipse plugin, which displays the detailed bug + description in a view (Phil Crosby)
  • +
  • Various tweaks to existing detectors to reduce false + warnings
  • +
  • New command line option -workHard enables + pruning of infeasible or unlikely exception edges, which results + in better accuracy in the open stream detector, at the expense of + a 30%-100% slowdown +
  • +
  • New website and HTML documentation design
  • +
  • Documentation includes an HTML document with descriptions + of all bug patterns reported by FindBugs
  • +
  • Web page has a link to a Japanese + translation of the FindBugs manual, contributed by Hiroshi + Okugawa +
  • +
  • Changed the Inconsistent Synchronization detector so that + fields synchronized 50% of the time (or more) are reported as + medium priority bugs (previously they were reported as low)
  • +
  • New detector to find code that catches + IllegalMonitorStateException
  • +
  • New detector to find private methods that are never called +
  • +
  • New detector to find suspicious uses of + non-short-circuiting boolean operators ( & and + | , rather than && and + || ) +
  • +
+ +

Changes since version 0.7.1:

+
    +
  • Incorporated patched version of BCEL, which allows classes + compiled with JDK 1.5.0 beta to be analyzed
  • +
  • Fixed some bugs related to lookups of array classes
  • +
  • Fixed bug that prevented GUI from loading XML result files + when running under JDK 1.5.0 beta
  • +
  • Added new experimental bug detector, LazyInit, which looks + for potentially buggy lazy initializations of static fields
  • +
  • Because of long filenames, switched to distributing the + source archive as a zip file rather than a tar file
  • +
  • The 0.7.1 source tarfile was botched - 0.7.2 has a valid + source archive
  • +
  • Fixed some problems in the Ant build script
  • +
  • Fixed NullPointerException when checking Class-Path + attribute for Jar files without manifests
  • +
  • Generate version numbers for the core and UI Eclipse + plugins using the Version class; all version numbers are now in a + common location
  • +
+ +

Changes since version 0.7.0:

+
    +
  • Eclipse plugin (contributed by Peter Friese)
  • +
  • Source package structure rearranged: all source (other + than Eclipse plugin UI) is in the edu.umd.cs.findbugs package, or + a subpackage
  • +
  • Class-Path attributes of manifests of analyzed jar files + are used to set the aux classpath automatically (Peter D. Stout)
  • +
  • GUI starts in directory specified by user.home property + (Peter D. Stout)
  • +
  • Added -project option to GUI (Mikko T.)
  • +
  • Added -look:{plastic,gtk,native} option to GUI, for + setting look and feel (Mikko T.)
  • +
  • Fixed DataflowAnalysisException in inconsistent + synchronization detector
  • +
  • Ant task supports failOnError parameter (Rohan Lloyd)
  • +
  • Serializable class warnings are downgraded to low priority + for GUI classes
  • +
  • MWN detector will only report calls to wait(), notify(), + and notifyAll() methods that have the correct signature
  • +
  • FindBugs works with latest CVS version of BCEL
  • +
  • Zip and Jar files may be added to the source path
  • +
  • The GUI will automatically find source files residing in + analyzed Zip or Jar files
  • +
+ +

Note that the version number jumped from 0.6.6 to 0.6.9; + there were no 0.6.7 or 0.6.8 releases.

+

Changes since version 0.6.9:

+
    +
  • Added -conserveSpace option to reduce memory use at the + expense of analysis precision
  • +
  • Bug fixes in findbugs.bat script: JAVA_HOME handling, + autodetection of FINDBUGS_HOME, missing output with -textui
  • +
  • Fixed NullPointerException when a missing class is + encountered
  • +
+ +

Changes since version 0.6.6:

+
    +
  • The null pointer dereference detector is more powerful
  • +
  • Significantly improved heuristics and bug fixes in + inconsistent synchronization detector
  • +
  • Improved heuristics in open stream and dropped exception + detectors; fewer false positives should be reported
  • +
  • Save HTML summary in XML results files, rather than + recomputing; this makes loading results in GUI much faster
  • +
  • Report at most one String comparison using == or != per + method
  • +
  • The findbugs.bat script on Windows autodetects + FINDBUGS_HOME, and doesn't open a DOS window when launching the + GUI (contributed by TJSB)
  • +
  • Emacs reporting format (contributed by David Li)
  • +
  • Various bug fixes
  • +
+ +

Changes since 0.6.5:

+
    +
  • Rewritten inconsistent synchronization detector; accuracy + is significantly improved, and bug reports are prioritized
  • +
  • New detector to find self assignment (x=x) of local + variables (suggested by Jeff Martin)
  • +
  • New detector to find calls to wait(), notify(), and + notifyAll() on an object which is not obviously locked
  • +
  • Open stream detector now reports Readers and Writers
  • +
  • Fixed bug in finalizer idioms detector which caused + spurious warnings about failure to call super.finalize() (reported + by Jim Menard)
  • +
  • Fixed bug where output stream was not closed using non-XML + output (reported by Sigiswald Madou)
  • +
  • Fixed corrupted HTML bug detail message (reported by + Trevor Harmon)
  • +
+ +

Changes since version 0.6.4:

+
    +
  • For redundant comparison of reference values, fixed false + positives resulting from duplication of code in finally blocks
  • +
  • Fixed false positives resulting from wrapped byte array + streams left open
  • +
  • Fixed bug in Ant task preventing output file from working + properly if a relative path was used
  • +
+ +

Changes since version 0.6.3:

+
    +
  • Fixed bug in Ant task where output would be corrupted, and + added a timeout attribute +
  • +
  • Added -outputFile option to text UI, for explicitly + specifying an output file
  • +
  • GUI has a summary window, for statistics about overall bug + densities (contributed by Mike Fagan)
  • +
  • Find redundant comparisons of reference values
  • +
  • More accurate detection of Strings compared with == and != + operators
  • +
  • Detection of other reference types which should generally + not be compared with == and != operators; Boolean, Integer, etc.
  • +
  • Find non-transient non-serializable instance fields in + Serializable classes
  • +
  • Source code may be compiled with latest early access + generics-enabled javac (version 2.2)
  • +
+ +

Changes since version 0.6.2:

+
    +
  • GUI supports filtering bugs by priority
  • +
  • Ant task rewritten; supports all functionality offered by + Text UI (contributed by Mike Fagan)
  • +
  • Ant task is fully documented in the manual
  • +
  • Classes in nested archives are analyzed; this allows full + support for analyzing .ear and .war files (contributed by Mike + Fagan)
  • +
  • DepthFirstSearch changed to use non-recursive + implementation; this should fix the StackOverflowErrors that + several users reported
  • +
  • Various minor bugfixes and improvements
  • +
+ +

Changes since version 0.6.1:

+
    +
  • New detector to look for useless control flow (suggested + by Richard P. King and Mike Fagan)
  • +
  • Look for places where return value of + java.io.File.createNewFile() is ignored (suggested by Richard P. + King)
  • +
  • Fixed bug in resolution of source files (only the first + source directory was searched)
  • +
  • Fixed a NullPointerException in the bytecode pattern + matching code
  • +
  • Ant task supports project files (contributed by Mike + Fagan)
  • +
  • Unix findbugs script honors the JAVA_HOME + environment variable (contributed by Pedro Morais) +
  • +
  • Allow .war and .ear files to be analyzed
  • +
+ +

Changes since version 0.6.0:

+
    +
  • New bug pattern detector which looks for places where a + null pointer might be dereferenced
  • +
  • New bug pattern detector which looks for IO streams that + are opened, do not escape the method, and are not closed on all + paths out of the method
  • +
  • New bug pattern detector to find methods that can return + null instead of a zero-length array
  • +
  • New bug pattern detector to find places where the == or != + operators are used to compare String objects
  • +
  • Command line interface can save bugs as XML
  • +
  • GUI can save bugs to and load bugs from XML
  • +
  • An "Annotations" window in the GUI allows the user to add + textual annotations to bug reports; these annotations are + preserved when bugs are saved as XML
  • +
  • In this release, the Japanese bug summary translations by + Germano Leichsenring are really included (they were inadvertently + omitted in the previous release)
  • +
  • Completely rewrote the control flow graph builder, + hopefully for the last time
  • +
  • Simplified implementation of control flow graphs, which + should reduce memory use and possibly improve performance
  • +
  • Improvements to command line interface (list bug + priorities, filter by priority, specify aux classpath, specify + project to analyze)
  • +
  • Various bug fixes and enhancements
  • +
+ +

Changes since version 0.5.4

+
    +
  • Added an Ant task for + FindBugs, contributed by Mike Fagan. +
  • +
  • Added a GUI dialog which allows individual bug pattern + detectors to be enabled or disabled.  Disabling certain slow + detectors can greatly speed up analysis of large programs, at the + expense of reducing the number of potential bugs found.
  • +
  • Added a new detector for finding improperly ignored return + values for methods such as String.trim() .  + Suggested by Andreas Mandel. +
  • +
  • Japanese translations of the bug summaries, contributed by + Germano Leichsenring.
  • +
  • Filtering of results is supported in command line + interface. See the FindBugs manual + for details. +
  • +
  • Added "byte code patterns", a general pattern matching + infrastructure for bytecode instructions.  This feature + significantly reduces the complexity of implementing new bug + pattern detectors.
  • +
  • Enabled a new general dataflow analysis to track values in + methods.
  • +
  • Switched to new control-flow graph builder implementation. +
  • +
+ +

Changes since version 0.5.3

+
    +
  • Fixed a bug in the script used to launch FindBugs on + Windows platforms.
  • +
  • Fixed crashes when analyzing class files without source + line information.
  • +
  • All major errors are reported using an error dialog; file + not found errors are more informative.
  • +
  • Minor GUI improvements.
  • +
+ +

Changes since version 0.5.2

+
    +
  • All of the source code and related files are in a single + directory tree.
  • +
  • Updated some of the detectors to produce source line + information.
  • +
  • Ant build script and + several GUI enhancements and fixes contributed by Mike Fagan.
  • +
  • Converted to use a plugin + architecture for loading bug detectors. +
  • +
  • Eliminated generics-related compiler warnings.
  • +
  • More complete documentation has been added.
  • +
+ +

Changes since version 0.5.1:

+
    +
  • Fixed a large number of bugs in the BCEL Repository and + FindBugs's use of the Repository.  With these changes, + FindBugs should never crash or otherwise misbehave + because of Repository lookup failures.  Because of these + changes, you must use a modified version of bcel.jar + with FindBugs.  This jar file is included in the FindBugs + 0.5.2 binary release.  A complete patch containing the modifications + against the BCEL CVS main branch as of April 30, 2003 is also + available. +
  • +
  • Implemented the "auxiliary classpath entry list".  + Aux classpath entries can be added to a project to provide classes + that are referenced by the analyzed application, but should not + themselves be analyzed.  Having all referenced classes + available allows FindBugs to produce more accurate results.
  • +
+ +

Changes since version 0.5.0:

+
    +
  • Many user interface bugs have been fixed.
  • +
  • Upgraded to a recent CVS version of BCEL, with some bug + fixes.  This should prevent FindBugs from crashing when there + is a failure to find a class on the classpath.
  • +
  • Added support for Plastic look and feel from jgoodies.com. +
  • +
  • Major overhaul of infrastructure for doing dataflow + analysis.
  • +
+

+ +

Send comments to findbugs@cs.umd.edu +

+SourceForge.net Logo + +

+ + + + diff --git a/doc/FAQ.html b/doc/FAQ.html new file mode 100644 index 0000000..d83b7ee --- /dev/null +++ b/doc/FAQ.html @@ -0,0 +1,261 @@ + + +FindBugs FAQ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FindBugs
 
Docs and Info
FindBugs 2.0
Demo and data
Users and supporters
FindBugs blog
Fact sheet
Manual
Manual(ja/日本語)
FAQ
Bug descriptions
Mailing lists
Documents and Publications
Links
 
Downloads
 
FindBugs Swag
 
Development
Open bugs
Reporting bugs
Contributing
Dev team
API [no frames]
Change log
SF project page
Browse source
Latest code changes
+
+

FindBugs FAQ

+ +

This document contains answers to frequently asked questions about +FindBugs.  If you just want general +information about FindBugs, have a look at the +fact sheet and the +manual. + +

Contents

+
    +
  1. I'm getting java.lang.UnsupportedClassVersionError when I try to run FindBugs +
  2. When I click the "Find Bugs!" button, I get a NoSuchMethodError or VerifyError +
  3. FindBugs is running out of memory, or is taking a long time to finish +
  4. What is the "auxiliary classpath"? Why should I specify it? +
  5. The Eclipse plugin doesn't load +
  6. I'm getting a lot of false "OS" and "ODR" warnings +
  7. The Eclipse plugin loads, but doesn't work correctly +
  8. Where is the Maven plugin for FindBugs? +
  9. Where is the NetBeans plugin for FindBugs? +
+ +

Q1: I'm getting java.lang.UnsupportedClassVersionError when I try to run FindBugs

+ +

FindBugs requires JRE 1.5.0 or later to run.  If you use an earlier version, +you will see an exception error message similar to the following: +

+Exception in thread "main" java.lang.UnsupportedClassVersionError:
+edu/umd/cs/findbugs/gui/FindBugsFrame (Unsupported major.minor version 48.0)
+
+The solution is to upgrade to JRE 1.5.0 or later. + +

Q2: When I click the "Find Bugs!" button, I get a NoSuchMethodError or VerifyError

+ +

The symptom of this bug is that when you start the FindBugs analysis, +you see an exception similar to the following: +

+java.lang.NoSuchMethodError: org.apache.bcel.Repository.setRepository(Lorg/apache/bcel/util/Repository;)V
+        at edu.umd.cs.findbugs.FindBugs.clearRepository(FindBugs.java:483)
+        ...
+
+ +or + +
+java.lang.VerifyError: Cannot inherit from final class
+    at java.lang.ClassLoader.defineClass0(Native Method)
+    at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
+    ...
+
+ +

The problem here is that the wrong version of the +Apache BCEL +library is being found.  FindBugs requires its own +version of BCEL, which normally will be used automatically +when you invoke the findbugs or findbugs.bat +scripts used to launch FindBugs.  If an old version of BCEL is installed +in a location, such as "lib/endorsed" in the JRE installation, +where it overrides classes on the application classpath, +FindBugs will not execute properly.  +We know of several reasons this could happen + +

    +
  • If you install the +Java(TM) Web Services +Developer Pack 1.2 +in the lib/endorsed directory of your Java Runtime Environment (JRE).  +The file xsltc.jar contains an old version of BCEL that is incompatible with +FindBugs.  + +
  • Another possibility is that you are using the IBM JDK.  +Some versions include a version of BCEL which conflicts with the +one required by FindBugs.  This problem is fixed in version 1.4.1 SP1, +so upgrading your JDK should allow FindBugs to run correctly. + +
  • Some versions of the Apache Xalan XSLT processor include +an old version of BCEL in xalan.jar. + +
+ +

In all of these cases, you should be able to run FindBugs +by either removing the offending version of BCEL from your JRE, +or installing a clean JRE or JDK and using that to run FindBugs. + +

Many thanks to Peter Meulmeester, Michael Levi, and Thomas Klaeger +for providing information on this problem. + +

Q3: FindBugs is running out of memory, or is taking a long time to finish

+ +

In general, FindBugs requires lots of memory and a relatively +fast CPU. For large applications, 512M or more of heap space may be +required. By default, FindBugs allocates 256M of heap space. +You can increase this using the -maxHeap n option, +where n is the number of megabytes of heap space to allocate. + + +

Q4: What is the "auxiliary classpath"? Why should I specify it?

+ +

Many important facts about a Java class require information about +the classes that it references.  For example: +

    +
  • What other classes and interfaces the class inherits from +
  • What exceptions can be thrown by methods in external classes +and interfaces +
+ +

The "auxiliary classpath" is a list of Jar files, directories, and +class files containing classes that are used by the code you +want FindBugs to analyze, but should not themselves be analyzed +by FindBugs. + +

If FindBugs doesn't have complete information about referenced classes, +it will not be able to produce results that are as accurate as possible.  +For example, having a complete repository of referenced classes allows +FindBugs to prune control flow information so it can concentrate on +paths through methods that are most likely to be feasible at runtime.  +Also, some bug detectors (such as the suspicious reference comparison detector) +rely on being able to perform type inference, which requires complete +type hierarchy information. + +

For these reasons, we strongly recommend that you completely specify +the auxiliary classpath when you run FindBugs.  You can do this +by using the -auxclasspath command line option, or the +"Classpath entries" list in the GUI project editor dialog. + +

If FindBugs cannot find a class referenced by your application, it +will print out a message when the analysis completes, specifying the +classes that were missing.  You should modify the auxiliary classpath +to specify how to find the missing classes, and then run FindBugs again. + +

Q5: The Eclipse plugin doesn't load

+ +

The symptom of this problem is that Eclipse fails to load +the FindBugs UI plugin with the message: +

+Plug-in "edu.umd.cs.findbugs.plugin.eclipse" was disabled due to missing or disabled +prerequisite plug-in "org.eclipse.ui.ide" +
+ +

The reason for this problem is that the Eclipse +plugin distributed with FindBugs +does not work with older 3.x versions of Eclipse. +Please use Eclipse version 3.6 (June 2010) or newer. + +

Q6: I'm getting a lot of false "OS" and "ODR" warnings

+ +

By default, FindBugs assumes that any method invocation can +throw an unchecked runtime exception.  As a result, +it may assume that an unchecked exception thrown out of the +method could bypass a call to a close() method +for a stream or database resource. + +

You can use the -workHard command line argument +or the findbugs.workHard boolean analysis property +to make FindBugs work harder to prune unlikely exception +edges.  This generally reduces the number of +false warnings, at the expense of slowing down the +analysis. + +

Q7: The Eclipse plugin loads, but doesn't work correctly

+ +

Make sure the Java code you trying to analyze is built properly and has no +classpath or compile errors. + +

Make sure the project and workspace FindBugs settings are valid - in doubt, revert them to defaults. + +

Make sure the Error log view does not show errors. + +

Q8: Where is the Maven plugin for FindBugs?

+ +

+The Maven Plugin for FindBugs +may be found here.  +Please note that the Maven plugin is not maintained by the FindBugs developers, +so we can't answer questions about it. +

+ +

Q9: Where is the NetBeans plugin for FindBugs?

+ +

We recommend SQE: Software Quality Environment +which bundles FindBugs, PMD and CheckStyle. Use the following +update site: +http://deadlock.netbeans.org/hudson/job/sqe/lastStableBuild/artifact/build/full-sqe-updatecenter/updates.xml +

Pease note that the SQE plugin is not maintained by the FindBugs developers, +so we can't answer questions about it. +

+ + +

+ +

Send comments to findbugs@cs.umd.edu +

+SourceForge.net Logo + +

+ + + + diff --git a/doc/FilterFile.txt b/doc/FilterFile.txt new file mode 100644 index 0000000..1fed032 --- /dev/null +++ b/doc/FilterFile.txt @@ -0,0 +1,125 @@ +============= +How it works: +============= + +A filter file is an XML file with a top-level "FindBugsFilter" element +which has some number of "Match" elements as children. Each Match +element represents a predicate which is applied to generated bug instances. +Usually, a filter will be used to exclude bug instances. For example: + + findbugs -textui -exclude myExcludeFilter.xml myApp.jar + +However, a filter could also be used to select bug instances to specifically +report: + + findbugs -textui -include myIncludeFilter.xml myApp.jar + +Match has "class" and "classregex" attributes specifying what class or classes +the predicate applies to. + +Match contains children, which are conjuncts of the predicate. +(I.e., each of the children must be true for the predicate to be true.) + +======================= +Types of Match clauses: +======================= + + specifies abbreviations of bugs. + The "name" attribute is a comma-seperated list of abbreviations. + + specifies a method. The "name" attribute is the name + of the method. The "params" attribute is a comma separated list + of the types of the method's parameters. The "returns" attribute is + the method's return type. In "params" and "returns", class names + must be fully qualified. (E.g., "java.lang.String" instead of just + "String".) Note that "params" and "returns" are optional; you can + just specify "name", and the clause will match all methods with + that name. However, if you specify either "params" or "returns", + you must specify both of them. + + combines Match clauses as disjuncts. I.e., you can put two + "Method" elements in an Or clause in order match either method. + +======== +Caveats: +======== + +Match clauses can only match information that is actually contained in the +bug instances. Every bug instance has a class, so in general, excluding +bugs by class will work. + +Some bug instances have two classes. For example, the DE (dropped exception) +bugs report both the class containing the method where the dropped exception +happens, and the class which represents the type of the dropped exception. +Only the FIRST (primary) class is matched against Match clauses. +So, for example, if you want to suppress IC (initialization circularity) +reports for classes "com.foobar.A" and "com.foobar.B", you would use +two Match clauses: + + + + + + + + + +Many kinds of bugs report what method they occur in. For those bug instances, +you can put Method clauses in the Match element and they should work +as expected. + +========= +Examples: +========= + + 1. Match all bug reports for a class. + + + + 2. Match certain tests from a class. + + + + + 3. Match certain tests from all classes. + + + + + + 4. Match bug types from specified methods of a class. + + + + + + + + + +================= +Complete Example: +================= + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/allBugDescriptions.html b/doc/allBugDescriptions.html new file mode 100644 index 0000000..a9e94e0 --- /dev/null +++ b/doc/allBugDescriptions.html @@ -0,0 +1,5500 @@ + +FindBugs Bug Descriptions (Unabridged) + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FindBugs
 
Docs and Info
FindBugs 2.0
Demo and data
Users and supporters
FindBugs blog
Fact sheet
Manual
Manual(ja/日本語)
FAQ
Bug descriptions
Mailing lists
Documents and Publications
Links
 
Downloads
 
FindBugs Swag
 
Development
Open bugs
Reporting bugs
Contributing
Dev team
API [no frames]
Change log
SF project page
Browse source
Latest code changes
+
+

FindBugs Bug Descriptions (Unabridged)

+

This document lists all of the bug patterns reported by the +latest development version of +FindBugs.  Note that this may include +bug patterns not available in any released version of FindBugs, +as well as bug patterns that are not enabled by default. +

Summary

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DescriptionCategory
AM: Creates an empty jar file entryBad practice
AM: Creates an empty zip file entryBad practice
BC: Equals method should not assume anything about the type of its argumentBad practice
BIT: Check for sign of bitwise operationBad practice
CN: Class implements Cloneable but does not define or use clone methodBad practice
CN: clone method does not call super.clone()Bad practice
CN: Class defines clone() but doesn't implement CloneableBad practice
Co: Abstract class defines covariant compareTo() methodBad practice
Co: Covariant compareTo() method definedBad practice
DE: Method might drop exceptionBad practice
DE: Method might ignore exceptionBad practice
DMI: Adding elements of an entry set may fail due to reuse of Entry objectsBad practice
DMI: Random object created and used only onceBad practice
DMI: Don't use removeAll to clear a collectionBad practice
Dm: Method invokes System.exit(...)Bad practice
Dm: Method invokes dangerous method runFinalizersOnExitBad practice
ES: Comparison of String parameter using == or !=Bad practice
ES: Comparison of String objects using == or !=Bad practice
Eq: Abstract class defines covariant equals() methodBad practice
Eq: Equals checks for incompatible operandBad practice
Eq: Class defines compareTo(...) and uses Object.equals()Bad practice
Eq: equals method fails for subtypesBad practice
Eq: Covariant equals() method definedBad practice
FI: Empty finalizer should be deletedBad practice
FI: Explicit invocation of finalizerBad practice
FI: Finalizer nulls fieldsBad practice
FI: Finalizer only nulls fieldsBad practice
FI: Finalizer does not call superclass finalizerBad practice
FI: Finalizer nullifies superclass finalizerBad practice
FI: Finalizer does nothing but call superclass finalizerBad practice
FS: Format string should use %n rather than \nBad practice
GC: Unchecked type in generic callBad practice
HE: Class defines equals() but not hashCode()Bad practice
HE: Class defines equals() and uses Object.hashCode()Bad practice
HE: Class defines hashCode() but not equals()Bad practice
HE: Class defines hashCode() and uses Object.equals()Bad practice
HE: Class inherits equals() and uses Object.hashCode()Bad practice
IC: Superclass uses subclass during initializationBad practice
IMSE: Dubious catching of IllegalMonitorStateExceptionBad practice
ISC: Needless instantiation of class that only supplies static methodsBad practice
It: Iterator next() method can't throw NoSuchElementExceptionBad practice
J2EE: Store of non serializable object into HttpSessionBad practice
JCIP: Fields of immutable classes should be finalBad practice
NP: Method with Boolean return type returns explicit nullBad practice
NP: Clone method may return nullBad practice
NP: equals() method does not check for null argumentBad practice
NP: toString method may return nullBad practice
Nm: Class names should start with an upper case letterBad practice
Nm: Class is not derived from an Exception, even though it is named as suchBad practice
Nm: Confusing method namesBad practice
Nm: Field names should start with a lower case letterBad practice
Nm: Use of identifier that is a keyword in later versions of JavaBad practice
Nm: Use of identifier that is a keyword in later versions of JavaBad practice
Nm: Method names should start with a lower case letterBad practice
Nm: Class names shouldn't shadow simple name of implemented interfaceBad practice
Nm: Class names shouldn't shadow simple name of superclassBad practice
Nm: Very confusing method names (but perhaps intentional)Bad practice
Nm: Method doesn't override method in superclass due to wrong package for parameterBad practice
ODR: Method may fail to close database resourceBad practice
ODR: Method may fail to close database resource on exceptionBad practice
OS: Method may fail to close streamBad practice
OS: Method may fail to close stream on exceptionBad practice
PZ: Don't reuse entry objects in iteratorsBad practice
RC: Suspicious reference comparison to constantBad practice
RC: Suspicious reference comparison of Boolean valuesBad practice
RR: Method ignores results of InputStream.read()Bad practice
RR: Method ignores results of InputStream.skip()Bad practice
RV: Negating the result of compareTo()/compare()Bad practice
RV: Method ignores exceptional return valueBad practice
SI: Static initializer creates instance before all static final fields assignedBad practice
SW: Certain swing methods needs to be invoked in Swing threadBad practice
Se: Non-transient non-serializable instance field in serializable classBad practice
Se: Non-serializable class has a serializable inner classBad practice
Se: Non-serializable value stored into instance field of a serializable classBad practice
Se: Comparator doesn't implement SerializableBad practice
Se: Serializable inner classBad practice
Se: serialVersionUID isn't finalBad practice
Se: serialVersionUID isn't longBad practice
Se: serialVersionUID isn't staticBad practice
Se: Class is Serializable but its superclass doesn't define a void constructorBad practice
Se: Class is Externalizable but doesn't define a void constructorBad practice
Se: The readResolve method must be declared with a return type of Object. Bad practice
Se: Transient field that isn't set by deserialization. Bad practice
SnVI: Class is Serializable, but doesn't define serialVersionUIDBad practice
UI: Usage of GetResource may be unsafe if class is extendedBad practice
BAC: Bad Applet Constructor relies on uninitialized AppletStubCorrectness
BC: Impossible castCorrectness
BC: Impossible downcastCorrectness
BC: Impossible downcast of toArray() resultCorrectness
BC: instanceof will always return falseCorrectness
BIT: Bitwise add of signed byte valueCorrectness
BIT: Incompatible bit masksCorrectness
BIT: Check to see if ((...) & 0) == 0Correctness
BIT: Incompatible bit masksCorrectness
BIT: Bitwise OR of signed byte valueCorrectness
BIT: Check for sign of bitwise operationCorrectness
BOA: Class overrides a method implemented in super class Adapter wronglyCorrectness
BSHIFT: 32 bit int shifted by an amount not in the range -31..31Correctness
Bx: Primitive value is unboxed and coerced for ternary operatorCorrectness
Co: compareTo()/compare() returns Integer.MIN_VALUECorrectness
DLS: Useless increment in return statementCorrectness
DLS: Dead store of class literalCorrectness
DLS: Overwritten incrementCorrectness
DMI: Reversed method argumentsCorrectness
DMI: Bad constant value for monthCorrectness
DMI: BigDecimal constructed from double that isn't represented preciselyCorrectness
DMI: hasNext method invokes nextCorrectness
DMI: Collections should not contain themselvesCorrectness
DMI: D'oh! A nonsensical method invocationCorrectness
DMI: Invocation of hashCode on an arrayCorrectness
DMI: Double.longBitsToDouble invoked on an intCorrectness
DMI: Vacuous call to collectionsCorrectness
Dm: Can't use reflection to check for presence of annotation without runtime retentionCorrectness
Dm: Futile attempt to change max pool size of ScheduledThreadPoolExecutorCorrectness
Dm: Creation of ScheduledThreadPoolExecutor with zero core threadsCorrectness
Dm: Useless/vacuous call to EasyMock methodCorrectness
EC: equals() used to compare array and nonarrayCorrectness
EC: Invocation of equals() on an array, which is equivalent to ==Correctness
EC: equals(...) used to compare incompatible arraysCorrectness
EC: Call to equals(null)Correctness
EC: Call to equals() comparing unrelated class and interfaceCorrectness
EC: Call to equals() comparing different interface typesCorrectness
EC: Call to equals() comparing different typesCorrectness
EC: Using pointer equality to compare different typesCorrectness
Eq: equals method always returns falseCorrectness
Eq: equals method always returns trueCorrectness
Eq: equals method compares class names rather than class objectsCorrectness
Eq: Covariant equals() method defined for enumCorrectness
Eq: equals() method defined that doesn't override equals(Object)Correctness
Eq: equals() method defined that doesn't override Object.equals(Object)Correctness
Eq: equals method overrides equals in superclass and may not be symmetricCorrectness
Eq: Covariant equals() method defined, Object.equals(Object) inheritedCorrectness
FB: Missing expected or desired warning from FindBugsCorrectness
FB: Unexpected/undesired warning from FindBugsCorrectness
FE: Doomed test for equality to NaNCorrectness
FL: Method performs math using floating point precisionCorrectness
FS: Format string placeholder incompatible with passed argumentCorrectness
FS: The type of a supplied argument doesn't match format specifierCorrectness
FS: MessageFormat supplied where printf style format expectedCorrectness
FS: More arguments are passed than are actually used in the format stringCorrectness
FS: Illegal format stringCorrectness
FS: Format string references missing argumentCorrectness
FS: No previous argument for format stringCorrectness
GC: No relationship between generic parameter and method argumentCorrectness
HE: Signature declares use of unhashable class in hashed constructCorrectness
HE: Use of class without a hashCode() method in a hashed data structureCorrectness
ICAST: int value converted to long and used as absolute timeCorrectness
ICAST: Integral value cast to double and then passed to Math.ceilCorrectness
ICAST: int value cast to float and then passed to Math.roundCorrectness
IJU: JUnit assertion in run method will not be noticed by JUnitCorrectness
IJU: TestCase declares a bad suite method Correctness
IJU: TestCase has no testsCorrectness
IJU: TestCase defines setUp that doesn't call super.setUp()Correctness
IJU: TestCase implements a non-static suite method Correctness
IJU: TestCase defines tearDown that doesn't call super.tearDown()Correctness
IL: A collection is added to itselfCorrectness
IL: An apparent infinite loopCorrectness
IL: An apparent infinite recursive loopCorrectness
IM: Integer multiply of result of integer remainderCorrectness
INT: Bad comparison of int value with long constantCorrectness
INT: Bad comparison of nonnegative value with negative constantCorrectness
INT: Bad comparison of signed byteCorrectness
IO: Doomed attempt to append to an object output streamCorrectness
IP: A parameter is dead upon entry to a method but overwrittenCorrectness
MF: Class defines field that masks a superclass fieldCorrectness
MF: Method defines a variable that obscures a fieldCorrectness
NP: Null pointer dereferenceCorrectness
NP: Null pointer dereference in method on exception pathCorrectness
NP: Method does not check for null argumentCorrectness
NP: close() invoked on a value that is always nullCorrectness
NP: Null value is guaranteed to be dereferencedCorrectness
NP: Value is null and guaranteed to be dereferenced on exception pathCorrectness
NP: Nonnull field is not initializedCorrectness
NP: Method call passes null to a nonnull parameter Correctness
NP: Method may return null, but is declared @NonNullCorrectness
NP: A known null value is checked to see if it is an instance of a typeCorrectness
NP: Possible null pointer dereferenceCorrectness
NP: Possible null pointer dereference in method on exception pathCorrectness
NP: Method call passes null for nonnull parameterCorrectness
NP: Method call passes null for nonnull parameterCorrectness
NP: Non-virtual method call passes null for nonnull parameterCorrectness
NP: Store of null value into field annotated NonNullCorrectness
NP: Read of unwritten fieldCorrectness
Nm: Class defines equal(Object); should it be equals(Object)?Correctness
Nm: Class defines hashcode(); should it be hashCode()?Correctness
Nm: Class defines tostring(); should it be toString()?Correctness
Nm: Apparent method/constructor confusionCorrectness
Nm: Very confusing method namesCorrectness
Nm: Method doesn't override method in superclass due to wrong package for parameterCorrectness
QBA: Method assigns boolean literal in boolean expressionCorrectness
RC: Suspicious reference comparisonCorrectness
RCN: Nullcheck of value previously dereferencedCorrectness
RE: Invalid syntax for regular expressionCorrectness
RE: File.separator used for regular expressionCorrectness
RE: "." or "|" used for regular expressionCorrectness
RV: Random value from 0 to 1 is coerced to the integer 0Correctness
RV: Bad attempt to compute absolute value of signed 32-bit hashcode Correctness
RV: Bad attempt to compute absolute value of signed random integerCorrectness
RV: Code checks for specific values returned by compareToCorrectness
RV: Exception created and dropped rather than thrownCorrectness
RV: Method ignores return valueCorrectness
RpC: Repeated conditional testsCorrectness
SA: Self assignment of fieldCorrectness
SA: Self comparison of field with itselfCorrectness
SA: Nonsensical self computation involving a field (e.g., x & x)Correctness
SA: Self assignment of local rather than assignment to fieldCorrectness
SA: Self comparison of value with itselfCorrectness
SA: Nonsensical self computation involving a variable (e.g., x & x)Correctness
SF: Dead store due to switch statement fall throughCorrectness
SF: Dead store due to switch statement fall through to throwCorrectness
SIC: Deadly embrace of non-static inner class and thread localCorrectness
SIO: Unnecessary type check done using instanceof operatorCorrectness
SQL: Method attempts to access a prepared statement parameter with index 0Correctness
SQL: Method attempts to access a result set field with index 0Correctness
STI: Unneeded use of currentThread() call, to call interrupted() Correctness
STI: Static Thread.interrupted() method invoked on thread instanceCorrectness
Se: Method must be private in order for serialization to workCorrectness
Se: The readResolve method must not be declared as a static method. Correctness
TQ: Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is requiredCorrectness
TQ: Comparing values with incompatible type qualifiersCorrectness
TQ: Value that might not carry a type qualifier is always used in a way requires that type qualifierCorrectness
TQ: Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifierCorrectness
TQ: Value annotated as never carrying a type qualifier used where value carrying that qualifier is requiredCorrectness
TQ: Value without a type qualifier used where a value is required to have that qualifierCorrectness
UMAC: Uncallable method defined in anonymous classCorrectness
UR: Uninitialized read of field in constructorCorrectness
UR: Uninitialized read of field method called from constructor of superclassCorrectness
USELESS_STRING: Invocation of toString on an unnamed arrayCorrectness
USELESS_STRING: Invocation of toString on an arrayCorrectness
USELESS_STRING: Array formatted in useless way using format stringCorrectness
UwF: Field only ever set to nullCorrectness
UwF: Unwritten fieldCorrectness
VA: Primitive array passed to function expecting a variable number of object argumentsCorrectness
VR: Class makes reference to unresolvable class or methodCorrectness
LG: Potential lost logger changes due to weak reference in OpenJDKExperimental
OBL: Method may fail to clean up stream or resourceExperimental
OBL: Method may fail to clean up stream or resource on checked exceptionExperimental
TEST: TestingExperimental
Dm: Consider using Locale parameterized version of invoked methodInternationalization
Dm: Reliance on default encodingInternationalization
DP: Classloaders should only be created inside doPrivileged blockMalicious code vulnerability
DP: Method invoked that should be only be invoked inside a doPrivileged blockMalicious code vulnerability
EI: May expose internal representation by returning reference to mutable objectMalicious code vulnerability
EI2: May expose internal representation by incorporating reference to mutable objectMalicious code vulnerability
FI: Finalizer should be protected, not publicMalicious code vulnerability
MS: May expose internal static state by storing a mutable object into a static fieldMalicious code vulnerability
MS: Field isn't final and can't be protected from malicious codeMalicious code vulnerability
MS: Public static method may expose internal representation by returning arrayMalicious code vulnerability
MS: Field should be both final and package protectedMalicious code vulnerability
MS: Field is a mutable arrayMalicious code vulnerability
MS: Field is a mutable HashtableMalicious code vulnerability
MS: Field should be moved out of an interface and made package protectedMalicious code vulnerability
MS: Field should be package protectedMalicious code vulnerability
MS: Field isn't final but should beMalicious code vulnerability
MS: Field isn't final but should be refactored to be soMalicious code vulnerability
AT: Sequence of calls to concurrent abstraction may not be atomicMultithreaded correctness
DC: Possible double check of fieldMultithreaded correctness
DL: Synchronization on BooleanMultithreaded correctness
DL: Synchronization on boxed primitiveMultithreaded correctness
DL: Synchronization on interned String Multithreaded correctness
DL: Synchronization on boxed primitive valuesMultithreaded correctness
Dm: Monitor wait() called on ConditionMultithreaded correctness
Dm: A thread was created using the default empty run methodMultithreaded correctness
ESync: Empty synchronized blockMultithreaded correctness
IS: Inconsistent synchronizationMultithreaded correctness
IS: Field not guarded against concurrent accessMultithreaded correctness
JLM: Synchronization performed on LockMultithreaded correctness
JLM: Synchronization performed on util.concurrent instanceMultithreaded correctness
JLM: Using monitor style wait methods on util.concurrent abstractionMultithreaded correctness
LI: Incorrect lazy initialization of static fieldMultithreaded correctness
LI: Incorrect lazy initialization and update of static fieldMultithreaded correctness
ML: Synchronization on field in futile attempt to guard that fieldMultithreaded correctness
ML: Method synchronizes on an updated fieldMultithreaded correctness
MSF: Mutable servlet fieldMultithreaded correctness
MWN: Mismatched notify()Multithreaded correctness
MWN: Mismatched wait()Multithreaded correctness
NN: Naked notifyMultithreaded correctness
NP: Synchronize and null check on the same field.Multithreaded correctness
No: Using notify() rather than notifyAll()Multithreaded correctness
RS: Class's readObject() method is synchronizedMultithreaded correctness
RV: Return value of putIfAbsent ignored, value passed to putIfAbsent reusedMultithreaded correctness
Ru: Invokes run on a thread (did you mean to start it instead?)Multithreaded correctness
SC: Constructor invokes Thread.start()Multithreaded correctness
SP: Method spins on fieldMultithreaded correctness
STCAL: Call to static CalendarMultithreaded correctness
STCAL: Call to static DateFormatMultithreaded correctness
STCAL: Static Calendar fieldMultithreaded correctness
STCAL: Static DateFormatMultithreaded correctness
SWL: Method calls Thread.sleep() with a lock heldMultithreaded correctness
TLW: Wait with two locks heldMultithreaded correctness
UG: Unsynchronized get method, synchronized set methodMultithreaded correctness
UL: Method does not release lock on all pathsMultithreaded correctness
UL: Method does not release lock on all exception pathsMultithreaded correctness
UW: Unconditional waitMultithreaded correctness
VO: An increment to a volatile field isn't atomicMultithreaded correctness
VO: A volatile reference to an array doesn't treat the array elements as volatileMultithreaded correctness
WL: Synchronization on getClass rather than class literalMultithreaded correctness
WS: Class's writeObject() method is synchronized but nothing else isMultithreaded correctness
Wa: Condition.await() not in loop Multithreaded correctness
Wa: Wait not in loop Multithreaded correctness
NOISE: Bogus warning about a field referenceBogus random noise
NOISE: Bogus warning about a method callBogus random noise
NOISE: Bogus warning about a null pointer dereferenceBogus random noise
NOISE: Bogus warning about an operationBogus random noise
Bx: Primitive value is boxed and then immediately unboxedPerformance
Bx: Primitive value is boxed then unboxed to perform primitive coercionPerformance
Bx: Boxed value is unboxed and then immediately reboxedPerformance
Bx: Boxing/unboxing to parse a primitivePerformance
Bx: Method allocates a boxed primitive just to call toStringPerformance
Bx: Method invokes inefficient floating-point Number constructor; use static valueOf insteadPerformance
Bx: Method invokes inefficient Number constructor; use static valueOf insteadPerformance
Dm: The equals and hashCode methods of URL are blockingPerformance
Dm: Maps and sets of URLs can be performance hogsPerformance
Dm: Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) insteadPerformance
Dm: Explicit garbage collection; extremely dubious except in benchmarking codePerformance
Dm: Method allocates an object, only to get the class objectPerformance
Dm: Use the nextInt method of Random rather than nextDouble to generate a random integerPerformance
Dm: Method invokes inefficient new String(String) constructorPerformance
Dm: Method invokes toString() method on a StringPerformance
Dm: Method invokes inefficient new String() constructorPerformance
HSC: Huge string constants is duplicated across multiple class filesPerformance
IMA: Method accesses a private member variable of owning classPerformance
ITA: Method uses toArray() with zero-length array argumentPerformance
SBSC: Method concatenates strings using + in a loopPerformance
SIC: Should be a static inner classPerformance
SIC: Could be refactored into a named static inner classPerformance
SIC: Could be refactored into a static inner classPerformance
SS: Unread field: should this field be static?Performance
UM: Method calls static Math class method on a constant valuePerformance
UPM: Private method is never calledPerformance
UrF: Unread fieldPerformance
UuF: Unused fieldPerformance
WMI: Inefficient use of keySet iterator instead of entrySet iteratorPerformance
Dm: Hardcoded constant database passwordSecurity
Dm: Empty database passwordSecurity
HRS: HTTP cookie formed from untrusted inputSecurity
HRS: HTTP Response splitting vulnerabilitySecurity
PT: Absolute path traversal in servletSecurity
PT: Relative path traversal in servletSecurity
SQL: Nonconstant string passed to execute method on an SQL statementSecurity
SQL: A prepared statement is generated from a nonconstant StringSecurity
XSS: JSP reflected cross site scripting vulnerabilitySecurity
XSS: Servlet reflected cross site scripting vulnerability in error pageSecurity
XSS: Servlet reflected cross site scripting vulnerabilitySecurity
BC: Questionable cast to abstract collection Dodgy code
BC: Questionable cast to concrete collectionDodgy code
BC: Unchecked/unconfirmed castDodgy code
BC: Unchecked/unconfirmed cast of return value from methodDodgy code
BC: instanceof will always return trueDodgy code
BSHIFT: Unsigned right shift cast to short/byteDodgy code
CD: Test for circular dependencies among classesDodgy code
CI: Class is final but declares protected fieldDodgy code
DB: Method uses the same code for two branchesDodgy code
DB: Method uses the same code for two switch clausesDodgy code
DLS: Dead store to local variableDodgy code
DLS: Useless assignment in return statementDodgy code
DLS: Dead store of null to local variableDodgy code
DLS: Dead store to local variable that shadows fieldDodgy code
DMI: Code contains a hard coded reference to an absolute pathnameDodgy code
DMI: Non serializable object written to ObjectOutputDodgy code
DMI: Invocation of substring(0), which returns the original valueDodgy code
Dm: Thread passed where Runnable expectedDodgy code
Dm: Call to unsupported methodDodgy code
Eq: Class doesn't override equals in superclassDodgy code
Eq: Unusual equals method Dodgy code
FE: Test for floating point equalityDodgy code
FS: Non-Boolean argument formatted using %b format specifierDodgy code
IA: Potentially ambiguous invocation of either an inherited or outer methodDodgy code
IC: Initialization circularityDodgy code
ICAST: Integral division result cast to double or floatDodgy code
ICAST: Result of integer multiplication cast to longDodgy code
IM: Computation of average could overflowDodgy code
IM: Check for oddness that won't work for negative numbers Dodgy code
INT: Integer remainder modulo 1Dodgy code
INT: Vacuous bit mask operation on integer valueDodgy code
INT: Vacuous comparison of integer valueDodgy code
MTIA: Class extends Servlet class and uses instance variablesDodgy code
MTIA: Class extends Struts Action class and uses instance variablesDodgy code
NP: Dereference of the result of readLine() without nullcheckDodgy code
NP: Immediate dereference of the result of readLine()Dodgy code
NP: Load of known null valueDodgy code
NP: Method tightens nullness annotation on parameterDodgy code
NP: Method relaxes nullness annotation on return valueDodgy code
NP: Possible null pointer dereference due to return value of called methodDodgy code
NP: Possible null pointer dereference on branch that might be infeasibleDodgy code
NP: Parameter must be nonnull but is marked as nullableDodgy code
NP: Read of unwritten public or protected fieldDodgy code
NS: Potentially dangerous use of non-short-circuit logicDodgy code
NS: Questionable use of non-short-circuit logicDodgy code
PS: Class exposes synchronization and semaphores in its public interfaceDodgy code
PZLA: Consider returning a zero length array rather than nullDodgy code
QF: Complicated, subtle or wrong increment in for-loop Dodgy code
RCN: Redundant comparison of non-null value to nullDodgy code
RCN: Redundant comparison of two null valuesDodgy code
RCN: Redundant nullcheck of value known to be non-nullDodgy code
RCN: Redundant nullcheck of value known to be nullDodgy code
REC: Exception is caught when Exception is not thrownDodgy code
RI: Class implements same interface as superclassDodgy code
RV: Method checks to see if result of String.indexOf is positiveDodgy code
RV: Method discards result of readLine after checking if it is nonnullDodgy code
RV: Remainder of hashCode could be negativeDodgy code
RV: Remainder of 32-bit signed random integerDodgy code
RV: Method ignores return value, is this OK?Dodgy code
SA: Double assignment of fieldDodgy code
SA: Double assignment of local variable Dodgy code
SA: Self assignment of local variableDodgy code
SF: Switch statement found where one case falls through to the next caseDodgy code
SF: Switch statement found where default case is missingDodgy code
ST: Write to static field from instance methodDodgy code
Se: Private readResolve method not inherited by subclassesDodgy code
Se: Transient field of class that isn't Serializable. Dodgy code
TQ: Value required to have type qualifier, but marked as unknownDodgy code
TQ: Value required to not have type qualifier, but marked as unknownDodgy code
UCF: Useless control flowDodgy code
UCF: Useless control flow to next lineDodgy code
USM: Abstract Method is already defined in implemented interfaceDodgy code
USM: Method superfluously delegates to parent class methodDodgy code
UrF: Unread public/protected fieldDodgy code
UuF: Unused public or protected fieldDodgy code
UwF: Field not initialized in constructor but dereferenced without null checkDodgy code
UwF: Unwritten public or protected fieldDodgy code
XFB: Method directly allocates a specific implementation of xml interfacesDodgy code
+

Descriptions

+

AM: Creates an empty jar file entry (AM_CREATES_EMPTY_JAR_FILE_ENTRY)

+ + +

The code calls putNextEntry(), immediately +followed by a call to closeEntry(). This results +in an empty JarFile entry. The contents of the entry +should be written to the JarFile between the calls to +putNextEntry() and +closeEntry().

+ + +

AM: Creates an empty zip file entry (AM_CREATES_EMPTY_ZIP_FILE_ENTRY)

+ + +

The code calls putNextEntry(), immediately +followed by a call to closeEntry(). This results +in an empty ZipFile entry. The contents of the entry +should be written to the ZipFile between the calls to +putNextEntry() and +closeEntry().

+ + +

BC: Equals method should not assume anything about the type of its argument (BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS)

+ + +

+The equals(Object o) method shouldn't make any assumptions +about the type of o. It should simply return +false if o is not the same type as this. +

+ + +

BIT: Check for sign of bitwise operation (BIT_SIGNED_CHECK)

+ + +

This method compares an expression such as

+
((event.detail & SWT.SELECTED) > 0)
. +

Using bit arithmetic and then comparing with the greater than operator can +lead to unexpected results (of course depending on the value of +SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate +for a bug. Even when SWT.SELECTED is not negative, it seems good practice +to use '!= 0' instead of '> 0'. +

+

+Boris Bokowski +

+ + +

CN: Class implements Cloneable but does not define or use clone method (CN_IDIOM)

+ + +

+ Class implements Cloneable but does not define or + use the clone method.

+ + +

CN: clone method does not call super.clone() (CN_IDIOM_NO_SUPER_CALL)

+ + +

This non-final class defines a clone() method that does not call super.clone(). +If this class ("A") is extended by a subclass ("B"), +and the subclass B calls super.clone(), then it is likely that +B's clone() method will return an object of type A, +which violates the standard contract for clone().

+ +

If all clone() methods call super.clone(), then they are guaranteed +to use Object.clone(), which always returns an object of the correct type.

+ + +

CN: Class defines clone() but doesn't implement Cloneable (CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE)

+ + +

This class defines a clone() method but the class doesn't implement Cloneable. +There are some situations in which this is OK (e.g., you want to control how subclasses +can clone themselves), but just make sure that this is what you intended. +

+ + +

Co: Abstract class defines covariant compareTo() method (CO_ABSTRACT_SELF)

+ + +

This class defines a covariant version of compareTo().  + To correctly override the compareTo() method in the + Comparable interface, the parameter of compareTo() + must have type java.lang.Object.

+ + +

Co: Covariant compareTo() method defined (CO_SELF_NO_OBJECT)

+ + +

This class defines a covariant version of compareTo().  + To correctly override the compareTo() method in the + Comparable interface, the parameter of compareTo() + must have type java.lang.Object.

+ + +

DE: Method might drop exception (DE_MIGHT_DROP)

+ + +

This method might drop an exception.  In general, exceptions + should be handled or reported in some way, or they should be thrown + out of the method.

+ + +

DE: Method might ignore exception (DE_MIGHT_IGNORE)

+ + +

This method might ignore an exception.  In general, exceptions + should be handled or reported in some way, or they should be thrown + out of the method.

+ + +

DMI: Adding elements of an entry set may fail due to reuse of Entry objects (DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS)

+ + +

The entrySet() method is allowed to return a view of the + underlying Map in which a single Entry object is reused and returned + during the iteration. As of Java 1.6, both IdentityHashMap + and EnumMap did so. When iterating through such a Map, + the Entry value is only valid until you advance to the next iteration. + If, for example, you try to pass such an entrySet to an addAll method, + things will go badly wrong. +

+ + +

DMI: Random object created and used only once (DMI_RANDOM_USED_ONLY_ONCE)

+ + +

This code creates a java.util.Random object, uses it to generate one random number, and then discards +the Random object. This produces mediocre quality random numbers and is inefficient. +If possible, rewrite the code so that the Random object is created once and saved, and each time a new random number +is required invoke a method on the existing Random object to obtain it. +

+ +

If it is important that the generated Random numbers not be guessable, you must not create a new Random for each random +number; the values are too easily guessable. You should strongly consider using a java.security.SecureRandom instead +(and avoid allocating a new SecureRandom for each random number needed). +

+ + +

DMI: Don't use removeAll to clear a collection (DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION)

+ + +

If you want to remove all elements from a collection c, use c.clear, +not c.removeAll(c). Calling c.removeAll(c) to clear a collection +is less clear, susceptible to errors from typos, less efficient and +for some collections, might throw a ConcurrentModificationException. +

+ + +

Dm: Method invokes System.exit(...) (DM_EXIT)

+ + +

Invoking System.exit shuts down the entire Java virtual machine. This + should only been done when it is appropriate. Such calls make it + hard or impossible for your code to be invoked by other code. + Consider throwing a RuntimeException instead.

+ + +

Dm: Method invokes dangerous method runFinalizersOnExit (DM_RUN_FINALIZERS_ON_EXIT)

+ + +

Never call System.runFinalizersOnExit +or Runtime.runFinalizersOnExit for any reason: they are among the most +dangerous methods in the Java libraries. -- Joshua Bloch

+ + +

ES: Comparison of String parameter using == or != (ES_COMPARING_PARAMETER_STRING_WITH_EQ)

+ + +

This code compares a java.lang.String parameter for reference +equality using the == or != operators. Requiring callers to +pass only String constants or interned strings to a method is unnecessarily +fragile, and rarely leads to measurable performance gains. Consider +using the equals(Object) method instead.

+ + +

ES: Comparison of String objects using == or != (ES_COMPARING_STRINGS_WITH_EQ)

+ + +

This code compares java.lang.String objects for reference +equality using the == or != operators. +Unless both strings are either constants in a source file, or have been +interned using the String.intern() method, the same string +value may be represented by two different String objects. Consider +using the equals(Object) method instead.

+ + +

Eq: Abstract class defines covariant equals() method (EQ_ABSTRACT_SELF)

+ + +

This class defines a covariant version of equals().  + To correctly override the equals() method in + java.lang.Object, the parameter of equals() + must have type java.lang.Object.

+ + +

Eq: Equals checks for incompatible operand (EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS)

+ + +

This equals method is checking to see if the argument is some incompatible type +(i.e., a class that is neither a supertype nor subtype of the class that defines +the equals method). For example, the Foo class might have an equals method +that looks like: +

+
+public boolean equals(Object o) {
+  if (o instanceof Foo)
+    return name.equals(((Foo)o).name);
+  else if (o instanceof String)
+    return name.equals(o);
+  else return false;
+
+ +

This is considered bad practice, as it makes it very hard to implement an equals method that +is symmetric and transitive. Without those properties, very unexpected behavoirs are possible. +

+ + +

Eq: Class defines compareTo(...) and uses Object.equals() (EQ_COMPARETO_USE_OBJECT_EQUALS)

+ + +

This class defines a compareTo(...) method but inherits its + equals() method from java.lang.Object. + Generally, the value of compareTo should return zero if and only if + equals returns true. If this is violated, weird and unpredictable + failures will occur in classes such as PriorityQueue. + In Java 5 the PriorityQueue.remove method uses the compareTo method, + while in Java 6 it uses the equals method. + +

From the JavaDoc for the compareTo method in the Comparable interface: +

+It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). +Generally speaking, any class that implements the Comparable interface and violates this condition +should clearly indicate this fact. The recommended language +is "Note: this class has a natural ordering that is inconsistent with equals." +
+ + +

Eq: equals method fails for subtypes (EQ_GETCLASS_AND_CLASS_CONSTANT)

+ + +

This class has an equals method that will be broken if it is inherited by subclasses. +It compares a class literal with the class of the argument (e.g., in class Foo +it might check if Foo.class == o.getClass()). +It is better to check if this.getClass() == o.getClass(). +

+ + +

Eq: Covariant equals() method defined (EQ_SELF_NO_OBJECT)

+ + +

This class defines a covariant version of equals().  + To correctly override the equals() method in + java.lang.Object, the parameter of equals() + must have type java.lang.Object.

+ + +

FI: Empty finalizer should be deleted (FI_EMPTY)

+ + +

Empty finalize() methods are useless, so they should + be deleted.

+ + +

FI: Explicit invocation of finalizer (FI_EXPLICIT_INVOCATION)

+ + +

This method contains an explicit invocation of the finalize() + method on an object.  Because finalizer methods are supposed to be + executed once, and only by the VM, this is a bad idea.

+

If a connected set of objects beings finalizable, then the VM will invoke the +finalize method on all the finalizable object, possibly at the same time in different threads. +Thus, it is a particularly bad idea, in the finalize method for a class X, invoke finalize +on objects referenced by X, because they may already be getting finalized in a separate thread. + + +

FI: Finalizer nulls fields (FI_FINALIZER_NULLS_FIELDS)

+ + +

This finalizer nulls out fields. This is usually an error, as it does not aid garbage collection, + and the object is going to be garbage collected anyway. + + +

FI: Finalizer only nulls fields (FI_FINALIZER_ONLY_NULLS_FIELDS)

+ + +

This finalizer does nothing except null out fields. This is completely pointless, and requires that +the object be garbage collected, finalized, and then garbage collected again. You should just remove the finalize +method. + + +

FI: Finalizer does not call superclass finalizer (FI_MISSING_SUPER_CALL)

+ + +

This finalize() method does not make a call to its + superclass's finalize() method.  So, any finalizer + actions defined for the superclass will not be performed.  + Add a call to super.finalize().

+ + +

FI: Finalizer nullifies superclass finalizer (FI_NULLIFY_SUPER)

+ + +

This empty finalize() method explicitly negates the + effect of any finalizer defined by its superclass.  Any finalizer + actions defined for the superclass will not be performed.  + Unless this is intended, delete this method.

+ + +

FI: Finalizer does nothing but call superclass finalizer (FI_USELESS)

+ + +

The only thing this finalize() method does is call + the superclass's finalize() method, making it + redundant.  Delete it.

+ + +

FS: Format string should use %n rather than \n (VA_FORMAT_STRING_USES_NEWLINE)

+ + +

+This format string include a newline character (\n). In format strings, it is generally + preferable better to use %n, which will produce the platform-specific line separator. +

+ + +

GC: Unchecked type in generic call (GC_UNCHECKED_TYPE_IN_GENERIC_CALL)

+ + +

This call to a generic collection method passes an argument + while compile type Object where a specific type from + the generic type parameters is expected. + Thus, neither the standard Java type system nor static analysis + can provide useful information on whether the + object being passed as a parameter is of an appropriate type. +

+ + +

HE: Class defines equals() but not hashCode() (HE_EQUALS_NO_HASHCODE)

+ + +

This class overrides equals(Object), but does not + override hashCode().  Therefore, the class may violate the + invariant that equal objects must have equal hashcodes.

+ + +

HE: Class defines equals() and uses Object.hashCode() (HE_EQUALS_USE_HASHCODE)

+ + +

This class overrides equals(Object), but does not + override hashCode(), and inherits the implementation of + hashCode() from java.lang.Object (which returns + the identity hash code, an arbitrary value assigned to the object + by the VM).  Therefore, the class is very likely to violate the + invariant that equal objects must have equal hashcodes.

+ +

If you don't think instances of this class will ever be inserted into a HashMap/HashTable, +the recommended hashCode implementation to use is:

+
public int hashCode() {
+  assert false : "hashCode not designed";
+  return 42; // any arbitrary constant will do
+  }
+ + +

HE: Class defines hashCode() but not equals() (HE_HASHCODE_NO_EQUALS)

+ + +

This class defines a hashCode() method but not an + equals() method.  Therefore, the class may + violate the invariant that equal objects must have equal hashcodes.

+ + +

HE: Class defines hashCode() and uses Object.equals() (HE_HASHCODE_USE_OBJECT_EQUALS)

+ + +

This class defines a hashCode() method but inherits its + equals() method from java.lang.Object + (which defines equality by comparing object references).  Although + this will probably satisfy the contract that equal objects must have + equal hashcodes, it is probably not what was intended by overriding + the hashCode() method.  (Overriding hashCode() + implies that the object's identity is based on criteria more complicated + than simple reference equality.)

+

If you don't think instances of this class will ever be inserted into a HashMap/HashTable, +the recommended hashCode implementation to use is:

+
public int hashCode() {
+  assert false : "hashCode not designed";
+  return 42; // any arbitrary constant will do
+  }
+ + +

HE: Class inherits equals() and uses Object.hashCode() (HE_INHERITS_EQUALS_USE_HASHCODE)

+ + +

This class inherits equals(Object) from an abstract + superclass, and hashCode() from +java.lang.Object (which returns + the identity hash code, an arbitrary value assigned to the object + by the VM).  Therefore, the class is very likely to violate the + invariant that equal objects must have equal hashcodes.

+ +

If you don't want to define a hashCode method, and/or don't + believe the object will ever be put into a HashMap/Hashtable, + define the hashCode() method + to throw UnsupportedOperationException.

+ + +

IC: Superclass uses subclass during initialization (IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION)

+ + +

During the initialization of a class, the class makes an active use of a subclass. +That subclass will not yet be initialized at the time of this use. +For example, in the following code, foo will be null.

+ +
+public class CircularClassInitialization {
+    static class InnerClassSingleton extends CircularClassInitialization {
+        static InnerClassSingleton singleton = new InnerClassSingleton();
+    }
+
+    static CircularClassInitialization foo = InnerClassSingleton.singleton;
+}
+
+ + + +

IMSE: Dubious catching of IllegalMonitorStateException (IMSE_DONT_CATCH_IMSE)

+ + +

IllegalMonitorStateException is generally only + thrown in case of a design flaw in your code (calling wait or + notify on an object you do not hold a lock on).

+ + +

ISC: Needless instantiation of class that only supplies static methods (ISC_INSTANTIATE_STATIC_CLASS)

+ + +

This class allocates an object that is based on a class that only supplies static methods. This object +does not need to be created, just access the static methods directly using the class name as a qualifier.

+ + +

It: Iterator next() method can't throw NoSuchElementException (IT_NO_SUCH_ELEMENT)

+ + +

This class implements the java.util.Iterator interface.  + However, its next() method is not capable of throwing + java.util.NoSuchElementException.  The next() + method should be changed so it throws NoSuchElementException + if is called when there are no more elements to return.

+ + +

J2EE: Store of non serializable object into HttpSession (J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION)

+ + +

+This code seems to be storing a non-serializable object into an HttpSession. +If this session is passivated or migrated, an error will result. +

+ + +

JCIP: Fields of immutable classes should be final (JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS)

+ + +

The class is annotated with net.jcip.annotations.Immutable or javax.annotation.concurrent.Immutable, + and the rules for those annotations require that all fields are final. + .

+ + +

NP: Method with Boolean return type returns explicit null (NP_BOOLEAN_RETURN_NULL)

+ + +

+ A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. + This method can be invoked as though it returned a value of type boolean, and + the compiler will insert automatic unboxing of the Boolean value. If a null value is returned, + this will result in a NullPointerException. +

+ + +

NP: Clone method may return null (NP_CLONE_COULD_RETURN_NULL)

+ + +

+ This clone method seems to return null in some circumstances, but clone is never + allowed to return a null value. If you are convinced this path is unreachable, throw an AssertionError + instead. +

+ + +

NP: equals() method does not check for null argument (NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT)

+ + +

+ This implementation of equals(Object) violates the contract defined + by java.lang.Object.equals() because it does not check for null + being passed as the argument. All equals() methods should return + false if passed a null value. +

+ + +

NP: toString method may return null (NP_TOSTRING_COULD_RETURN_NULL)

+ + +

+ This toString method seems to return null in some circumstances. A liberal reading of the + spec could be interpreted as allowing this, but it is probably a bad idea and could cause + other code to break. Return the empty string or some other appropriate string rather than null. +

+ + +

Nm: Class names should start with an upper case letter (NM_CLASS_NAMING_CONVENTION)

+ + +

Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML). +

+ + +

Nm: Class is not derived from an Exception, even though it is named as such (NM_CLASS_NOT_EXCEPTION)

+ + +

This class is not derived from another exception, but ends with 'Exception'. This will +be confusing to users of this class.

+ + +

Nm: Confusing method names (NM_CONFUSING)

+ + +

The referenced methods have names that differ only by capitalization.

+ + +

Nm: Field names should start with a lower case letter (NM_FIELD_NAMING_CONVENTION)

+ + +

+Names of fields that are not final should be in mixed case with a lowercase first letter and the first letters of subsequent words capitalized. +

+ + +

Nm: Use of identifier that is a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER)

+ + +

The identifier is a word that is reserved as a keyword in later versions of Java, and your code will need to be changed +in order to compile it in later versions of Java.

+ + + +

Nm: Use of identifier that is a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER)

+ + +

This identifier is used as a keyword in later versions of Java. This code, and +any code that references this API, +will need to be changed in order to compile it in later versions of Java.

+ + + +

Nm: Method names should start with a lower case letter (NM_METHOD_NAMING_CONVENTION)

+ + +

+Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. +

+ + +

Nm: Class names shouldn't shadow simple name of implemented interface (NM_SAME_SIMPLE_NAME_AS_INTERFACE)

+ + +

This class/interface has a simple name that is identical to that of an implemented/extended interface, except +that the interface is in a different package (e.g., alpha.Foo extends beta.Foo). +This can be exceptionally confusing, create lots of situations in which you have to look at import statements +to resolve references and creates many +opportunities to accidently define methods that do not override methods in their superclasses. +

+ + +

Nm: Class names shouldn't shadow simple name of superclass (NM_SAME_SIMPLE_NAME_AS_SUPERCLASS)

+ + +

This class has a simple name that is identical to that of its superclass, except +that its superclass is in a different package (e.g., alpha.Foo extends beta.Foo). +This can be exceptionally confusing, create lots of situations in which you have to look at import statements +to resolve references and creates many +opportunities to accidently define methods that do not override methods in their superclasses. +

+ + +

Nm: Very confusing method names (but perhaps intentional) (NM_VERY_CONFUSING_INTENTIONAL)

+ + +

The referenced methods have names that differ only by capitalization. +This is very confusing because if the capitalization were +identical then one of the methods would override the other. From the existence of other methods, it +seems that the existence of both of these methods is intentional, but is sure is confusing. +You should try hard to eliminate one of them, unless you are forced to have both due to frozen APIs. +

+ + +

Nm: Method doesn't override method in superclass due to wrong package for parameter (NM_WRONG_PACKAGE_INTENTIONAL)

+ + +

The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match +the type of the corresponding parameter in the superclass. For example, if you have:

+ +
+
+import alpha.Foo;
+public class A {
+  public int f(Foo x) { return 17; }
+}
+----
+import beta.Foo;
+public class B extends A {
+  public int f(Foo x) { return 42; }
+  public int f(alpha.Foo x) { return 27; }
+}
+
+
+ +

The f(Foo) method defined in class B doesn't +override the +f(Foo) method defined in class A, because the argument +types are Foo's from different packages. +

+ +

In this case, the subclass does define a method with a signature identical to the method in the superclass, +so this is presumably understood. However, such methods are exceptionally confusing. You should strongly consider +removing or deprecating the method with the similar but not identical signature. +

+ + +

ODR: Method may fail to close database resource (ODR_OPEN_DATABASE_RESOURCE)

+ + +

The method creates a database resource (such as a database connection +or row set), does not assign it to any +fields, pass it to other methods, or return it, and does not appear to close +the object on all paths out of the method.  Failure to +close database resources on all paths out of a method may +result in poor performance, and could cause the application to +have problems communicating with the database. +

+ + +

ODR: Method may fail to close database resource on exception (ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH)

+ + +

The method creates a database resource (such as a database connection +or row set), does not assign it to any +fields, pass it to other methods, or return it, and does not appear to close +the object on all exception paths out of the method.  Failure to +close database resources on all paths out of a method may +result in poor performance, and could cause the application to +have problems communicating with the database.

+ + +

OS: Method may fail to close stream (OS_OPEN_STREAM)

+ + +

The method creates an IO stream object, does not assign it to any +fields, pass it to other methods that might close it, +or return it, and does not appear to close +the stream on all paths out of the method.  This may result in +a file descriptor leak.  It is generally a good +idea to use a finally block to ensure that streams are +closed.

+ + +

OS: Method may fail to close stream on exception (OS_OPEN_STREAM_EXCEPTION_PATH)

+ + +

The method creates an IO stream object, does not assign it to any +fields, pass it to other methods, or return it, and does not appear to close +it on all possible exception paths out of the method.  +This may result in a file descriptor leak.  It is generally a good +idea to use a finally block to ensure that streams are +closed.

+ + +

PZ: Don't reuse entry objects in iterators (PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS)

+ + +

The entrySet() method is allowed to return a view of the + underlying Map in which an Iterator and Map.Entry. This clever + idea was used in several Map implementations, but introduces the possibility + of nasty coding mistakes. If a map m returns + such an iterator for an entrySet, then + c.addAll(m.entrySet()) will go badly wrong. All of + the Map implementations in OpenJDK 1.7 have been rewritten to avoid this, + you should to. +

+ + +

RC: Suspicious reference comparison to constant (RC_REF_COMPARISON_BAD_PRACTICE)

+ + +

This method compares a reference value to a constant using the == or != operator, +where the correct way to compare instances of this type is generally +with the equals() method. +It is possible to create distinct instances that are equal but do not compare as == since +they are different objects. +Examples of classes which should generally +not be compared by reference are java.lang.Integer, java.lang.Float, etc.

+ + +

RC: Suspicious reference comparison of Boolean values (RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN)

+ + +

This method compares two Boolean values using the == or != operator. +Normally, there are only two Boolean values (Boolean.TRUE and Boolean.FALSE), +but it is possible to create other Boolean objects using the new Boolean(b) +constructor. It is best to avoid such objects, but if they do exist, +then checking Boolean objects for equality using == or != will give results +than are different than you would get using .equals(...) +

+ + +

RR: Method ignores results of InputStream.read() (RR_NOT_CHECKED)

+ + +

This method ignores the return value of one of the variants of + java.io.InputStream.read() which can return multiple bytes.  + If the return value is not checked, the caller will not be able to correctly + handle the case where fewer bytes were read than the caller requested.  + This is a particularly insidious kind of bug, because in many programs, + reads from input streams usually do read the full amount of data requested, + causing the program to fail only sporadically.

+ + +

RR: Method ignores results of InputStream.skip() (SR_NOT_CHECKED)

+ + +

This method ignores the return value of + java.io.InputStream.skip() which can skip multiple bytes.  + If the return value is not checked, the caller will not be able to correctly + handle the case where fewer bytes were skipped than the caller requested.  + This is a particularly insidious kind of bug, because in many programs, + skips from input streams usually do skip the full amount of data requested, + causing the program to fail only sporadically. With Buffered streams, however, + skip() will only skip data in the buffer, and will routinely fail to skip the + requested number of bytes.

+ + +

RV: Negating the result of compareTo()/compare() (RV_NEGATING_RESULT_OF_COMPARETO)

+ + +

This code negatives the return value of a compareTo or compare method. +This is a questionable or bad programming practice, since if the return +value is Integer.MIN_VALUE, negating the return value won't +negate the sign of the result. You can achieve the same intended result +by reversing the order of the operands rather than by negating the results. +

+ + +

RV: Method ignores exceptional return value (RV_RETURN_VALUE_IGNORED_BAD_PRACTICE)

+ + +

This method returns a value that is not checked. The return value should be checked +since it can indicate an unusual or unexpected function execution. For +example, the File.delete() method returns false +if the file could not be successfully deleted (rather than +throwing an Exception). +If you don't check the result, you won't notice if the method invocation +signals unexpected behavior by returning an atypical return value. +

+ + +

SI: Static initializer creates instance before all static final fields assigned (SI_INSTANCE_BEFORE_FINALS_ASSIGNED)

+ + +

The class's static initializer creates an instance of the class +before all of the static final fields are assigned.

+ + +

SW: Certain swing methods needs to be invoked in Swing thread (SW_SWING_METHODS_INVOKED_IN_SWING_THREAD)

+ + +

(From JDC Tech Tip): The Swing methods +show(), setVisible(), and pack() will create the associated peer for the frame. +With the creation of the peer, the system creates the event dispatch thread. +This makes things problematic because the event dispatch thread could be notifying +listeners while pack and validate are still processing. This situation could result in +two threads going through the Swing component-based GUI -- it's a serious flaw that +could result in deadlocks or other related threading issues. A pack call causes +components to be realized. As they are being realized (that is, not necessarily +visible), they could trigger listener notification on the event dispatch thread.

+ + + +

Se: Non-transient non-serializable instance field in serializable class (SE_BAD_FIELD)

+ + +

This Serializable class defines a non-primitive instance field which is neither transient, +Serializable, or java.lang.Object, and does not appear to implement +the Externalizable interface or the +readObject() and writeObject() methods.  +Objects of this class will not be deserialized correctly if a non-Serializable +object is stored in this field.

+ + +

Se: Non-serializable class has a serializable inner class (SE_BAD_FIELD_INNER_CLASS)

+ + +

This Serializable class is an inner class of a non-serializable class. +Thus, attempts to serialize it will also attempt to associate instance of the outer +class with which it is associated, leading to a runtime error. +

+

If possible, making the inner class a static inner class should solve the +problem. Making the outer class serializable might also work, but that would +mean serializing an instance of the inner class would always also serialize the instance +of the outer class, which it often not what you really want. + + +

Se: Non-serializable value stored into instance field of a serializable class (SE_BAD_FIELD_STORE)

+ + +

A non-serializable value is stored into a non-transient field +of a serializable class.

+ + +

Se: Comparator doesn't implement Serializable (SE_COMPARATOR_SHOULD_BE_SERIALIZABLE)

+ + +

This class implements the Comparator interface. You +should consider whether or not it should also implement the Serializable +interface. If a comparator is used to construct an ordered collection +such as a TreeMap, then the TreeMap +will be serializable only if the comparator is also serializable. +As most comparators have little or no state, making them serializable +is generally easy and good defensive programming. +

+ + +

Se: Serializable inner class (SE_INNER_CLASS)

+ + +

This Serializable class is an inner class. Any attempt to serialize +it will also serialize the associated outer instance. The outer instance is serializable, +so this won't fail, but it might serialize a lot more data than intended. +If possible, making the inner class a static inner class (also known as a nested class) should solve the +problem. + + +

Se: serialVersionUID isn't final (SE_NONFINAL_SERIALVERSIONID)

+ + +

This class defines a serialVersionUID field that is not final.  + The field should be made final + if it is intended to specify + the version UID for purposes of serialization.

+ + +

Se: serialVersionUID isn't long (SE_NONLONG_SERIALVERSIONID)

+ + +

This class defines a serialVersionUID field that is not long.  + The field should be made long + if it is intended to specify + the version UID for purposes of serialization.

+ + +

Se: serialVersionUID isn't static (SE_NONSTATIC_SERIALVERSIONID)

+ + +

This class defines a serialVersionUID field that is not static.  + The field should be made static + if it is intended to specify + the version UID for purposes of serialization.

+ + +

Se: Class is Serializable but its superclass doesn't define a void constructor (SE_NO_SUITABLE_CONSTRUCTOR)

+ + +

This class implements the Serializable interface + and its superclass does not. When such an object is deserialized, + the fields of the superclass need to be initialized by + invoking the void constructor of the superclass. + Since the superclass does not have one, + serialization and deserialization will fail at runtime.

+ + +

Se: Class is Externalizable but doesn't define a void constructor (SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION)

+ + +

This class implements the Externalizable interface, but does + not define a void constructor. When Externalizable objects are deserialized, + they first need to be constructed by invoking the void + constructor. Since this class does not have one, + serialization and deserialization will fail at runtime.

+ + +

Se: The readResolve method must be declared with a return type of Object. (SE_READ_RESOLVE_MUST_RETURN_OBJECT)

+ + +

In order for the readResolve method to be recognized by the serialization +mechanism, it must be declared to have a return type of Object. +

+ + +

Se: Transient field that isn't set by deserialization. (SE_TRANSIENT_FIELD_NOT_RESTORED)

+ + +

This class contains a field that is updated at multiple places in the class, thus it seems to be part of the state of the class. However, since the field is marked as transient and not set in readObject or readResolve, it will contain the default value in any +deserialized instance of the class. +

+ + +

SnVI: Class is Serializable, but doesn't define serialVersionUID (SE_NO_SERIALVERSIONID)

+ + +

This class implements the Serializable interface, but does + not define a serialVersionUID field.  + A change as simple as adding a reference to a .class object + will add synthetic fields to the class, + which will unfortunately change the implicit + serialVersionUID (e.g., adding a reference to String.class + will generate a static field class$java$lang$String). + Also, different source code to bytecode compilers may use different + naming conventions for synthetic variables generated for + references to class objects or inner classes. + To ensure interoperability of Serializable across versions, + consider adding an explicit serialVersionUID.

+ + +

UI: Usage of GetResource may be unsafe if class is extended (UI_INHERITANCE_UNSAFE_GETRESOURCE)

+ + +

Calling this.getClass().getResource(...) could give +results other than expected if this class is extended by a class in +another package.

+ + +

BAC: Bad Applet Constructor relies on uninitialized AppletStub (BAC_BAD_APPLET_CONSTRUCTOR)

+ + +

+This constructor calls methods in the parent Applet that rely on the AppletStub. Since the AppletStub +isn't initialized until the init() method of this applet is called, these methods will not perform +correctly. +

+ + +

BC: Impossible cast (BC_IMPOSSIBLE_CAST)

+ + +

+This cast will always throw a ClassCastException. +FindBugs tracks type information from instanceof checks, +and also uses more precise information about the types +of values returned from methods and loaded from fields. +Thus, it may have more precise information that just +the declared type of a variable, and can use this to determine +that a cast will always throw an exception at runtime. + +

+ + +

BC: Impossible downcast (BC_IMPOSSIBLE_DOWNCAST)

+ + +

+This cast will always throw a ClassCastException. +The analysis believes it knows +the precise type of the value being cast, and the attempt to +downcast it to a subtype will always fail by throwing a ClassCastException. +

+ + +

BC: Impossible downcast of toArray() result (BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY)

+ + +

+This code is casting the result of calling toArray() on a collection +to a type more specific than Object[], as in:

+
+String[] getAsArray(Collection<String> c) {
+  return (String[]) c.toArray();
+  }
+
+

This will usually fail by throwing a ClassCastException. The toArray() +of almost all collections return an Object[]. They can't really do anything else, +since the Collection object has no reference to the declared generic type of the collection. +

The correct way to do get an array of a specific type from a collection is to use + c.toArray(new String[]); + or c.toArray(new String[c.size()]); (the latter is slightly more efficient). +

There is one common/known exception exception to this. The toArray() +method of lists returned by Arrays.asList(...) will return a covariantly +typed array. For example, Arrays.asArray(new String[] { "a" }).toArray() +will return a String []. FindBugs attempts to detect and suppress +such cases, but may miss some. +

+ + +

BC: instanceof will always return false (BC_IMPOSSIBLE_INSTANCEOF)

+ + +

+This instanceof test will always return false. Although this is safe, make sure it isn't +an indication of some misunderstanding or some other logic error. +

+ + +

BIT: Bitwise add of signed byte value (BIT_ADD_OF_SIGNED_BYTE)

+ + +

Adds a byte value and a value which is known to have the 8 lower bits clear. +Values loaded from a byte array are sign extended to 32 bits +before any any bitwise operations are performed on the value. +Thus, if b[0] contains the value 0xff, and +x is initially 0, then the code +((x << 8) + b[0]) will sign extend 0xff +to get 0xffffffff, and thus give the value +0xffffffff as the result. +

+ +

In particular, the following code for packing a byte array into an int is badly wrong:

+
+int result = 0;
+for(int i = 0; i < 4; i++)
+  result = ((result << 8) + b[i]);
+
+ +

The following idiom will work instead:

+
+int result = 0;
+for(int i = 0; i < 4; i++)
+  result = ((result << 8) + (b[i] & 0xff));
+
+ + + +

BIT: Incompatible bit masks (BIT_AND)

+ + +

This method compares an expression of the form (e & C) to D, +which will always compare unequal +due to the specific values of constants C and D. +This may indicate a logic error or typo.

+ + +

BIT: Check to see if ((...) & 0) == 0 (BIT_AND_ZZ)

+ + +

This method compares an expression of the form (e & 0) to 0, +which will always compare equal. +This may indicate a logic error or typo.

+ + +

BIT: Incompatible bit masks (BIT_IOR)

+ + +

This method compares an expression of the form (e | C) to D. +which will always compare unequal +due to the specific values of constants C and D. +This may indicate a logic error or typo.

+ +

Typically, this bug occurs because the code wants to perform +a membership test in a bit set, but uses the bitwise OR +operator ("|") instead of bitwise AND ("&").

+ + +

BIT: Bitwise OR of signed byte value (BIT_IOR_OF_SIGNED_BYTE)

+ + +

Loads a byte value (e.g., a value loaded from a byte array or returned by a method +with return type byte) and performs a bitwise OR with +that value. Byte values are sign extended to 32 bits +before any any bitwise operations are performed on the value. +Thus, if b[0] contains the value 0xff, and +x is initially 0, then the code +((x << 8) | b[0]) will sign extend 0xff +to get 0xffffffff, and thus give the value +0xffffffff as the result. +

+ +

In particular, the following code for packing a byte array into an int is badly wrong:

+
+int result = 0;
+for(int i = 0; i < 4; i++)
+  result = ((result << 8) | b[i]);
+
+ +

The following idiom will work instead:

+
+int result = 0;
+for(int i = 0; i < 4; i++)
+  result = ((result << 8) | (b[i] & 0xff));
+
+ + + +

BIT: Check for sign of bitwise operation (BIT_SIGNED_CHECK_HIGH_BIT)

+ + +

This method compares an expression such as

+
((event.detail & SWT.SELECTED) > 0)
. +

Using bit arithmetic and then comparing with the greater than operator can +lead to unexpected results (of course depending on the value of +SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate +for a bug. Even when SWT.SELECTED is not negative, it seems good practice +to use '!= 0' instead of '> 0'. +

+

+Boris Bokowski +

+ + +

BOA: Class overrides a method implemented in super class Adapter wrongly (BOA_BADLY_OVERRIDDEN_ADAPTER)

+ + +

This method overrides a method found in a parent class, where that class is an Adapter that implements +a listener defined in the java.awt.event or javax.swing.event package. As a result, this method will not +get called when the event occurs.

+ + +

BSHIFT: 32 bit int shifted by an amount not in the range -31..31 (ICAST_BAD_SHIFT_AMOUNT)

+ + +

+The code performs shift of a 32 bit int by a constant amount outside +the range -31..31. +The effect of this is to use the lower 5 bits of the integer +value to decide how much to shift by (e.g., shifting by 40 bits is the same as shifting by 8 bits, +and shifting by 32 bits is the same as shifting by zero bits). This probably isn't what was expected, +and it is at least confusing. +

+ + +

Bx: Primitive value is unboxed and coerced for ternary operator (BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR)

+ + +

A wrapped primitive value is unboxed and converted to another primitive type as part of the +evaluation of a conditional ternary operator (the b ? e1 : e2 operator). The +semantics of Java mandate that if e1 and e2 are wrapped +numeric values, the values are unboxed and converted/coerced to their common type (e.g, +if e1 is of type Integer +and e2 is of type Float, then e1 is unboxed, +converted to a floating point value, and boxed. See JLS Section 15.25. +

+ + +

Co: compareTo()/compare() returns Integer.MIN_VALUE (CO_COMPARETO_RESULTS_MIN_VALUE)

+ + +

In some situation, this compareTo or compare method returns +the constant Integer.MIN_VALUE, which is an exceptionally bad practice. + The only thing that matters about the return value of compareTo is the sign of the result. + But people will sometimes negate the return value of compareTo, expecting that this will negate + the sign of the result. And it will, except in the case where the value returned is Integer.MIN_VALUE. + So just return -1 rather than Integer.MIN_VALUE. + + +

DLS: Useless increment in return statement (DLS_DEAD_LOCAL_INCREMENT_IN_RETURN)

+ + +

This statement has a return such as return x++;. +A postfix increment/decrement does not impact the value of the expression, +so this increment/decrement has no effect. +Please verify that this statement does the right thing. +

+ + +

DLS: Dead store of class literal (DLS_DEAD_STORE_OF_CLASS_LITERAL)

+ + +

+This instruction assigns a class literal to a variable and then never uses it. +The behavior of this differs in Java 1.4 and in Java 5. +In Java 1.4 and earlier, a reference to Foo.class would force the static initializer +for Foo to be executed, if it has not been executed already. +In Java 5 and later, it does not. +

+

See Sun's article on Java SE compatibility +for more details and examples, and suggestions on how to force class initialization in Java 5. +

+ + +

DLS: Overwritten increment (DLS_OVERWRITTEN_INCREMENT)

+ + +

+The code performs an increment operation (e.g., i++) and then +immediately overwrites it. For example, i = i++ immediately +overwrites the incremented value with the original value. +

+ + +

DMI: Reversed method arguments (DMI_ARGUMENTS_WRONG_ORDER)

+ + +

The arguments to this method call seem to be in the wrong order. +For example, a call Preconditions.checkNotNull("message", message) +has reserved arguments: the value to be checked is the first argument. +

+ + +

DMI: Bad constant value for month (DMI_BAD_MONTH)

+ + +

+This code passes a constant month +value outside the expected range of 0..11 to a method. +

+ + +

DMI: BigDecimal constructed from double that isn't represented precisely (DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE)

+ + +

+This code creates a BigDecimal from a double value that doesn't translate well to a +decimal number. +For example, one might assume that writing new BigDecimal(0.1) in Java creates a BigDecimal which is exactly equal to 0.1 (an unscaled value of 1, with a scale of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583404541015625. +You probably want to use the BigDecimal.valueOf(double d) method, which uses the String representation +of the double to create the BigDecimal (e.g., BigDecimal.valueOf(0.1) gives 0.1). +

+ + + +

DMI: hasNext method invokes next (DMI_CALLING_NEXT_FROM_HASNEXT)

+ + +

+The hasNext() method invokes the next() method. This is almost certainly wrong, +since the hasNext() method is not supposed to change the state of the iterator, +and the next method is supposed to change the state of the iterator. +

+ + +

DMI: Collections should not contain themselves (DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES)

+ + +

This call to a generic collection's method would only make sense if a collection contained +itself (e.g., if s.contains(s) were true). This is unlikely to be true and would cause +problems if it were true (such as the computation of the hash code resulting in infinite recursion). +It is likely that the wrong value is being passed as a parameter. +

+ + +

DMI: D'oh! A nonsensical method invocation (DMI_DOH)

+ + +

+This partical method invocation doesn't make sense, for reasons that should be apparent from inspection. +

+ + + +

DMI: Invocation of hashCode on an array (DMI_INVOKING_HASHCODE_ON_ARRAY)

+ + +

+The code invokes hashCode on an array. Calling hashCode on +an array returns the same value as System.identityHashCode, and ingores +the contents and length of the array. If you need a hashCode that +depends on the contents of an array a, +use java.util.Arrays.hashCode(a). + +

+ + +

DMI: Double.longBitsToDouble invoked on an int (DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT)

+ + +

The Double.longBitsToDouble method is invoked, but a 32 bit int value is passed + as an argument. This almostly certainly is not intended and is unlikely + to give the intended result. +

+ + +

DMI: Vacuous call to collections (DMI_VACUOUS_SELF_COLLECTION_CALL)

+ + +

This call doesn't make sense. For any collection c, calling c.containsAll(c) should +always be true, and c.retainAll(c) should have no effect. +

+ + +

Dm: Can't use reflection to check for presence of annotation without runtime retention (DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION)

+ + +

Unless an annotation has itself been annotated with @Retention(RetentionPolicy.RUNTIME), the annotation can't be observed using reflection +(e.g., by using the isAnnotationPresent method). + .

+ + +

Dm: Futile attempt to change max pool size of ScheduledThreadPoolExecutor (DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR)

+ + +

(Javadoc) +While ScheduledThreadPoolExecutor inherits from ThreadPoolExecutor, a few of the inherited tuning methods are not useful for it. In particular, because it acts as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustments to maximumPoolSize have no useful effect. +

+ + + +

Dm: Creation of ScheduledThreadPoolExecutor with zero core threads (DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS)

+ + +

(Javadoc) +A ScheduledThreadPoolExecutor with zero core threads will never execute anything; changes to the max pool size are ignored. +

+ + + +

Dm: Useless/vacuous call to EasyMock method (DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD)

+ + +

This call doesn't pass any objects to the EasyMock method, so the call doesn't do anything. +

+ + + +

EC: equals() used to compare array and nonarray (EC_ARRAY_AND_NONARRAY)

+ + +

+This method invokes the .equals(Object o) to compare an array and a reference that doesn't seem +to be an array. If things being compared are of different types, they are guaranteed to be unequal +and the comparison is almost certainly an error. Even if they are both arrays, the equals method +on arrays only determines of the two arrays are the same object. +To compare the +contents of the arrays, use java.util.Arrays.equals(Object[], Object[]). +

+ + +

EC: Invocation of equals() on an array, which is equivalent to == (EC_BAD_ARRAY_COMPARE)

+ + +

+This method invokes the .equals(Object o) method on an array. Since arrays do not override the equals +method of Object, calling equals on an array is the same as comparing their addresses. To compare the +contents of the arrays, use java.util.Arrays.equals(Object[], Object[]). +To compare the addresses of the arrays, it would be +less confusing to explicitly check pointer equality using ==. +

+ + +

EC: equals(...) used to compare incompatible arrays (EC_INCOMPATIBLE_ARRAY_COMPARE)

+ + +

+This method invokes the .equals(Object o) to compare two arrays, but the arrays of +of incompatible types (e.g., String[] and StringBuffer[], or String[] and int[]). +They will never be equal. In addition, when equals(...) is used to compare arrays it +only checks to see if they are the same array, and ignores the contents of the arrays. +

+ + +

EC: Call to equals(null) (EC_NULL_ARG)

+ + +

This method calls equals(Object), passing a null value as +the argument. According to the contract of the equals() method, +this call should always return false.

+ + +

EC: Call to equals() comparing unrelated class and interface (EC_UNRELATED_CLASS_AND_INTERFACE)

+ + +

+This method calls equals(Object) on two references, one of which is a class +and the other an interface, where neither the class nor any of its +non-abstract subclasses implement the interface. +Therefore, the objects being compared +are unlikely to be members of the same class at runtime +(unless some application classes were not analyzed, or dynamic class +loading can occur at runtime). +According to the contract of equals(), +objects of different +classes should always compare as unequal; therefore, according to the +contract defined by java.lang.Object.equals(Object), +the result of this comparison will always be false at runtime. +

+ + +

EC: Call to equals() comparing different interface types (EC_UNRELATED_INTERFACES)

+ + +

This method calls equals(Object) on two references of unrelated +interface types, where neither is a subtype of the other, +and there are no known non-abstract classes which implement both interfaces. +Therefore, the objects being compared +are unlikely to be members of the same class at runtime +(unless some application classes were not analyzed, or dynamic class +loading can occur at runtime). +According to the contract of equals(), +objects of different +classes should always compare as unequal; therefore, according to the +contract defined by java.lang.Object.equals(Object), +the result of this comparison will always be false at runtime. +

+ + +

EC: Call to equals() comparing different types (EC_UNRELATED_TYPES)

+ + +

This method calls equals(Object) on two references of different +class types with no common subclasses. +Therefore, the objects being compared +are unlikely to be members of the same class at runtime +(unless some application classes were not analyzed, or dynamic class +loading can occur at runtime). +According to the contract of equals(), +objects of different +classes should always compare as unequal; therefore, according to the +contract defined by java.lang.Object.equals(Object), +the result of this comparison will always be false at runtime. +

+ + +

EC: Using pointer equality to compare different types (EC_UNRELATED_TYPES_USING_POINTER_EQUALITY)

+ + +

This method uses using pointer equality to compare two references that seem to be of +different types. The result of this comparison will always be false at runtime. +

+ + +

Eq: equals method always returns false (EQ_ALWAYS_FALSE)

+ + +

This class defines an equals method that always returns false. This means that an object is not equal to itself, and it is impossible to create useful Maps or Sets of this class. More fundamentally, it means +that equals is not reflexive, one of the requirements of the equals method.

+

The likely intended semantics are object identity: that an object is equal to itself. This is the behavior inherited from class Object. If you need to override an equals inherited from a different +superclass, you can use use:

+
+public boolean equals(Object o) { return this == o; }
+
+ + +

Eq: equals method always returns true (EQ_ALWAYS_TRUE)

+ + +

This class defines an equals method that always returns true. This is imaginative, but not very smart. +Plus, it means that the equals method is not symmetric. +

+ + +

Eq: equals method compares class names rather than class objects (EQ_COMPARING_CLASS_NAMES)

+ + +

This method checks to see if two objects are the same class by checking to see if the names +of their classes are equal. You can have different classes with the same name if they are loaded by +different class loaders. Just check to see if the class objects are the same. +

+ + +

Eq: Covariant equals() method defined for enum (EQ_DONT_DEFINE_EQUALS_FOR_ENUM)

+ + +

This class defines an enumeration, and equality on enumerations are defined +using object identity. Defining a covariant equals method for an enumeration +value is exceptionally bad practice, since it would likely result +in having two different enumeration values that compare as equals using +the covariant enum method, and as not equal when compared normally. +Don't do it. +

+ + +

Eq: equals() method defined that doesn't override equals(Object) (EQ_OTHER_NO_OBJECT)

+ + +

This class defines an equals() + method, that doesn't override the normal equals(Object) method + defined in the base java.lang.Object class.  Instead, it + inherits an equals(Object) method from a superclass. + The class should probably define a boolean equals(Object) method. +

+ + +

Eq: equals() method defined that doesn't override Object.equals(Object) (EQ_OTHER_USE_OBJECT)

+ + +

This class defines an equals() + method, that doesn't override the normal equals(Object) method + defined in the base java.lang.Object class.  + The class should probably define a boolean equals(Object) method. +

+ + +

Eq: equals method overrides equals in superclass and may not be symmetric (EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC)

+ + +

This class defines an equals method that overrides an equals method in a superclass. Both equals methods +methods use instanceof in the determination of whether two objects are equal. This is fraught with peril, +since it is important that the equals method is symmetrical (in other words, a.equals(b) == b.equals(a)). +If B is a subtype of A, and A's equals method checks that the argument is an instanceof A, and B's equals method +checks that the argument is an instanceof B, it is quite likely that the equivalence relation defined by these +methods is not symmetric. +

+ + +

Eq: Covariant equals() method defined, Object.equals(Object) inherited (EQ_SELF_USE_OBJECT)

+ + +

This class defines a covariant version of the equals() + method, but inherits the normal equals(Object) method + defined in the base java.lang.Object class.  + The class should probably define a boolean equals(Object) method. +

+ + +

FB: Missing expected or desired warning from FindBugs (FB_MISSING_EXPECTED_WARNING)

+ + +

FindBugs didn't generate generated a warning that, according to a @ExpectedWarning annotated, + is expected or desired

+ + +

FB: Unexpected/undesired warning from FindBugs (FB_UNEXPECTED_WARNING)

+ + +

FindBugs generated a warning that, according to a @NoWarning annotated, + is unexpected or undesired

+ + +

FE: Doomed test for equality to NaN (FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER)

+ + +

+ This code checks to see if a floating point value is equal to the special + Not A Number value (e.g., if (x == Double.NaN)). However, + because of the special semantics of NaN, no value + is equal to Nan, including NaN. Thus, + x == Double.NaN always evaluates to false. + + To check to see if a value contained in x + is the special Not A Number value, use + Double.isNaN(x) (or Float.isNaN(x) if + x is floating point precision). +

+ + +

FL: Method performs math using floating point precision (FL_MATH_USING_FLOAT_PRECISION)

+ + +

+ The method performs math operations using floating point precision. + Floating point precision is very imprecise. For example, + 16777216.0f + 1.0f = 16777216.0f. Consider using double math instead.

+ + +

FS: Format string placeholder incompatible with passed argument (VA_FORMAT_STRING_BAD_ARGUMENT)

+ + +

+The format string placeholder is incompatible with the corresponding +argument. For example, + + System.out.println("%d\n", "hello"); + +

The %d placeholder requires a numeric argument, but a string value is +passed instead. +A runtime exception will occur when +this statement is executed. +

+ + +

FS: The type of a supplied argument doesn't match format specifier (VA_FORMAT_STRING_BAD_CONVERSION)

+ + +

+One of the arguments is uncompatible with the corresponding format string specifier. +As a result, this will generate a runtime exception when executed. +For example, String.format("%d", "1") will generate an exception, since +the String "1" is incompatible with the format specifier %d. +

+ + +

FS: MessageFormat supplied where printf style format expected (VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED)

+ + +

+A method is called that expects a Java printf format string and a list of arguments. +However, the format string doesn't contain any format specifiers (e.g., %s) but +does contain message format elements (e.g., {0}). It is likely +that the code is supplying a MessageFormat string when a printf-style format string +is required. At runtime, all of the arguments will be ignored +and the format string will be returned exactly as provided without any formatting. +

+ + +

FS: More arguments are passed than are actually used in the format string (VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED)

+ + +

+A format-string method with a variable number of arguments is called, +but more arguments are passed than are actually used by the format string. +This won't cause a runtime exception, but the code may be silently omitting +information that was intended to be included in the formatted string. +

+ + +

FS: Illegal format string (VA_FORMAT_STRING_ILLEGAL)

+ + +

+The format string is syntactically invalid, +and a runtime exception will occur when +this statement is executed. +

+ + +

FS: Format string references missing argument (VA_FORMAT_STRING_MISSING_ARGUMENT)

+ + +

+Not enough arguments are passed to satisfy a placeholder in the format string. +A runtime exception will occur when +this statement is executed. +

+ + +

FS: No previous argument for format string (VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT)

+ + +

+The format string specifies a relative index to request that the argument for the previous format specifier +be reused. However, there is no previous argument. +For example, +

+

formatter.format("%<s %s", "a", "b") +

+

would throw a MissingFormatArgumentException when executed. +

+ + +

GC: No relationship between generic parameter and method argument (GC_UNRELATED_TYPES)

+ + +

This call to a generic collection method contains an argument + with an incompatible class from that of the collection's parameter + (i.e., the type of the argument is neither a supertype nor a subtype + of the corresponding generic type argument). + Therefore, it is unlikely that the collection contains any objects + that are equal to the method argument used here. + Most likely, the wrong value is being passed to the method.

+

In general, instances of two unrelated classes are not equal. + For example, if the Foo and Bar classes + are not related by subtyping, then an instance of Foo + should not be equal to an instance of Bar. + Among other issues, doing so will likely result in an equals method + that is not symmetrical. For example, if you define the Foo class + so that a Foo can be equal to a String, + your equals method isn't symmetrical since a String can only be equal + to a String. +

+

In rare cases, people do define nonsymmetrical equals methods and still manage to make + their code work. Although none of the APIs document or guarantee it, it is typically + the case that if you check if a Collection<String> contains + a Foo, the equals method of argument (e.g., the equals method of the + Foo class) used to perform the equality checks. +

+ + +

HE: Signature declares use of unhashable class in hashed construct (HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS)

+ + +

A method, field or class declares a generic signature where a non-hashable class +is used in context where a hashable class is required. +A class that declares an equals method but inherits a hashCode() method +from Object is unhashable, since it doesn't fulfill the requirement that +equal objects have equal hashCodes. +

+ + +

HE: Use of class without a hashCode() method in a hashed data structure (HE_USE_OF_UNHASHABLE_CLASS)

+ + +

A class defines an equals(Object) method but not a hashCode() method, +and thus doesn't fulfill the requirement that equal objects have equal hashCodes. +An instance of this class is used in a hash data structure, making the need to +fix this problem of highest importance. + + +

ICAST: int value converted to long and used as absolute time (ICAST_INT_2_LONG_AS_INSTANT)

+ + +

+This code converts a 32-bit int value to a 64-bit long value, and then +passes that value for a method parameter that requires an absolute time value. +An absolute time value is the number +of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT. +For example, the following method, intended to convert seconds since the epoc into a Date, is badly +broken:

+
+Date getDate(int seconds) { return new Date(seconds * 1000); }
+
+

The multiplication is done using 32-bit arithmetic, and then converted to a 64-bit value. +When a 32-bit value is converted to 64-bits and used to express an absolute time +value, only dates in December 1969 and January 1970 can be represented.

+ +

Correct implementations for the above method are:

+ +
+// Fails for dates after 2037
+Date getDate(int seconds) { return new Date(seconds * 1000L); }
+
+// better, works for all dates
+Date getDate(long seconds) { return new Date(seconds * 1000); }
+
+ + +

ICAST: Integral value cast to double and then passed to Math.ceil (ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL)

+ + +

+This code converts an integral value (e.g., int or long) +to a double precision +floating point number and then +passing the result to the Math.ceil() function, which rounds a double to +the next higher integer value. This operation should always be a no-op, +since the converting an integer to a double should give a number with no fractional part. +It is likely that the operation that generated the value to be passed +to Math.ceil was intended to be performed using double precision +floating point arithmetic. +

+ + + +

ICAST: int value cast to float and then passed to Math.round (ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND)

+ + +

+This code converts an int value to a float precision +floating point number and then +passing the result to the Math.round() function, which returns the int/long closest +to the argument. This operation should always be a no-op, +since the converting an integer to a float should give a number with no fractional part. +It is likely that the operation that generated the value to be passed +to Math.round was intended to be performed using +floating point arithmetic. +

+ + + +

IJU: JUnit assertion in run method will not be noticed by JUnit (IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD)

+ + +

A JUnit assertion is performed in a run method. Failed JUnit assertions +just result in exceptions being thrown. +Thus, if this exception occurs in a thread other than the thread that invokes +the test method, the exception will terminate the thread but not result +in the test failing. +

+ + +

IJU: TestCase declares a bad suite method (IJU_BAD_SUITE_METHOD)

+ + +

Class is a JUnit TestCase and defines a suite() method. +However, the suite method needs to be declared as either

+
public static junit.framework.Test suite()
+or +
public static junit.framework.TestSuite suite()
+ + +

IJU: TestCase has no tests (IJU_NO_TESTS)

+ + +

Class is a JUnit TestCase but has not implemented any test methods

+ + +

IJU: TestCase defines setUp that doesn't call super.setUp() (IJU_SETUP_NO_SUPER)

+ + +

Class is a JUnit TestCase and implements the setUp method. The setUp method should call +super.setUp(), but doesn't.

+ + +

IJU: TestCase implements a non-static suite method (IJU_SUITE_NOT_STATIC)

+ + +

Class is a JUnit TestCase and implements the suite() method. + The suite method should be declared as being static, but isn't.

+ + +

IJU: TestCase defines tearDown that doesn't call super.tearDown() (IJU_TEARDOWN_NO_SUPER)

+ + +

Class is a JUnit TestCase and implements the tearDown method. The tearDown method should call +super.tearDown(), but doesn't.

+ + +

IL: A collection is added to itself (IL_CONTAINER_ADDED_TO_ITSELF)

+ + +

A collection is added to itself. As a result, computing the hashCode of this +set will throw a StackOverflowException. +

+ + +

IL: An apparent infinite loop (IL_INFINITE_LOOP)

+ + +

This loop doesn't seem to have a way to terminate (other than by perhaps +throwing an exception).

+ + +

IL: An apparent infinite recursive loop (IL_INFINITE_RECURSIVE_LOOP)

+ + +

This method unconditionally invokes itself. This would seem to indicate +an infinite recursive loop that will result in a stack overflow.

+ + +

IM: Integer multiply of result of integer remainder (IM_MULTIPLYING_RESULT_OF_IREM)

+ + +

+The code multiplies the result of an integer remaining by an integer constant. +Be sure you don't have your operator precedence confused. For example +i % 60 * 1000 is (i % 60) * 1000, not i % (60 * 1000). +

+ + +

INT: Bad comparison of int value with long constant (INT_BAD_COMPARISON_WITH_INT_VALUE)

+ + +

This code compares an int value with a long constant that is outside +the range of values that can be represented as an int value. +This comparison is vacuous and possibily to be incorrect. +

+ + +

INT: Bad comparison of nonnegative value with negative constant (INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE)

+ + +

This code compares a value that is guaranteed to be non-negative with a negative constant. +

+ + +

INT: Bad comparison of signed byte (INT_BAD_COMPARISON_WITH_SIGNED_BYTE)

+ + +

Signed bytes can only have a value in the range -128 to 127. Comparing +a signed byte with a value outside that range is vacuous and likely to be incorrect. +To convert a signed byte b to an unsigned value in the range 0..255, +use 0xff & b +

+ + +

IO: Doomed attempt to append to an object output stream (IO_APPENDING_TO_OBJECT_OUTPUT_STREAM)

+ + +

+ This code opens a file in append mode and then wraps the result in an object output stream. + This won't allow you to append to an existing object output stream stored in a file. If you want to be + able to append to an object output stream, you need to keep the object output stream open. +

+

The only situation in which opening a file in append mode and the writing an object output stream + could work is if on reading the file you plan to open it in random access mode and seek to the byte offset + where the append started. +

+ +

+ TODO: example. +

+ + +

IP: A parameter is dead upon entry to a method but overwritten (IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN)

+ + +

+The initial value of this parameter is ignored, and the parameter +is overwritten here. This often indicates a mistaken belief that +the write to the parameter will be conveyed back to +the caller. +

+ + +

MF: Class defines field that masks a superclass field (MF_CLASS_MASKS_FIELD)

+ + +

This class defines a field with the same name as a visible +instance field in a superclass. This is confusing, and +may indicate an error if methods update or access one of +the fields when they wanted the other.

+ + +

MF: Method defines a variable that obscures a field (MF_METHOD_MASKS_FIELD)

+ + +

This method defines a local variable with the same name as a field +in this class or a superclass. This may cause the method to +read an uninitialized value from the field, leave the field uninitialized, +or both.

+ + +

NP: Null pointer dereference (NP_ALWAYS_NULL)

+ + +

A null pointer is dereferenced here.  This will lead to a +NullPointerException when the code is executed.

+ + +

NP: Null pointer dereference in method on exception path (NP_ALWAYS_NULL_EXCEPTION)

+ + +

A pointer which is null on an exception path is dereferenced here.  +This will lead to a NullPointerException when the code is executed.  +Note that because FindBugs currently does not prune infeasible exception paths, +this may be a false warning.

+ +

Also note that FindBugs considers the default case of a switch statement to +be an exception path, since the default case is often infeasible.

+ + +

NP: Method does not check for null argument (NP_ARGUMENT_MIGHT_BE_NULL)

+ + +

+ A parameter to this method has been identified as a value that should + always be checked to see whether or not it is null, but it is being dereferenced + without a preceding null check. +

+ + +

NP: close() invoked on a value that is always null (NP_CLOSING_NULL)

+ + +

close() is being invoked on a value that is always null. If this statement is executed, +a null pointer exception will occur. But the big risk here you never close +something that should be closed. + + +

NP: Null value is guaranteed to be dereferenced (NP_GUARANTEED_DEREF)

+ + +

+ There is a statement or branch that if executed guarantees that + a value is null at this point, and that + value that is guaranteed to be dereferenced + (except on forward paths involving runtime exceptions). +

+

Note that a check such as + if (x == null) throw new NullPointerException(); + is treated as a dereference of x. + + +

NP: Value is null and guaranteed to be dereferenced on exception path (NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH)

+ + +

+ There is a statement or branch on an exception path + that if executed guarantees that + a value is null at this point, and that + value that is guaranteed to be dereferenced + (except on forward paths involving runtime exceptions). +

+ + +

NP: Nonnull field is not initialized (NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)

+ + +

The field is marked as nonnull, but isn't written to by the constructor. + The field might be initialized elsewhere during constructor, or might always + be initialized before use. +

+ + +

NP: Method call passes null to a nonnull parameter (NP_NONNULL_PARAM_VIOLATION)

+ + +

+ This method passes a null value as the parameter of a method which + must be nonnull. Either this parameter has been explicitly marked + as @Nonnull, or analysis has determined that this parameter is + always dereferenced. +

+ + +

NP: Method may return null, but is declared @NonNull (NP_NONNULL_RETURN_VIOLATION)

+ + +

+ This method may return a null value, but the method (or a superclass method + which it overrides) is declared to return @NonNull. +

+ + +

NP: A known null value is checked to see if it is an instance of a type (NP_NULL_INSTANCEOF)

+ + +

+This instanceof test will always return false, since the value being checked is guaranteed to be null. +Although this is safe, make sure it isn't +an indication of some misunderstanding or some other logic error. +

+ + +

NP: Possible null pointer dereference (NP_NULL_ON_SOME_PATH)

+ + +

There is a branch of statement that, if executed, guarantees that +a null value will be dereferenced, which +would generate a NullPointerException when the code is executed. +Of course, the problem might be that the branch or statement is infeasible and that +the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs. +

+ + +

NP: Possible null pointer dereference in method on exception path (NP_NULL_ON_SOME_PATH_EXCEPTION)

+ + +

A reference value which is null on some exception control path is +dereferenced here.  This may lead to a NullPointerException +when the code is executed.  +Note that because FindBugs currently does not prune infeasible exception paths, +this may be a false warning.

+ +

Also note that FindBugs considers the default case of a switch statement to +be an exception path, since the default case is often infeasible.

+ + +

NP: Method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF)

+ + +

+ This method call passes a null value for a nonnull method parameter. + Either the parameter is annotated as a parameter that should + always be nonnull, or analysis has shown that it will always be + dereferenced. +

+ + +

NP: Method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS)

+ + +

+ A possibly-null value is passed at a call site where all known + target methods require the parameter to be nonnull. + Either the parameter is annotated as a parameter that should + always be nonnull, or analysis has shown that it will always be + dereferenced. +

+ + +

NP: Non-virtual method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF_NONVIRTUAL)

+ + +

+ A possibly-null value is passed to a nonnull method parameter. + Either the parameter is annotated as a parameter that should + always be nonnull, or analysis has shown that it will always be + dereferenced. +

+ + +

NP: Store of null value into field annotated NonNull (NP_STORE_INTO_NONNULL_FIELD)

+ + +

A value that could be null is stored into a field that has been annotated as NonNull.

+ + +

NP: Read of unwritten field (NP_UNWRITTEN_FIELD)

+ + +

The program is dereferencing a field that does not seem to ever have a non-null value written to it. +Unless the field is initialized via some mechanism not seen by the analysis, +dereferencing this value will generate a null pointer exception. +

+ + +

Nm: Class defines equal(Object); should it be equals(Object)? (NM_BAD_EQUAL)

+ + +

This class defines a method equal(Object).  This method does +not override the equals(Object) method in java.lang.Object, +which is probably what was intended.

+ + +

Nm: Class defines hashcode(); should it be hashCode()? (NM_LCASE_HASHCODE)

+ + +

This class defines a method called hashcode().  This method + does not override the hashCode() method in java.lang.Object, + which is probably what was intended.

+ + +

Nm: Class defines tostring(); should it be toString()? (NM_LCASE_TOSTRING)

+ + +

This class defines a method called tostring().  This method + does not override the toString() method in java.lang.Object, + which is probably what was intended.

+ + +

Nm: Apparent method/constructor confusion (NM_METHOD_CONSTRUCTOR_CONFUSION)

+ + +

This regular method has the same name as the class it is defined in. It is likely that this was intended to be a constructor. + If it was intended to be a constructor, remove the declaration of a void return value. + If you had accidently defined this method, realized the mistake, defined a proper constructor + but can't get rid of this method due to backwards compatibility, deprecate the method. +

+ + +

Nm: Very confusing method names (NM_VERY_CONFUSING)

+ + +

The referenced methods have names that differ only by capitalization. +This is very confusing because if the capitalization were +identical then one of the methods would override the other. +

+ + +

Nm: Method doesn't override method in superclass due to wrong package for parameter (NM_WRONG_PACKAGE)

+ + +

The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match +the type of the corresponding parameter in the superclass. For example, if you have:

+ +
+
+import alpha.Foo;
+public class A {
+  public int f(Foo x) { return 17; }
+}
+----
+import beta.Foo;
+public class B extends A {
+  public int f(Foo x) { return 42; }
+}
+
+
+ +

The f(Foo) method defined in class B doesn't +override the +f(Foo) method defined in class A, because the argument +types are Foo's from different packages. +

+ + +

QBA: Method assigns boolean literal in boolean expression (QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT)

+ + +

+ This method assigns a literal boolean value (true or false) to a boolean variable inside + an if or while expression. Most probably this was supposed to be a boolean comparison using + ==, not an assignment using =. +

+ + +

RC: Suspicious reference comparison (RC_REF_COMPARISON)

+ + +

This method compares two reference values using the == or != operator, +where the correct way to compare instances of this type is generally +with the equals() method. +It is possible to create distinct instances that are equal but do not compare as == since +they are different objects. +Examples of classes which should generally +not be compared by reference are java.lang.Integer, java.lang.Float, etc.

+ + +

RCN: Nullcheck of value previously dereferenced (RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE)

+ + +

A value is checked here to see whether it is null, but this value can't +be null because it was previously dereferenced and if it were null a null pointer +exception would have occurred at the earlier dereference. +Essentially, this code and the previous dereference +disagree as to whether this value is allowed to be null. Either the check is redundant +or the previous dereference is erroneous.

+ + +

RE: Invalid syntax for regular expression (RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION)

+ + +

+The code here uses a regular expression that is invalid according to the syntax +for regular expressions. This statement will throw a PatternSyntaxException when +executed. +

+ + +

RE: File.separator used for regular expression (RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION)

+ + +

+The code here uses File.separator +where a regular expression is required. This will fail on Windows +platforms, where the File.separator is a backslash, which is interpreted in a +regular expression as an escape character. Amoung other options, you can just use +File.separatorChar=='\\' ? "\\\\" : File.separator instead of +File.separator + +

+ + +

RE: "." or "|" used for regular expression (RE_POSSIBLE_UNINTENDED_PATTERN)

+ + +

+A String function is being invoked and "." or "|" is being passed +to a parameter that takes a regular expression as an argument. Is this what you intended? +For example +

  • s.replaceAll(".", "/") will return a String in which every character has been replaced by a '/' character +
  • s.split(".") always returns a zero length array of String +
  • "ab|cd".replaceAll("|", "/") will return "/a/b/|/c/d/" +
  • "ab|cd".split("|") will return array with six (!) elements: [, a, b, |, c, d] +

    + + +

    RV: Random value from 0 to 1 is coerced to the integer 0 (RV_01_TO_INT)

    + + +

    A random value from 0 to 1 is being coerced to the integer value 0. You probably +want to multiple the random value by something else before coercing it to an integer, or use the Random.nextInt(n) method. +

    + + +

    RV: Bad attempt to compute absolute value of signed 32-bit hashcode (RV_ABSOLUTE_VALUE_OF_HASHCODE)

    + + +

    This code generates a hashcode and then computes +the absolute value of that hashcode. If the hashcode +is Integer.MIN_VALUE, then the result will be negative as well (since +Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE). +

    +

    One out of 2^32 strings have a hashCode of Integer.MIN_VALUE, +including "polygenelubricants" "GydZG_" and ""DESIGNING WORKHOUSES". +

    + + +

    RV: Bad attempt to compute absolute value of signed random integer (RV_ABSOLUTE_VALUE_OF_RANDOM_INT)

    + + +

    This code generates a random signed integer and then computes +the absolute value of that random integer. If the number returned by the random number +generator is Integer.MIN_VALUE, then the result will be negative as well (since +Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE). (Same problem arised for long values as well). +

    + + +

    RV: Code checks for specific values returned by compareTo (RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE)

    + + +

    This code invoked a compareTo or compare method, and checks to see if the return value is a specific value, +such as 1 or -1. When invoking these methods, you should only check the sign of the result, not for any specific +non-zero value. While many or most compareTo and compare methods only return -1, 0 or 1, some of them +will return other values. + + +

    RV: Exception created and dropped rather than thrown (RV_EXCEPTION_NOT_THROWN)

    + + +

    This code creates an exception (or error) object, but doesn't do anything with it. For example, +something like

    +
    +
    +if (x < 0)
    +  new IllegalArgumentException("x must be nonnegative");
    +
    +
    +

    It was probably the intent of the programmer to throw the created exception:

    +
    +
    +if (x < 0)
    +  throw new IllegalArgumentException("x must be nonnegative");
    +
    +
    + + +

    RV: Method ignores return value (RV_RETURN_VALUE_IGNORED)

    + + +

    The return value of this method should be checked. One common +cause of this warning is to invoke a method on an immutable object, +thinking that it updates the object. For example, in the following code +fragment,

    +
    +
    +String dateString = getHeaderField(name);
    +dateString.trim();
    +
    +
    +

    the programmer seems to be thinking that the trim() method will update +the String referenced by dateString. But since Strings are immutable, the trim() +function returns a new String value, which is being ignored here. The code +should be corrected to:

    +
    +
    +String dateString = getHeaderField(name);
    +dateString = dateString.trim();
    +
    +
    + + +

    RpC: Repeated conditional tests (RpC_REPEATED_CONDITIONAL_TEST)

    + + +

    The code contains a conditional test is performed twice, one right after the other +(e.g., x == 0 || x == 0). Perhaps the second occurrence is intended to be something else +(e.g., x == 0 || y == 0). +

    + + +

    SA: Self assignment of field (SA_FIELD_SELF_ASSIGNMENT)

    + + +

    This method contains a self assignment of a field; e.g. +

    +
    +  int x;
    +  public void foo() {
    +    x = x;
    +  }
    +
    +

    Such assignments are useless, and may indicate a logic error or typo.

    + + +

    SA: Self comparison of field with itself (SA_FIELD_SELF_COMPARISON)

    + + +

    This method compares a field with itself, and may indicate a typo or +a logic error. Make sure that you are comparing the right things. +

    + + +

    SA: Nonsensical self computation involving a field (e.g., x & x) (SA_FIELD_SELF_COMPUTATION)

    + + +

    This method performs a nonsensical computation of a field with another +reference to the same field (e.g., x&x or x-x). Because of the nature +of the computation, this operation doesn't seem to make sense, +and may indicate a typo or +a logic error. Double check the computation. +

    + + +

    SA: Self assignment of local rather than assignment to field (SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD)

    + + +

    This method contains a self assignment of a local variable, and there +is a field with an identical name. +assignment appears to have been ; e.g.

    +
    +  int foo;
    +  public void setFoo(int foo) {
    +    foo = foo;
    +  }
    +
    +

    The assignment is useless. Did you mean to assign to the field instead?

    + + +

    SA: Self comparison of value with itself (SA_LOCAL_SELF_COMPARISON)

    + + +

    This method compares a local variable with itself, and may indicate a typo or +a logic error. Make sure that you are comparing the right things. +

    + + +

    SA: Nonsensical self computation involving a variable (e.g., x & x) (SA_LOCAL_SELF_COMPUTATION)

    + + +

    This method performs a nonsensical computation of a local variable with another +reference to the same variable (e.g., x&x or x-x). Because of the nature +of the computation, this operation doesn't seem to make sense, +and may indicate a typo or +a logic error. Double check the computation. +

    + + +

    SF: Dead store due to switch statement fall through (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH)

    + + +

    A value stored in the previous switch case is overwritten here due to a switch fall through. It is likely that + you forgot to put a break or return at the end of the previous case. +

    + + +

    SF: Dead store due to switch statement fall through to throw (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW)

    + + +

    A value stored in the previous switch case is ignored here due to a switch fall through to a place where + an exception is thrown. It is likely that + you forgot to put a break or return at the end of the previous case. +

    + + +

    SIC: Deadly embrace of non-static inner class and thread local (SIC_THREADLOCAL_DEADLY_EMBRACE)

    + + +

    This class is an inner class, but should probably be a static inner class. + As it is, there is a serious danger of a deadly embrace between the inner class + and the thread local in the outer class. Because the inner class isn't static, + it retains a reference to the outer class. + If the thread local contains a reference to an instance of the inner + class, the inner and outer instance will both be reachable + and not eligible for garbage collection. +

    + + +

    SIO: Unnecessary type check done using instanceof operator (SIO_SUPERFLUOUS_INSTANCEOF)

    + + +

    Type check performed using the instanceof operator where it can be statically determined whether the object +is of the type requested.

    + + +

    SQL: Method attempts to access a prepared statement parameter with index 0 (SQL_BAD_PREPARED_STATEMENT_ACCESS)

    + + +

    A call to a setXXX method of a prepared statement was made where the +parameter index is 0. As parameter indexes start at index 1, this is always a mistake.

    + + +

    SQL: Method attempts to access a result set field with index 0 (SQL_BAD_RESULTSET_ACCESS)

    + + +

    A call to getXXX or updateXXX methods of a result set was made where the +field index is 0. As ResultSet fields start at index 1, this is always a mistake.

    + + +

    STI: Unneeded use of currentThread() call, to call interrupted() (STI_INTERRUPTED_ON_CURRENTTHREAD)

    + + +

    +This method invokes the Thread.currentThread() call, just to call the interrupted() method. As interrupted() is a +static method, is more simple and clear to use Thread.interrupted(). +

    + + +

    STI: Static Thread.interrupted() method invoked on thread instance (STI_INTERRUPTED_ON_UNKNOWNTHREAD)

    + + +

    +This method invokes the Thread.interrupted() method on a Thread object that appears to be a Thread object that is +not the current thread. As the interrupted() method is static, the interrupted method will be called on a different +object than the one the author intended. +

    + + +

    Se: Method must be private in order for serialization to work (SE_METHOD_MUST_BE_PRIVATE)

    + + +

    This class implements the Serializable interface, and defines a method + for custom serialization/deserialization. But since that method isn't declared private, + it will be silently ignored by the serialization/deserialization API.

    + + +

    Se: The readResolve method must not be declared as a static method. (SE_READ_RESOLVE_IS_STATIC)

    + + +

    In order for the readResolve method to be recognized by the serialization +mechanism, it must not be declared as a static method. +

    + + +

    TQ: Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is required (TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED)

    + + +

    + A value specified as carrying a type qualifier annotation is + consumed in a location or locations requiring that the value not + carry that annotation. +

    + +

    + More precisely, a value annotated with a type qualifier specifying when=ALWAYS + is guaranteed to reach a use or uses where the same type qualifier specifies when=NEVER. +

    + +

    + For example, say that @NonNegative is a nickname for + the type qualifier annotation @Negative(when=When.NEVER). + The following code will generate this warning because + the return statement requires a @NonNegative value, + but receives one that is marked as @Negative. +

    +
    +
    +public @NonNegative Integer example(@Negative Integer value) {
    +    return value;
    +}
    +
    +
    + + +

    TQ: Comparing values with incompatible type qualifiers (TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS)

    + + +

    + A value specified as carrying a type qualifier annotation is + compared with a value that doesn't ever carry that qualifier. +

    + +

    + More precisely, a value annotated with a type qualifier specifying when=ALWAYS + is compared with a value that where the same type qualifier specifies when=NEVER. +

    + +

    + For example, say that @NonNegative is a nickname for + the type qualifier annotation @Negative(when=When.NEVER). + The following code will generate this warning because + the return statement requires a @NonNegative value, + but receives one that is marked as @Negative. +

    +
    +
    +public boolean example(@Negative Integer value1, @NonNegative Integer value2) {
    +    return value1.equals(value2);
    +}
    +
    +
    + + +

    TQ: Value that might not carry a type qualifier is always used in a way requires that type qualifier (TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK)

    + + +

    + A value that is annotated as possibility not being an instance of + the values denoted by the type qualifier, and the value is guaranteed to be used + in a way that requires values denoted by that type qualifier. +

    + + +

    TQ: Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifier (TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK)

    + + +

    + A value that is annotated as possibility being an instance of + the values denoted by the type qualifier, and the value is guaranteed to be used + in a way that prohibits values denoted by that type qualifier. +

    + + +

    TQ: Value annotated as never carrying a type qualifier used where value carrying that qualifier is required (TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED)

    + + +

    + A value specified as not carrying a type qualifier annotation is guaranteed + to be consumed in a location or locations requiring that the value does + carry that annotation. +

    + +

    + More precisely, a value annotated with a type qualifier specifying when=NEVER + is guaranteed to reach a use or uses where the same type qualifier specifies when=ALWAYS. +

    + +

    + TODO: example +

    + + +

    TQ: Value without a type qualifier used where a value is required to have that qualifier (TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED)

    + + +

    + A value is being used in a way that requires the value be annotation with a type qualifier. + The type qualifier is strict, so the tool rejects any values that do not have + the appropriate annotation. +

    + +

    + To coerce a value to have a strict annotation, define an identity function where the return value is annotated + with the strict annotation. + This is the only way to turn a non-annotated value into a value with a strict type qualifier annotation. +

    + + + +

    UMAC: Uncallable method defined in anonymous class (UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS)

    + + +

    This anonymous class defined a method that is not directly invoked and does not override +a method in a superclass. Since methods in other classes cannot directly invoke methods +declared in an anonymous class, it seems that this method is uncallable. The method +might simply be dead code, but it is also possible that the method is intended to +override a method declared in a superclass, and due to an typo or other error the method does not, +in fact, override the method it is intended to. +

    + + +

    UR: Uninitialized read of field in constructor (UR_UNINIT_READ)

    + + +

    This constructor reads a field which has not yet been assigned a value.  + This is often caused when the programmer mistakenly uses the field instead + of one of the constructor's parameters.

    + + +

    UR: Uninitialized read of field method called from constructor of superclass (UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR)

    + + +

    This method is invoked in the constructor of of the superclass. At this point, + the fields of the class have not yet initialized.

    +

    To make this more concrete, consider the following classes:

    +
    abstract class A {
    +  int hashCode;
    +  abstract Object getValue();
    +  A() {
    +    hashCode = getValue().hashCode();
    +    }
    +  }
    +class B extends A {
    +  Object value;
    +  B(Object v) {
    +    this.value = v;
    +    }
    +  Object getValue() {
    +    return value;
    +  }
    +  }
    +

    When a B is constructed, +the constructor for the A class is invoked +before the constructor for B sets value. +Thus, when the constructor for A invokes getValue, +an uninitialized value is read for value +

    + + +

    USELESS_STRING: Invocation of toString on an unnamed array (DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY)

    + + +

    +The code invokes toString on an (anonymous) array. Calling toString on an array generates a fairly useless result +such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable +String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12. +

    + + +

    USELESS_STRING: Invocation of toString on an array (DMI_INVOKING_TOSTRING_ON_ARRAY)

    + + +

    +The code invokes toString on an array, which will generate a fairly useless result +such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable +String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12. +

    + + +

    USELESS_STRING: Array formatted in useless way using format string (VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY)

    + + +

    +One of the arguments being formatted with a format string is an array. This will be formatted +using a fairly useless format, such as [I@304282, which doesn't actually show the contents +of the array. +Consider wrapping the array using Arrays.asList(...) before handling it off to a formatted. +

    + + +

    UwF: Field only ever set to null (UWF_NULL_FIELD)

    + + +

    All writes to this field are of the constant value null, and thus +all reads of the field will return null. +Check for errors, or remove it if it is useless.

    + + +

    UwF: Unwritten field (UWF_UNWRITTEN_FIELD)

    + + +

    This field is never written.  All reads of it will return the default +value. Check for errors (should it have been initialized?), or remove it if it is useless.

    + + +

    VA: Primitive array passed to function expecting a variable number of object arguments (VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG)

    + + +

    +This code passes a primitive array to a function that takes a variable number of object arguments. +This creates an array of length one to hold the primitive array and passes it to the function. +

    + + +

    VR: Class makes reference to unresolvable class or method (VR_UNRESOLVABLE_REFERENCE)

    + + +

    + This class makes a reference to a class or method that can not be + resolved using against the libraries it is being analyzed with. +

    + + +

    LG: Potential lost logger changes due to weak reference in OpenJDK (LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE)

    + + +

    OpenJDK introduces a potential incompatibility. + In particular, the java.util.logging.Logger behavior has + changed. Instead of using strong references, it now uses weak references + internally. That's a reasonable change, but unfortunately some code relies on + the old behavior - when changing logger configuration, it simply drops the + logger reference. That means that the garbage collector is free to reclaim + that memory, which means that the logger configuration is lost. For example, +consider: +

    + +
    public static void initLogging() throws Exception {
    + Logger logger = Logger.getLogger("edu.umd.cs");
    + logger.addHandler(new FileHandler()); // call to change logger configuration
    + logger.setUseParentHandlers(false); // another call to change logger configuration
    +}
    + +

    The logger reference is lost at the end of the method (it doesn't +escape the method), so if you have a garbage collection cycle just +after the call to initLogging, the logger configuration is lost +(because Logger only keeps weak references).

    + +
    public static void main(String[] args) throws Exception {
    + initLogging(); // adds a file handler to the logger
    + System.gc(); // logger configuration lost
    + Logger.getLogger("edu.umd.cs").info("Some message"); // this isn't logged to the file as expected
    +}
    +

    Ulf Ochsenfahrt and Eric Fellheimer

    + + +

    OBL: Method may fail to clean up stream or resource (OBL_UNSATISFIED_OBLIGATION)

    + + +

    + This method may fail to clean up (close, dispose of) a stream, + database object, or other + resource requiring an explicit cleanup operation. +

    + +

    + In general, if a method opens a stream or other resource, + the method should use a try/finally block to ensure that + the stream or resource is cleaned up before the method + returns. +

    + +

    + This bug pattern is essentially the same as the + OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE + bug patterns, but is based on a different + (and hopefully better) static analysis technique. + We are interested is getting feedback about the + usefulness of this bug pattern. + To send feedback, either: +

    + + +

    + In particular, + the false-positive suppression heuristics for this + bug pattern have not been extensively tuned, so + reports about false positives are helpful to us. +

    + +

    + See Weimer and Necula, Finding and Preventing Run-Time Error Handling Mistakes, for + a description of the analysis technique. +

    + + +

    OBL: Method may fail to clean up stream or resource on checked exception (OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE)

    + + +

    + This method may fail to clean up (close, dispose of) a stream, + database object, or other + resource requiring an explicit cleanup operation. +

    + +

    + In general, if a method opens a stream or other resource, + the method should use a try/finally block to ensure that + the stream or resource is cleaned up before the method + returns. +

    + +

    + This bug pattern is essentially the same as the + OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE + bug patterns, but is based on a different + (and hopefully better) static analysis technique. + We are interested is getting feedback about the + usefulness of this bug pattern. + To send feedback, either: +

    + + +

    + In particular, + the false-positive suppression heuristics for this + bug pattern have not been extensively tuned, so + reports about false positives are helpful to us. +

    + +

    + See Weimer and Necula, Finding and Preventing Run-Time Error Handling Mistakes, for + a description of the analysis technique. +

    + + +

    TEST: Testing (TESTING)

    + + +

    This bug pattern is only generated by new, incompletely implemented +bug detectors.

    + + +

    Dm: Consider using Locale parameterized version of invoked method (DM_CONVERT_CASE)

    + + +

    A String is being converted to upper or lowercase, using the platform's default encoding. This may + result in improper conversions when used with international characters. Use the

    +
      +
    • String.toUpperCase( Locale l )
    • +
    • String.toLowerCase( Locale l )
    • +
    +

    versions instead.

    + + +

    Dm: Reliance on default encoding (DM_DEFAULT_ENCODING)

    + + +

    Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.

    + + +

    DP: Classloaders should only be created inside doPrivileged block (DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED)

    + + +

    This code creates a classloader, which needs permission if a security manage is installed. + If this code might be invoked by code that does not + have security permissions, then the classloader creation needs to occur inside a doPrivileged block.

    + + +

    DP: Method invoked that should be only be invoked inside a doPrivileged block (DP_DO_INSIDE_DO_PRIVILEGED)

    + + +

    This code invokes a method that requires a security permission check. + If this code will be granted security permissions, but might be invoked by code that does not + have security permissions, then the invocation needs to occur inside a doPrivileged block.

    + + +

    EI: May expose internal representation by returning reference to mutable object (EI_EXPOSE_REP)

    + + +

    Returning a reference to a mutable object value stored in one of the object's fields + exposes the internal representation of the object.  + If instances + are accessed by untrusted code, and unchecked changes to + the mutable object would compromise security or other + important properties, you will need to do something different. + Returning a new copy of the object is better approach in many situations.

    + + +

    EI2: May expose internal representation by incorporating reference to mutable object (EI_EXPOSE_REP2)

    + + +

    This code stores a reference to an externally mutable object into the + internal representation of the object.  + If instances + are accessed by untrusted code, and unchecked changes to + the mutable object would compromise security or other + important properties, you will need to do something different. + Storing a copy of the object is better approach in many situations.

    + + +

    FI: Finalizer should be protected, not public (FI_PUBLIC_SHOULD_BE_PROTECTED)

    + + +

    A class's finalize() method should have protected access, + not public.

    + + +

    MS: May expose internal static state by storing a mutable object into a static field (EI_EXPOSE_STATIC_REP2)

    + + +

    This code stores a reference to an externally mutable object into a static + field. + If unchecked changes to + the mutable object would compromise security or other + important properties, you will need to do something different. + Storing a copy of the object is better approach in many situations.

    + + +

    MS: Field isn't final and can't be protected from malicious code (MS_CANNOT_BE_FINAL)

    + + +

    + A mutable static field could be changed by malicious code or + by accident from another package. + Unfortunately, the way the field is used doesn't allow + any easy fix to this problem.

    + + +

    MS: Public static method may expose internal representation by returning array (MS_EXPOSE_REP)

    + + +

    A public static method returns a reference to + an array that is part of the static state of the class. + Any code that calls this method can freely modify + the underlying array. + One fix is to return a copy of the array.

    + + +

    MS: Field should be both final and package protected (MS_FINAL_PKGPROTECT)

    + + +

    + A mutable static field could be changed by malicious code or + by accident from another package. + The field could be made package protected and/or made final + to avoid + this vulnerability.

    + + +

    MS: Field is a mutable array (MS_MUTABLE_ARRAY)

    + + +

    A final static field references an array + and can be accessed by malicious code or + by accident from another package. + This code can freely modify the contents of the array.

    + + +

    MS: Field is a mutable Hashtable (MS_MUTABLE_HASHTABLE)

    + + +

    A final static field references a Hashtable + and can be accessed by malicious code or + by accident from another package. + This code can freely modify the contents of the Hashtable.

    + + +

    MS: Field should be moved out of an interface and made package protected (MS_OOI_PKGPROTECT)

    + + +

    + A final static field that is +defined in an interface references a mutable + object such as an array or hashtable. + This mutable object could + be changed by malicious code or + by accident from another package. + To solve this, the field needs to be moved to a class + and made package protected + to avoid + this vulnerability.

    + + +

    MS: Field should be package protected (MS_PKGPROTECT)

    + + +

    A mutable static field could be changed by malicious code or + by accident. + The field could be made package protected to avoid + this vulnerability.

    + + +

    MS: Field isn't final but should be (MS_SHOULD_BE_FINAL)

    + + +

    +This static field public but not final, and +could be changed by malicious code or + by accident from another package. + The field could be made final to avoid + this vulnerability.

    + + +

    MS: Field isn't final but should be refactored to be so (MS_SHOULD_BE_REFACTORED_TO_BE_FINAL)

    + + +

    +This static field public but not final, and +could be changed by malicious code or +by accident from another package. +The field could be made final to avoid +this vulnerability. However, the static initializer contains more than one write +to the field, so doing so will require some refactoring. +

    + + +

    AT: Sequence of calls to concurrent abstraction may not be atomic (AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION)

    + + +

    This code contains a sequence of calls to a concurrent abstraction + (such as a concurrent hash map). + These calls will not be executed atomically. + + +

    DC: Possible double check of field (DC_DOUBLECHECK)

    + + +

    This method may contain an instance of double-checked locking.  + This idiom is not correct according to the semantics of the Java memory + model.  For more information, see the web page + http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html.

    + + +

    DL: Synchronization on Boolean (DL_SYNCHRONIZATION_ON_BOOLEAN)

    + + +

    The code synchronizes on a boxed primitive constant, such as an Boolean.

    +
    +private static Boolean inited = Boolean.FALSE;
    +...
    +  synchronized(inited) {
    +    if (!inited) {
    +       init();
    +       inited = Boolean.TRUE;
    +       }
    +     }
    +...
    +
    +

    Since there normally exist only two Boolean objects, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness +and possible deadlock

    +

    See CERT CON08-J. Do not synchronize on objects that may be reused for more information.

    + + +

    DL: Synchronization on boxed primitive (DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE)

    + + +

    The code synchronizes on a boxed primitive constant, such as an Integer.

    +
    +private static Integer count = 0;
    +...
    +  synchronized(count) {
    +     count++;
    +     }
    +...
    +
    +

    Since Integer objects can be cached and shared, +this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness +and possible deadlock

    +

    See CERT CON08-J. Do not synchronize on objects that may be reused for more information.

    + + +

    DL: Synchronization on interned String (DL_SYNCHRONIZATION_ON_SHARED_CONSTANT)

    + + +

    The code synchronizes on interned String.

    +
    +private static String LOCK = "LOCK";
    +...
    +  synchronized(LOCK) { ...}
    +...
    +
    +

    Constant Strings are interned and shared across all other classes loaded by the JVM. Thus, this could +is locking on something that other code might also be locking. This could result in very strange and hard to diagnose +blocking and deadlock behavior. See http://www.javalobby.org/java/forums/t96352.html and http://jira.codehaus.org/browse/JETTY-352. +

    +

    See CERT CON08-J. Do not synchronize on objects that may be reused for more information.

    + + +

    DL: Synchronization on boxed primitive values (DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE)

    + + +

    The code synchronizes on an apparently unshared boxed primitive, +such as an Integer.

    +
    +private static final Integer fileLock = new Integer(1);
    +...
    +  synchronized(fileLock) {
    +     .. do something ..
    +     }
    +...
    +
    +

    It would be much better, in this code, to redeclare fileLock as

    +
    +private static final Object fileLock = new Object();
    +
    +

    +The existing code might be OK, but it is confusing and a +future refactoring, such as the "Remove Boxing" refactoring in IntelliJ, +might replace this with the use of an interned Integer object shared +throughout the JVM, leading to very confusing behavior and potential deadlock. +

    + + +

    Dm: Monitor wait() called on Condition (DM_MONITOR_WAIT_ON_CONDITION)

    + + +

    + This method calls wait() on a + java.util.concurrent.locks.Condition object.  + Waiting for a Condition should be done using one of the await() + methods defined by the Condition interface. +

    + + +

    Dm: A thread was created using the default empty run method (DM_USELESS_THREAD)

    + + +

    This method creates a thread without specifying a run method either by deriving from the Thread class, or + by passing a Runnable object. This thread, then, does nothing but waste time. +

    + + +

    ESync: Empty synchronized block (ESync_EMPTY_SYNC)

    + + +

    The code contains an empty synchronized block:

    +
    +synchronized() {}
    +
    +

    Empty synchronized blocks are far more subtle and hard to use correctly +than most people recognize, and empty synchronized blocks +are almost never a better solution +than less contrived solutions. +

    + + +

    IS: Inconsistent synchronization (IS2_INCONSISTENT_SYNC)

    + + +

    The fields of this class appear to be accessed inconsistently with respect + to synchronization.  This bug report indicates that the bug pattern detector + judged that +

    +
      +
    • The class contains a mix of locked and unlocked accesses,
    • +
    • The class is not annotated as javax.annotation.concurrent.NotThreadSafe,
    • +
    • At least one locked access was performed by one of the class's own methods, and
    • +
    • The number of unsynchronized field accesses (reads and writes) was no more than + one third of all accesses, with writes being weighed twice as high as reads
    • +
    + +

    A typical bug matching this bug pattern is forgetting to synchronize + one of the methods in a class that is intended to be thread-safe.

    + +

    You can select the nodes labeled "Unsynchronized access" to show the + code locations where the detector believed that a field was accessed + without synchronization.

    + +

    Note that there are various sources of inaccuracy in this detector; + for example, the detector cannot statically detect all situations in which + a lock is held.  Also, even when the detector is accurate in + distinguishing locked vs. unlocked accesses, the code in question may still + be correct.

    + + + +

    IS: Field not guarded against concurrent access (IS_FIELD_NOT_GUARDED)

    + + +

    This field is annotated with net.jcip.annotations.GuardedBy or javax.annotation.concurrent.GuardedBy, +but can be accessed in a way that seems to violate those annotations.

    + + +

    JLM: Synchronization performed on Lock (JLM_JSR166_LOCK_MONITORENTER)

    + + +

    This method performs synchronization an object that implements +java.util.concurrent.locks.Lock. Such an object is locked/unlocked +using +acquire()/release() rather +than using the synchronized (...) construct. +

    + + +

    JLM: Synchronization performed on util.concurrent instance (JLM_JSR166_UTILCONCURRENT_MONITORENTER)

    + + +

    This method performs synchronization an object that is an instance of +a class from the java.util.concurrent package (or its subclasses). Instances +of these classes have their own concurrency control mechanisms that are orthogonal to +the synchronization provided by the Java keyword synchronized. For example, +synchronizing on an AtomicBoolean will not prevent other threads +from modifying the AtomicBoolean.

    +

    Such code may be correct, but should be carefully reviewed and documented, +and may confuse people who have to maintain the code at a later date. +

    + + +

    JLM: Using monitor style wait methods on util.concurrent abstraction (JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT)

    + + +

    This method calls +wait(), +notify() or +notifyAll()() +on an object that also provides an +await(), +signal(), +signalAll() method (such as util.concurrent Condition objects). +This probably isn't what you want, and even if you do want it, you should consider changing +your design, as other developers will find it exceptionally confusing. +

    + + +

    LI: Incorrect lazy initialization of static field (LI_LAZY_INIT_STATIC)

    + + +

    This method contains an unsynchronized lazy initialization of a non-volatile static field. +Because the compiler or processor may reorder instructions, +threads are not guaranteed to see a completely initialized object, +if the method can be called by multiple threads. +You can make the field volatile to correct the problem. +For more information, see the +Java Memory Model web site. +

    + + +

    LI: Incorrect lazy initialization and update of static field (LI_LAZY_INIT_UPDATE_STATIC)

    + + +

    This method contains an unsynchronized lazy initialization of a static field. +After the field is set, the object stored into that location is further updated or accessed. +The setting of the field is visible to other threads as soon as it is set. If the +futher accesses in the method that set the field serve to initialize the object, then +you have a very serious multithreading bug, unless something else prevents +any other thread from accessing the stored object until it is fully initialized. +

    +

    Even if you feel confident that the method is never called by multiple +threads, it might be better to not set the static field until the value +you are setting it to is fully populated/initialized. + + +

    ML: Synchronization on field in futile attempt to guard that field (ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD)

    + + +

    This method synchronizes on a field in what appears to be an attempt +to guard against simultaneous updates to that field. But guarding a field +gets a lock on the referenced object, not on the field. This may not +provide the mutual exclusion you need, and other threads might +be obtaining locks on the referenced objects (for other purposes). An example +of this pattern would be:

    +
    +private Long myNtfSeqNbrCounter = new Long(0);
    +private Long getNotificationSequenceNumber() {
    +     Long result = null;
    +     synchronized(myNtfSeqNbrCounter) {
    +         result = new Long(myNtfSeqNbrCounter.longValue() + 1);
    +         myNtfSeqNbrCounter = new Long(result.longValue());
    +     }
    +     return result;
    + }
    +
    + + +

    ML: Method synchronizes on an updated field (ML_SYNC_ON_UPDATED_FIELD)

    + + +

    This method synchronizes on an object + referenced from a mutable field. + This is unlikely to have useful semantics, since different +threads may be synchronizing on different objects.

    + + +

    MSF: Mutable servlet field (MSF_MUTABLE_SERVLET_FIELD)

    + + +

    A web server generally only creates one instance of servlet or jsp class (i.e., treats +the class as a Singleton), +and will +have multiple threads invoke methods on that instance to service multiple +simultaneous requests. +Thus, having a mutable instance field generally creates race conditions. + + +

    MWN: Mismatched notify() (MWN_MISMATCHED_NOTIFY)

    + + +

    This method calls Object.notify() or Object.notifyAll() without obviously holding a lock +on the object.  Calling notify() or notifyAll() without a lock held will result in +an IllegalMonitorStateException being thrown.

    + + +

    MWN: Mismatched wait() (MWN_MISMATCHED_WAIT)

    + + +

    This method calls Object.wait() without obviously holding a lock +on the object.  Calling wait() without a lock held will result in +an IllegalMonitorStateException being thrown.

    + + +

    NN: Naked notify (NN_NAKED_NOTIFY)

    + + +

    A call to notify() or notifyAll() + was made without any (apparent) accompanying + modification to mutable object state.  In general, calling a notify + method on a monitor is done because some condition another thread is + waiting for has become true.  However, for the condition to be meaningful, + it must involve a heap object that is visible to both threads.

    + +

    This bug does not necessarily indicate an error, since the change to + mutable object state may have taken place in a method which then called + the method containing the notification.

    + + +

    NP: Synchronize and null check on the same field. (NP_SYNC_AND_NULL_CHECK_FIELD)

    + + +

    Since the field is synchronized on, it seems not likely to be null. +If it is null and then synchronized on a NullPointerException will be +thrown and the check would be pointless. Better to synchronize on +another field.

    + + + +

    No: Using notify() rather than notifyAll() (NO_NOTIFY_NOT_NOTIFYALL)

    + + +

    This method calls notify() rather than notifyAll().  + Java monitors are often used for multiple conditions.  Calling notify() + only wakes up one thread, meaning that the thread woken up might not be the + one waiting for the condition that the caller just satisfied.

    + + +

    RS: Class's readObject() method is synchronized (RS_READOBJECT_SYNC)

    + + +

    This serializable class defines a readObject() which is + synchronized.  By definition, an object created by deserialization + is only reachable by one thread, and thus there is no need for + readObject() to be synchronized.  If the readObject() + method itself is causing the object to become visible to another thread, + that is an example of very dubious coding style.

    + + +

    RV: Return value of putIfAbsent ignored, value passed to putIfAbsent reused (RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED)

    + + + The putIfAbsent method is typically used to ensure that a + single value is associated with a given key (the first value for which put + if absent succeeds). + If you ignore the return value and retain a reference to the value passed in, + you run the risk of retaining a value that is not the one that is associated with the key in the map. + If it matters which one you use and you use the one that isn't stored in the map, + your program will behave incorrectly. + + +

    Ru: Invokes run on a thread (did you mean to start it instead?) (RU_INVOKE_RUN)

    + + +

    This method explicitly invokes run() on an object.  + In general, classes implement the Runnable interface because + they are going to have their run() method invoked in a new thread, + in which case Thread.start() is the right method to call.

    + + +

    SC: Constructor invokes Thread.start() (SC_START_IN_CTOR)

    + + +

    The constructor starts a thread. This is likely to be wrong if + the class is ever extended/subclassed, since the thread will be started + before the subclass constructor is started.

    + + +

    SP: Method spins on field (SP_SPIN_ON_FIELD)

    + + +

    This method spins in a loop which reads a field.  The compiler + may legally hoist the read out of the loop, turning the code into an + infinite loop.  The class should be changed so it uses proper + synchronization (including wait and notify calls).

    + + +

    STCAL: Call to static Calendar (STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE)

    + + +

    Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use. +The detector has found a call to an instance of Calendar that has been obtained via a static +field. This looks suspicous.

    +

    For more information on this see Sun Bug #6231579 +and Sun Bug #6178997.

    + + +

    STCAL: Call to static DateFormat (STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE)

    + + +

    As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use. +The detector has found a call to an instance of DateFormat that has been obtained via a static +field. This looks suspicous.

    +

    For more information on this see Sun Bug #6231579 +and Sun Bug #6178997.

    + + +

    STCAL: Static Calendar field (STCAL_STATIC_CALENDAR_INSTANCE)

    + + +

    Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use. +Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the +application. Under 1.4 problems seem to surface less often than under Java 5 where you will probably see +random ArrayIndexOutOfBoundsExceptions or IndexOutOfBoundsExceptions in sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate().

    +

    You may also experience serialization problems.

    +

    Using an instance field is recommended.

    +

    For more information on this see Sun Bug #6231579 +and Sun Bug #6178997.

    + + +

    STCAL: Static DateFormat (STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE)

    + + +

    As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use. +Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the +application.

    +

    You may also experience serialization problems.

    +

    Using an instance field is recommended.

    +

    For more information on this see Sun Bug #6231579 +and Sun Bug #6178997.

    + + +

    SWL: Method calls Thread.sleep() with a lock held (SWL_SLEEP_WITH_LOCK_HELD)

    + + +

    + This method calls Thread.sleep() with a lock held. This may result + in very poor performance and scalability, or a deadlock, since other threads may + be waiting to acquire the lock. It is a much better idea to call + wait() on the lock, which releases the lock and allows other threads + to run. +

    + + +

    TLW: Wait with two locks held (TLW_TWO_LOCK_WAIT)

    + + +

    Waiting on a monitor while two locks are held may cause + deadlock. +   + Performing a wait only releases the lock on the object + being waited on, not any other locks. +   +This not necessarily a bug, but is worth examining + closely.

    + + +

    UG: Unsynchronized get method, synchronized set method (UG_SYNC_SET_UNSYNC_GET)

    + + +

    This class contains similarly-named get and set + methods where the set method is synchronized and the get method is not.  + This may result in incorrect behavior at runtime, as callers of the get + method will not necessarily see a consistent state for the object.  + The get method should be made synchronized.

    + + +

    UL: Method does not release lock on all paths (UL_UNRELEASED_LOCK)

    + + +

    This method acquires a JSR-166 (java.util.concurrent) lock, +but does not release it on all paths out of the method. In general, the correct idiom +for using a JSR-166 lock is: +

    +
    +    Lock l = ...;
    +    l.lock();
    +    try {
    +        // do something
    +    } finally {
    +        l.unlock();
    +    }
    +
    + + +

    UL: Method does not release lock on all exception paths (UL_UNRELEASED_LOCK_EXCEPTION_PATH)

    + + +

    This method acquires a JSR-166 (java.util.concurrent) lock, +but does not release it on all exception paths out of the method. In general, the correct idiom +for using a JSR-166 lock is: +

    +
    +    Lock l = ...;
    +    l.lock();
    +    try {
    +        // do something
    +    } finally {
    +        l.unlock();
    +    }
    +
    + + +

    UW: Unconditional wait (UW_UNCOND_WAIT)

    + + +

    This method contains a call to java.lang.Object.wait() which + is not guarded by conditional control flow.  The code should + verify that condition it intends to wait for is not already satisfied + before calling wait; any previous notifications will be ignored. +

    + + +

    VO: An increment to a volatile field isn't atomic (VO_VOLATILE_INCREMENT)

    + + +

    This code increments a volatile field. Increments of volatile fields aren't +atomic. If more than one thread is incrementing the field at the same time, +increments could be lost. +

    + + +

    VO: A volatile reference to an array doesn't treat the array elements as volatile (VO_VOLATILE_REFERENCE_TO_ARRAY)

    + + +

    This declares a volatile reference to an array, which might not be what +you want. With a volatile reference to an array, reads and writes of +the reference to the array are treated as volatile, but the array elements +are non-volatile. To get volatile array elements, you will need to use +one of the atomic array classes in java.util.concurrent (provided +in Java 5.0).

    + + +

    WL: Synchronization on getClass rather than class literal (WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL)

    + + +

    + This instance method synchronizes on this.getClass(). If this class is subclassed, + subclasses will synchronize on the class object for the subclass, which isn't likely what was intended. + For example, consider this code from java.awt.Label:

    +
    +     private static final String base = "label";
    +     private static int nameCounter = 0;
    +     String constructComponentName() {
    +        synchronized (getClass()) {
    +            return base + nameCounter++;
    +        }
    +     }
    +     
    +

    Subclasses of Label won't synchronize on the same subclass, giving rise to a datarace. + Instead, this code should be synchronizing on Label.class

    +
    +     private static final String base = "label";
    +     private static int nameCounter = 0;
    +     String constructComponentName() {
    +        synchronized (Label.class) {
    +            return base + nameCounter++;
    +        }
    +     }
    +     
    +

    Bug pattern contributed by Jason Mehrens

    + + +

    WS: Class's writeObject() method is synchronized but nothing else is (WS_WRITEOBJECT_SYNC)

    + + +

    This class has a writeObject() method which is synchronized; + however, no other method of the class is synchronized.

    + + +

    Wa: Condition.await() not in loop (WA_AWAIT_NOT_IN_LOOP)

    + + +

    This method contains a call to java.util.concurrent.await() + (or variants) + which is not in a loop.  If the object is used for multiple conditions, + the condition the caller intended to wait for might not be the one + that actually occurred.

    + + +

    Wa: Wait not in loop (WA_NOT_IN_LOOP)

    + + +

    This method contains a call to java.lang.Object.wait() + which is not in a loop.  If the monitor is used for multiple conditions, + the condition the caller intended to wait for might not be the one + that actually occurred.

    + + +

    NOISE: Bogus warning about a field reference (NOISE_FIELD_REFERENCE)

    + + +

    Bogus warning.

    + + +

    NOISE: Bogus warning about a method call (NOISE_METHOD_CALL)

    + + +

    Bogus warning.

    + + +

    NOISE: Bogus warning about a null pointer dereference (NOISE_NULL_DEREFERENCE)

    + + +

    Bogus warning.

    + + +

    NOISE: Bogus warning about an operation (NOISE_OPERATION)

    + + +

    Bogus warning.

    + + +

    Bx: Primitive value is boxed and then immediately unboxed (BX_BOXING_IMMEDIATELY_UNBOXED)

    + + +

    A primitive is boxed, and then immediately unboxed. This probably is due to a manual + boxing in a place where an unboxed value is required, thus forcing the compiler +to immediately undo the work of the boxing. +

    + + +

    Bx: Primitive value is boxed then unboxed to perform primitive coercion (BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION)

    + + +

    A primitive boxed value constructed and then immediately converted into a different primitive type +(e.g., new Double(d).intValue()). Just perform direct primitive coercion (e.g., (int) d).

    + + +

    Bx: Boxed value is unboxed and then immediately reboxed (BX_UNBOXING_IMMEDIATELY_REBOXED)

    + + +

    A boxed value is unboxed and then immediately reboxed. +

    + + +

    Bx: Boxing/unboxing to parse a primitive (DM_BOXED_PRIMITIVE_FOR_PARSING)

    + + +

    A boxed primitive is created from a String, just to extract the unboxed primitive value. + It is more efficient to just call the static parseXXX method.

    + + +

    Bx: Method allocates a boxed primitive just to call toString (DM_BOXED_PRIMITIVE_TOSTRING)

    + + +

    A boxed primitive is allocated just to call toString(). It is more effective to just use the static + form of toString which takes the primitive value. So,

    + + + + + + + + + +
    Replace...With this...
    new Integer(1).toString()Integer.toString(1)
    new Long(1).toString()Long.toString(1)
    new Float(1.0).toString()Float.toString(1.0)
    new Double(1.0).toString()Double.toString(1.0)
    new Byte(1).toString()Byte.toString(1)
    new Short(1).toString()Short.toString(1)
    new Boolean(true).toString()Boolean.toString(true)
    + + +

    Bx: Method invokes inefficient floating-point Number constructor; use static valueOf instead (DM_FP_NUMBER_CTOR)

    + + +

    + Using new Double(double) is guaranteed to always result in a new object whereas + Double.valueOf(double) allows caching of values to be done by the compiler, class library, or JVM. + Using of cached values avoids object allocation and the code will be faster. +

    +

    + Unless the class must be compatible with JVMs predating Java 1.5, + use either autoboxing or the valueOf() method when creating instances of Double and Float. +

    + + +

    Bx: Method invokes inefficient Number constructor; use static valueOf instead (DM_NUMBER_CTOR)

    + + +

    + Using new Integer(int) is guaranteed to always result in a new object whereas + Integer.valueOf(int) allows caching of values to be done by the compiler, class library, or JVM. + Using of cached values avoids object allocation and the code will be faster. +

    +

    + Values between -128 and 127 are guaranteed to have corresponding cached instances + and using valueOf is approximately 3.5 times faster than using constructor. + For values outside the constant range the performance of both styles is the same. +

    +

    + Unless the class must be compatible with JVMs predating Java 1.5, + use either autoboxing or the valueOf() method when creating instances of + Long, Integer, Short, Character, and Byte. +

    + + +

    Dm: The equals and hashCode methods of URL are blocking (DMI_BLOCKING_METHODS_ON_URL)

    + + +

    The equals and hashCode +method of URL perform domain name resolution, this can result in a big performance hit. +See http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html for more information. +Consider using java.net.URI instead. +

    + + +

    Dm: Maps and sets of URLs can be performance hogs (DMI_COLLECTION_OF_URLS)

    + + +

    This method or field is or uses a Map or Set of URLs. Since both the equals and hashCode +method of URL perform domain name resolution, this can result in a big performance hit. +See http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html for more information. +Consider using java.net.URI instead. +

    + + +

    Dm: Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead (DM_BOOLEAN_CTOR)

    + + +

    Creating new instances of java.lang.Boolean wastes + memory, since Boolean objects are immutable and there are + only two useful values of this type.  Use the Boolean.valueOf() + method (or Java 1.5 autoboxing) to create Boolean objects instead.

    + + +

    Dm: Explicit garbage collection; extremely dubious except in benchmarking code (DM_GC)

    + + +

    Code explicitly invokes garbage collection. + Except for specific use in benchmarking, this is very dubious.

    +

    In the past, situations where people have explicitly invoked + the garbage collector in routines such as close or finalize methods + has led to huge performance black holes. Garbage collection + can be expensive. Any situation that forces hundreds or thousands + of garbage collections will bring the machine to a crawl.

    + + +

    Dm: Method allocates an object, only to get the class object (DM_NEW_FOR_GETCLASS)

    + + +

    This method allocates an object just to call getClass() on it, in order to + retrieve the Class object for it. It is simpler to just access the .class property of the class.

    + + +

    Dm: Use the nextInt method of Random rather than nextDouble to generate a random integer (DM_NEXTINT_VIA_NEXTDOUBLE)

    + + +

    If r is a java.util.Random, you can generate a random number from 0 to n-1 +using r.nextInt(n), rather than using (int)(r.nextDouble() * n). +

    +

    The argument to nextInt must be positive. If, for example, you want to generate a random +value from -99 to 0, use -r.nextInt(100). +

    + + +

    Dm: Method invokes inefficient new String(String) constructor (DM_STRING_CTOR)

    + + +

    Using the java.lang.String(String) constructor wastes memory + because the object so constructed will be functionally indistinguishable + from the String passed as a parameter.  Just use the + argument String directly.

    + + +

    Dm: Method invokes toString() method on a String (DM_STRING_TOSTRING)

    + + +

    Calling String.toString() is just a redundant operation. + Just use the String.

    + + +

    Dm: Method invokes inefficient new String() constructor (DM_STRING_VOID_CTOR)

    + + +

    Creating a new java.lang.String object using the + no-argument constructor wastes memory because the object so created will + be functionally indistinguishable from the empty string constant + "".  Java guarantees that identical string constants + will be represented by the same String object.  Therefore, + you should just use the empty string constant directly.

    + + +

    HSC: Huge string constants is duplicated across multiple class files (HSC_HUGE_SHARED_STRING_CONSTANT)

    + + +

    + A large String constant is duplicated across multiple class files. + This is likely because a final field is initialized to a String constant, and the Java language + mandates that all references to a final field from other classes be inlined into +that classfile. See JDK bug 6447475 + for a description of an occurrence of this bug in the JDK and how resolving it reduced + the size of the JDK by 1 megabyte. +

    + + +

    IMA: Method accesses a private member variable of owning class (IMA_INEFFICIENT_MEMBER_ACCESS)

    + + +

    + This method of an inner class reads from or writes to a private member variable of the owning class, + or calls a private method of the owning class. The compiler must generate a special method to access this + private member, causing this to be less efficient. Relaxing the protection of the member variable or method + will allow the compiler to treat this as a normal access. +

    + + +

    ITA: Method uses toArray() with zero-length array argument (ITA_INEFFICIENT_TO_ARRAY)

    + + +

    This method uses the toArray() method of a collection derived class, and passes +in a zero-length prototype array argument. It is more efficient to use +myCollection.toArray(new Foo[myCollection.size()]) +If the array passed in is big enough to store all of the +elements of the collection, then it is populated and returned +directly. This avoids the need to create a second array +(by reflection) to return as the result.

    + + +

    SBSC: Method concatenates strings using + in a loop (SBSC_USE_STRINGBUFFER_CONCATENATION)

    + + +

    The method seems to be building a String using concatenation in a loop. +In each iteration, the String is converted to a StringBuffer/StringBuilder, + appended to, and converted back to a String. + This can lead to a cost quadratic in the number of iterations, + as the growing string is recopied in each iteration.

    + +

    Better performance can be obtained by using +a StringBuffer (or StringBuilder in Java 1.5) explicitly.

    + +

    For example:

    +
    +  // This is bad
    +  String s = "";
    +  for (int i = 0; i < field.length; ++i) {
    +    s = s + field[i];
    +  }
    +
    +  // This is better
    +  StringBuffer buf = new StringBuffer();
    +  for (int i = 0; i < field.length; ++i) {
    +    buf.append(field[i]);
    +  }
    +  String s = buf.toString();
    +
    + + +

    SIC: Should be a static inner class (SIC_INNER_SHOULD_BE_STATIC)

    + + +

    This class is an inner class, but does not use its embedded reference + to the object which created it.  This reference makes the instances + of the class larger, and may keep the reference to the creator object + alive longer than necessary.  If possible, the class should be + made static. +

    + + +

    SIC: Could be refactored into a named static inner class (SIC_INNER_SHOULD_BE_STATIC_ANON)

    + + +

    This class is an inner class, but does not use its embedded reference + to the object which created it.  This reference makes the instances + of the class larger, and may keep the reference to the creator object + alive longer than necessary.  If possible, the class should be + made into a static inner class. Since anonymous inner +classes cannot be marked as static, doing this will require refactoring +the inner class so that it is a named inner class.

    + + +

    SIC: Could be refactored into a static inner class (SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS)

    + + +

    This class is an inner class, but does not use its embedded reference + to the object which created it except during construction of the +inner object.  This reference makes the instances + of the class larger, and may keep the reference to the creator object + alive longer than necessary.  If possible, the class should be + made into a static inner class. Since the reference to the + outer object is required during construction of the inner instance, + the inner class will need to be refactored so as to + pass a reference to the outer instance to the constructor + for the inner class.

    + + +

    SS: Unread field: should this field be static? (SS_SHOULD_BE_STATIC)

    + + +

    This class contains an instance final field that + is initialized to a compile-time static value. + Consider making the field static.

    + + +

    UM: Method calls static Math class method on a constant value (UM_UNNECESSARY_MATH)

    + + +

    This method uses a static method from java.lang.Math on a constant value. This method's +result in this case, can be determined statically, and is faster and sometimes more accurate to +just use the constant. Methods detected are: +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Parameter
    abs -any-
    acos 0.0 or 1.0
    asin 0.0 or 1.0
    atan 0.0 or 1.0
    atan2 0.0
    cbrt 0.0 or 1.0
    ceil -any-
    cos 0.0
    cosh 0.0
    exp 0.0 or 1.0
    expm1 0.0
    floor -any-
    log 0.0 or 1.0
    log10 0.0 or 1.0
    rint -any-
    round -any-
    sin 0.0
    sinh 0.0
    sqrt 0.0 or 1.0
    tan 0.0
    tanh 0.0
    toDegrees 0.0 or 1.0
    toRadians 0.0
    + + +

    UPM: Private method is never called (UPM_UNCALLED_PRIVATE_METHOD)

    + + +

    This private method is never called. Although it is +possible that the method will be invoked through reflection, +it is more likely that the method is never used, and should be +removed. +

    + + +

    UrF: Unread field (URF_UNREAD_FIELD)

    + + +

    This field is never read.  Consider removing it from the class.

    + + +

    UuF: Unused field (UUF_UNUSED_FIELD)

    + + +

    This field is never used.  Consider removing it from the class.

    + + +

    WMI: Inefficient use of keySet iterator instead of entrySet iterator (WMI_WRONG_MAP_ITERATOR)

    + + +

    This method accesses the value of a Map entry, using a key that was retrieved from +a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the +Map.get(key) lookup.

    + + +

    Dm: Hardcoded constant database password (DMI_CONSTANT_DB_PASSWORD)

    + + +

    This code creates a database connect using a hardcoded, constant password. Anyone with access to either the source code or the compiled code can + easily learn the password. +

    + + + +

    Dm: Empty database password (DMI_EMPTY_DB_PASSWORD)

    + + +

    This code creates a database connect using a blank or empty password. This indicates that the database is not protected by a password. +

    + + + +

    HRS: HTTP cookie formed from untrusted input (HRS_REQUEST_PARAMETER_TO_COOKIE)

    + + +

    This code constructs an HTTP Cookie using an untrusted HTTP parameter. If this cookie is added to an HTTP response, it will allow a HTTP response splitting +vulnerability. See http://en.wikipedia.org/wiki/HTTP_response_splitting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of HTTP response splitting. +If FindBugs found any, you almost certainly have more +vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    HRS: HTTP Response splitting vulnerability (HRS_REQUEST_PARAMETER_TO_HTTP_HEADER)

    + + +

    This code directly writes an HTTP parameter to an HTTP header, which allows for a HTTP response splitting +vulnerability. See http://en.wikipedia.org/wiki/HTTP_response_splitting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of HTTP response splitting. +If FindBugs found any, you almost certainly have more +vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    PT: Absolute path traversal in servlet (PT_ABSOLUTE_PATH_TRAVERSAL)

    + + +

    The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory, +but it does not properly neutralize absolute path sequences such as "/abs/path" that can resolve to a location that is outside of that directory. + +See http://cwe.mitre.org/data/definitions/36.html +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of absolute path traversal. +If FindBugs found any, you almost certainly have more +vulnerabilities that FindBugs doesn't report. If you are concerned about absolute path traversal, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    PT: Relative path traversal in servlet (PT_RELATIVE_PATH_TRAVERSAL)

    + + +

    The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. + +See http://cwe.mitre.org/data/definitions/23.html +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of relative path traversal. +If FindBugs found any, you almost certainly have more +vulnerabilities that FindBugs doesn't report. If you are concerned about relative path traversal, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    SQL: Nonconstant string passed to execute method on an SQL statement (SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE)

    + + +

    The method invokes the execute method on an SQL statement with a String that seems +to be dynamically generated. Consider using +a prepared statement instead. It is more efficient and less vulnerable to +SQL injection attacks. +

    + + +

    SQL: A prepared statement is generated from a nonconstant String (SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING)

    + + +

    The code creates an SQL prepared statement from a nonconstant String. +If unchecked, tainted data from a user is used in building this String, SQL injection could +be used to make the prepared statement do something unexpected and undesirable. +

    + + +

    XSS: JSP reflected cross site scripting vulnerability (XSS_REQUEST_PARAMETER_TO_JSP_WRITER)

    + + +

    This code directly writes an HTTP parameter to JSP output, which allows for a cross site scripting +vulnerability. See http://en.wikipedia.org/wiki/Cross-site_scripting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of cross site scripting. +If FindBugs found any, you almost certainly have more cross site scripting +vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + +

    XSS: Servlet reflected cross site scripting vulnerability in error page (XSS_REQUEST_PARAMETER_TO_SEND_ERROR)

    + + +

    This code directly writes an HTTP parameter to a Server error page (using HttpServletResponse.sendError). Echoing this untrusted input allows +for a reflected cross site scripting +vulnerability. See http://en.wikipedia.org/wiki/Cross-site_scripting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of cross site scripting. +If FindBugs found any, you almost certainly have more cross site scripting +vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    XSS: Servlet reflected cross site scripting vulnerability (XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER)

    + + +

    This code directly writes an HTTP parameter to Servlet output, which allows for a reflected cross site scripting +vulnerability. See http://en.wikipedia.org/wiki/Cross-site_scripting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of cross site scripting. +If FindBugs found any, you almost certainly have more cross site scripting +vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    BC: Questionable cast to abstract collection (BC_BAD_CAST_TO_ABSTRACT_COLLECTION)

    + + +

    +This code casts a Collection to an abstract collection +(such as List, Set, or Map). +Ensure that you are guaranteed that the object is of the type +you are casting to. If all you need is to be able +to iterate through a collection, you don't need to cast it to a Set or List. +

    + + +

    BC: Questionable cast to concrete collection (BC_BAD_CAST_TO_CONCRETE_COLLECTION)

    + + +

    +This code casts an abstract collection (such as a Collection, List, or Set) +to a specific concrete implementation (such as an ArrayList or HashSet). +This might not be correct, and it may make your code fragile, since +it makes it harder to switch to other concrete implementations at a future +point. Unless you have a particular reason to do so, just use the abstract +collection class. +

    + + +

    BC: Unchecked/unconfirmed cast (BC_UNCONFIRMED_CAST)

    + + +

    +This cast is unchecked, and not all instances of the type casted from can be cast to +the type it is being cast to. Check that your program logic ensures that this +cast will not fail. +

    + + +

    BC: Unchecked/unconfirmed cast of return value from method (BC_UNCONFIRMED_CAST_OF_RETURN_VALUE)

    + + +

    +This code performs an unchecked cast of the return value of a method. +The code might be calling the method in such a way that the cast is guaranteed to be +safe, but FindBugs is unable to verify that the cast is safe. Check that your program logic ensures that this +cast will not fail. +

    + + +

    BC: instanceof will always return true (BC_VACUOUS_INSTANCEOF)

    + + +

    +This instanceof test will always return true (unless the value being tested is null). +Although this is safe, make sure it isn't +an indication of some misunderstanding or some other logic error. +If you really want to test the value for being null, perhaps it would be clearer to do +better to do a null test rather than an instanceof test. +

    + + +

    BSHIFT: Unsigned right shift cast to short/byte (ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT)

    + + +

    +The code performs an unsigned right shift, whose result is then +cast to a short or byte, which discards the upper bits of the result. +Since the upper bits are discarded, there may be no difference between +a signed and unsigned right shift (depending upon the size of the shift). +

    + + +

    CD: Test for circular dependencies among classes (CD_CIRCULAR_DEPENDENCY)

    + + +

    + This class has a circular dependency with other classes. This makes building these classes + difficult, as each is dependent on the other to build correctly. Consider using interfaces + to break the hard dependency. +

    + + +

    CI: Class is final but declares protected field (CI_CONFUSED_INHERITANCE)

    + + +

    + This class is declared to be final, but declares fields to be protected. Since the class + is final, it can not be derived from, and the use of protected is confusing. The access + modifier for the field should be changed to private or public to represent the true + use for the field. +

    + + +

    DB: Method uses the same code for two branches (DB_DUPLICATE_BRANCHES)

    + + +

    + This method uses the same code to implement two branches of a conditional branch. + Check to ensure that this isn't a coding mistake. +

    + + +

    DB: Method uses the same code for two switch clauses (DB_DUPLICATE_SWITCH_CLAUSES)

    + + +

    + This method uses the same code to implement two clauses of a switch statement. + This could be a case of duplicate code, but it might also indicate + a coding mistake. +

    + + +

    DLS: Dead store to local variable (DLS_DEAD_LOCAL_STORE)

    + + +

    +This instruction assigns a value to a local variable, +but the value is not read or used in any subsequent instruction. +Often, this indicates an error, because the value computed is never +used. +

    +

    +Note that Sun's javac compiler often generates dead stores for +final local variables. Because FindBugs is a bytecode-based tool, +there is no easy way to eliminate these false positives. +

    + + +

    DLS: Useless assignment in return statement (DLS_DEAD_LOCAL_STORE_IN_RETURN)

    + + +

    +This statement assigns to a local variable in a return statement. This assignment +has effect. Please verify that this statement does the right thing. +

    + + +

    DLS: Dead store of null to local variable (DLS_DEAD_LOCAL_STORE_OF_NULL)

    + + +

    The code stores null into a local variable, and the stored value is not +read. This store may have been introduced to assist the garbage collector, but +as of Java SE 6.0, this is no longer needed or useful. +

    + + +

    DLS: Dead store to local variable that shadows field (DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD)

    + + +

    +This instruction assigns a value to a local variable, +but the value is not read or used in any subsequent instruction. +Often, this indicates an error, because the value computed is never +used. There is a field with the same name as the local variable. Did you +mean to assign to that variable instead? +

    + + +

    DMI: Code contains a hard coded reference to an absolute pathname (DMI_HARDCODED_ABSOLUTE_FILENAME)

    + + +

    This code constructs a File object using a hard coded to an absolute pathname +(e.g., new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment"); +

    + + +

    DMI: Non serializable object written to ObjectOutput (DMI_NONSERIALIZABLE_OBJECT_WRITTEN)

    + + +

    +This code seems to be passing a non-serializable object to the ObjectOutput.writeObject method. +If the object is, indeed, non-serializable, an error will result. +

    + + +

    DMI: Invocation of substring(0), which returns the original value (DMI_USELESS_SUBSTRING)

    + + +

    +This code invokes substring(0) on a String, which returns the original value. +

    + + +

    Dm: Thread passed where Runnable expected (DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED)

    + + +

    A Thread object is passed as a parameter to a method where +a Runnable is expected. This is rather unusual, and may indicate a logic error +or cause unexpected behavior. +

    + + +

    Dm: Call to unsupported method (DMI_UNSUPPORTED_METHOD)

    + + +

    All targets of this method invocation throw an UnsupportedOperationException. +

    + + + +

    Eq: Class doesn't override equals in superclass (EQ_DOESNT_OVERRIDE_EQUALS)

    + + +

    This class extends a class that defines an equals method and adds fields, but doesn't +define an equals method itself. Thus, equality on instances of this class will +ignore the identity of the subclass and the added fields. Be sure this is what is intended, +and that you don't need to override the equals method. Even if you don't need to override +the equals method, consider overriding it anyway to document the fact +that the equals method for the subclass just return the result of +invoking super.equals(o). +

    + + +

    Eq: Unusual equals method (EQ_UNUSUAL)

    + + +

    This class doesn't do any of the patterns we recognize for checking that the type of the argument +is compatible with the type of the this object. There might not be anything wrong with +this code, but it is worth reviewing. +

    + + +

    FE: Test for floating point equality (FE_FLOATING_POINT_EQUALITY)

    + + +

    + This operation compares two floating point values for equality. + Because floating point calculations may involve rounding, + calculated float and double values may not be accurate. + For values that must be precise, such as monetary values, + consider using a fixed-precision type such as BigDecimal. + For values that need not be precise, consider comparing for equality + within some range, for example: + if ( Math.abs(x - y) < .0000001 ). + See the Java Language Specification, section 4.2.4. +

    + + +

    FS: Non-Boolean argument formatted using %b format specifier (VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN)

    + + +

    +An argument not of type Boolean is being formatted with a %b format specifier. This won't throw an +exception; instead, it will print true for any nonnull value, and false for null. +This feature of format strings is strange, and may not be what you intended. +

    + + +

    IA: Potentially ambiguous invocation of either an inherited or outer method (IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD)

    + + +

    +An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class. +For example, you invoke foo(17), which is defined in both a superclass and in an outer method. +By the Java semantics, +it will be resolved to invoke the inherited method, but this may not be want +you intend. +

    +

    If you really intend to invoke the inherited method, +invoke it by invoking the method on super (e.g., invoke super.foo(17)), and +thus it will be clear to other readers of your code and to FindBugs +that you want to invoke the inherited method, not the method in the outer class. +

    +

    If you call this.foo(17), then the inherited method will be invoked. However, since FindBugs only looks at +classfiles, it +can't tell the difference between an invocation of this.foo(17) and foo(17), it will still +complain about a potential ambiguous invocation. +

    + + +

    IC: Initialization circularity (IC_INIT_CIRCULARITY)

    + + +

    A circularity was detected in the static initializers of the two + classes referenced by the bug instance.  Many kinds of unexpected + behavior may arise from such circularity.

    + + +

    ICAST: Integral division result cast to double or float (ICAST_IDIV_CAST_TO_DOUBLE)

    + + +

    +This code casts the result of an integral division (e.g., int or long division) +operation to double or +float. +Doing division on integers truncates the result +to the integer value closest to zero. The fact that the result +was cast to double suggests that this precision should have been retained. +What was probably meant was to cast one or both of the operands to +double before performing the division. Here is an example: +

    +
    +
    +int x = 2;
    +int y = 5;
    +// Wrong: yields result 0.0
    +double value1 =  x / y;
    +
    +// Right: yields result 0.4
    +double value2 =  x / (double) y;
    +
    +
    + + +

    ICAST: Result of integer multiplication cast to long (ICAST_INTEGER_MULTIPLY_CAST_TO_LONG)

    + + +

    +This code performs integer multiply and then converts the result to a long, +as in:

    +
    +    long convertDaysToMilliseconds(int days) { return 1000*3600*24*days; }
    +
    +

    +If the multiplication is done using long arithmetic, you can avoid +the possibility that the result will overflow. For example, you +could fix the above code to:

    +
    +    long convertDaysToMilliseconds(int days) { return 1000L*3600*24*days; }
    +
    +or +
    +    static final long MILLISECONDS_PER_DAY = 24L*3600*1000;
    +    long convertDaysToMilliseconds(int days) { return days * MILLISECONDS_PER_DAY; }
    +
    + + +

    IM: Computation of average could overflow (IM_AVERAGE_COMPUTATION_COULD_OVERFLOW)

    + + +

    The code computes the average of two integers using either division or signed right shift, +and then uses the result as the index of an array. +If the values being averaged are very large, this can overflow (resulting in the computation +of a negative average). Assuming that the result is intended to be nonnegative, you +can use an unsigned right shift instead. In other words, rather that using (low+high)/2, +use (low+high) >>> 1 +

    +

    This bug exists in many earlier implementations of binary search and merge sort. +Martin Buchholz found and fixed it +in the JDK libraries, and Joshua Bloch +widely +publicized the bug pattern. +

    + + +

    IM: Check for oddness that won't work for negative numbers (IM_BAD_CHECK_FOR_ODD)

    + + +

    +The code uses x % 2 == 1 to check to see if a value is odd, but this won't work +for negative numbers (e.g., (-5) % 2 == -1). If this code is intending to check +for oddness, consider using x & 1 == 1, or x % 2 != 0. +

    + + +

    INT: Integer remainder modulo 1 (INT_BAD_REM_BY_1)

    + + +

    Any expression (exp % 1) is guaranteed to always return zero. +Did you mean (exp & 1) or (exp % 2) instead? +

    + + +

    INT: Vacuous bit mask operation on integer value (INT_VACUOUS_BIT_OPERATION)

    + + +

    This is an integer bit operation (and, or, or exclusive or) that doesn't do any useful work +(e.g., v & 0xffffffff). + +

    + + +

    INT: Vacuous comparison of integer value (INT_VACUOUS_COMPARISON)

    + + +

    There is an integer comparison that always returns +the same value (e.g., x <= Integer.MAX_VALUE). +

    + + +

    MTIA: Class extends Servlet class and uses instance variables (MTIA_SUSPECT_SERVLET_INSTANCE_FIELD)

    + + +

    + This class extends from a Servlet class, and uses an instance member variable. Since only + one instance of a Servlet class is created by the J2EE framework, and used in a + multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider + only using method local variables. +

    + + +

    MTIA: Class extends Struts Action class and uses instance variables (MTIA_SUSPECT_STRUTS_INSTANCE_FIELD)

    + + +

    + This class extends from a Struts Action class, and uses an instance member variable. Since only + one instance of a struts Action class is created by the Struts framework, and used in a + multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider + only using method local variables. Only instance fields that are written outside of a monitor + are reported. +

    + + +

    NP: Dereference of the result of readLine() without nullcheck (NP_DEREFERENCE_OF_READLINE_VALUE)

    + + +

    The result of invoking readLine() is dereferenced without checking to see if the result is null. If there are no more lines of text +to read, readLine() will return null and dereferencing that will generate a null pointer exception. +

    + + +

    NP: Immediate dereference of the result of readLine() (NP_IMMEDIATE_DEREFERENCE_OF_READLINE)

    + + +

    The result of invoking readLine() is immediately dereferenced. If there are no more lines of text +to read, readLine() will return null and dereferencing that will generate a null pointer exception. +

    + + +

    NP: Load of known null value (NP_LOAD_OF_KNOWN_NULL_VALUE)

    + + +

    The variable referenced at this point is known to be null due to an earlier + check against null. Although this is valid, it might be a mistake (perhaps you +intended to refer to a different variable, or perhaps the earlier check to see if the +variable is null should have been a check to see if it was nonnull). +

    + + +

    NP: Method tightens nullness annotation on parameter (NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION)

    + +

    + A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter + that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull. + Doing so violates the contract that the method should handle a null parameter. +

    + +

    NP: Method relaxes nullness annotation on return value (NP_METHOD_RETURN_RELAXING_ANNOTATION)

    + +

    + A method should always implement the contract of a method it overrides. Thus, if a method takes is annotated + as returning a @Nonnull value, + you shouldn't override that method in a subclass with a method annotated as returning a @Nullable or @CheckForNull value. + Doing so violates the contract that the method shouldn't return null. +

    + +

    NP: Possible null pointer dereference due to return value of called method (NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE)

    + + +

    The return value from a method is dereferenced without a null check, +and the return value of that method is one that should generally be checked +for null. This may lead to a NullPointerException when the code is executed. +

    + + +

    NP: Possible null pointer dereference on branch that might be infeasible (NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE)

    + + +

    There is a branch of statement that, if executed, guarantees that +a null value will be dereferenced, which +would generate a NullPointerException when the code is executed. +Of course, the problem might be that the branch or statement is infeasible and that +the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs. +Due to the fact that this value had been previously tested for nullness, +this is a definite possibility. +

    + + +

    NP: Parameter must be nonnull but is marked as nullable (NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE)

    + + +

    This parameter is always used in a way that requires it to be nonnull, +but the parameter is explicitly annotated as being Nullable. Either the use +of the parameter or the annotation is wrong. +

    + + +

    NP: Read of unwritten public or protected field (NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)

    + + +

    The program is dereferencing a public or protected +field that does not seem to ever have a non-null value written to it. +Unless the field is initialized via some mechanism not seen by the analysis, +dereferencing this value will generate a null pointer exception. +

    + + +

    NS: Potentially dangerous use of non-short-circuit logic (NS_DANGEROUS_NON_SHORT_CIRCUIT)

    + + +

    This code seems to be using non-short-circuit logic (e.g., & +or |) +rather than short-circuit logic (&& or ||). In addition, +it seem possible that, depending on the value of the left hand side, you might not +want to evaluate the right hand side (because it would have side effects, could cause an exception +or could be expensive.

    +

    +Non-short-circuit logic causes both sides of the expression +to be evaluated even when the result can be inferred from +knowing the left-hand side. This can be less efficient and +can result in errors if the left-hand side guards cases +when evaluating the right-hand side can generate an error. +

    + +

    See the Java +Language Specification for details + +

    + + +

    NS: Questionable use of non-short-circuit logic (NS_NON_SHORT_CIRCUIT)

    + + +

    This code seems to be using non-short-circuit logic (e.g., & +or |) +rather than short-circuit logic (&& or ||). +Non-short-circuit logic causes both sides of the expression +to be evaluated even when the result can be inferred from +knowing the left-hand side. This can be less efficient and +can result in errors if the left-hand side guards cases +when evaluating the right-hand side can generate an error. + +

    See the Java +Language Specification for details + +

    + + +

    PS: Class exposes synchronization and semaphores in its public interface (PS_PUBLIC_SEMAPHORES)

    + + +

    + This class uses synchronization along with wait(), notify() or notifyAll() on itself (the this + reference). Client classes that use this class, may, in addition, use an instance of this class + as a synchronizing object. Because two classes are using the same object for synchronization, + Multithread correctness is suspect. You should not synchronize nor call semaphore methods on + a public reference. Consider using a internal private member variable to control synchronization. +

    + + +

    PZLA: Consider returning a zero length array rather than null (PZLA_PREFER_ZERO_LENGTH_ARRAYS)

    + + +

    It is often a better design to +return a length zero array rather than a null reference to indicate that there +are no results (i.e., an empty list of results). +This way, no explicit check for null is needed by clients of the method.

    + +

    On the other hand, using null to indicate +"there is no answer to this question" is probably appropriate. +For example, File.listFiles() returns an empty list +if given a directory containing no files, and returns null if the file +is not a directory.

    + + +

    QF: Complicated, subtle or wrong increment in for-loop (QF_QUESTIONABLE_FOR_LOOP)

    + + +

    Are you sure this for loop is incrementing the correct variable? + It appears that another variable is being initialized and checked + by the for loop. +

    + + +

    RCN: Redundant comparison of non-null value to null (RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE)

    + + +

    This method contains a reference known to be non-null with another reference +known to be null.

    + + +

    RCN: Redundant comparison of two null values (RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES)

    + + +

    This method contains a redundant comparison of two references known to +both be definitely null.

    + + +

    RCN: Redundant nullcheck of value known to be non-null (RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE)

    + + +

    This method contains a redundant check of a known non-null value against +the constant null.

    + + +

    RCN: Redundant nullcheck of value known to be null (RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE)

    + + +

    This method contains a redundant check of a known null value against +the constant null.

    + + +

    REC: Exception is caught when Exception is not thrown (REC_CATCH_EXCEPTION)

    + + +

    + This method uses a try-catch block that catches Exception objects, but Exception is not + thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to + say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception + each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, + masking potential bugs. +

    +

    A better approach is to either explicitly catch the specific exceptions that are thrown, + or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

    +
    +  try {
    +    ...
    +  } catch (RuntimeException e) {
    +    throw e;
    +  } catch (Exception e) {
    +    ... deal with all non-runtime exceptions ...
    +  }
    + + +

    RI: Class implements same interface as superclass (RI_REDUNDANT_INTERFACES)

    + + +

    + This class declares that it implements an interface that is also implemented by a superclass. + This is redundant because once a superclass implements an interface, all subclasses by default also + implement this interface. It may point out that the inheritance hierarchy has changed since + this class was created, and consideration should be given to the ownership of + the interface's implementation. +

    + + +

    RV: Method checks to see if result of String.indexOf is positive (RV_CHECK_FOR_POSITIVE_INDEXOF)

    + + +

    The method invokes String.indexOf and checks to see if the result is positive or non-positive. + It is much more typical to check to see if the result is negative or non-negative. It is + positive only if the substring checked for occurs at some place other than at the beginning of + the String.

    + + +

    RV: Method discards result of readLine after checking if it is nonnull (RV_DONT_JUST_NULL_CHECK_READLINE)

    + + +

    The value returned by readLine is discarded after checking to see if the return +value is non-null. In almost all situations, if the result is non-null, you will want +to use that non-null value. Calling readLine again will give you a different line.

    + + +

    RV: Remainder of hashCode could be negative (RV_REM_OF_HASHCODE)

    + + +

    This code computes a hashCode, and then computes +the remainder of that value modulo another value. Since the hashCode +can be negative, the result of the remainder operation +can also be negative.

    +

    Assuming you want to ensure that the result of your computation is nonnegative, +you may need to change your code. +If you know the divisor is a power of 2, +you can use a bitwise and operator instead (i.e., instead of +using x.hashCode()%n, use x.hashCode()&(n-1). +This is probably faster than computing the remainder as well. +If you don't know that the divisor is a power of 2, take the absolute +value of the result of the remainder operation (i.e., use +Math.abs(x.hashCode()%n) +

    + + +

    RV: Remainder of 32-bit signed random integer (RV_REM_OF_RANDOM_INT)

    + + +

    This code generates a random signed integer and then computes +the remainder of that value modulo another value. Since the random +number can be negative, the result of the remainder operation +can also be negative. Be sure this is intended, and strongly +consider using the Random.nextInt(int) method instead. +

    + + +

    RV: Method ignores return value, is this OK? (RV_RETURN_VALUE_IGNORED_INFERRED)

    + + +

    This code calls a method and ignores the return value. The return value +is the same type as the type the method is invoked on, and from our analysis it looks +like the return value might be important (e.g., like ignoring the +return value of String.toLowerCase()). +

    +

    We are guessing that ignoring the return value might be a bad idea just from +a simple analysis of the body of the method. You can use a @CheckReturnValue annotation +to instruct FindBugs as to whether ignoring the return value of this method +is important or acceptable. +

    +

    Please investigate this closely to decide whether it is OK to ignore the return value. +

    + + +

    SA: Double assignment of field (SA_FIELD_DOUBLE_ASSIGNMENT)

    + + +

    This method contains a double assignment of a field; e.g. +

    +
    +  int x,y;
    +  public void foo() {
    +    x = x = 17;
    +  }
    +
    +

    Assigning to a field twice is useless, and may indicate a logic error or typo.

    + + +

    SA: Double assignment of local variable (SA_LOCAL_DOUBLE_ASSIGNMENT)

    + + +

    This method contains a double assignment of a local variable; e.g. +

    +
    +  public void foo() {
    +    int x,y;
    +    x = x = 17;
    +  }
    +
    +

    Assigning the same value to a variable twice is useless, and may indicate a logic error or typo.

    + + +

    SA: Self assignment of local variable (SA_LOCAL_SELF_ASSIGNMENT)

    + + +

    This method contains a self assignment of a local variable; e.g.

    +
    +  public void foo() {
    +    int x = 3;
    +    x = x;
    +  }
    +
    +

    +Such assignments are useless, and may indicate a logic error or typo. +

    + + +

    SF: Switch statement found where one case falls through to the next case (SF_SWITCH_FALLTHROUGH)

    + + +

    This method contains a switch statement where one case branch will fall through to the next case. + Usually you need to end this case with a break or return.

    + + +

    SF: Switch statement found where default case is missing (SF_SWITCH_NO_DEFAULT)

    + + +

    This method contains a switch statement where default case is missing. + Usually you need to provide a default case.

    +

    Because the analysis only looks at the generated bytecode, this warning can be incorrect triggered if +the default case is at the end of the switch statement and doesn't end with a break statement. + + +

    ST: Write to static field from instance method (ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD)

    + + +

    This instance method writes to a static field. This is tricky to get +correct if multiple instances are being manipulated, +and generally bad practice. +

    + + +

    Se: Private readResolve method not inherited by subclasses (SE_PRIVATE_READ_RESOLVE_NOT_INHERITED)

    + + +

    This class defines a private readResolve method. Since it is private, it won't be inherited by subclasses. +This might be intentional and OK, but should be reviewed to ensure it is what is intended. +

    + + +

    Se: Transient field of class that isn't Serializable. (SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS)

    + + +

    The field is marked as transient, but the class isn't Serializable, so marking it as transient +has absolutely no effect. +This may be leftover marking from a previous version of the code in which the class was transient, or +it may indicate a misunderstanding of how serialization works. +

    + + +

    TQ: Value required to have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK)

    + + +

    + A value is used in a way that requires it to be always be a value denoted by a type qualifier, but + there is an explicit annotation stating that it is not known where the value is required to have that type qualifier. + Either the usage or the annotation is incorrect. +

    + + +

    TQ: Value required to not have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK)

    + + +

    + A value is used in a way that requires it to be never be a value denoted by a type qualifier, but + there is an explicit annotation stating that it is not known where the value is prohibited from having that type qualifier. + Either the usage or the annotation is incorrect. +

    + + +

    UCF: Useless control flow (UCF_USELESS_CONTROL_FLOW)

    + + +

    This method contains a useless control flow statement, where +control flow continues onto the same place regardless of whether or not +the branch is taken. For example, +this is caused by having an empty statement +block for an if statement:

    +
    +    if (argv.length == 0) {
    +    // TODO: handle this case
    +    }
    +
    + + +

    UCF: Useless control flow to next line (UCF_USELESS_CONTROL_FLOW_NEXT_LINE)

    + + +

    This method contains a useless control flow statement in which control +flow follows to the same or following line regardless of whether or not +the branch is taken. +Often, this is caused by inadvertently using an empty statement as the +body of an if statement, e.g.:

    +
    +    if (argv.length == 1);
    +        System.out.println("Hello, " + argv[0]);
    +
    + + +

    USM: Abstract Method is already defined in implemented interface (USM_USELESS_ABSTRACT_METHOD)

    + + +

    + This abstract method is already defined in an interface that is implemented by this abstract + class. This method can be removed, as it provides no additional value. +

    + + +

    USM: Method superfluously delegates to parent class method (USM_USELESS_SUBCLASS_METHOD)

    + + +

    + This derived method merely calls the same superclass method passing in the exact parameters + received. This method can be removed, as it provides no additional value. +

    + + +

    UrF: Unread public/protected field (URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD)

    + + +

    This field is never read.  +The field is public or protected, so perhaps + it is intended to be used with classes not seen as part of the analysis. If not, +consider removing it from the class.

    + + +

    UuF: Unused public or protected field (UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD)

    + + +

    This field is never used.  +The field is public or protected, so perhaps + it is intended to be used with classes not seen as part of the analysis. If not, +consider removing it from the class.

    + + +

    UwF: Field not initialized in constructor but dereferenced without null check (UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)

    + + +

    This field is never initialized within any constructor, and is therefore could be null after +the object is constructed. Elsewhere, it is loaded and dereferenced without a null check. +This could be a either an error or a questionable design, since +it means a null pointer exception will be generated if that field is dereferenced +before being initialized. +

    + + +

    UwF: Unwritten public or protected field (UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)

    + + +

    No writes were seen to this public/protected field.  All reads of it will return the default +value. Check for errors (should it have been initialized?), or remove it if it is useless.

    + + +

    XFB: Method directly allocates a specific implementation of xml interfaces (XFB_XML_FACTORY_BYPASS)

    + + +

    + This method allocates a specific implementation of an xml interface. It is preferable to use + the supplied factory classes to create these objects so that the implementation can be + changed at runtime. See +

    +
      +
    • javax.xml.parsers.DocumentBuilderFactory
    • +
    • javax.xml.parsers.SAXParserFactory
    • +
    • javax.xml.transform.TransformerFactory
    • +
    • org.w3c.dom.Document.createXXXX
    • +
    +

    for details.

    + + + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo +

  • + diff --git a/doc/bug-logo.png b/doc/bug-logo.png new file mode 100644 index 0000000..8d719d0 Binary files /dev/null and b/doc/bug-logo.png differ diff --git a/doc/bugDescriptions.html b/doc/bugDescriptions.html new file mode 100644 index 0000000..be1c9d7 --- /dev/null +++ b/doc/bugDescriptions.html @@ -0,0 +1,5325 @@ + +FindBugs Bug Descriptions + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    +

    FindBugs Bug Descriptions

    +

    This document lists the standard bug patterns reported by +FindBugs version 2.0.3.

    +

    Summary

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    DescriptionCategory
    BC: Equals method should not assume anything about the type of its argumentBad practice
    BIT: Check for sign of bitwise operationBad practice
    CN: Class implements Cloneable but does not define or use clone methodBad practice
    CN: clone method does not call super.clone()Bad practice
    CN: Class defines clone() but doesn't implement CloneableBad practice
    Co: Abstract class defines covariant compareTo() methodBad practice
    Co: Covariant compareTo() method definedBad practice
    DE: Method might drop exceptionBad practice
    DE: Method might ignore exceptionBad practice
    DMI: Adding elements of an entry set may fail due to reuse of Entry objectsBad practice
    DMI: Random object created and used only onceBad practice
    DMI: Don't use removeAll to clear a collectionBad practice
    Dm: Method invokes System.exit(...)Bad practice
    Dm: Method invokes dangerous method runFinalizersOnExitBad practice
    ES: Comparison of String parameter using == or !=Bad practice
    ES: Comparison of String objects using == or !=Bad practice
    Eq: Abstract class defines covariant equals() methodBad practice
    Eq: Equals checks for incompatible operandBad practice
    Eq: Class defines compareTo(...) and uses Object.equals()Bad practice
    Eq: equals method fails for subtypesBad practice
    Eq: Covariant equals() method definedBad practice
    FI: Empty finalizer should be deletedBad practice
    FI: Explicit invocation of finalizerBad practice
    FI: Finalizer nulls fieldsBad practice
    FI: Finalizer only nulls fieldsBad practice
    FI: Finalizer does not call superclass finalizerBad practice
    FI: Finalizer nullifies superclass finalizerBad practice
    FI: Finalizer does nothing but call superclass finalizerBad practice
    FS: Format string should use %n rather than \nBad practice
    GC: Unchecked type in generic callBad practice
    HE: Class defines equals() but not hashCode()Bad practice
    HE: Class defines equals() and uses Object.hashCode()Bad practice
    HE: Class defines hashCode() but not equals()Bad practice
    HE: Class defines hashCode() and uses Object.equals()Bad practice
    HE: Class inherits equals() and uses Object.hashCode()Bad practice
    IC: Superclass uses subclass during initializationBad practice
    IMSE: Dubious catching of IllegalMonitorStateExceptionBad practice
    ISC: Needless instantiation of class that only supplies static methodsBad practice
    It: Iterator next() method can't throw NoSuchElementExceptionBad practice
    J2EE: Store of non serializable object into HttpSessionBad practice
    JCIP: Fields of immutable classes should be finalBad practice
    NP: Method with Boolean return type returns explicit nullBad practice
    NP: Clone method may return nullBad practice
    NP: equals() method does not check for null argumentBad practice
    NP: toString method may return nullBad practice
    Nm: Class names should start with an upper case letterBad practice
    Nm: Class is not derived from an Exception, even though it is named as suchBad practice
    Nm: Confusing method namesBad practice
    Nm: Field names should start with a lower case letterBad practice
    Nm: Use of identifier that is a keyword in later versions of JavaBad practice
    Nm: Use of identifier that is a keyword in later versions of JavaBad practice
    Nm: Method names should start with a lower case letterBad practice
    Nm: Class names shouldn't shadow simple name of implemented interfaceBad practice
    Nm: Class names shouldn't shadow simple name of superclassBad practice
    Nm: Very confusing method names (but perhaps intentional)Bad practice
    Nm: Method doesn't override method in superclass due to wrong package for parameterBad practice
    ODR: Method may fail to close database resourceBad practice
    ODR: Method may fail to close database resource on exceptionBad practice
    OS: Method may fail to close streamBad practice
    OS: Method may fail to close stream on exceptionBad practice
    PZ: Don't reuse entry objects in iteratorsBad practice
    RC: Suspicious reference comparison to constantBad practice
    RC: Suspicious reference comparison of Boolean valuesBad practice
    RR: Method ignores results of InputStream.read()Bad practice
    RR: Method ignores results of InputStream.skip()Bad practice
    RV: Negating the result of compareTo()/compare()Bad practice
    RV: Method ignores exceptional return valueBad practice
    SI: Static initializer creates instance before all static final fields assignedBad practice
    SW: Certain swing methods needs to be invoked in Swing threadBad practice
    Se: Non-transient non-serializable instance field in serializable classBad practice
    Se: Non-serializable class has a serializable inner classBad practice
    Se: Non-serializable value stored into instance field of a serializable classBad practice
    Se: Comparator doesn't implement SerializableBad practice
    Se: Serializable inner classBad practice
    Se: serialVersionUID isn't finalBad practice
    Se: serialVersionUID isn't longBad practice
    Se: serialVersionUID isn't staticBad practice
    Se: Class is Serializable but its superclass doesn't define a void constructorBad practice
    Se: Class is Externalizable but doesn't define a void constructorBad practice
    Se: The readResolve method must be declared with a return type of Object. Bad practice
    Se: Transient field that isn't set by deserialization. Bad practice
    SnVI: Class is Serializable, but doesn't define serialVersionUIDBad practice
    UI: Usage of GetResource may be unsafe if class is extendedBad practice
    BC: Impossible castCorrectness
    BC: Impossible downcastCorrectness
    BC: Impossible downcast of toArray() resultCorrectness
    BC: instanceof will always return falseCorrectness
    BIT: Bitwise add of signed byte valueCorrectness
    BIT: Incompatible bit masksCorrectness
    BIT: Check to see if ((...) & 0) == 0Correctness
    BIT: Incompatible bit masksCorrectness
    BIT: Bitwise OR of signed byte valueCorrectness
    BIT: Check for sign of bitwise operationCorrectness
    BOA: Class overrides a method implemented in super class Adapter wronglyCorrectness
    BSHIFT: 32 bit int shifted by an amount not in the range -31..31Correctness
    Bx: Primitive value is unboxed and coerced for ternary operatorCorrectness
    Co: compareTo()/compare() returns Integer.MIN_VALUECorrectness
    DLS: Useless increment in return statementCorrectness
    DLS: Dead store of class literalCorrectness
    DLS: Overwritten incrementCorrectness
    DMI: Reversed method argumentsCorrectness
    DMI: Bad constant value for monthCorrectness
    DMI: BigDecimal constructed from double that isn't represented preciselyCorrectness
    DMI: hasNext method invokes nextCorrectness
    DMI: Collections should not contain themselvesCorrectness
    DMI: D'oh! A nonsensical method invocationCorrectness
    DMI: Invocation of hashCode on an arrayCorrectness
    DMI: Double.longBitsToDouble invoked on an intCorrectness
    DMI: Vacuous call to collectionsCorrectness
    Dm: Can't use reflection to check for presence of annotation without runtime retentionCorrectness
    Dm: Futile attempt to change max pool size of ScheduledThreadPoolExecutorCorrectness
    Dm: Creation of ScheduledThreadPoolExecutor with zero core threadsCorrectness
    Dm: Useless/vacuous call to EasyMock methodCorrectness
    EC: equals() used to compare array and nonarrayCorrectness
    EC: Invocation of equals() on an array, which is equivalent to ==Correctness
    EC: equals(...) used to compare incompatible arraysCorrectness
    EC: Call to equals(null)Correctness
    EC: Call to equals() comparing unrelated class and interfaceCorrectness
    EC: Call to equals() comparing different interface typesCorrectness
    EC: Call to equals() comparing different typesCorrectness
    EC: Using pointer equality to compare different typesCorrectness
    Eq: equals method always returns falseCorrectness
    Eq: equals method always returns trueCorrectness
    Eq: equals method compares class names rather than class objectsCorrectness
    Eq: Covariant equals() method defined for enumCorrectness
    Eq: equals() method defined that doesn't override equals(Object)Correctness
    Eq: equals() method defined that doesn't override Object.equals(Object)Correctness
    Eq: equals method overrides equals in superclass and may not be symmetricCorrectness
    Eq: Covariant equals() method defined, Object.equals(Object) inheritedCorrectness
    FE: Doomed test for equality to NaNCorrectness
    FS: Format string placeholder incompatible with passed argumentCorrectness
    FS: The type of a supplied argument doesn't match format specifierCorrectness
    FS: MessageFormat supplied where printf style format expectedCorrectness
    FS: More arguments are passed than are actually used in the format stringCorrectness
    FS: Illegal format stringCorrectness
    FS: Format string references missing argumentCorrectness
    FS: No previous argument for format stringCorrectness
    GC: No relationship between generic parameter and method argumentCorrectness
    HE: Signature declares use of unhashable class in hashed constructCorrectness
    HE: Use of class without a hashCode() method in a hashed data structureCorrectness
    ICAST: int value converted to long and used as absolute timeCorrectness
    ICAST: Integral value cast to double and then passed to Math.ceilCorrectness
    ICAST: int value cast to float and then passed to Math.roundCorrectness
    IJU: JUnit assertion in run method will not be noticed by JUnitCorrectness
    IJU: TestCase declares a bad suite method Correctness
    IJU: TestCase has no testsCorrectness
    IJU: TestCase defines setUp that doesn't call super.setUp()Correctness
    IJU: TestCase implements a non-static suite method Correctness
    IJU: TestCase defines tearDown that doesn't call super.tearDown()Correctness
    IL: A collection is added to itselfCorrectness
    IL: An apparent infinite loopCorrectness
    IL: An apparent infinite recursive loopCorrectness
    IM: Integer multiply of result of integer remainderCorrectness
    INT: Bad comparison of int value with long constantCorrectness
    INT: Bad comparison of nonnegative value with negative constantCorrectness
    INT: Bad comparison of signed byteCorrectness
    IO: Doomed attempt to append to an object output streamCorrectness
    IP: A parameter is dead upon entry to a method but overwrittenCorrectness
    MF: Class defines field that masks a superclass fieldCorrectness
    MF: Method defines a variable that obscures a fieldCorrectness
    NP: Null pointer dereferenceCorrectness
    NP: Null pointer dereference in method on exception pathCorrectness
    NP: Method does not check for null argumentCorrectness
    NP: close() invoked on a value that is always nullCorrectness
    NP: Null value is guaranteed to be dereferencedCorrectness
    NP: Value is null and guaranteed to be dereferenced on exception pathCorrectness
    NP: Nonnull field is not initializedCorrectness
    NP: Method call passes null to a nonnull parameter Correctness
    NP: Method may return null, but is declared @NonNullCorrectness
    NP: A known null value is checked to see if it is an instance of a typeCorrectness
    NP: Possible null pointer dereferenceCorrectness
    NP: Possible null pointer dereference in method on exception pathCorrectness
    NP: Method call passes null for nonnull parameterCorrectness
    NP: Method call passes null for nonnull parameterCorrectness
    NP: Non-virtual method call passes null for nonnull parameterCorrectness
    NP: Store of null value into field annotated NonNullCorrectness
    NP: Read of unwritten fieldCorrectness
    Nm: Class defines equal(Object); should it be equals(Object)?Correctness
    Nm: Class defines hashcode(); should it be hashCode()?Correctness
    Nm: Class defines tostring(); should it be toString()?Correctness
    Nm: Apparent method/constructor confusionCorrectness
    Nm: Very confusing method namesCorrectness
    Nm: Method doesn't override method in superclass due to wrong package for parameterCorrectness
    QBA: Method assigns boolean literal in boolean expressionCorrectness
    RC: Suspicious reference comparisonCorrectness
    RCN: Nullcheck of value previously dereferencedCorrectness
    RE: Invalid syntax for regular expressionCorrectness
    RE: File.separator used for regular expressionCorrectness
    RE: "." or "|" used for regular expressionCorrectness
    RV: Random value from 0 to 1 is coerced to the integer 0Correctness
    RV: Bad attempt to compute absolute value of signed 32-bit hashcode Correctness
    RV: Bad attempt to compute absolute value of signed random integerCorrectness
    RV: Code checks for specific values returned by compareToCorrectness
    RV: Exception created and dropped rather than thrownCorrectness
    RV: Method ignores return valueCorrectness
    RpC: Repeated conditional testsCorrectness
    SA: Self assignment of fieldCorrectness
    SA: Self comparison of field with itselfCorrectness
    SA: Nonsensical self computation involving a field (e.g., x & x)Correctness
    SA: Self assignment of local rather than assignment to fieldCorrectness
    SA: Self comparison of value with itselfCorrectness
    SA: Nonsensical self computation involving a variable (e.g., x & x)Correctness
    SF: Dead store due to switch statement fall throughCorrectness
    SF: Dead store due to switch statement fall through to throwCorrectness
    SIC: Deadly embrace of non-static inner class and thread localCorrectness
    SIO: Unnecessary type check done using instanceof operatorCorrectness
    SQL: Method attempts to access a prepared statement parameter with index 0Correctness
    SQL: Method attempts to access a result set field with index 0Correctness
    STI: Unneeded use of currentThread() call, to call interrupted() Correctness
    STI: Static Thread.interrupted() method invoked on thread instanceCorrectness
    Se: Method must be private in order for serialization to workCorrectness
    Se: The readResolve method must not be declared as a static method. Correctness
    TQ: Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is requiredCorrectness
    TQ: Comparing values with incompatible type qualifiersCorrectness
    TQ: Value that might not carry a type qualifier is always used in a way requires that type qualifierCorrectness
    TQ: Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifierCorrectness
    TQ: Value annotated as never carrying a type qualifier used where value carrying that qualifier is requiredCorrectness
    TQ: Value without a type qualifier used where a value is required to have that qualifierCorrectness
    UMAC: Uncallable method defined in anonymous classCorrectness
    UR: Uninitialized read of field in constructorCorrectness
    UR: Uninitialized read of field method called from constructor of superclassCorrectness
    USELESS_STRING: Invocation of toString on an unnamed arrayCorrectness
    USELESS_STRING: Invocation of toString on an arrayCorrectness
    USELESS_STRING: Array formatted in useless way using format stringCorrectness
    UwF: Field only ever set to nullCorrectness
    UwF: Unwritten fieldCorrectness
    VA: Primitive array passed to function expecting a variable number of object argumentsCorrectness
    LG: Potential lost logger changes due to weak reference in OpenJDKExperimental
    OBL: Method may fail to clean up stream or resourceExperimental
    OBL: Method may fail to clean up stream or resource on checked exceptionExperimental
    Dm: Consider using Locale parameterized version of invoked methodInternationalization
    Dm: Reliance on default encodingInternationalization
    DP: Classloaders should only be created inside doPrivileged blockMalicious code vulnerability
    DP: Method invoked that should be only be invoked inside a doPrivileged blockMalicious code vulnerability
    EI: May expose internal representation by returning reference to mutable objectMalicious code vulnerability
    EI2: May expose internal representation by incorporating reference to mutable objectMalicious code vulnerability
    FI: Finalizer should be protected, not publicMalicious code vulnerability
    MS: May expose internal static state by storing a mutable object into a static fieldMalicious code vulnerability
    MS: Field isn't final and can't be protected from malicious codeMalicious code vulnerability
    MS: Public static method may expose internal representation by returning arrayMalicious code vulnerability
    MS: Field should be both final and package protectedMalicious code vulnerability
    MS: Field is a mutable arrayMalicious code vulnerability
    MS: Field is a mutable HashtableMalicious code vulnerability
    MS: Field should be moved out of an interface and made package protectedMalicious code vulnerability
    MS: Field should be package protectedMalicious code vulnerability
    MS: Field isn't final but should beMalicious code vulnerability
    MS: Field isn't final but should be refactored to be soMalicious code vulnerability
    AT: Sequence of calls to concurrent abstraction may not be atomicMultithreaded correctness
    DC: Possible double check of fieldMultithreaded correctness
    DL: Synchronization on BooleanMultithreaded correctness
    DL: Synchronization on boxed primitiveMultithreaded correctness
    DL: Synchronization on interned String Multithreaded correctness
    DL: Synchronization on boxed primitive valuesMultithreaded correctness
    Dm: Monitor wait() called on ConditionMultithreaded correctness
    Dm: A thread was created using the default empty run methodMultithreaded correctness
    ESync: Empty synchronized blockMultithreaded correctness
    IS: Inconsistent synchronizationMultithreaded correctness
    IS: Field not guarded against concurrent accessMultithreaded correctness
    JLM: Synchronization performed on LockMultithreaded correctness
    JLM: Synchronization performed on util.concurrent instanceMultithreaded correctness
    JLM: Using monitor style wait methods on util.concurrent abstractionMultithreaded correctness
    LI: Incorrect lazy initialization of static fieldMultithreaded correctness
    LI: Incorrect lazy initialization and update of static fieldMultithreaded correctness
    ML: Synchronization on field in futile attempt to guard that fieldMultithreaded correctness
    ML: Method synchronizes on an updated fieldMultithreaded correctness
    MSF: Mutable servlet fieldMultithreaded correctness
    MWN: Mismatched notify()Multithreaded correctness
    MWN: Mismatched wait()Multithreaded correctness
    NN: Naked notifyMultithreaded correctness
    NP: Synchronize and null check on the same field.Multithreaded correctness
    No: Using notify() rather than notifyAll()Multithreaded correctness
    RS: Class's readObject() method is synchronizedMultithreaded correctness
    RV: Return value of putIfAbsent ignored, value passed to putIfAbsent reusedMultithreaded correctness
    Ru: Invokes run on a thread (did you mean to start it instead?)Multithreaded correctness
    SC: Constructor invokes Thread.start()Multithreaded correctness
    SP: Method spins on fieldMultithreaded correctness
    STCAL: Call to static CalendarMultithreaded correctness
    STCAL: Call to static DateFormatMultithreaded correctness
    STCAL: Static Calendar fieldMultithreaded correctness
    STCAL: Static DateFormatMultithreaded correctness
    SWL: Method calls Thread.sleep() with a lock heldMultithreaded correctness
    TLW: Wait with two locks heldMultithreaded correctness
    UG: Unsynchronized get method, synchronized set methodMultithreaded correctness
    UL: Method does not release lock on all pathsMultithreaded correctness
    UL: Method does not release lock on all exception pathsMultithreaded correctness
    UW: Unconditional waitMultithreaded correctness
    VO: An increment to a volatile field isn't atomicMultithreaded correctness
    VO: A volatile reference to an array doesn't treat the array elements as volatileMultithreaded correctness
    WL: Synchronization on getClass rather than class literalMultithreaded correctness
    WS: Class's writeObject() method is synchronized but nothing else isMultithreaded correctness
    Wa: Condition.await() not in loop Multithreaded correctness
    Wa: Wait not in loop Multithreaded correctness
    Bx: Primitive value is boxed and then immediately unboxedPerformance
    Bx: Primitive value is boxed then unboxed to perform primitive coercionPerformance
    Bx: Boxed value is unboxed and then immediately reboxedPerformance
    Bx: Boxing/unboxing to parse a primitivePerformance
    Bx: Method allocates a boxed primitive just to call toStringPerformance
    Bx: Method invokes inefficient floating-point Number constructor; use static valueOf insteadPerformance
    Bx: Method invokes inefficient Number constructor; use static valueOf insteadPerformance
    Dm: The equals and hashCode methods of URL are blockingPerformance
    Dm: Maps and sets of URLs can be performance hogsPerformance
    Dm: Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) insteadPerformance
    Dm: Explicit garbage collection; extremely dubious except in benchmarking codePerformance
    Dm: Method allocates an object, only to get the class objectPerformance
    Dm: Use the nextInt method of Random rather than nextDouble to generate a random integerPerformance
    Dm: Method invokes inefficient new String(String) constructorPerformance
    Dm: Method invokes toString() method on a StringPerformance
    Dm: Method invokes inefficient new String() constructorPerformance
    HSC: Huge string constants is duplicated across multiple class filesPerformance
    ITA: Method uses toArray() with zero-length array argumentPerformance
    SBSC: Method concatenates strings using + in a loopPerformance
    SIC: Should be a static inner classPerformance
    SIC: Could be refactored into a named static inner classPerformance
    SIC: Could be refactored into a static inner classPerformance
    SS: Unread field: should this field be static?Performance
    UM: Method calls static Math class method on a constant valuePerformance
    UPM: Private method is never calledPerformance
    UrF: Unread fieldPerformance
    UuF: Unused fieldPerformance
    WMI: Inefficient use of keySet iterator instead of entrySet iteratorPerformance
    Dm: Hardcoded constant database passwordSecurity
    Dm: Empty database passwordSecurity
    HRS: HTTP cookie formed from untrusted inputSecurity
    HRS: HTTP Response splitting vulnerabilitySecurity
    PT: Absolute path traversal in servletSecurity
    PT: Relative path traversal in servletSecurity
    SQL: Nonconstant string passed to execute method on an SQL statementSecurity
    SQL: A prepared statement is generated from a nonconstant StringSecurity
    XSS: JSP reflected cross site scripting vulnerabilitySecurity
    XSS: Servlet reflected cross site scripting vulnerability in error pageSecurity
    XSS: Servlet reflected cross site scripting vulnerabilitySecurity
    BC: Questionable cast to abstract collection Dodgy code
    BC: Questionable cast to concrete collectionDodgy code
    BC: Unchecked/unconfirmed castDodgy code
    BC: Unchecked/unconfirmed cast of return value from methodDodgy code
    BC: instanceof will always return trueDodgy code
    BSHIFT: Unsigned right shift cast to short/byteDodgy code
    CI: Class is final but declares protected fieldDodgy code
    DB: Method uses the same code for two branchesDodgy code
    DB: Method uses the same code for two switch clausesDodgy code
    DLS: Dead store to local variableDodgy code
    DLS: Useless assignment in return statementDodgy code
    DLS: Dead store of null to local variableDodgy code
    DLS: Dead store to local variable that shadows fieldDodgy code
    DMI: Code contains a hard coded reference to an absolute pathnameDodgy code
    DMI: Non serializable object written to ObjectOutputDodgy code
    DMI: Invocation of substring(0), which returns the original valueDodgy code
    Dm: Thread passed where Runnable expectedDodgy code
    Eq: Class doesn't override equals in superclassDodgy code
    Eq: Unusual equals method Dodgy code
    FE: Test for floating point equalityDodgy code
    FS: Non-Boolean argument formatted using %b format specifierDodgy code
    IA: Potentially ambiguous invocation of either an inherited or outer methodDodgy code
    IC: Initialization circularityDodgy code
    ICAST: Integral division result cast to double or floatDodgy code
    ICAST: Result of integer multiplication cast to longDodgy code
    IM: Computation of average could overflowDodgy code
    IM: Check for oddness that won't work for negative numbers Dodgy code
    INT: Integer remainder modulo 1Dodgy code
    INT: Vacuous bit mask operation on integer valueDodgy code
    INT: Vacuous comparison of integer valueDodgy code
    MTIA: Class extends Servlet class and uses instance variablesDodgy code
    MTIA: Class extends Struts Action class and uses instance variablesDodgy code
    NP: Dereference of the result of readLine() without nullcheckDodgy code
    NP: Immediate dereference of the result of readLine()Dodgy code
    NP: Load of known null valueDodgy code
    NP: Method tightens nullness annotation on parameterDodgy code
    NP: Method relaxes nullness annotation on return valueDodgy code
    NP: Possible null pointer dereference due to return value of called methodDodgy code
    NP: Possible null pointer dereference on branch that might be infeasibleDodgy code
    NP: Parameter must be nonnull but is marked as nullableDodgy code
    NP: Read of unwritten public or protected fieldDodgy code
    NS: Potentially dangerous use of non-short-circuit logicDodgy code
    NS: Questionable use of non-short-circuit logicDodgy code
    PZLA: Consider returning a zero length array rather than nullDodgy code
    QF: Complicated, subtle or wrong increment in for-loop Dodgy code
    RCN: Redundant comparison of non-null value to nullDodgy code
    RCN: Redundant comparison of two null valuesDodgy code
    RCN: Redundant nullcheck of value known to be non-nullDodgy code
    RCN: Redundant nullcheck of value known to be nullDodgy code
    REC: Exception is caught when Exception is not thrownDodgy code
    RI: Class implements same interface as superclassDodgy code
    RV: Method checks to see if result of String.indexOf is positiveDodgy code
    RV: Method discards result of readLine after checking if it is nonnullDodgy code
    RV: Remainder of hashCode could be negativeDodgy code
    RV: Remainder of 32-bit signed random integerDodgy code
    RV: Method ignores return value, is this OK?Dodgy code
    SA: Double assignment of fieldDodgy code
    SA: Double assignment of local variable Dodgy code
    SA: Self assignment of local variableDodgy code
    SF: Switch statement found where one case falls through to the next caseDodgy code
    SF: Switch statement found where default case is missingDodgy code
    ST: Write to static field from instance methodDodgy code
    Se: Private readResolve method not inherited by subclassesDodgy code
    Se: Transient field of class that isn't Serializable. Dodgy code
    TQ: Value required to have type qualifier, but marked as unknownDodgy code
    TQ: Value required to not have type qualifier, but marked as unknownDodgy code
    UCF: Useless control flowDodgy code
    UCF: Useless control flow to next lineDodgy code
    UrF: Unread public/protected fieldDodgy code
    UuF: Unused public or protected fieldDodgy code
    UwF: Field not initialized in constructor but dereferenced without null checkDodgy code
    UwF: Unwritten public or protected fieldDodgy code
    XFB: Method directly allocates a specific implementation of xml interfacesDodgy code
    +

    Descriptions

    +

    BC: Equals method should not assume anything about the type of its argument (BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS)

    + + +

    +The equals(Object o) method shouldn't make any assumptions +about the type of o. It should simply return +false if o is not the same type as this. +

    + + +

    BIT: Check for sign of bitwise operation (BIT_SIGNED_CHECK)

    + + +

    This method compares an expression such as

    +
    ((event.detail & SWT.SELECTED) > 0)
    . +

    Using bit arithmetic and then comparing with the greater than operator can +lead to unexpected results (of course depending on the value of +SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate +for a bug. Even when SWT.SELECTED is not negative, it seems good practice +to use '!= 0' instead of '> 0'. +

    +

    +Boris Bokowski +

    + + +

    CN: Class implements Cloneable but does not define or use clone method (CN_IDIOM)

    + + +

    + Class implements Cloneable but does not define or + use the clone method.

    + + +

    CN: clone method does not call super.clone() (CN_IDIOM_NO_SUPER_CALL)

    + + +

    This non-final class defines a clone() method that does not call super.clone(). +If this class ("A") is extended by a subclass ("B"), +and the subclass B calls super.clone(), then it is likely that +B's clone() method will return an object of type A, +which violates the standard contract for clone().

    + +

    If all clone() methods call super.clone(), then they are guaranteed +to use Object.clone(), which always returns an object of the correct type.

    + + +

    CN: Class defines clone() but doesn't implement Cloneable (CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE)

    + + +

    This class defines a clone() method but the class doesn't implement Cloneable. +There are some situations in which this is OK (e.g., you want to control how subclasses +can clone themselves), but just make sure that this is what you intended. +

    + + +

    Co: Abstract class defines covariant compareTo() method (CO_ABSTRACT_SELF)

    + + +

    This class defines a covariant version of compareTo().  + To correctly override the compareTo() method in the + Comparable interface, the parameter of compareTo() + must have type java.lang.Object.

    + + +

    Co: Covariant compareTo() method defined (CO_SELF_NO_OBJECT)

    + + +

    This class defines a covariant version of compareTo().  + To correctly override the compareTo() method in the + Comparable interface, the parameter of compareTo() + must have type java.lang.Object.

    + + +

    DE: Method might drop exception (DE_MIGHT_DROP)

    + + +

    This method might drop an exception.  In general, exceptions + should be handled or reported in some way, or they should be thrown + out of the method.

    + + +

    DE: Method might ignore exception (DE_MIGHT_IGNORE)

    + + +

    This method might ignore an exception.  In general, exceptions + should be handled or reported in some way, or they should be thrown + out of the method.

    + + +

    DMI: Adding elements of an entry set may fail due to reuse of Entry objects (DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS)

    + + +

    The entrySet() method is allowed to return a view of the + underlying Map in which a single Entry object is reused and returned + during the iteration. As of Java 1.6, both IdentityHashMap + and EnumMap did so. When iterating through such a Map, + the Entry value is only valid until you advance to the next iteration. + If, for example, you try to pass such an entrySet to an addAll method, + things will go badly wrong. +

    + + +

    DMI: Random object created and used only once (DMI_RANDOM_USED_ONLY_ONCE)

    + + +

    This code creates a java.util.Random object, uses it to generate one random number, and then discards +the Random object. This produces mediocre quality random numbers and is inefficient. +If possible, rewrite the code so that the Random object is created once and saved, and each time a new random number +is required invoke a method on the existing Random object to obtain it. +

    + +

    If it is important that the generated Random numbers not be guessable, you must not create a new Random for each random +number; the values are too easily guessable. You should strongly consider using a java.security.SecureRandom instead +(and avoid allocating a new SecureRandom for each random number needed). +

    + + +

    DMI: Don't use removeAll to clear a collection (DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION)

    + + +

    If you want to remove all elements from a collection c, use c.clear, +not c.removeAll(c). Calling c.removeAll(c) to clear a collection +is less clear, susceptible to errors from typos, less efficient and +for some collections, might throw a ConcurrentModificationException. +

    + + +

    Dm: Method invokes System.exit(...) (DM_EXIT)

    + + +

    Invoking System.exit shuts down the entire Java virtual machine. This + should only been done when it is appropriate. Such calls make it + hard or impossible for your code to be invoked by other code. + Consider throwing a RuntimeException instead.

    + + +

    Dm: Method invokes dangerous method runFinalizersOnExit (DM_RUN_FINALIZERS_ON_EXIT)

    + + +

    Never call System.runFinalizersOnExit +or Runtime.runFinalizersOnExit for any reason: they are among the most +dangerous methods in the Java libraries. -- Joshua Bloch

    + + +

    ES: Comparison of String parameter using == or != (ES_COMPARING_PARAMETER_STRING_WITH_EQ)

    + + +

    This code compares a java.lang.String parameter for reference +equality using the == or != operators. Requiring callers to +pass only String constants or interned strings to a method is unnecessarily +fragile, and rarely leads to measurable performance gains. Consider +using the equals(Object) method instead.

    + + +

    ES: Comparison of String objects using == or != (ES_COMPARING_STRINGS_WITH_EQ)

    + + +

    This code compares java.lang.String objects for reference +equality using the == or != operators. +Unless both strings are either constants in a source file, or have been +interned using the String.intern() method, the same string +value may be represented by two different String objects. Consider +using the equals(Object) method instead.

    + + +

    Eq: Abstract class defines covariant equals() method (EQ_ABSTRACT_SELF)

    + + +

    This class defines a covariant version of equals().  + To correctly override the equals() method in + java.lang.Object, the parameter of equals() + must have type java.lang.Object.

    + + +

    Eq: Equals checks for incompatible operand (EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS)

    + + +

    This equals method is checking to see if the argument is some incompatible type +(i.e., a class that is neither a supertype nor subtype of the class that defines +the equals method). For example, the Foo class might have an equals method +that looks like: +

    +
    +public boolean equals(Object o) {
    +  if (o instanceof Foo)
    +    return name.equals(((Foo)o).name);
    +  else if (o instanceof String)
    +    return name.equals(o);
    +  else return false;
    +
    + +

    This is considered bad practice, as it makes it very hard to implement an equals method that +is symmetric and transitive. Without those properties, very unexpected behavoirs are possible. +

    + + +

    Eq: Class defines compareTo(...) and uses Object.equals() (EQ_COMPARETO_USE_OBJECT_EQUALS)

    + + +

    This class defines a compareTo(...) method but inherits its + equals() method from java.lang.Object. + Generally, the value of compareTo should return zero if and only if + equals returns true. If this is violated, weird and unpredictable + failures will occur in classes such as PriorityQueue. + In Java 5 the PriorityQueue.remove method uses the compareTo method, + while in Java 6 it uses the equals method. + +

    From the JavaDoc for the compareTo method in the Comparable interface: +

    +It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). +Generally speaking, any class that implements the Comparable interface and violates this condition +should clearly indicate this fact. The recommended language +is "Note: this class has a natural ordering that is inconsistent with equals." +
    + + +

    Eq: equals method fails for subtypes (EQ_GETCLASS_AND_CLASS_CONSTANT)

    + + +

    This class has an equals method that will be broken if it is inherited by subclasses. +It compares a class literal with the class of the argument (e.g., in class Foo +it might check if Foo.class == o.getClass()). +It is better to check if this.getClass() == o.getClass(). +

    + + +

    Eq: Covariant equals() method defined (EQ_SELF_NO_OBJECT)

    + + +

    This class defines a covariant version of equals().  + To correctly override the equals() method in + java.lang.Object, the parameter of equals() + must have type java.lang.Object.

    + + +

    FI: Empty finalizer should be deleted (FI_EMPTY)

    + + +

    Empty finalize() methods are useless, so they should + be deleted.

    + + +

    FI: Explicit invocation of finalizer (FI_EXPLICIT_INVOCATION)

    + + +

    This method contains an explicit invocation of the finalize() + method on an object.  Because finalizer methods are supposed to be + executed once, and only by the VM, this is a bad idea.

    +

    If a connected set of objects beings finalizable, then the VM will invoke the +finalize method on all the finalizable object, possibly at the same time in different threads. +Thus, it is a particularly bad idea, in the finalize method for a class X, invoke finalize +on objects referenced by X, because they may already be getting finalized in a separate thread. + + +

    FI: Finalizer nulls fields (FI_FINALIZER_NULLS_FIELDS)

    + + +

    This finalizer nulls out fields. This is usually an error, as it does not aid garbage collection, + and the object is going to be garbage collected anyway. + + +

    FI: Finalizer only nulls fields (FI_FINALIZER_ONLY_NULLS_FIELDS)

    + + +

    This finalizer does nothing except null out fields. This is completely pointless, and requires that +the object be garbage collected, finalized, and then garbage collected again. You should just remove the finalize +method. + + +

    FI: Finalizer does not call superclass finalizer (FI_MISSING_SUPER_CALL)

    + + +

    This finalize() method does not make a call to its + superclass's finalize() method.  So, any finalizer + actions defined for the superclass will not be performed.  + Add a call to super.finalize().

    + + +

    FI: Finalizer nullifies superclass finalizer (FI_NULLIFY_SUPER)

    + + +

    This empty finalize() method explicitly negates the + effect of any finalizer defined by its superclass.  Any finalizer + actions defined for the superclass will not be performed.  + Unless this is intended, delete this method.

    + + +

    FI: Finalizer does nothing but call superclass finalizer (FI_USELESS)

    + + +

    The only thing this finalize() method does is call + the superclass's finalize() method, making it + redundant.  Delete it.

    + + +

    FS: Format string should use %n rather than \n (VA_FORMAT_STRING_USES_NEWLINE)

    + + +

    +This format string include a newline character (\n). In format strings, it is generally + preferable better to use %n, which will produce the platform-specific line separator. +

    + + +

    GC: Unchecked type in generic call (GC_UNCHECKED_TYPE_IN_GENERIC_CALL)

    + + +

    This call to a generic collection method passes an argument + while compile type Object where a specific type from + the generic type parameters is expected. + Thus, neither the standard Java type system nor static analysis + can provide useful information on whether the + object being passed as a parameter is of an appropriate type. +

    + + +

    HE: Class defines equals() but not hashCode() (HE_EQUALS_NO_HASHCODE)

    + + +

    This class overrides equals(Object), but does not + override hashCode().  Therefore, the class may violate the + invariant that equal objects must have equal hashcodes.

    + + +

    HE: Class defines equals() and uses Object.hashCode() (HE_EQUALS_USE_HASHCODE)

    + + +

    This class overrides equals(Object), but does not + override hashCode(), and inherits the implementation of + hashCode() from java.lang.Object (which returns + the identity hash code, an arbitrary value assigned to the object + by the VM).  Therefore, the class is very likely to violate the + invariant that equal objects must have equal hashcodes.

    + +

    If you don't think instances of this class will ever be inserted into a HashMap/HashTable, +the recommended hashCode implementation to use is:

    +
    public int hashCode() {
    +  assert false : "hashCode not designed";
    +  return 42; // any arbitrary constant will do
    +  }
    + + +

    HE: Class defines hashCode() but not equals() (HE_HASHCODE_NO_EQUALS)

    + + +

    This class defines a hashCode() method but not an + equals() method.  Therefore, the class may + violate the invariant that equal objects must have equal hashcodes.

    + + +

    HE: Class defines hashCode() and uses Object.equals() (HE_HASHCODE_USE_OBJECT_EQUALS)

    + + +

    This class defines a hashCode() method but inherits its + equals() method from java.lang.Object + (which defines equality by comparing object references).  Although + this will probably satisfy the contract that equal objects must have + equal hashcodes, it is probably not what was intended by overriding + the hashCode() method.  (Overriding hashCode() + implies that the object's identity is based on criteria more complicated + than simple reference equality.)

    +

    If you don't think instances of this class will ever be inserted into a HashMap/HashTable, +the recommended hashCode implementation to use is:

    +
    public int hashCode() {
    +  assert false : "hashCode not designed";
    +  return 42; // any arbitrary constant will do
    +  }
    + + +

    HE: Class inherits equals() and uses Object.hashCode() (HE_INHERITS_EQUALS_USE_HASHCODE)

    + + +

    This class inherits equals(Object) from an abstract + superclass, and hashCode() from +java.lang.Object (which returns + the identity hash code, an arbitrary value assigned to the object + by the VM).  Therefore, the class is very likely to violate the + invariant that equal objects must have equal hashcodes.

    + +

    If you don't want to define a hashCode method, and/or don't + believe the object will ever be put into a HashMap/Hashtable, + define the hashCode() method + to throw UnsupportedOperationException.

    + + +

    IC: Superclass uses subclass during initialization (IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION)

    + + +

    During the initialization of a class, the class makes an active use of a subclass. +That subclass will not yet be initialized at the time of this use. +For example, in the following code, foo will be null.

    + +
    +public class CircularClassInitialization {
    +    static class InnerClassSingleton extends CircularClassInitialization {
    +        static InnerClassSingleton singleton = new InnerClassSingleton();
    +    }
    +
    +    static CircularClassInitialization foo = InnerClassSingleton.singleton;
    +}
    +
    + + + +

    IMSE: Dubious catching of IllegalMonitorStateException (IMSE_DONT_CATCH_IMSE)

    + + +

    IllegalMonitorStateException is generally only + thrown in case of a design flaw in your code (calling wait or + notify on an object you do not hold a lock on).

    + + +

    ISC: Needless instantiation of class that only supplies static methods (ISC_INSTANTIATE_STATIC_CLASS)

    + + +

    This class allocates an object that is based on a class that only supplies static methods. This object +does not need to be created, just access the static methods directly using the class name as a qualifier.

    + + +

    It: Iterator next() method can't throw NoSuchElementException (IT_NO_SUCH_ELEMENT)

    + + +

    This class implements the java.util.Iterator interface.  + However, its next() method is not capable of throwing + java.util.NoSuchElementException.  The next() + method should be changed so it throws NoSuchElementException + if is called when there are no more elements to return.

    + + +

    J2EE: Store of non serializable object into HttpSession (J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION)

    + + +

    +This code seems to be storing a non-serializable object into an HttpSession. +If this session is passivated or migrated, an error will result. +

    + + +

    JCIP: Fields of immutable classes should be final (JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS)

    + + +

    The class is annotated with net.jcip.annotations.Immutable or javax.annotation.concurrent.Immutable, + and the rules for those annotations require that all fields are final. + .

    + + +

    NP: Method with Boolean return type returns explicit null (NP_BOOLEAN_RETURN_NULL)

    + + +

    + A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. + This method can be invoked as though it returned a value of type boolean, and + the compiler will insert automatic unboxing of the Boolean value. If a null value is returned, + this will result in a NullPointerException. +

    + + +

    NP: Clone method may return null (NP_CLONE_COULD_RETURN_NULL)

    + + +

    + This clone method seems to return null in some circumstances, but clone is never + allowed to return a null value. If you are convinced this path is unreachable, throw an AssertionError + instead. +

    + + +

    NP: equals() method does not check for null argument (NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT)

    + + +

    + This implementation of equals(Object) violates the contract defined + by java.lang.Object.equals() because it does not check for null + being passed as the argument. All equals() methods should return + false if passed a null value. +

    + + +

    NP: toString method may return null (NP_TOSTRING_COULD_RETURN_NULL)

    + + +

    + This toString method seems to return null in some circumstances. A liberal reading of the + spec could be interpreted as allowing this, but it is probably a bad idea and could cause + other code to break. Return the empty string or some other appropriate string rather than null. +

    + + +

    Nm: Class names should start with an upper case letter (NM_CLASS_NAMING_CONVENTION)

    + + +

    Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML). +

    + + +

    Nm: Class is not derived from an Exception, even though it is named as such (NM_CLASS_NOT_EXCEPTION)

    + + +

    This class is not derived from another exception, but ends with 'Exception'. This will +be confusing to users of this class.

    + + +

    Nm: Confusing method names (NM_CONFUSING)

    + + +

    The referenced methods have names that differ only by capitalization.

    + + +

    Nm: Field names should start with a lower case letter (NM_FIELD_NAMING_CONVENTION)

    + + +

    +Names of fields that are not final should be in mixed case with a lowercase first letter and the first letters of subsequent words capitalized. +

    + + +

    Nm: Use of identifier that is a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER)

    + + +

    The identifier is a word that is reserved as a keyword in later versions of Java, and your code will need to be changed +in order to compile it in later versions of Java.

    + + + +

    Nm: Use of identifier that is a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER)

    + + +

    This identifier is used as a keyword in later versions of Java. This code, and +any code that references this API, +will need to be changed in order to compile it in later versions of Java.

    + + + +

    Nm: Method names should start with a lower case letter (NM_METHOD_NAMING_CONVENTION)

    + + +

    +Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. +

    + + +

    Nm: Class names shouldn't shadow simple name of implemented interface (NM_SAME_SIMPLE_NAME_AS_INTERFACE)

    + + +

    This class/interface has a simple name that is identical to that of an implemented/extended interface, except +that the interface is in a different package (e.g., alpha.Foo extends beta.Foo). +This can be exceptionally confusing, create lots of situations in which you have to look at import statements +to resolve references and creates many +opportunities to accidently define methods that do not override methods in their superclasses. +

    + + +

    Nm: Class names shouldn't shadow simple name of superclass (NM_SAME_SIMPLE_NAME_AS_SUPERCLASS)

    + + +

    This class has a simple name that is identical to that of its superclass, except +that its superclass is in a different package (e.g., alpha.Foo extends beta.Foo). +This can be exceptionally confusing, create lots of situations in which you have to look at import statements +to resolve references and creates many +opportunities to accidently define methods that do not override methods in their superclasses. +

    + + +

    Nm: Very confusing method names (but perhaps intentional) (NM_VERY_CONFUSING_INTENTIONAL)

    + + +

    The referenced methods have names that differ only by capitalization. +This is very confusing because if the capitalization were +identical then one of the methods would override the other. From the existence of other methods, it +seems that the existence of both of these methods is intentional, but is sure is confusing. +You should try hard to eliminate one of them, unless you are forced to have both due to frozen APIs. +

    + + +

    Nm: Method doesn't override method in superclass due to wrong package for parameter (NM_WRONG_PACKAGE_INTENTIONAL)

    + + +

    The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match +the type of the corresponding parameter in the superclass. For example, if you have:

    + +
    +
    +import alpha.Foo;
    +public class A {
    +  public int f(Foo x) { return 17; }
    +}
    +----
    +import beta.Foo;
    +public class B extends A {
    +  public int f(Foo x) { return 42; }
    +  public int f(alpha.Foo x) { return 27; }
    +}
    +
    +
    + +

    The f(Foo) method defined in class B doesn't +override the +f(Foo) method defined in class A, because the argument +types are Foo's from different packages. +

    + +

    In this case, the subclass does define a method with a signature identical to the method in the superclass, +so this is presumably understood. However, such methods are exceptionally confusing. You should strongly consider +removing or deprecating the method with the similar but not identical signature. +

    + + +

    ODR: Method may fail to close database resource (ODR_OPEN_DATABASE_RESOURCE)

    + + +

    The method creates a database resource (such as a database connection +or row set), does not assign it to any +fields, pass it to other methods, or return it, and does not appear to close +the object on all paths out of the method.  Failure to +close database resources on all paths out of a method may +result in poor performance, and could cause the application to +have problems communicating with the database. +

    + + +

    ODR: Method may fail to close database resource on exception (ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH)

    + + +

    The method creates a database resource (such as a database connection +or row set), does not assign it to any +fields, pass it to other methods, or return it, and does not appear to close +the object on all exception paths out of the method.  Failure to +close database resources on all paths out of a method may +result in poor performance, and could cause the application to +have problems communicating with the database.

    + + +

    OS: Method may fail to close stream (OS_OPEN_STREAM)

    + + +

    The method creates an IO stream object, does not assign it to any +fields, pass it to other methods that might close it, +or return it, and does not appear to close +the stream on all paths out of the method.  This may result in +a file descriptor leak.  It is generally a good +idea to use a finally block to ensure that streams are +closed.

    + + +

    OS: Method may fail to close stream on exception (OS_OPEN_STREAM_EXCEPTION_PATH)

    + + +

    The method creates an IO stream object, does not assign it to any +fields, pass it to other methods, or return it, and does not appear to close +it on all possible exception paths out of the method.  +This may result in a file descriptor leak.  It is generally a good +idea to use a finally block to ensure that streams are +closed.

    + + +

    PZ: Don't reuse entry objects in iterators (PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS)

    + + +

    The entrySet() method is allowed to return a view of the + underlying Map in which an Iterator and Map.Entry. This clever + idea was used in several Map implementations, but introduces the possibility + of nasty coding mistakes. If a map m returns + such an iterator for an entrySet, then + c.addAll(m.entrySet()) will go badly wrong. All of + the Map implementations in OpenJDK 1.7 have been rewritten to avoid this, + you should to. +

    + + +

    RC: Suspicious reference comparison to constant (RC_REF_COMPARISON_BAD_PRACTICE)

    + + +

    This method compares a reference value to a constant using the == or != operator, +where the correct way to compare instances of this type is generally +with the equals() method. +It is possible to create distinct instances that are equal but do not compare as == since +they are different objects. +Examples of classes which should generally +not be compared by reference are java.lang.Integer, java.lang.Float, etc.

    + + +

    RC: Suspicious reference comparison of Boolean values (RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN)

    + + +

    This method compares two Boolean values using the == or != operator. +Normally, there are only two Boolean values (Boolean.TRUE and Boolean.FALSE), +but it is possible to create other Boolean objects using the new Boolean(b) +constructor. It is best to avoid such objects, but if they do exist, +then checking Boolean objects for equality using == or != will give results +than are different than you would get using .equals(...) +

    + + +

    RR: Method ignores results of InputStream.read() (RR_NOT_CHECKED)

    + + +

    This method ignores the return value of one of the variants of + java.io.InputStream.read() which can return multiple bytes.  + If the return value is not checked, the caller will not be able to correctly + handle the case where fewer bytes were read than the caller requested.  + This is a particularly insidious kind of bug, because in many programs, + reads from input streams usually do read the full amount of data requested, + causing the program to fail only sporadically.

    + + +

    RR: Method ignores results of InputStream.skip() (SR_NOT_CHECKED)

    + + +

    This method ignores the return value of + java.io.InputStream.skip() which can skip multiple bytes.  + If the return value is not checked, the caller will not be able to correctly + handle the case where fewer bytes were skipped than the caller requested.  + This is a particularly insidious kind of bug, because in many programs, + skips from input streams usually do skip the full amount of data requested, + causing the program to fail only sporadically. With Buffered streams, however, + skip() will only skip data in the buffer, and will routinely fail to skip the + requested number of bytes.

    + + +

    RV: Negating the result of compareTo()/compare() (RV_NEGATING_RESULT_OF_COMPARETO)

    + + +

    This code negatives the return value of a compareTo or compare method. +This is a questionable or bad programming practice, since if the return +value is Integer.MIN_VALUE, negating the return value won't +negate the sign of the result. You can achieve the same intended result +by reversing the order of the operands rather than by negating the results. +

    + + +

    RV: Method ignores exceptional return value (RV_RETURN_VALUE_IGNORED_BAD_PRACTICE)

    + + +

    This method returns a value that is not checked. The return value should be checked +since it can indicate an unusual or unexpected function execution. For +example, the File.delete() method returns false +if the file could not be successfully deleted (rather than +throwing an Exception). +If you don't check the result, you won't notice if the method invocation +signals unexpected behavior by returning an atypical return value. +

    + + +

    SI: Static initializer creates instance before all static final fields assigned (SI_INSTANCE_BEFORE_FINALS_ASSIGNED)

    + + +

    The class's static initializer creates an instance of the class +before all of the static final fields are assigned.

    + + +

    SW: Certain swing methods needs to be invoked in Swing thread (SW_SWING_METHODS_INVOKED_IN_SWING_THREAD)

    + + +

    (From JDC Tech Tip): The Swing methods +show(), setVisible(), and pack() will create the associated peer for the frame. +With the creation of the peer, the system creates the event dispatch thread. +This makes things problematic because the event dispatch thread could be notifying +listeners while pack and validate are still processing. This situation could result in +two threads going through the Swing component-based GUI -- it's a serious flaw that +could result in deadlocks or other related threading issues. A pack call causes +components to be realized. As they are being realized (that is, not necessarily +visible), they could trigger listener notification on the event dispatch thread.

    + + + +

    Se: Non-transient non-serializable instance field in serializable class (SE_BAD_FIELD)

    + + +

    This Serializable class defines a non-primitive instance field which is neither transient, +Serializable, or java.lang.Object, and does not appear to implement +the Externalizable interface or the +readObject() and writeObject() methods.  +Objects of this class will not be deserialized correctly if a non-Serializable +object is stored in this field.

    + + +

    Se: Non-serializable class has a serializable inner class (SE_BAD_FIELD_INNER_CLASS)

    + + +

    This Serializable class is an inner class of a non-serializable class. +Thus, attempts to serialize it will also attempt to associate instance of the outer +class with which it is associated, leading to a runtime error. +

    +

    If possible, making the inner class a static inner class should solve the +problem. Making the outer class serializable might also work, but that would +mean serializing an instance of the inner class would always also serialize the instance +of the outer class, which it often not what you really want. + + +

    Se: Non-serializable value stored into instance field of a serializable class (SE_BAD_FIELD_STORE)

    + + +

    A non-serializable value is stored into a non-transient field +of a serializable class.

    + + +

    Se: Comparator doesn't implement Serializable (SE_COMPARATOR_SHOULD_BE_SERIALIZABLE)

    + + +

    This class implements the Comparator interface. You +should consider whether or not it should also implement the Serializable +interface. If a comparator is used to construct an ordered collection +such as a TreeMap, then the TreeMap +will be serializable only if the comparator is also serializable. +As most comparators have little or no state, making them serializable +is generally easy and good defensive programming. +

    + + +

    Se: Serializable inner class (SE_INNER_CLASS)

    + + +

    This Serializable class is an inner class. Any attempt to serialize +it will also serialize the associated outer instance. The outer instance is serializable, +so this won't fail, but it might serialize a lot more data than intended. +If possible, making the inner class a static inner class (also known as a nested class) should solve the +problem. + + +

    Se: serialVersionUID isn't final (SE_NONFINAL_SERIALVERSIONID)

    + + +

    This class defines a serialVersionUID field that is not final.  + The field should be made final + if it is intended to specify + the version UID for purposes of serialization.

    + + +

    Se: serialVersionUID isn't long (SE_NONLONG_SERIALVERSIONID)

    + + +

    This class defines a serialVersionUID field that is not long.  + The field should be made long + if it is intended to specify + the version UID for purposes of serialization.

    + + +

    Se: serialVersionUID isn't static (SE_NONSTATIC_SERIALVERSIONID)

    + + +

    This class defines a serialVersionUID field that is not static.  + The field should be made static + if it is intended to specify + the version UID for purposes of serialization.

    + + +

    Se: Class is Serializable but its superclass doesn't define a void constructor (SE_NO_SUITABLE_CONSTRUCTOR)

    + + +

    This class implements the Serializable interface + and its superclass does not. When such an object is deserialized, + the fields of the superclass need to be initialized by + invoking the void constructor of the superclass. + Since the superclass does not have one, + serialization and deserialization will fail at runtime.

    + + +

    Se: Class is Externalizable but doesn't define a void constructor (SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION)

    + + +

    This class implements the Externalizable interface, but does + not define a void constructor. When Externalizable objects are deserialized, + they first need to be constructed by invoking the void + constructor. Since this class does not have one, + serialization and deserialization will fail at runtime.

    + + +

    Se: The readResolve method must be declared with a return type of Object. (SE_READ_RESOLVE_MUST_RETURN_OBJECT)

    + + +

    In order for the readResolve method to be recognized by the serialization +mechanism, it must be declared to have a return type of Object. +

    + + +

    Se: Transient field that isn't set by deserialization. (SE_TRANSIENT_FIELD_NOT_RESTORED)

    + + +

    This class contains a field that is updated at multiple places in the class, thus it seems to be part of the state of the class. However, since the field is marked as transient and not set in readObject or readResolve, it will contain the default value in any +deserialized instance of the class. +

    + + +

    SnVI: Class is Serializable, but doesn't define serialVersionUID (SE_NO_SERIALVERSIONID)

    + + +

    This class implements the Serializable interface, but does + not define a serialVersionUID field.  + A change as simple as adding a reference to a .class object + will add synthetic fields to the class, + which will unfortunately change the implicit + serialVersionUID (e.g., adding a reference to String.class + will generate a static field class$java$lang$String). + Also, different source code to bytecode compilers may use different + naming conventions for synthetic variables generated for + references to class objects or inner classes. + To ensure interoperability of Serializable across versions, + consider adding an explicit serialVersionUID.

    + + +

    UI: Usage of GetResource may be unsafe if class is extended (UI_INHERITANCE_UNSAFE_GETRESOURCE)

    + + +

    Calling this.getClass().getResource(...) could give +results other than expected if this class is extended by a class in +another package.

    + + +

    BC: Impossible cast (BC_IMPOSSIBLE_CAST)

    + + +

    +This cast will always throw a ClassCastException. +FindBugs tracks type information from instanceof checks, +and also uses more precise information about the types +of values returned from methods and loaded from fields. +Thus, it may have more precise information that just +the declared type of a variable, and can use this to determine +that a cast will always throw an exception at runtime. + +

    + + +

    BC: Impossible downcast (BC_IMPOSSIBLE_DOWNCAST)

    + + +

    +This cast will always throw a ClassCastException. +The analysis believes it knows +the precise type of the value being cast, and the attempt to +downcast it to a subtype will always fail by throwing a ClassCastException. +

    + + +

    BC: Impossible downcast of toArray() result (BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY)

    + + +

    +This code is casting the result of calling toArray() on a collection +to a type more specific than Object[], as in:

    +
    +String[] getAsArray(Collection<String> c) {
    +  return (String[]) c.toArray();
    +  }
    +
    +

    This will usually fail by throwing a ClassCastException. The toArray() +of almost all collections return an Object[]. They can't really do anything else, +since the Collection object has no reference to the declared generic type of the collection. +

    The correct way to do get an array of a specific type from a collection is to use + c.toArray(new String[]); + or c.toArray(new String[c.size()]); (the latter is slightly more efficient). +

    There is one common/known exception exception to this. The toArray() +method of lists returned by Arrays.asList(...) will return a covariantly +typed array. For example, Arrays.asArray(new String[] { "a" }).toArray() +will return a String []. FindBugs attempts to detect and suppress +such cases, but may miss some. +

    + + +

    BC: instanceof will always return false (BC_IMPOSSIBLE_INSTANCEOF)

    + + +

    +This instanceof test will always return false. Although this is safe, make sure it isn't +an indication of some misunderstanding or some other logic error. +

    + + +

    BIT: Bitwise add of signed byte value (BIT_ADD_OF_SIGNED_BYTE)

    + + +

    Adds a byte value and a value which is known to have the 8 lower bits clear. +Values loaded from a byte array are sign extended to 32 bits +before any any bitwise operations are performed on the value. +Thus, if b[0] contains the value 0xff, and +x is initially 0, then the code +((x << 8) + b[0]) will sign extend 0xff +to get 0xffffffff, and thus give the value +0xffffffff as the result. +

    + +

    In particular, the following code for packing a byte array into an int is badly wrong:

    +
    +int result = 0;
    +for(int i = 0; i < 4; i++)
    +  result = ((result << 8) + b[i]);
    +
    + +

    The following idiom will work instead:

    +
    +int result = 0;
    +for(int i = 0; i < 4; i++)
    +  result = ((result << 8) + (b[i] & 0xff));
    +
    + + + +

    BIT: Incompatible bit masks (BIT_AND)

    + + +

    This method compares an expression of the form (e & C) to D, +which will always compare unequal +due to the specific values of constants C and D. +This may indicate a logic error or typo.

    + + +

    BIT: Check to see if ((...) & 0) == 0 (BIT_AND_ZZ)

    + + +

    This method compares an expression of the form (e & 0) to 0, +which will always compare equal. +This may indicate a logic error or typo.

    + + +

    BIT: Incompatible bit masks (BIT_IOR)

    + + +

    This method compares an expression of the form (e | C) to D. +which will always compare unequal +due to the specific values of constants C and D. +This may indicate a logic error or typo.

    + +

    Typically, this bug occurs because the code wants to perform +a membership test in a bit set, but uses the bitwise OR +operator ("|") instead of bitwise AND ("&").

    + + +

    BIT: Bitwise OR of signed byte value (BIT_IOR_OF_SIGNED_BYTE)

    + + +

    Loads a byte value (e.g., a value loaded from a byte array or returned by a method +with return type byte) and performs a bitwise OR with +that value. Byte values are sign extended to 32 bits +before any any bitwise operations are performed on the value. +Thus, if b[0] contains the value 0xff, and +x is initially 0, then the code +((x << 8) | b[0]) will sign extend 0xff +to get 0xffffffff, and thus give the value +0xffffffff as the result. +

    + +

    In particular, the following code for packing a byte array into an int is badly wrong:

    +
    +int result = 0;
    +for(int i = 0; i < 4; i++)
    +  result = ((result << 8) | b[i]);
    +
    + +

    The following idiom will work instead:

    +
    +int result = 0;
    +for(int i = 0; i < 4; i++)
    +  result = ((result << 8) | (b[i] & 0xff));
    +
    + + + +

    BIT: Check for sign of bitwise operation (BIT_SIGNED_CHECK_HIGH_BIT)

    + + +

    This method compares an expression such as

    +
    ((event.detail & SWT.SELECTED) > 0)
    . +

    Using bit arithmetic and then comparing with the greater than operator can +lead to unexpected results (of course depending on the value of +SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate +for a bug. Even when SWT.SELECTED is not negative, it seems good practice +to use '!= 0' instead of '> 0'. +

    +

    +Boris Bokowski +

    + + +

    BOA: Class overrides a method implemented in super class Adapter wrongly (BOA_BADLY_OVERRIDDEN_ADAPTER)

    + + +

    This method overrides a method found in a parent class, where that class is an Adapter that implements +a listener defined in the java.awt.event or javax.swing.event package. As a result, this method will not +get called when the event occurs.

    + + +

    BSHIFT: 32 bit int shifted by an amount not in the range -31..31 (ICAST_BAD_SHIFT_AMOUNT)

    + + +

    +The code performs shift of a 32 bit int by a constant amount outside +the range -31..31. +The effect of this is to use the lower 5 bits of the integer +value to decide how much to shift by (e.g., shifting by 40 bits is the same as shifting by 8 bits, +and shifting by 32 bits is the same as shifting by zero bits). This probably isn't what was expected, +and it is at least confusing. +

    + + +

    Bx: Primitive value is unboxed and coerced for ternary operator (BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR)

    + + +

    A wrapped primitive value is unboxed and converted to another primitive type as part of the +evaluation of a conditional ternary operator (the b ? e1 : e2 operator). The +semantics of Java mandate that if e1 and e2 are wrapped +numeric values, the values are unboxed and converted/coerced to their common type (e.g, +if e1 is of type Integer +and e2 is of type Float, then e1 is unboxed, +converted to a floating point value, and boxed. See JLS Section 15.25. +

    + + +

    Co: compareTo()/compare() returns Integer.MIN_VALUE (CO_COMPARETO_RESULTS_MIN_VALUE)

    + + +

    In some situation, this compareTo or compare method returns +the constant Integer.MIN_VALUE, which is an exceptionally bad practice. + The only thing that matters about the return value of compareTo is the sign of the result. + But people will sometimes negate the return value of compareTo, expecting that this will negate + the sign of the result. And it will, except in the case where the value returned is Integer.MIN_VALUE. + So just return -1 rather than Integer.MIN_VALUE. + + +

    DLS: Useless increment in return statement (DLS_DEAD_LOCAL_INCREMENT_IN_RETURN)

    + + +

    This statement has a return such as return x++;. +A postfix increment/decrement does not impact the value of the expression, +so this increment/decrement has no effect. +Please verify that this statement does the right thing. +

    + + +

    DLS: Dead store of class literal (DLS_DEAD_STORE_OF_CLASS_LITERAL)

    + + +

    +This instruction assigns a class literal to a variable and then never uses it. +The behavior of this differs in Java 1.4 and in Java 5. +In Java 1.4 and earlier, a reference to Foo.class would force the static initializer +for Foo to be executed, if it has not been executed already. +In Java 5 and later, it does not. +

    +

    See Sun's article on Java SE compatibility +for more details and examples, and suggestions on how to force class initialization in Java 5. +

    + + +

    DLS: Overwritten increment (DLS_OVERWRITTEN_INCREMENT)

    + + +

    +The code performs an increment operation (e.g., i++) and then +immediately overwrites it. For example, i = i++ immediately +overwrites the incremented value with the original value. +

    + + +

    DMI: Reversed method arguments (DMI_ARGUMENTS_WRONG_ORDER)

    + + +

    The arguments to this method call seem to be in the wrong order. +For example, a call Preconditions.checkNotNull("message", message) +has reserved arguments: the value to be checked is the first argument. +

    + + +

    DMI: Bad constant value for month (DMI_BAD_MONTH)

    + + +

    +This code passes a constant month +value outside the expected range of 0..11 to a method. +

    + + +

    DMI: BigDecimal constructed from double that isn't represented precisely (DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE)

    + + +

    +This code creates a BigDecimal from a double value that doesn't translate well to a +decimal number. +For example, one might assume that writing new BigDecimal(0.1) in Java creates a BigDecimal which is exactly equal to 0.1 (an unscaled value of 1, with a scale of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583404541015625. +You probably want to use the BigDecimal.valueOf(double d) method, which uses the String representation +of the double to create the BigDecimal (e.g., BigDecimal.valueOf(0.1) gives 0.1). +

    + + + +

    DMI: hasNext method invokes next (DMI_CALLING_NEXT_FROM_HASNEXT)

    + + +

    +The hasNext() method invokes the next() method. This is almost certainly wrong, +since the hasNext() method is not supposed to change the state of the iterator, +and the next method is supposed to change the state of the iterator. +

    + + +

    DMI: Collections should not contain themselves (DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES)

    + + +

    This call to a generic collection's method would only make sense if a collection contained +itself (e.g., if s.contains(s) were true). This is unlikely to be true and would cause +problems if it were true (such as the computation of the hash code resulting in infinite recursion). +It is likely that the wrong value is being passed as a parameter. +

    + + +

    DMI: D'oh! A nonsensical method invocation (DMI_DOH)

    + + +

    +This partical method invocation doesn't make sense, for reasons that should be apparent from inspection. +

    + + + +

    DMI: Invocation of hashCode on an array (DMI_INVOKING_HASHCODE_ON_ARRAY)

    + + +

    +The code invokes hashCode on an array. Calling hashCode on +an array returns the same value as System.identityHashCode, and ingores +the contents and length of the array. If you need a hashCode that +depends on the contents of an array a, +use java.util.Arrays.hashCode(a). + +

    + + +

    DMI: Double.longBitsToDouble invoked on an int (DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT)

    + + +

    The Double.longBitsToDouble method is invoked, but a 32 bit int value is passed + as an argument. This almostly certainly is not intended and is unlikely + to give the intended result. +

    + + +

    DMI: Vacuous call to collections (DMI_VACUOUS_SELF_COLLECTION_CALL)

    + + +

    This call doesn't make sense. For any collection c, calling c.containsAll(c) should +always be true, and c.retainAll(c) should have no effect. +

    + + +

    Dm: Can't use reflection to check for presence of annotation without runtime retention (DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION)

    + + +

    Unless an annotation has itself been annotated with @Retention(RetentionPolicy.RUNTIME), the annotation can't be observed using reflection +(e.g., by using the isAnnotationPresent method). + .

    + + +

    Dm: Futile attempt to change max pool size of ScheduledThreadPoolExecutor (DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR)

    + + +

    (Javadoc) +While ScheduledThreadPoolExecutor inherits from ThreadPoolExecutor, a few of the inherited tuning methods are not useful for it. In particular, because it acts as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustments to maximumPoolSize have no useful effect. +

    + + + +

    Dm: Creation of ScheduledThreadPoolExecutor with zero core threads (DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS)

    + + +

    (Javadoc) +A ScheduledThreadPoolExecutor with zero core threads will never execute anything; changes to the max pool size are ignored. +

    + + + +

    Dm: Useless/vacuous call to EasyMock method (DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD)

    + + +

    This call doesn't pass any objects to the EasyMock method, so the call doesn't do anything. +

    + + + +

    EC: equals() used to compare array and nonarray (EC_ARRAY_AND_NONARRAY)

    + + +

    +This method invokes the .equals(Object o) to compare an array and a reference that doesn't seem +to be an array. If things being compared are of different types, they are guaranteed to be unequal +and the comparison is almost certainly an error. Even if they are both arrays, the equals method +on arrays only determines of the two arrays are the same object. +To compare the +contents of the arrays, use java.util.Arrays.equals(Object[], Object[]). +

    + + +

    EC: Invocation of equals() on an array, which is equivalent to == (EC_BAD_ARRAY_COMPARE)

    + + +

    +This method invokes the .equals(Object o) method on an array. Since arrays do not override the equals +method of Object, calling equals on an array is the same as comparing their addresses. To compare the +contents of the arrays, use java.util.Arrays.equals(Object[], Object[]). +To compare the addresses of the arrays, it would be +less confusing to explicitly check pointer equality using ==. +

    + + +

    EC: equals(...) used to compare incompatible arrays (EC_INCOMPATIBLE_ARRAY_COMPARE)

    + + +

    +This method invokes the .equals(Object o) to compare two arrays, but the arrays of +of incompatible types (e.g., String[] and StringBuffer[], or String[] and int[]). +They will never be equal. In addition, when equals(...) is used to compare arrays it +only checks to see if they are the same array, and ignores the contents of the arrays. +

    + + +

    EC: Call to equals(null) (EC_NULL_ARG)

    + + +

    This method calls equals(Object), passing a null value as +the argument. According to the contract of the equals() method, +this call should always return false.

    + + +

    EC: Call to equals() comparing unrelated class and interface (EC_UNRELATED_CLASS_AND_INTERFACE)

    + + +

    +This method calls equals(Object) on two references, one of which is a class +and the other an interface, where neither the class nor any of its +non-abstract subclasses implement the interface. +Therefore, the objects being compared +are unlikely to be members of the same class at runtime +(unless some application classes were not analyzed, or dynamic class +loading can occur at runtime). +According to the contract of equals(), +objects of different +classes should always compare as unequal; therefore, according to the +contract defined by java.lang.Object.equals(Object), +the result of this comparison will always be false at runtime. +

    + + +

    EC: Call to equals() comparing different interface types (EC_UNRELATED_INTERFACES)

    + + +

    This method calls equals(Object) on two references of unrelated +interface types, where neither is a subtype of the other, +and there are no known non-abstract classes which implement both interfaces. +Therefore, the objects being compared +are unlikely to be members of the same class at runtime +(unless some application classes were not analyzed, or dynamic class +loading can occur at runtime). +According to the contract of equals(), +objects of different +classes should always compare as unequal; therefore, according to the +contract defined by java.lang.Object.equals(Object), +the result of this comparison will always be false at runtime. +

    + + +

    EC: Call to equals() comparing different types (EC_UNRELATED_TYPES)

    + + +

    This method calls equals(Object) on two references of different +class types with no common subclasses. +Therefore, the objects being compared +are unlikely to be members of the same class at runtime +(unless some application classes were not analyzed, or dynamic class +loading can occur at runtime). +According to the contract of equals(), +objects of different +classes should always compare as unequal; therefore, according to the +contract defined by java.lang.Object.equals(Object), +the result of this comparison will always be false at runtime. +

    + + +

    EC: Using pointer equality to compare different types (EC_UNRELATED_TYPES_USING_POINTER_EQUALITY)

    + + +

    This method uses using pointer equality to compare two references that seem to be of +different types. The result of this comparison will always be false at runtime. +

    + + +

    Eq: equals method always returns false (EQ_ALWAYS_FALSE)

    + + +

    This class defines an equals method that always returns false. This means that an object is not equal to itself, and it is impossible to create useful Maps or Sets of this class. More fundamentally, it means +that equals is not reflexive, one of the requirements of the equals method.

    +

    The likely intended semantics are object identity: that an object is equal to itself. This is the behavior inherited from class Object. If you need to override an equals inherited from a different +superclass, you can use use:

    +
    +public boolean equals(Object o) { return this == o; }
    +
    + + +

    Eq: equals method always returns true (EQ_ALWAYS_TRUE)

    + + +

    This class defines an equals method that always returns true. This is imaginative, but not very smart. +Plus, it means that the equals method is not symmetric. +

    + + +

    Eq: equals method compares class names rather than class objects (EQ_COMPARING_CLASS_NAMES)

    + + +

    This method checks to see if two objects are the same class by checking to see if the names +of their classes are equal. You can have different classes with the same name if they are loaded by +different class loaders. Just check to see if the class objects are the same. +

    + + +

    Eq: Covariant equals() method defined for enum (EQ_DONT_DEFINE_EQUALS_FOR_ENUM)

    + + +

    This class defines an enumeration, and equality on enumerations are defined +using object identity. Defining a covariant equals method for an enumeration +value is exceptionally bad practice, since it would likely result +in having two different enumeration values that compare as equals using +the covariant enum method, and as not equal when compared normally. +Don't do it. +

    + + +

    Eq: equals() method defined that doesn't override equals(Object) (EQ_OTHER_NO_OBJECT)

    + + +

    This class defines an equals() + method, that doesn't override the normal equals(Object) method + defined in the base java.lang.Object class.  Instead, it + inherits an equals(Object) method from a superclass. + The class should probably define a boolean equals(Object) method. +

    + + +

    Eq: equals() method defined that doesn't override Object.equals(Object) (EQ_OTHER_USE_OBJECT)

    + + +

    This class defines an equals() + method, that doesn't override the normal equals(Object) method + defined in the base java.lang.Object class.  + The class should probably define a boolean equals(Object) method. +

    + + +

    Eq: equals method overrides equals in superclass and may not be symmetric (EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC)

    + + +

    This class defines an equals method that overrides an equals method in a superclass. Both equals methods +methods use instanceof in the determination of whether two objects are equal. This is fraught with peril, +since it is important that the equals method is symmetrical (in other words, a.equals(b) == b.equals(a)). +If B is a subtype of A, and A's equals method checks that the argument is an instanceof A, and B's equals method +checks that the argument is an instanceof B, it is quite likely that the equivalence relation defined by these +methods is not symmetric. +

    + + +

    Eq: Covariant equals() method defined, Object.equals(Object) inherited (EQ_SELF_USE_OBJECT)

    + + +

    This class defines a covariant version of the equals() + method, but inherits the normal equals(Object) method + defined in the base java.lang.Object class.  + The class should probably define a boolean equals(Object) method. +

    + + +

    FE: Doomed test for equality to NaN (FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER)

    + + +

    + This code checks to see if a floating point value is equal to the special + Not A Number value (e.g., if (x == Double.NaN)). However, + because of the special semantics of NaN, no value + is equal to Nan, including NaN. Thus, + x == Double.NaN always evaluates to false. + + To check to see if a value contained in x + is the special Not A Number value, use + Double.isNaN(x) (or Float.isNaN(x) if + x is floating point precision). +

    + + +

    FS: Format string placeholder incompatible with passed argument (VA_FORMAT_STRING_BAD_ARGUMENT)

    + + +

    +The format string placeholder is incompatible with the corresponding +argument. For example, + + System.out.println("%d\n", "hello"); + +

    The %d placeholder requires a numeric argument, but a string value is +passed instead. +A runtime exception will occur when +this statement is executed. +

    + + +

    FS: The type of a supplied argument doesn't match format specifier (VA_FORMAT_STRING_BAD_CONVERSION)

    + + +

    +One of the arguments is uncompatible with the corresponding format string specifier. +As a result, this will generate a runtime exception when executed. +For example, String.format("%d", "1") will generate an exception, since +the String "1" is incompatible with the format specifier %d. +

    + + +

    FS: MessageFormat supplied where printf style format expected (VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED)

    + + +

    +A method is called that expects a Java printf format string and a list of arguments. +However, the format string doesn't contain any format specifiers (e.g., %s) but +does contain message format elements (e.g., {0}). It is likely +that the code is supplying a MessageFormat string when a printf-style format string +is required. At runtime, all of the arguments will be ignored +and the format string will be returned exactly as provided without any formatting. +

    + + +

    FS: More arguments are passed than are actually used in the format string (VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED)

    + + +

    +A format-string method with a variable number of arguments is called, +but more arguments are passed than are actually used by the format string. +This won't cause a runtime exception, but the code may be silently omitting +information that was intended to be included in the formatted string. +

    + + +

    FS: Illegal format string (VA_FORMAT_STRING_ILLEGAL)

    + + +

    +The format string is syntactically invalid, +and a runtime exception will occur when +this statement is executed. +

    + + +

    FS: Format string references missing argument (VA_FORMAT_STRING_MISSING_ARGUMENT)

    + + +

    +Not enough arguments are passed to satisfy a placeholder in the format string. +A runtime exception will occur when +this statement is executed. +

    + + +

    FS: No previous argument for format string (VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT)

    + + +

    +The format string specifies a relative index to request that the argument for the previous format specifier +be reused. However, there is no previous argument. +For example, +

    +

    formatter.format("%<s %s", "a", "b") +

    +

    would throw a MissingFormatArgumentException when executed. +

    + + +

    GC: No relationship between generic parameter and method argument (GC_UNRELATED_TYPES)

    + + +

    This call to a generic collection method contains an argument + with an incompatible class from that of the collection's parameter + (i.e., the type of the argument is neither a supertype nor a subtype + of the corresponding generic type argument). + Therefore, it is unlikely that the collection contains any objects + that are equal to the method argument used here. + Most likely, the wrong value is being passed to the method.

    +

    In general, instances of two unrelated classes are not equal. + For example, if the Foo and Bar classes + are not related by subtyping, then an instance of Foo + should not be equal to an instance of Bar. + Among other issues, doing so will likely result in an equals method + that is not symmetrical. For example, if you define the Foo class + so that a Foo can be equal to a String, + your equals method isn't symmetrical since a String can only be equal + to a String. +

    +

    In rare cases, people do define nonsymmetrical equals methods and still manage to make + their code work. Although none of the APIs document or guarantee it, it is typically + the case that if you check if a Collection<String> contains + a Foo, the equals method of argument (e.g., the equals method of the + Foo class) used to perform the equality checks. +

    + + +

    HE: Signature declares use of unhashable class in hashed construct (HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS)

    + + +

    A method, field or class declares a generic signature where a non-hashable class +is used in context where a hashable class is required. +A class that declares an equals method but inherits a hashCode() method +from Object is unhashable, since it doesn't fulfill the requirement that +equal objects have equal hashCodes. +

    + + +

    HE: Use of class without a hashCode() method in a hashed data structure (HE_USE_OF_UNHASHABLE_CLASS)

    + + +

    A class defines an equals(Object) method but not a hashCode() method, +and thus doesn't fulfill the requirement that equal objects have equal hashCodes. +An instance of this class is used in a hash data structure, making the need to +fix this problem of highest importance. + + +

    ICAST: int value converted to long and used as absolute time (ICAST_INT_2_LONG_AS_INSTANT)

    + + +

    +This code converts a 32-bit int value to a 64-bit long value, and then +passes that value for a method parameter that requires an absolute time value. +An absolute time value is the number +of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT. +For example, the following method, intended to convert seconds since the epoc into a Date, is badly +broken:

    +
    +Date getDate(int seconds) { return new Date(seconds * 1000); }
    +
    +

    The multiplication is done using 32-bit arithmetic, and then converted to a 64-bit value. +When a 32-bit value is converted to 64-bits and used to express an absolute time +value, only dates in December 1969 and January 1970 can be represented.

    + +

    Correct implementations for the above method are:

    + +
    +// Fails for dates after 2037
    +Date getDate(int seconds) { return new Date(seconds * 1000L); }
    +
    +// better, works for all dates
    +Date getDate(long seconds) { return new Date(seconds * 1000); }
    +
    + + +

    ICAST: Integral value cast to double and then passed to Math.ceil (ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL)

    + + +

    +This code converts an integral value (e.g., int or long) +to a double precision +floating point number and then +passing the result to the Math.ceil() function, which rounds a double to +the next higher integer value. This operation should always be a no-op, +since the converting an integer to a double should give a number with no fractional part. +It is likely that the operation that generated the value to be passed +to Math.ceil was intended to be performed using double precision +floating point arithmetic. +

    + + + +

    ICAST: int value cast to float and then passed to Math.round (ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND)

    + + +

    +This code converts an int value to a float precision +floating point number and then +passing the result to the Math.round() function, which returns the int/long closest +to the argument. This operation should always be a no-op, +since the converting an integer to a float should give a number with no fractional part. +It is likely that the operation that generated the value to be passed +to Math.round was intended to be performed using +floating point arithmetic. +

    + + + +

    IJU: JUnit assertion in run method will not be noticed by JUnit (IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD)

    + + +

    A JUnit assertion is performed in a run method. Failed JUnit assertions +just result in exceptions being thrown. +Thus, if this exception occurs in a thread other than the thread that invokes +the test method, the exception will terminate the thread but not result +in the test failing. +

    + + +

    IJU: TestCase declares a bad suite method (IJU_BAD_SUITE_METHOD)

    + + +

    Class is a JUnit TestCase and defines a suite() method. +However, the suite method needs to be declared as either

    +
    public static junit.framework.Test suite()
    +or +
    public static junit.framework.TestSuite suite()
    + + +

    IJU: TestCase has no tests (IJU_NO_TESTS)

    + + +

    Class is a JUnit TestCase but has not implemented any test methods

    + + +

    IJU: TestCase defines setUp that doesn't call super.setUp() (IJU_SETUP_NO_SUPER)

    + + +

    Class is a JUnit TestCase and implements the setUp method. The setUp method should call +super.setUp(), but doesn't.

    + + +

    IJU: TestCase implements a non-static suite method (IJU_SUITE_NOT_STATIC)

    + + +

    Class is a JUnit TestCase and implements the suite() method. + The suite method should be declared as being static, but isn't.

    + + +

    IJU: TestCase defines tearDown that doesn't call super.tearDown() (IJU_TEARDOWN_NO_SUPER)

    + + +

    Class is a JUnit TestCase and implements the tearDown method. The tearDown method should call +super.tearDown(), but doesn't.

    + + +

    IL: A collection is added to itself (IL_CONTAINER_ADDED_TO_ITSELF)

    + + +

    A collection is added to itself. As a result, computing the hashCode of this +set will throw a StackOverflowException. +

    + + +

    IL: An apparent infinite loop (IL_INFINITE_LOOP)

    + + +

    This loop doesn't seem to have a way to terminate (other than by perhaps +throwing an exception).

    + + +

    IL: An apparent infinite recursive loop (IL_INFINITE_RECURSIVE_LOOP)

    + + +

    This method unconditionally invokes itself. This would seem to indicate +an infinite recursive loop that will result in a stack overflow.

    + + +

    IM: Integer multiply of result of integer remainder (IM_MULTIPLYING_RESULT_OF_IREM)

    + + +

    +The code multiplies the result of an integer remaining by an integer constant. +Be sure you don't have your operator precedence confused. For example +i % 60 * 1000 is (i % 60) * 1000, not i % (60 * 1000). +

    + + +

    INT: Bad comparison of int value with long constant (INT_BAD_COMPARISON_WITH_INT_VALUE)

    + + +

    This code compares an int value with a long constant that is outside +the range of values that can be represented as an int value. +This comparison is vacuous and possibily to be incorrect. +

    + + +

    INT: Bad comparison of nonnegative value with negative constant (INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE)

    + + +

    This code compares a value that is guaranteed to be non-negative with a negative constant. +

    + + +

    INT: Bad comparison of signed byte (INT_BAD_COMPARISON_WITH_SIGNED_BYTE)

    + + +

    Signed bytes can only have a value in the range -128 to 127. Comparing +a signed byte with a value outside that range is vacuous and likely to be incorrect. +To convert a signed byte b to an unsigned value in the range 0..255, +use 0xff & b +

    + + +

    IO: Doomed attempt to append to an object output stream (IO_APPENDING_TO_OBJECT_OUTPUT_STREAM)

    + + +

    + This code opens a file in append mode and then wraps the result in an object output stream. + This won't allow you to append to an existing object output stream stored in a file. If you want to be + able to append to an object output stream, you need to keep the object output stream open. +

    +

    The only situation in which opening a file in append mode and the writing an object output stream + could work is if on reading the file you plan to open it in random access mode and seek to the byte offset + where the append started. +

    + +

    + TODO: example. +

    + + +

    IP: A parameter is dead upon entry to a method but overwritten (IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN)

    + + +

    +The initial value of this parameter is ignored, and the parameter +is overwritten here. This often indicates a mistaken belief that +the write to the parameter will be conveyed back to +the caller. +

    + + +

    MF: Class defines field that masks a superclass field (MF_CLASS_MASKS_FIELD)

    + + +

    This class defines a field with the same name as a visible +instance field in a superclass. This is confusing, and +may indicate an error if methods update or access one of +the fields when they wanted the other.

    + + +

    MF: Method defines a variable that obscures a field (MF_METHOD_MASKS_FIELD)

    + + +

    This method defines a local variable with the same name as a field +in this class or a superclass. This may cause the method to +read an uninitialized value from the field, leave the field uninitialized, +or both.

    + + +

    NP: Null pointer dereference (NP_ALWAYS_NULL)

    + + +

    A null pointer is dereferenced here.  This will lead to a +NullPointerException when the code is executed.

    + + +

    NP: Null pointer dereference in method on exception path (NP_ALWAYS_NULL_EXCEPTION)

    + + +

    A pointer which is null on an exception path is dereferenced here.  +This will lead to a NullPointerException when the code is executed.  +Note that because FindBugs currently does not prune infeasible exception paths, +this may be a false warning.

    + +

    Also note that FindBugs considers the default case of a switch statement to +be an exception path, since the default case is often infeasible.

    + + +

    NP: Method does not check for null argument (NP_ARGUMENT_MIGHT_BE_NULL)

    + + +

    + A parameter to this method has been identified as a value that should + always be checked to see whether or not it is null, but it is being dereferenced + without a preceding null check. +

    + + +

    NP: close() invoked on a value that is always null (NP_CLOSING_NULL)

    + + +

    close() is being invoked on a value that is always null. If this statement is executed, +a null pointer exception will occur. But the big risk here you never close +something that should be closed. + + +

    NP: Null value is guaranteed to be dereferenced (NP_GUARANTEED_DEREF)

    + + +

    + There is a statement or branch that if executed guarantees that + a value is null at this point, and that + value that is guaranteed to be dereferenced + (except on forward paths involving runtime exceptions). +

    +

    Note that a check such as + if (x == null) throw new NullPointerException(); + is treated as a dereference of x. + + +

    NP: Value is null and guaranteed to be dereferenced on exception path (NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH)

    + + +

    + There is a statement or branch on an exception path + that if executed guarantees that + a value is null at this point, and that + value that is guaranteed to be dereferenced + (except on forward paths involving runtime exceptions). +

    + + +

    NP: Nonnull field is not initialized (NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)

    + + +

    The field is marked as nonnull, but isn't written to by the constructor. + The field might be initialized elsewhere during constructor, or might always + be initialized before use. +

    + + +

    NP: Method call passes null to a nonnull parameter (NP_NONNULL_PARAM_VIOLATION)

    + + +

    + This method passes a null value as the parameter of a method which + must be nonnull. Either this parameter has been explicitly marked + as @Nonnull, or analysis has determined that this parameter is + always dereferenced. +

    + + +

    NP: Method may return null, but is declared @NonNull (NP_NONNULL_RETURN_VIOLATION)

    + + +

    + This method may return a null value, but the method (or a superclass method + which it overrides) is declared to return @NonNull. +

    + + +

    NP: A known null value is checked to see if it is an instance of a type (NP_NULL_INSTANCEOF)

    + + +

    +This instanceof test will always return false, since the value being checked is guaranteed to be null. +Although this is safe, make sure it isn't +an indication of some misunderstanding or some other logic error. +

    + + +

    NP: Possible null pointer dereference (NP_NULL_ON_SOME_PATH)

    + + +

    There is a branch of statement that, if executed, guarantees that +a null value will be dereferenced, which +would generate a NullPointerException when the code is executed. +Of course, the problem might be that the branch or statement is infeasible and that +the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs. +

    + + +

    NP: Possible null pointer dereference in method on exception path (NP_NULL_ON_SOME_PATH_EXCEPTION)

    + + +

    A reference value which is null on some exception control path is +dereferenced here.  This may lead to a NullPointerException +when the code is executed.  +Note that because FindBugs currently does not prune infeasible exception paths, +this may be a false warning.

    + +

    Also note that FindBugs considers the default case of a switch statement to +be an exception path, since the default case is often infeasible.

    + + +

    NP: Method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF)

    + + +

    + This method call passes a null value for a nonnull method parameter. + Either the parameter is annotated as a parameter that should + always be nonnull, or analysis has shown that it will always be + dereferenced. +

    + + +

    NP: Method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS)

    + + +

    + A possibly-null value is passed at a call site where all known + target methods require the parameter to be nonnull. + Either the parameter is annotated as a parameter that should + always be nonnull, or analysis has shown that it will always be + dereferenced. +

    + + +

    NP: Non-virtual method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF_NONVIRTUAL)

    + + +

    + A possibly-null value is passed to a nonnull method parameter. + Either the parameter is annotated as a parameter that should + always be nonnull, or analysis has shown that it will always be + dereferenced. +

    + + +

    NP: Store of null value into field annotated NonNull (NP_STORE_INTO_NONNULL_FIELD)

    + + +

    A value that could be null is stored into a field that has been annotated as NonNull.

    + + +

    NP: Read of unwritten field (NP_UNWRITTEN_FIELD)

    + + +

    The program is dereferencing a field that does not seem to ever have a non-null value written to it. +Unless the field is initialized via some mechanism not seen by the analysis, +dereferencing this value will generate a null pointer exception. +

    + + +

    Nm: Class defines equal(Object); should it be equals(Object)? (NM_BAD_EQUAL)

    + + +

    This class defines a method equal(Object).  This method does +not override the equals(Object) method in java.lang.Object, +which is probably what was intended.

    + + +

    Nm: Class defines hashcode(); should it be hashCode()? (NM_LCASE_HASHCODE)

    + + +

    This class defines a method called hashcode().  This method + does not override the hashCode() method in java.lang.Object, + which is probably what was intended.

    + + +

    Nm: Class defines tostring(); should it be toString()? (NM_LCASE_TOSTRING)

    + + +

    This class defines a method called tostring().  This method + does not override the toString() method in java.lang.Object, + which is probably what was intended.

    + + +

    Nm: Apparent method/constructor confusion (NM_METHOD_CONSTRUCTOR_CONFUSION)

    + + +

    This regular method has the same name as the class it is defined in. It is likely that this was intended to be a constructor. + If it was intended to be a constructor, remove the declaration of a void return value. + If you had accidently defined this method, realized the mistake, defined a proper constructor + but can't get rid of this method due to backwards compatibility, deprecate the method. +

    + + +

    Nm: Very confusing method names (NM_VERY_CONFUSING)

    + + +

    The referenced methods have names that differ only by capitalization. +This is very confusing because if the capitalization were +identical then one of the methods would override the other. +

    + + +

    Nm: Method doesn't override method in superclass due to wrong package for parameter (NM_WRONG_PACKAGE)

    + + +

    The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match +the type of the corresponding parameter in the superclass. For example, if you have:

    + +
    +
    +import alpha.Foo;
    +public class A {
    +  public int f(Foo x) { return 17; }
    +}
    +----
    +import beta.Foo;
    +public class B extends A {
    +  public int f(Foo x) { return 42; }
    +}
    +
    +
    + +

    The f(Foo) method defined in class B doesn't +override the +f(Foo) method defined in class A, because the argument +types are Foo's from different packages. +

    + + +

    QBA: Method assigns boolean literal in boolean expression (QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT)

    + + +

    + This method assigns a literal boolean value (true or false) to a boolean variable inside + an if or while expression. Most probably this was supposed to be a boolean comparison using + ==, not an assignment using =. +

    + + +

    RC: Suspicious reference comparison (RC_REF_COMPARISON)

    + + +

    This method compares two reference values using the == or != operator, +where the correct way to compare instances of this type is generally +with the equals() method. +It is possible to create distinct instances that are equal but do not compare as == since +they are different objects. +Examples of classes which should generally +not be compared by reference are java.lang.Integer, java.lang.Float, etc.

    + + +

    RCN: Nullcheck of value previously dereferenced (RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE)

    + + +

    A value is checked here to see whether it is null, but this value can't +be null because it was previously dereferenced and if it were null a null pointer +exception would have occurred at the earlier dereference. +Essentially, this code and the previous dereference +disagree as to whether this value is allowed to be null. Either the check is redundant +or the previous dereference is erroneous.

    + + +

    RE: Invalid syntax for regular expression (RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION)

    + + +

    +The code here uses a regular expression that is invalid according to the syntax +for regular expressions. This statement will throw a PatternSyntaxException when +executed. +

    + + +

    RE: File.separator used for regular expression (RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION)

    + + +

    +The code here uses File.separator +where a regular expression is required. This will fail on Windows +platforms, where the File.separator is a backslash, which is interpreted in a +regular expression as an escape character. Amoung other options, you can just use +File.separatorChar=='\\' ? "\\\\" : File.separator instead of +File.separator + +

    + + +

    RE: "." or "|" used for regular expression (RE_POSSIBLE_UNINTENDED_PATTERN)

    + + +

    +A String function is being invoked and "." or "|" is being passed +to a parameter that takes a regular expression as an argument. Is this what you intended? +For example +

  • s.replaceAll(".", "/") will return a String in which every character has been replaced by a '/' character +
  • s.split(".") always returns a zero length array of String +
  • "ab|cd".replaceAll("|", "/") will return "/a/b/|/c/d/" +
  • "ab|cd".split("|") will return array with six (!) elements: [, a, b, |, c, d] +

    + + +

    RV: Random value from 0 to 1 is coerced to the integer 0 (RV_01_TO_INT)

    + + +

    A random value from 0 to 1 is being coerced to the integer value 0. You probably +want to multiple the random value by something else before coercing it to an integer, or use the Random.nextInt(n) method. +

    + + +

    RV: Bad attempt to compute absolute value of signed 32-bit hashcode (RV_ABSOLUTE_VALUE_OF_HASHCODE)

    + + +

    This code generates a hashcode and then computes +the absolute value of that hashcode. If the hashcode +is Integer.MIN_VALUE, then the result will be negative as well (since +Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE). +

    +

    One out of 2^32 strings have a hashCode of Integer.MIN_VALUE, +including "polygenelubricants" "GydZG_" and ""DESIGNING WORKHOUSES". +

    + + +

    RV: Bad attempt to compute absolute value of signed random integer (RV_ABSOLUTE_VALUE_OF_RANDOM_INT)

    + + +

    This code generates a random signed integer and then computes +the absolute value of that random integer. If the number returned by the random number +generator is Integer.MIN_VALUE, then the result will be negative as well (since +Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE). (Same problem arised for long values as well). +

    + + +

    RV: Code checks for specific values returned by compareTo (RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE)

    + + +

    This code invoked a compareTo or compare method, and checks to see if the return value is a specific value, +such as 1 or -1. When invoking these methods, you should only check the sign of the result, not for any specific +non-zero value. While many or most compareTo and compare methods only return -1, 0 or 1, some of them +will return other values. + + +

    RV: Exception created and dropped rather than thrown (RV_EXCEPTION_NOT_THROWN)

    + + +

    This code creates an exception (or error) object, but doesn't do anything with it. For example, +something like

    +
    +
    +if (x < 0)
    +  new IllegalArgumentException("x must be nonnegative");
    +
    +
    +

    It was probably the intent of the programmer to throw the created exception:

    +
    +
    +if (x < 0)
    +  throw new IllegalArgumentException("x must be nonnegative");
    +
    +
    + + +

    RV: Method ignores return value (RV_RETURN_VALUE_IGNORED)

    + + +

    The return value of this method should be checked. One common +cause of this warning is to invoke a method on an immutable object, +thinking that it updates the object. For example, in the following code +fragment,

    +
    +
    +String dateString = getHeaderField(name);
    +dateString.trim();
    +
    +
    +

    the programmer seems to be thinking that the trim() method will update +the String referenced by dateString. But since Strings are immutable, the trim() +function returns a new String value, which is being ignored here. The code +should be corrected to:

    +
    +
    +String dateString = getHeaderField(name);
    +dateString = dateString.trim();
    +
    +
    + + +

    RpC: Repeated conditional tests (RpC_REPEATED_CONDITIONAL_TEST)

    + + +

    The code contains a conditional test is performed twice, one right after the other +(e.g., x == 0 || x == 0). Perhaps the second occurrence is intended to be something else +(e.g., x == 0 || y == 0). +

    + + +

    SA: Self assignment of field (SA_FIELD_SELF_ASSIGNMENT)

    + + +

    This method contains a self assignment of a field; e.g. +

    +
    +  int x;
    +  public void foo() {
    +    x = x;
    +  }
    +
    +

    Such assignments are useless, and may indicate a logic error or typo.

    + + +

    SA: Self comparison of field with itself (SA_FIELD_SELF_COMPARISON)

    + + +

    This method compares a field with itself, and may indicate a typo or +a logic error. Make sure that you are comparing the right things. +

    + + +

    SA: Nonsensical self computation involving a field (e.g., x & x) (SA_FIELD_SELF_COMPUTATION)

    + + +

    This method performs a nonsensical computation of a field with another +reference to the same field (e.g., x&x or x-x). Because of the nature +of the computation, this operation doesn't seem to make sense, +and may indicate a typo or +a logic error. Double check the computation. +

    + + +

    SA: Self assignment of local rather than assignment to field (SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD)

    + + +

    This method contains a self assignment of a local variable, and there +is a field with an identical name. +assignment appears to have been ; e.g.

    +
    +  int foo;
    +  public void setFoo(int foo) {
    +    foo = foo;
    +  }
    +
    +

    The assignment is useless. Did you mean to assign to the field instead?

    + + +

    SA: Self comparison of value with itself (SA_LOCAL_SELF_COMPARISON)

    + + +

    This method compares a local variable with itself, and may indicate a typo or +a logic error. Make sure that you are comparing the right things. +

    + + +

    SA: Nonsensical self computation involving a variable (e.g., x & x) (SA_LOCAL_SELF_COMPUTATION)

    + + +

    This method performs a nonsensical computation of a local variable with another +reference to the same variable (e.g., x&x or x-x). Because of the nature +of the computation, this operation doesn't seem to make sense, +and may indicate a typo or +a logic error. Double check the computation. +

    + + +

    SF: Dead store due to switch statement fall through (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH)

    + + +

    A value stored in the previous switch case is overwritten here due to a switch fall through. It is likely that + you forgot to put a break or return at the end of the previous case. +

    + + +

    SF: Dead store due to switch statement fall through to throw (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW)

    + + +

    A value stored in the previous switch case is ignored here due to a switch fall through to a place where + an exception is thrown. It is likely that + you forgot to put a break or return at the end of the previous case. +

    + + +

    SIC: Deadly embrace of non-static inner class and thread local (SIC_THREADLOCAL_DEADLY_EMBRACE)

    + + +

    This class is an inner class, but should probably be a static inner class. + As it is, there is a serious danger of a deadly embrace between the inner class + and the thread local in the outer class. Because the inner class isn't static, + it retains a reference to the outer class. + If the thread local contains a reference to an instance of the inner + class, the inner and outer instance will both be reachable + and not eligible for garbage collection. +

    + + +

    SIO: Unnecessary type check done using instanceof operator (SIO_SUPERFLUOUS_INSTANCEOF)

    + + +

    Type check performed using the instanceof operator where it can be statically determined whether the object +is of the type requested.

    + + +

    SQL: Method attempts to access a prepared statement parameter with index 0 (SQL_BAD_PREPARED_STATEMENT_ACCESS)

    + + +

    A call to a setXXX method of a prepared statement was made where the +parameter index is 0. As parameter indexes start at index 1, this is always a mistake.

    + + +

    SQL: Method attempts to access a result set field with index 0 (SQL_BAD_RESULTSET_ACCESS)

    + + +

    A call to getXXX or updateXXX methods of a result set was made where the +field index is 0. As ResultSet fields start at index 1, this is always a mistake.

    + + +

    STI: Unneeded use of currentThread() call, to call interrupted() (STI_INTERRUPTED_ON_CURRENTTHREAD)

    + + +

    +This method invokes the Thread.currentThread() call, just to call the interrupted() method. As interrupted() is a +static method, is more simple and clear to use Thread.interrupted(). +

    + + +

    STI: Static Thread.interrupted() method invoked on thread instance (STI_INTERRUPTED_ON_UNKNOWNTHREAD)

    + + +

    +This method invokes the Thread.interrupted() method on a Thread object that appears to be a Thread object that is +not the current thread. As the interrupted() method is static, the interrupted method will be called on a different +object than the one the author intended. +

    + + +

    Se: Method must be private in order for serialization to work (SE_METHOD_MUST_BE_PRIVATE)

    + + +

    This class implements the Serializable interface, and defines a method + for custom serialization/deserialization. But since that method isn't declared private, + it will be silently ignored by the serialization/deserialization API.

    + + +

    Se: The readResolve method must not be declared as a static method. (SE_READ_RESOLVE_IS_STATIC)

    + + +

    In order for the readResolve method to be recognized by the serialization +mechanism, it must not be declared as a static method. +

    + + +

    TQ: Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is required (TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED)

    + + +

    + A value specified as carrying a type qualifier annotation is + consumed in a location or locations requiring that the value not + carry that annotation. +

    + +

    + More precisely, a value annotated with a type qualifier specifying when=ALWAYS + is guaranteed to reach a use or uses where the same type qualifier specifies when=NEVER. +

    + +

    + For example, say that @NonNegative is a nickname for + the type qualifier annotation @Negative(when=When.NEVER). + The following code will generate this warning because + the return statement requires a @NonNegative value, + but receives one that is marked as @Negative. +

    +
    +
    +public @NonNegative Integer example(@Negative Integer value) {
    +    return value;
    +}
    +
    +
    + + +

    TQ: Comparing values with incompatible type qualifiers (TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS)

    + + +

    + A value specified as carrying a type qualifier annotation is + compared with a value that doesn't ever carry that qualifier. +

    + +

    + More precisely, a value annotated with a type qualifier specifying when=ALWAYS + is compared with a value that where the same type qualifier specifies when=NEVER. +

    + +

    + For example, say that @NonNegative is a nickname for + the type qualifier annotation @Negative(when=When.NEVER). + The following code will generate this warning because + the return statement requires a @NonNegative value, + but receives one that is marked as @Negative. +

    +
    +
    +public boolean example(@Negative Integer value1, @NonNegative Integer value2) {
    +    return value1.equals(value2);
    +}
    +
    +
    + + +

    TQ: Value that might not carry a type qualifier is always used in a way requires that type qualifier (TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK)

    + + +

    + A value that is annotated as possibility not being an instance of + the values denoted by the type qualifier, and the value is guaranteed to be used + in a way that requires values denoted by that type qualifier. +

    + + +

    TQ: Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifier (TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK)

    + + +

    + A value that is annotated as possibility being an instance of + the values denoted by the type qualifier, and the value is guaranteed to be used + in a way that prohibits values denoted by that type qualifier. +

    + + +

    TQ: Value annotated as never carrying a type qualifier used where value carrying that qualifier is required (TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED)

    + + +

    + A value specified as not carrying a type qualifier annotation is guaranteed + to be consumed in a location or locations requiring that the value does + carry that annotation. +

    + +

    + More precisely, a value annotated with a type qualifier specifying when=NEVER + is guaranteed to reach a use or uses where the same type qualifier specifies when=ALWAYS. +

    + +

    + TODO: example +

    + + +

    TQ: Value without a type qualifier used where a value is required to have that qualifier (TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED)

    + + +

    + A value is being used in a way that requires the value be annotation with a type qualifier. + The type qualifier is strict, so the tool rejects any values that do not have + the appropriate annotation. +

    + +

    + To coerce a value to have a strict annotation, define an identity function where the return value is annotated + with the strict annotation. + This is the only way to turn a non-annotated value into a value with a strict type qualifier annotation. +

    + + + +

    UMAC: Uncallable method defined in anonymous class (UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS)

    + + +

    This anonymous class defined a method that is not directly invoked and does not override +a method in a superclass. Since methods in other classes cannot directly invoke methods +declared in an anonymous class, it seems that this method is uncallable. The method +might simply be dead code, but it is also possible that the method is intended to +override a method declared in a superclass, and due to an typo or other error the method does not, +in fact, override the method it is intended to. +

    + + +

    UR: Uninitialized read of field in constructor (UR_UNINIT_READ)

    + + +

    This constructor reads a field which has not yet been assigned a value.  + This is often caused when the programmer mistakenly uses the field instead + of one of the constructor's parameters.

    + + +

    UR: Uninitialized read of field method called from constructor of superclass (UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR)

    + + +

    This method is invoked in the constructor of of the superclass. At this point, + the fields of the class have not yet initialized.

    +

    To make this more concrete, consider the following classes:

    +
    abstract class A {
    +  int hashCode;
    +  abstract Object getValue();
    +  A() {
    +    hashCode = getValue().hashCode();
    +    }
    +  }
    +class B extends A {
    +  Object value;
    +  B(Object v) {
    +    this.value = v;
    +    }
    +  Object getValue() {
    +    return value;
    +  }
    +  }
    +

    When a B is constructed, +the constructor for the A class is invoked +before the constructor for B sets value. +Thus, when the constructor for A invokes getValue, +an uninitialized value is read for value +

    + + +

    USELESS_STRING: Invocation of toString on an unnamed array (DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY)

    + + +

    +The code invokes toString on an (anonymous) array. Calling toString on an array generates a fairly useless result +such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable +String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12. +

    + + +

    USELESS_STRING: Invocation of toString on an array (DMI_INVOKING_TOSTRING_ON_ARRAY)

    + + +

    +The code invokes toString on an array, which will generate a fairly useless result +such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable +String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12. +

    + + +

    USELESS_STRING: Array formatted in useless way using format string (VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY)

    + + +

    +One of the arguments being formatted with a format string is an array. This will be formatted +using a fairly useless format, such as [I@304282, which doesn't actually show the contents +of the array. +Consider wrapping the array using Arrays.asList(...) before handling it off to a formatted. +

    + + +

    UwF: Field only ever set to null (UWF_NULL_FIELD)

    + + +

    All writes to this field are of the constant value null, and thus +all reads of the field will return null. +Check for errors, or remove it if it is useless.

    + + +

    UwF: Unwritten field (UWF_UNWRITTEN_FIELD)

    + + +

    This field is never written.  All reads of it will return the default +value. Check for errors (should it have been initialized?), or remove it if it is useless.

    + + +

    VA: Primitive array passed to function expecting a variable number of object arguments (VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG)

    + + +

    +This code passes a primitive array to a function that takes a variable number of object arguments. +This creates an array of length one to hold the primitive array and passes it to the function. +

    + + +

    LG: Potential lost logger changes due to weak reference in OpenJDK (LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE)

    + + +

    OpenJDK introduces a potential incompatibility. + In particular, the java.util.logging.Logger behavior has + changed. Instead of using strong references, it now uses weak references + internally. That's a reasonable change, but unfortunately some code relies on + the old behavior - when changing logger configuration, it simply drops the + logger reference. That means that the garbage collector is free to reclaim + that memory, which means that the logger configuration is lost. For example, +consider: +

    + +
    public static void initLogging() throws Exception {
    + Logger logger = Logger.getLogger("edu.umd.cs");
    + logger.addHandler(new FileHandler()); // call to change logger configuration
    + logger.setUseParentHandlers(false); // another call to change logger configuration
    +}
    + +

    The logger reference is lost at the end of the method (it doesn't +escape the method), so if you have a garbage collection cycle just +after the call to initLogging, the logger configuration is lost +(because Logger only keeps weak references).

    + +
    public static void main(String[] args) throws Exception {
    + initLogging(); // adds a file handler to the logger
    + System.gc(); // logger configuration lost
    + Logger.getLogger("edu.umd.cs").info("Some message"); // this isn't logged to the file as expected
    +}
    +

    Ulf Ochsenfahrt and Eric Fellheimer

    + + +

    OBL: Method may fail to clean up stream or resource (OBL_UNSATISFIED_OBLIGATION)

    + + +

    + This method may fail to clean up (close, dispose of) a stream, + database object, or other + resource requiring an explicit cleanup operation. +

    + +

    + In general, if a method opens a stream or other resource, + the method should use a try/finally block to ensure that + the stream or resource is cleaned up before the method + returns. +

    + +

    + This bug pattern is essentially the same as the + OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE + bug patterns, but is based on a different + (and hopefully better) static analysis technique. + We are interested is getting feedback about the + usefulness of this bug pattern. + To send feedback, either: +

    + + +

    + In particular, + the false-positive suppression heuristics for this + bug pattern have not been extensively tuned, so + reports about false positives are helpful to us. +

    + +

    + See Weimer and Necula, Finding and Preventing Run-Time Error Handling Mistakes, for + a description of the analysis technique. +

    + + +

    OBL: Method may fail to clean up stream or resource on checked exception (OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE)

    + + +

    + This method may fail to clean up (close, dispose of) a stream, + database object, or other + resource requiring an explicit cleanup operation. +

    + +

    + In general, if a method opens a stream or other resource, + the method should use a try/finally block to ensure that + the stream or resource is cleaned up before the method + returns. +

    + +

    + This bug pattern is essentially the same as the + OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE + bug patterns, but is based on a different + (and hopefully better) static analysis technique. + We are interested is getting feedback about the + usefulness of this bug pattern. + To send feedback, either: +

    + + +

    + In particular, + the false-positive suppression heuristics for this + bug pattern have not been extensively tuned, so + reports about false positives are helpful to us. +

    + +

    + See Weimer and Necula, Finding and Preventing Run-Time Error Handling Mistakes, for + a description of the analysis technique. +

    + + +

    Dm: Consider using Locale parameterized version of invoked method (DM_CONVERT_CASE)

    + + +

    A String is being converted to upper or lowercase, using the platform's default encoding. This may + result in improper conversions when used with international characters. Use the

    +
      +
    • String.toUpperCase( Locale l )
    • +
    • String.toLowerCase( Locale l )
    • +
    +

    versions instead.

    + + +

    Dm: Reliance on default encoding (DM_DEFAULT_ENCODING)

    + + +

    Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.

    + + +

    DP: Classloaders should only be created inside doPrivileged block (DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED)

    + + +

    This code creates a classloader, which needs permission if a security manage is installed. + If this code might be invoked by code that does not + have security permissions, then the classloader creation needs to occur inside a doPrivileged block.

    + + +

    DP: Method invoked that should be only be invoked inside a doPrivileged block (DP_DO_INSIDE_DO_PRIVILEGED)

    + + +

    This code invokes a method that requires a security permission check. + If this code will be granted security permissions, but might be invoked by code that does not + have security permissions, then the invocation needs to occur inside a doPrivileged block.

    + + +

    EI: May expose internal representation by returning reference to mutable object (EI_EXPOSE_REP)

    + + +

    Returning a reference to a mutable object value stored in one of the object's fields + exposes the internal representation of the object.  + If instances + are accessed by untrusted code, and unchecked changes to + the mutable object would compromise security or other + important properties, you will need to do something different. + Returning a new copy of the object is better approach in many situations.

    + + +

    EI2: May expose internal representation by incorporating reference to mutable object (EI_EXPOSE_REP2)

    + + +

    This code stores a reference to an externally mutable object into the + internal representation of the object.  + If instances + are accessed by untrusted code, and unchecked changes to + the mutable object would compromise security or other + important properties, you will need to do something different. + Storing a copy of the object is better approach in many situations.

    + + +

    FI: Finalizer should be protected, not public (FI_PUBLIC_SHOULD_BE_PROTECTED)

    + + +

    A class's finalize() method should have protected access, + not public.

    + + +

    MS: May expose internal static state by storing a mutable object into a static field (EI_EXPOSE_STATIC_REP2)

    + + +

    This code stores a reference to an externally mutable object into a static + field. + If unchecked changes to + the mutable object would compromise security or other + important properties, you will need to do something different. + Storing a copy of the object is better approach in many situations.

    + + +

    MS: Field isn't final and can't be protected from malicious code (MS_CANNOT_BE_FINAL)

    + + +

    + A mutable static field could be changed by malicious code or + by accident from another package. + Unfortunately, the way the field is used doesn't allow + any easy fix to this problem.

    + + +

    MS: Public static method may expose internal representation by returning array (MS_EXPOSE_REP)

    + + +

    A public static method returns a reference to + an array that is part of the static state of the class. + Any code that calls this method can freely modify + the underlying array. + One fix is to return a copy of the array.

    + + +

    MS: Field should be both final and package protected (MS_FINAL_PKGPROTECT)

    + + +

    + A mutable static field could be changed by malicious code or + by accident from another package. + The field could be made package protected and/or made final + to avoid + this vulnerability.

    + + +

    MS: Field is a mutable array (MS_MUTABLE_ARRAY)

    + + +

    A final static field references an array + and can be accessed by malicious code or + by accident from another package. + This code can freely modify the contents of the array.

    + + +

    MS: Field is a mutable Hashtable (MS_MUTABLE_HASHTABLE)

    + + +

    A final static field references a Hashtable + and can be accessed by malicious code or + by accident from another package. + This code can freely modify the contents of the Hashtable.

    + + +

    MS: Field should be moved out of an interface and made package protected (MS_OOI_PKGPROTECT)

    + + +

    + A final static field that is +defined in an interface references a mutable + object such as an array or hashtable. + This mutable object could + be changed by malicious code or + by accident from another package. + To solve this, the field needs to be moved to a class + and made package protected + to avoid + this vulnerability.

    + + +

    MS: Field should be package protected (MS_PKGPROTECT)

    + + +

    A mutable static field could be changed by malicious code or + by accident. + The field could be made package protected to avoid + this vulnerability.

    + + +

    MS: Field isn't final but should be (MS_SHOULD_BE_FINAL)

    + + +

    +This static field public but not final, and +could be changed by malicious code or + by accident from another package. + The field could be made final to avoid + this vulnerability.

    + + +

    MS: Field isn't final but should be refactored to be so (MS_SHOULD_BE_REFACTORED_TO_BE_FINAL)

    + + +

    +This static field public but not final, and +could be changed by malicious code or +by accident from another package. +The field could be made final to avoid +this vulnerability. However, the static initializer contains more than one write +to the field, so doing so will require some refactoring. +

    + + +

    AT: Sequence of calls to concurrent abstraction may not be atomic (AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION)

    + + +

    This code contains a sequence of calls to a concurrent abstraction + (such as a concurrent hash map). + These calls will not be executed atomically. + + +

    DC: Possible double check of field (DC_DOUBLECHECK)

    + + +

    This method may contain an instance of double-checked locking.  + This idiom is not correct according to the semantics of the Java memory + model.  For more information, see the web page + http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html.

    + + +

    DL: Synchronization on Boolean (DL_SYNCHRONIZATION_ON_BOOLEAN)

    + + +

    The code synchronizes on a boxed primitive constant, such as an Boolean.

    +
    +private static Boolean inited = Boolean.FALSE;
    +...
    +  synchronized(inited) {
    +    if (!inited) {
    +       init();
    +       inited = Boolean.TRUE;
    +       }
    +     }
    +...
    +
    +

    Since there normally exist only two Boolean objects, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness +and possible deadlock

    +

    See CERT CON08-J. Do not synchronize on objects that may be reused for more information.

    + + +

    DL: Synchronization on boxed primitive (DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE)

    + + +

    The code synchronizes on a boxed primitive constant, such as an Integer.

    +
    +private static Integer count = 0;
    +...
    +  synchronized(count) {
    +     count++;
    +     }
    +...
    +
    +

    Since Integer objects can be cached and shared, +this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness +and possible deadlock

    +

    See CERT CON08-J. Do not synchronize on objects that may be reused for more information.

    + + +

    DL: Synchronization on interned String (DL_SYNCHRONIZATION_ON_SHARED_CONSTANT)

    + + +

    The code synchronizes on interned String.

    +
    +private static String LOCK = "LOCK";
    +...
    +  synchronized(LOCK) { ...}
    +...
    +
    +

    Constant Strings are interned and shared across all other classes loaded by the JVM. Thus, this could +is locking on something that other code might also be locking. This could result in very strange and hard to diagnose +blocking and deadlock behavior. See http://www.javalobby.org/java/forums/t96352.html and http://jira.codehaus.org/browse/JETTY-352. +

    +

    See CERT CON08-J. Do not synchronize on objects that may be reused for more information.

    + + +

    DL: Synchronization on boxed primitive values (DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE)

    + + +

    The code synchronizes on an apparently unshared boxed primitive, +such as an Integer.

    +
    +private static final Integer fileLock = new Integer(1);
    +...
    +  synchronized(fileLock) {
    +     .. do something ..
    +     }
    +...
    +
    +

    It would be much better, in this code, to redeclare fileLock as

    +
    +private static final Object fileLock = new Object();
    +
    +

    +The existing code might be OK, but it is confusing and a +future refactoring, such as the "Remove Boxing" refactoring in IntelliJ, +might replace this with the use of an interned Integer object shared +throughout the JVM, leading to very confusing behavior and potential deadlock. +

    + + +

    Dm: Monitor wait() called on Condition (DM_MONITOR_WAIT_ON_CONDITION)

    + + +

    + This method calls wait() on a + java.util.concurrent.locks.Condition object.  + Waiting for a Condition should be done using one of the await() + methods defined by the Condition interface. +

    + + +

    Dm: A thread was created using the default empty run method (DM_USELESS_THREAD)

    + + +

    This method creates a thread without specifying a run method either by deriving from the Thread class, or + by passing a Runnable object. This thread, then, does nothing but waste time. +

    + + +

    ESync: Empty synchronized block (ESync_EMPTY_SYNC)

    + + +

    The code contains an empty synchronized block:

    +
    +synchronized() {}
    +
    +

    Empty synchronized blocks are far more subtle and hard to use correctly +than most people recognize, and empty synchronized blocks +are almost never a better solution +than less contrived solutions. +

    + + +

    IS: Inconsistent synchronization (IS2_INCONSISTENT_SYNC)

    + + +

    The fields of this class appear to be accessed inconsistently with respect + to synchronization.  This bug report indicates that the bug pattern detector + judged that +

    +
      +
    • The class contains a mix of locked and unlocked accesses,
    • +
    • The class is not annotated as javax.annotation.concurrent.NotThreadSafe,
    • +
    • At least one locked access was performed by one of the class's own methods, and
    • +
    • The number of unsynchronized field accesses (reads and writes) was no more than + one third of all accesses, with writes being weighed twice as high as reads
    • +
    + +

    A typical bug matching this bug pattern is forgetting to synchronize + one of the methods in a class that is intended to be thread-safe.

    + +

    You can select the nodes labeled "Unsynchronized access" to show the + code locations where the detector believed that a field was accessed + without synchronization.

    + +

    Note that there are various sources of inaccuracy in this detector; + for example, the detector cannot statically detect all situations in which + a lock is held.  Also, even when the detector is accurate in + distinguishing locked vs. unlocked accesses, the code in question may still + be correct.

    + + + +

    IS: Field not guarded against concurrent access (IS_FIELD_NOT_GUARDED)

    + + +

    This field is annotated with net.jcip.annotations.GuardedBy or javax.annotation.concurrent.GuardedBy, +but can be accessed in a way that seems to violate those annotations.

    + + +

    JLM: Synchronization performed on Lock (JLM_JSR166_LOCK_MONITORENTER)

    + + +

    This method performs synchronization an object that implements +java.util.concurrent.locks.Lock. Such an object is locked/unlocked +using +acquire()/release() rather +than using the synchronized (...) construct. +

    + + +

    JLM: Synchronization performed on util.concurrent instance (JLM_JSR166_UTILCONCURRENT_MONITORENTER)

    + + +

    This method performs synchronization an object that is an instance of +a class from the java.util.concurrent package (or its subclasses). Instances +of these classes have their own concurrency control mechanisms that are orthogonal to +the synchronization provided by the Java keyword synchronized. For example, +synchronizing on an AtomicBoolean will not prevent other threads +from modifying the AtomicBoolean.

    +

    Such code may be correct, but should be carefully reviewed and documented, +and may confuse people who have to maintain the code at a later date. +

    + + +

    JLM: Using monitor style wait methods on util.concurrent abstraction (JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT)

    + + +

    This method calls +wait(), +notify() or +notifyAll()() +on an object that also provides an +await(), +signal(), +signalAll() method (such as util.concurrent Condition objects). +This probably isn't what you want, and even if you do want it, you should consider changing +your design, as other developers will find it exceptionally confusing. +

    + + +

    LI: Incorrect lazy initialization of static field (LI_LAZY_INIT_STATIC)

    + + +

    This method contains an unsynchronized lazy initialization of a non-volatile static field. +Because the compiler or processor may reorder instructions, +threads are not guaranteed to see a completely initialized object, +if the method can be called by multiple threads. +You can make the field volatile to correct the problem. +For more information, see the +Java Memory Model web site. +

    + + +

    LI: Incorrect lazy initialization and update of static field (LI_LAZY_INIT_UPDATE_STATIC)

    + + +

    This method contains an unsynchronized lazy initialization of a static field. +After the field is set, the object stored into that location is further updated or accessed. +The setting of the field is visible to other threads as soon as it is set. If the +futher accesses in the method that set the field serve to initialize the object, then +you have a very serious multithreading bug, unless something else prevents +any other thread from accessing the stored object until it is fully initialized. +

    +

    Even if you feel confident that the method is never called by multiple +threads, it might be better to not set the static field until the value +you are setting it to is fully populated/initialized. + + +

    ML: Synchronization on field in futile attempt to guard that field (ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD)

    + + +

    This method synchronizes on a field in what appears to be an attempt +to guard against simultaneous updates to that field. But guarding a field +gets a lock on the referenced object, not on the field. This may not +provide the mutual exclusion you need, and other threads might +be obtaining locks on the referenced objects (for other purposes). An example +of this pattern would be:

    +
    +private Long myNtfSeqNbrCounter = new Long(0);
    +private Long getNotificationSequenceNumber() {
    +     Long result = null;
    +     synchronized(myNtfSeqNbrCounter) {
    +         result = new Long(myNtfSeqNbrCounter.longValue() + 1);
    +         myNtfSeqNbrCounter = new Long(result.longValue());
    +     }
    +     return result;
    + }
    +
    + + +

    ML: Method synchronizes on an updated field (ML_SYNC_ON_UPDATED_FIELD)

    + + +

    This method synchronizes on an object + referenced from a mutable field. + This is unlikely to have useful semantics, since different +threads may be synchronizing on different objects.

    + + +

    MSF: Mutable servlet field (MSF_MUTABLE_SERVLET_FIELD)

    + + +

    A web server generally only creates one instance of servlet or jsp class (i.e., treats +the class as a Singleton), +and will +have multiple threads invoke methods on that instance to service multiple +simultaneous requests. +Thus, having a mutable instance field generally creates race conditions. + + +

    MWN: Mismatched notify() (MWN_MISMATCHED_NOTIFY)

    + + +

    This method calls Object.notify() or Object.notifyAll() without obviously holding a lock +on the object.  Calling notify() or notifyAll() without a lock held will result in +an IllegalMonitorStateException being thrown.

    + + +

    MWN: Mismatched wait() (MWN_MISMATCHED_WAIT)

    + + +

    This method calls Object.wait() without obviously holding a lock +on the object.  Calling wait() without a lock held will result in +an IllegalMonitorStateException being thrown.

    + + +

    NN: Naked notify (NN_NAKED_NOTIFY)

    + + +

    A call to notify() or notifyAll() + was made without any (apparent) accompanying + modification to mutable object state.  In general, calling a notify + method on a monitor is done because some condition another thread is + waiting for has become true.  However, for the condition to be meaningful, + it must involve a heap object that is visible to both threads.

    + +

    This bug does not necessarily indicate an error, since the change to + mutable object state may have taken place in a method which then called + the method containing the notification.

    + + +

    NP: Synchronize and null check on the same field. (NP_SYNC_AND_NULL_CHECK_FIELD)

    + + +

    Since the field is synchronized on, it seems not likely to be null. +If it is null and then synchronized on a NullPointerException will be +thrown and the check would be pointless. Better to synchronize on +another field.

    + + + +

    No: Using notify() rather than notifyAll() (NO_NOTIFY_NOT_NOTIFYALL)

    + + +

    This method calls notify() rather than notifyAll().  + Java monitors are often used for multiple conditions.  Calling notify() + only wakes up one thread, meaning that the thread woken up might not be the + one waiting for the condition that the caller just satisfied.

    + + +

    RS: Class's readObject() method is synchronized (RS_READOBJECT_SYNC)

    + + +

    This serializable class defines a readObject() which is + synchronized.  By definition, an object created by deserialization + is only reachable by one thread, and thus there is no need for + readObject() to be synchronized.  If the readObject() + method itself is causing the object to become visible to another thread, + that is an example of very dubious coding style.

    + + +

    RV: Return value of putIfAbsent ignored, value passed to putIfAbsent reused (RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED)

    + + + The putIfAbsent method is typically used to ensure that a + single value is associated with a given key (the first value for which put + if absent succeeds). + If you ignore the return value and retain a reference to the value passed in, + you run the risk of retaining a value that is not the one that is associated with the key in the map. + If it matters which one you use and you use the one that isn't stored in the map, + your program will behave incorrectly. + + +

    Ru: Invokes run on a thread (did you mean to start it instead?) (RU_INVOKE_RUN)

    + + +

    This method explicitly invokes run() on an object.  + In general, classes implement the Runnable interface because + they are going to have their run() method invoked in a new thread, + in which case Thread.start() is the right method to call.

    + + +

    SC: Constructor invokes Thread.start() (SC_START_IN_CTOR)

    + + +

    The constructor starts a thread. This is likely to be wrong if + the class is ever extended/subclassed, since the thread will be started + before the subclass constructor is started.

    + + +

    SP: Method spins on field (SP_SPIN_ON_FIELD)

    + + +

    This method spins in a loop which reads a field.  The compiler + may legally hoist the read out of the loop, turning the code into an + infinite loop.  The class should be changed so it uses proper + synchronization (including wait and notify calls).

    + + +

    STCAL: Call to static Calendar (STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE)

    + + +

    Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use. +The detector has found a call to an instance of Calendar that has been obtained via a static +field. This looks suspicous.

    +

    For more information on this see Sun Bug #6231579 +and Sun Bug #6178997.

    + + +

    STCAL: Call to static DateFormat (STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE)

    + + +

    As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use. +The detector has found a call to an instance of DateFormat that has been obtained via a static +field. This looks suspicous.

    +

    For more information on this see Sun Bug #6231579 +and Sun Bug #6178997.

    + + +

    STCAL: Static Calendar field (STCAL_STATIC_CALENDAR_INSTANCE)

    + + +

    Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use. +Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the +application. Under 1.4 problems seem to surface less often than under Java 5 where you will probably see +random ArrayIndexOutOfBoundsExceptions or IndexOutOfBoundsExceptions in sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate().

    +

    You may also experience serialization problems.

    +

    Using an instance field is recommended.

    +

    For more information on this see Sun Bug #6231579 +and Sun Bug #6178997.

    + + +

    STCAL: Static DateFormat (STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE)

    + + +

    As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use. +Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the +application.

    +

    You may also experience serialization problems.

    +

    Using an instance field is recommended.

    +

    For more information on this see Sun Bug #6231579 +and Sun Bug #6178997.

    + + +

    SWL: Method calls Thread.sleep() with a lock held (SWL_SLEEP_WITH_LOCK_HELD)

    + + +

    + This method calls Thread.sleep() with a lock held. This may result + in very poor performance and scalability, or a deadlock, since other threads may + be waiting to acquire the lock. It is a much better idea to call + wait() on the lock, which releases the lock and allows other threads + to run. +

    + + +

    TLW: Wait with two locks held (TLW_TWO_LOCK_WAIT)

    + + +

    Waiting on a monitor while two locks are held may cause + deadlock. +   + Performing a wait only releases the lock on the object + being waited on, not any other locks. +   +This not necessarily a bug, but is worth examining + closely.

    + + +

    UG: Unsynchronized get method, synchronized set method (UG_SYNC_SET_UNSYNC_GET)

    + + +

    This class contains similarly-named get and set + methods where the set method is synchronized and the get method is not.  + This may result in incorrect behavior at runtime, as callers of the get + method will not necessarily see a consistent state for the object.  + The get method should be made synchronized.

    + + +

    UL: Method does not release lock on all paths (UL_UNRELEASED_LOCK)

    + + +

    This method acquires a JSR-166 (java.util.concurrent) lock, +but does not release it on all paths out of the method. In general, the correct idiom +for using a JSR-166 lock is: +

    +
    +    Lock l = ...;
    +    l.lock();
    +    try {
    +        // do something
    +    } finally {
    +        l.unlock();
    +    }
    +
    + + +

    UL: Method does not release lock on all exception paths (UL_UNRELEASED_LOCK_EXCEPTION_PATH)

    + + +

    This method acquires a JSR-166 (java.util.concurrent) lock, +but does not release it on all exception paths out of the method. In general, the correct idiom +for using a JSR-166 lock is: +

    +
    +    Lock l = ...;
    +    l.lock();
    +    try {
    +        // do something
    +    } finally {
    +        l.unlock();
    +    }
    +
    + + +

    UW: Unconditional wait (UW_UNCOND_WAIT)

    + + +

    This method contains a call to java.lang.Object.wait() which + is not guarded by conditional control flow.  The code should + verify that condition it intends to wait for is not already satisfied + before calling wait; any previous notifications will be ignored. +

    + + +

    VO: An increment to a volatile field isn't atomic (VO_VOLATILE_INCREMENT)

    + + +

    This code increments a volatile field. Increments of volatile fields aren't +atomic. If more than one thread is incrementing the field at the same time, +increments could be lost. +

    + + +

    VO: A volatile reference to an array doesn't treat the array elements as volatile (VO_VOLATILE_REFERENCE_TO_ARRAY)

    + + +

    This declares a volatile reference to an array, which might not be what +you want. With a volatile reference to an array, reads and writes of +the reference to the array are treated as volatile, but the array elements +are non-volatile. To get volatile array elements, you will need to use +one of the atomic array classes in java.util.concurrent (provided +in Java 5.0).

    + + +

    WL: Synchronization on getClass rather than class literal (WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL)

    + + +

    + This instance method synchronizes on this.getClass(). If this class is subclassed, + subclasses will synchronize on the class object for the subclass, which isn't likely what was intended. + For example, consider this code from java.awt.Label:

    +
    +     private static final String base = "label";
    +     private static int nameCounter = 0;
    +     String constructComponentName() {
    +        synchronized (getClass()) {
    +            return base + nameCounter++;
    +        }
    +     }
    +     
    +

    Subclasses of Label won't synchronize on the same subclass, giving rise to a datarace. + Instead, this code should be synchronizing on Label.class

    +
    +     private static final String base = "label";
    +     private static int nameCounter = 0;
    +     String constructComponentName() {
    +        synchronized (Label.class) {
    +            return base + nameCounter++;
    +        }
    +     }
    +     
    +

    Bug pattern contributed by Jason Mehrens

    + + +

    WS: Class's writeObject() method is synchronized but nothing else is (WS_WRITEOBJECT_SYNC)

    + + +

    This class has a writeObject() method which is synchronized; + however, no other method of the class is synchronized.

    + + +

    Wa: Condition.await() not in loop (WA_AWAIT_NOT_IN_LOOP)

    + + +

    This method contains a call to java.util.concurrent.await() + (or variants) + which is not in a loop.  If the object is used for multiple conditions, + the condition the caller intended to wait for might not be the one + that actually occurred.

    + + +

    Wa: Wait not in loop (WA_NOT_IN_LOOP)

    + + +

    This method contains a call to java.lang.Object.wait() + which is not in a loop.  If the monitor is used for multiple conditions, + the condition the caller intended to wait for might not be the one + that actually occurred.

    + + +

    Bx: Primitive value is boxed and then immediately unboxed (BX_BOXING_IMMEDIATELY_UNBOXED)

    + + +

    A primitive is boxed, and then immediately unboxed. This probably is due to a manual + boxing in a place where an unboxed value is required, thus forcing the compiler +to immediately undo the work of the boxing. +

    + + +

    Bx: Primitive value is boxed then unboxed to perform primitive coercion (BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION)

    + + +

    A primitive boxed value constructed and then immediately converted into a different primitive type +(e.g., new Double(d).intValue()). Just perform direct primitive coercion (e.g., (int) d).

    + + +

    Bx: Boxed value is unboxed and then immediately reboxed (BX_UNBOXING_IMMEDIATELY_REBOXED)

    + + +

    A boxed value is unboxed and then immediately reboxed. +

    + + +

    Bx: Boxing/unboxing to parse a primitive (DM_BOXED_PRIMITIVE_FOR_PARSING)

    + + +

    A boxed primitive is created from a String, just to extract the unboxed primitive value. + It is more efficient to just call the static parseXXX method.

    + + +

    Bx: Method allocates a boxed primitive just to call toString (DM_BOXED_PRIMITIVE_TOSTRING)

    + + +

    A boxed primitive is allocated just to call toString(). It is more effective to just use the static + form of toString which takes the primitive value. So,

    + + + + + + + + + +
    Replace...With this...
    new Integer(1).toString()Integer.toString(1)
    new Long(1).toString()Long.toString(1)
    new Float(1.0).toString()Float.toString(1.0)
    new Double(1.0).toString()Double.toString(1.0)
    new Byte(1).toString()Byte.toString(1)
    new Short(1).toString()Short.toString(1)
    new Boolean(true).toString()Boolean.toString(true)
    + + +

    Bx: Method invokes inefficient floating-point Number constructor; use static valueOf instead (DM_FP_NUMBER_CTOR)

    + + +

    + Using new Double(double) is guaranteed to always result in a new object whereas + Double.valueOf(double) allows caching of values to be done by the compiler, class library, or JVM. + Using of cached values avoids object allocation and the code will be faster. +

    +

    + Unless the class must be compatible with JVMs predating Java 1.5, + use either autoboxing or the valueOf() method when creating instances of Double and Float. +

    + + +

    Bx: Method invokes inefficient Number constructor; use static valueOf instead (DM_NUMBER_CTOR)

    + + +

    + Using new Integer(int) is guaranteed to always result in a new object whereas + Integer.valueOf(int) allows caching of values to be done by the compiler, class library, or JVM. + Using of cached values avoids object allocation and the code will be faster. +

    +

    + Values between -128 and 127 are guaranteed to have corresponding cached instances + and using valueOf is approximately 3.5 times faster than using constructor. + For values outside the constant range the performance of both styles is the same. +

    +

    + Unless the class must be compatible with JVMs predating Java 1.5, + use either autoboxing or the valueOf() method when creating instances of + Long, Integer, Short, Character, and Byte. +

    + + +

    Dm: The equals and hashCode methods of URL are blocking (DMI_BLOCKING_METHODS_ON_URL)

    + + +

    The equals and hashCode +method of URL perform domain name resolution, this can result in a big performance hit. +See http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html for more information. +Consider using java.net.URI instead. +

    + + +

    Dm: Maps and sets of URLs can be performance hogs (DMI_COLLECTION_OF_URLS)

    + + +

    This method or field is or uses a Map or Set of URLs. Since both the equals and hashCode +method of URL perform domain name resolution, this can result in a big performance hit. +See http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html for more information. +Consider using java.net.URI instead. +

    + + +

    Dm: Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead (DM_BOOLEAN_CTOR)

    + + +

    Creating new instances of java.lang.Boolean wastes + memory, since Boolean objects are immutable and there are + only two useful values of this type.  Use the Boolean.valueOf() + method (or Java 1.5 autoboxing) to create Boolean objects instead.

    + + +

    Dm: Explicit garbage collection; extremely dubious except in benchmarking code (DM_GC)

    + + +

    Code explicitly invokes garbage collection. + Except for specific use in benchmarking, this is very dubious.

    +

    In the past, situations where people have explicitly invoked + the garbage collector in routines such as close or finalize methods + has led to huge performance black holes. Garbage collection + can be expensive. Any situation that forces hundreds or thousands + of garbage collections will bring the machine to a crawl.

    + + +

    Dm: Method allocates an object, only to get the class object (DM_NEW_FOR_GETCLASS)

    + + +

    This method allocates an object just to call getClass() on it, in order to + retrieve the Class object for it. It is simpler to just access the .class property of the class.

    + + +

    Dm: Use the nextInt method of Random rather than nextDouble to generate a random integer (DM_NEXTINT_VIA_NEXTDOUBLE)

    + + +

    If r is a java.util.Random, you can generate a random number from 0 to n-1 +using r.nextInt(n), rather than using (int)(r.nextDouble() * n). +

    +

    The argument to nextInt must be positive. If, for example, you want to generate a random +value from -99 to 0, use -r.nextInt(100). +

    + + +

    Dm: Method invokes inefficient new String(String) constructor (DM_STRING_CTOR)

    + + +

    Using the java.lang.String(String) constructor wastes memory + because the object so constructed will be functionally indistinguishable + from the String passed as a parameter.  Just use the + argument String directly.

    + + +

    Dm: Method invokes toString() method on a String (DM_STRING_TOSTRING)

    + + +

    Calling String.toString() is just a redundant operation. + Just use the String.

    + + +

    Dm: Method invokes inefficient new String() constructor (DM_STRING_VOID_CTOR)

    + + +

    Creating a new java.lang.String object using the + no-argument constructor wastes memory because the object so created will + be functionally indistinguishable from the empty string constant + "".  Java guarantees that identical string constants + will be represented by the same String object.  Therefore, + you should just use the empty string constant directly.

    + + +

    HSC: Huge string constants is duplicated across multiple class files (HSC_HUGE_SHARED_STRING_CONSTANT)

    + + +

    + A large String constant is duplicated across multiple class files. + This is likely because a final field is initialized to a String constant, and the Java language + mandates that all references to a final field from other classes be inlined into +that classfile. See JDK bug 6447475 + for a description of an occurrence of this bug in the JDK and how resolving it reduced + the size of the JDK by 1 megabyte. +

    + + +

    ITA: Method uses toArray() with zero-length array argument (ITA_INEFFICIENT_TO_ARRAY)

    + + +

    This method uses the toArray() method of a collection derived class, and passes +in a zero-length prototype array argument. It is more efficient to use +myCollection.toArray(new Foo[myCollection.size()]) +If the array passed in is big enough to store all of the +elements of the collection, then it is populated and returned +directly. This avoids the need to create a second array +(by reflection) to return as the result.

    + + +

    SBSC: Method concatenates strings using + in a loop (SBSC_USE_STRINGBUFFER_CONCATENATION)

    + + +

    The method seems to be building a String using concatenation in a loop. +In each iteration, the String is converted to a StringBuffer/StringBuilder, + appended to, and converted back to a String. + This can lead to a cost quadratic in the number of iterations, + as the growing string is recopied in each iteration.

    + +

    Better performance can be obtained by using +a StringBuffer (or StringBuilder in Java 1.5) explicitly.

    + +

    For example:

    +
    +  // This is bad
    +  String s = "";
    +  for (int i = 0; i < field.length; ++i) {
    +    s = s + field[i];
    +  }
    +
    +  // This is better
    +  StringBuffer buf = new StringBuffer();
    +  for (int i = 0; i < field.length; ++i) {
    +    buf.append(field[i]);
    +  }
    +  String s = buf.toString();
    +
    + + +

    SIC: Should be a static inner class (SIC_INNER_SHOULD_BE_STATIC)

    + + +

    This class is an inner class, but does not use its embedded reference + to the object which created it.  This reference makes the instances + of the class larger, and may keep the reference to the creator object + alive longer than necessary.  If possible, the class should be + made static. +

    + + +

    SIC: Could be refactored into a named static inner class (SIC_INNER_SHOULD_BE_STATIC_ANON)

    + + +

    This class is an inner class, but does not use its embedded reference + to the object which created it.  This reference makes the instances + of the class larger, and may keep the reference to the creator object + alive longer than necessary.  If possible, the class should be + made into a static inner class. Since anonymous inner +classes cannot be marked as static, doing this will require refactoring +the inner class so that it is a named inner class.

    + + +

    SIC: Could be refactored into a static inner class (SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS)

    + + +

    This class is an inner class, but does not use its embedded reference + to the object which created it except during construction of the +inner object.  This reference makes the instances + of the class larger, and may keep the reference to the creator object + alive longer than necessary.  If possible, the class should be + made into a static inner class. Since the reference to the + outer object is required during construction of the inner instance, + the inner class will need to be refactored so as to + pass a reference to the outer instance to the constructor + for the inner class.

    + + +

    SS: Unread field: should this field be static? (SS_SHOULD_BE_STATIC)

    + + +

    This class contains an instance final field that + is initialized to a compile-time static value. + Consider making the field static.

    + + +

    UM: Method calls static Math class method on a constant value (UM_UNNECESSARY_MATH)

    + + +

    This method uses a static method from java.lang.Math on a constant value. This method's +result in this case, can be determined statically, and is faster and sometimes more accurate to +just use the constant. Methods detected are: +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Parameter
    abs -any-
    acos 0.0 or 1.0
    asin 0.0 or 1.0
    atan 0.0 or 1.0
    atan2 0.0
    cbrt 0.0 or 1.0
    ceil -any-
    cos 0.0
    cosh 0.0
    exp 0.0 or 1.0
    expm1 0.0
    floor -any-
    log 0.0 or 1.0
    log10 0.0 or 1.0
    rint -any-
    round -any-
    sin 0.0
    sinh 0.0
    sqrt 0.0 or 1.0
    tan 0.0
    tanh 0.0
    toDegrees 0.0 or 1.0
    toRadians 0.0
    + + +

    UPM: Private method is never called (UPM_UNCALLED_PRIVATE_METHOD)

    + + +

    This private method is never called. Although it is +possible that the method will be invoked through reflection, +it is more likely that the method is never used, and should be +removed. +

    + + +

    UrF: Unread field (URF_UNREAD_FIELD)

    + + +

    This field is never read.  Consider removing it from the class.

    + + +

    UuF: Unused field (UUF_UNUSED_FIELD)

    + + +

    This field is never used.  Consider removing it from the class.

    + + +

    WMI: Inefficient use of keySet iterator instead of entrySet iterator (WMI_WRONG_MAP_ITERATOR)

    + + +

    This method accesses the value of a Map entry, using a key that was retrieved from +a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the +Map.get(key) lookup.

    + + +

    Dm: Hardcoded constant database password (DMI_CONSTANT_DB_PASSWORD)

    + + +

    This code creates a database connect using a hardcoded, constant password. Anyone with access to either the source code or the compiled code can + easily learn the password. +

    + + + +

    Dm: Empty database password (DMI_EMPTY_DB_PASSWORD)

    + + +

    This code creates a database connect using a blank or empty password. This indicates that the database is not protected by a password. +

    + + + +

    HRS: HTTP cookie formed from untrusted input (HRS_REQUEST_PARAMETER_TO_COOKIE)

    + + +

    This code constructs an HTTP Cookie using an untrusted HTTP parameter. If this cookie is added to an HTTP response, it will allow a HTTP response splitting +vulnerability. See http://en.wikipedia.org/wiki/HTTP_response_splitting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of HTTP response splitting. +If FindBugs found any, you almost certainly have more +vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    HRS: HTTP Response splitting vulnerability (HRS_REQUEST_PARAMETER_TO_HTTP_HEADER)

    + + +

    This code directly writes an HTTP parameter to an HTTP header, which allows for a HTTP response splitting +vulnerability. See http://en.wikipedia.org/wiki/HTTP_response_splitting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of HTTP response splitting. +If FindBugs found any, you almost certainly have more +vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    PT: Absolute path traversal in servlet (PT_ABSOLUTE_PATH_TRAVERSAL)

    + + +

    The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory, +but it does not properly neutralize absolute path sequences such as "/abs/path" that can resolve to a location that is outside of that directory. + +See http://cwe.mitre.org/data/definitions/36.html +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of absolute path traversal. +If FindBugs found any, you almost certainly have more +vulnerabilities that FindBugs doesn't report. If you are concerned about absolute path traversal, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    PT: Relative path traversal in servlet (PT_RELATIVE_PATH_TRAVERSAL)

    + + +

    The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. + +See http://cwe.mitre.org/data/definitions/23.html +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of relative path traversal. +If FindBugs found any, you almost certainly have more +vulnerabilities that FindBugs doesn't report. If you are concerned about relative path traversal, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    SQL: Nonconstant string passed to execute method on an SQL statement (SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE)

    + + +

    The method invokes the execute method on an SQL statement with a String that seems +to be dynamically generated. Consider using +a prepared statement instead. It is more efficient and less vulnerable to +SQL injection attacks. +

    + + +

    SQL: A prepared statement is generated from a nonconstant String (SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING)

    + + +

    The code creates an SQL prepared statement from a nonconstant String. +If unchecked, tainted data from a user is used in building this String, SQL injection could +be used to make the prepared statement do something unexpected and undesirable. +

    + + +

    XSS: JSP reflected cross site scripting vulnerability (XSS_REQUEST_PARAMETER_TO_JSP_WRITER)

    + + +

    This code directly writes an HTTP parameter to JSP output, which allows for a cross site scripting +vulnerability. See http://en.wikipedia.org/wiki/Cross-site_scripting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of cross site scripting. +If FindBugs found any, you almost certainly have more cross site scripting +vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + +

    XSS: Servlet reflected cross site scripting vulnerability in error page (XSS_REQUEST_PARAMETER_TO_SEND_ERROR)

    + + +

    This code directly writes an HTTP parameter to a Server error page (using HttpServletResponse.sendError). Echoing this untrusted input allows +for a reflected cross site scripting +vulnerability. See http://en.wikipedia.org/wiki/Cross-site_scripting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of cross site scripting. +If FindBugs found any, you almost certainly have more cross site scripting +vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    XSS: Servlet reflected cross site scripting vulnerability (XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER)

    + + +

    This code directly writes an HTTP parameter to Servlet output, which allows for a reflected cross site scripting +vulnerability. See http://en.wikipedia.org/wiki/Cross-site_scripting +for more information.

    +

    FindBugs looks only for the most blatant, obvious cases of cross site scripting. +If FindBugs found any, you almost certainly have more cross site scripting +vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously +consider using a commercial static analysis or pen-testing tool. +

    + + + +

    BC: Questionable cast to abstract collection (BC_BAD_CAST_TO_ABSTRACT_COLLECTION)

    + + +

    +This code casts a Collection to an abstract collection +(such as List, Set, or Map). +Ensure that you are guaranteed that the object is of the type +you are casting to. If all you need is to be able +to iterate through a collection, you don't need to cast it to a Set or List. +

    + + +

    BC: Questionable cast to concrete collection (BC_BAD_CAST_TO_CONCRETE_COLLECTION)

    + + +

    +This code casts an abstract collection (such as a Collection, List, or Set) +to a specific concrete implementation (such as an ArrayList or HashSet). +This might not be correct, and it may make your code fragile, since +it makes it harder to switch to other concrete implementations at a future +point. Unless you have a particular reason to do so, just use the abstract +collection class. +

    + + +

    BC: Unchecked/unconfirmed cast (BC_UNCONFIRMED_CAST)

    + + +

    +This cast is unchecked, and not all instances of the type casted from can be cast to +the type it is being cast to. Check that your program logic ensures that this +cast will not fail. +

    + + +

    BC: Unchecked/unconfirmed cast of return value from method (BC_UNCONFIRMED_CAST_OF_RETURN_VALUE)

    + + +

    +This code performs an unchecked cast of the return value of a method. +The code might be calling the method in such a way that the cast is guaranteed to be +safe, but FindBugs is unable to verify that the cast is safe. Check that your program logic ensures that this +cast will not fail. +

    + + +

    BC: instanceof will always return true (BC_VACUOUS_INSTANCEOF)

    + + +

    +This instanceof test will always return true (unless the value being tested is null). +Although this is safe, make sure it isn't +an indication of some misunderstanding or some other logic error. +If you really want to test the value for being null, perhaps it would be clearer to do +better to do a null test rather than an instanceof test. +

    + + +

    BSHIFT: Unsigned right shift cast to short/byte (ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT)

    + + +

    +The code performs an unsigned right shift, whose result is then +cast to a short or byte, which discards the upper bits of the result. +Since the upper bits are discarded, there may be no difference between +a signed and unsigned right shift (depending upon the size of the shift). +

    + + +

    CI: Class is final but declares protected field (CI_CONFUSED_INHERITANCE)

    + + +

    + This class is declared to be final, but declares fields to be protected. Since the class + is final, it can not be derived from, and the use of protected is confusing. The access + modifier for the field should be changed to private or public to represent the true + use for the field. +

    + + +

    DB: Method uses the same code for two branches (DB_DUPLICATE_BRANCHES)

    + + +

    + This method uses the same code to implement two branches of a conditional branch. + Check to ensure that this isn't a coding mistake. +

    + + +

    DB: Method uses the same code for two switch clauses (DB_DUPLICATE_SWITCH_CLAUSES)

    + + +

    + This method uses the same code to implement two clauses of a switch statement. + This could be a case of duplicate code, but it might also indicate + a coding mistake. +

    + + +

    DLS: Dead store to local variable (DLS_DEAD_LOCAL_STORE)

    + + +

    +This instruction assigns a value to a local variable, +but the value is not read or used in any subsequent instruction. +Often, this indicates an error, because the value computed is never +used. +

    +

    +Note that Sun's javac compiler often generates dead stores for +final local variables. Because FindBugs is a bytecode-based tool, +there is no easy way to eliminate these false positives. +

    + + +

    DLS: Useless assignment in return statement (DLS_DEAD_LOCAL_STORE_IN_RETURN)

    + + +

    +This statement assigns to a local variable in a return statement. This assignment +has effect. Please verify that this statement does the right thing. +

    + + +

    DLS: Dead store of null to local variable (DLS_DEAD_LOCAL_STORE_OF_NULL)

    + + +

    The code stores null into a local variable, and the stored value is not +read. This store may have been introduced to assist the garbage collector, but +as of Java SE 6.0, this is no longer needed or useful. +

    + + +

    DLS: Dead store to local variable that shadows field (DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD)

    + + +

    +This instruction assigns a value to a local variable, +but the value is not read or used in any subsequent instruction. +Often, this indicates an error, because the value computed is never +used. There is a field with the same name as the local variable. Did you +mean to assign to that variable instead? +

    + + +

    DMI: Code contains a hard coded reference to an absolute pathname (DMI_HARDCODED_ABSOLUTE_FILENAME)

    + + +

    This code constructs a File object using a hard coded to an absolute pathname +(e.g., new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment"); +

    + + +

    DMI: Non serializable object written to ObjectOutput (DMI_NONSERIALIZABLE_OBJECT_WRITTEN)

    + + +

    +This code seems to be passing a non-serializable object to the ObjectOutput.writeObject method. +If the object is, indeed, non-serializable, an error will result. +

    + + +

    DMI: Invocation of substring(0), which returns the original value (DMI_USELESS_SUBSTRING)

    + + +

    +This code invokes substring(0) on a String, which returns the original value. +

    + + +

    Dm: Thread passed where Runnable expected (DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED)

    + + +

    A Thread object is passed as a parameter to a method where +a Runnable is expected. This is rather unusual, and may indicate a logic error +or cause unexpected behavior. +

    + + +

    Eq: Class doesn't override equals in superclass (EQ_DOESNT_OVERRIDE_EQUALS)

    + + +

    This class extends a class that defines an equals method and adds fields, but doesn't +define an equals method itself. Thus, equality on instances of this class will +ignore the identity of the subclass and the added fields. Be sure this is what is intended, +and that you don't need to override the equals method. Even if you don't need to override +the equals method, consider overriding it anyway to document the fact +that the equals method for the subclass just return the result of +invoking super.equals(o). +

    + + +

    Eq: Unusual equals method (EQ_UNUSUAL)

    + + +

    This class doesn't do any of the patterns we recognize for checking that the type of the argument +is compatible with the type of the this object. There might not be anything wrong with +this code, but it is worth reviewing. +

    + + +

    FE: Test for floating point equality (FE_FLOATING_POINT_EQUALITY)

    + + +

    + This operation compares two floating point values for equality. + Because floating point calculations may involve rounding, + calculated float and double values may not be accurate. + For values that must be precise, such as monetary values, + consider using a fixed-precision type such as BigDecimal. + For values that need not be precise, consider comparing for equality + within some range, for example: + if ( Math.abs(x - y) < .0000001 ). + See the Java Language Specification, section 4.2.4. +

    + + +

    FS: Non-Boolean argument formatted using %b format specifier (VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN)

    + + +

    +An argument not of type Boolean is being formatted with a %b format specifier. This won't throw an +exception; instead, it will print true for any nonnull value, and false for null. +This feature of format strings is strange, and may not be what you intended. +

    + + +

    IA: Potentially ambiguous invocation of either an inherited or outer method (IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD)

    + + +

    +An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class. +For example, you invoke foo(17), which is defined in both a superclass and in an outer method. +By the Java semantics, +it will be resolved to invoke the inherited method, but this may not be want +you intend. +

    +

    If you really intend to invoke the inherited method, +invoke it by invoking the method on super (e.g., invoke super.foo(17)), and +thus it will be clear to other readers of your code and to FindBugs +that you want to invoke the inherited method, not the method in the outer class. +

    +

    If you call this.foo(17), then the inherited method will be invoked. However, since FindBugs only looks at +classfiles, it +can't tell the difference between an invocation of this.foo(17) and foo(17), it will still +complain about a potential ambiguous invocation. +

    + + +

    IC: Initialization circularity (IC_INIT_CIRCULARITY)

    + + +

    A circularity was detected in the static initializers of the two + classes referenced by the bug instance.  Many kinds of unexpected + behavior may arise from such circularity.

    + + +

    ICAST: Integral division result cast to double or float (ICAST_IDIV_CAST_TO_DOUBLE)

    + + +

    +This code casts the result of an integral division (e.g., int or long division) +operation to double or +float. +Doing division on integers truncates the result +to the integer value closest to zero. The fact that the result +was cast to double suggests that this precision should have been retained. +What was probably meant was to cast one or both of the operands to +double before performing the division. Here is an example: +

    +
    +
    +int x = 2;
    +int y = 5;
    +// Wrong: yields result 0.0
    +double value1 =  x / y;
    +
    +// Right: yields result 0.4
    +double value2 =  x / (double) y;
    +
    +
    + + +

    ICAST: Result of integer multiplication cast to long (ICAST_INTEGER_MULTIPLY_CAST_TO_LONG)

    + + +

    +This code performs integer multiply and then converts the result to a long, +as in:

    +
    +    long convertDaysToMilliseconds(int days) { return 1000*3600*24*days; }
    +
    +

    +If the multiplication is done using long arithmetic, you can avoid +the possibility that the result will overflow. For example, you +could fix the above code to:

    +
    +    long convertDaysToMilliseconds(int days) { return 1000L*3600*24*days; }
    +
    +or +
    +    static final long MILLISECONDS_PER_DAY = 24L*3600*1000;
    +    long convertDaysToMilliseconds(int days) { return days * MILLISECONDS_PER_DAY; }
    +
    + + +

    IM: Computation of average could overflow (IM_AVERAGE_COMPUTATION_COULD_OVERFLOW)

    + + +

    The code computes the average of two integers using either division or signed right shift, +and then uses the result as the index of an array. +If the values being averaged are very large, this can overflow (resulting in the computation +of a negative average). Assuming that the result is intended to be nonnegative, you +can use an unsigned right shift instead. In other words, rather that using (low+high)/2, +use (low+high) >>> 1 +

    +

    This bug exists in many earlier implementations of binary search and merge sort. +Martin Buchholz found and fixed it +in the JDK libraries, and Joshua Bloch +widely +publicized the bug pattern. +

    + + +

    IM: Check for oddness that won't work for negative numbers (IM_BAD_CHECK_FOR_ODD)

    + + +

    +The code uses x % 2 == 1 to check to see if a value is odd, but this won't work +for negative numbers (e.g., (-5) % 2 == -1). If this code is intending to check +for oddness, consider using x & 1 == 1, or x % 2 != 0. +

    + + +

    INT: Integer remainder modulo 1 (INT_BAD_REM_BY_1)

    + + +

    Any expression (exp % 1) is guaranteed to always return zero. +Did you mean (exp & 1) or (exp % 2) instead? +

    + + +

    INT: Vacuous bit mask operation on integer value (INT_VACUOUS_BIT_OPERATION)

    + + +

    This is an integer bit operation (and, or, or exclusive or) that doesn't do any useful work +(e.g., v & 0xffffffff). + +

    + + +

    INT: Vacuous comparison of integer value (INT_VACUOUS_COMPARISON)

    + + +

    There is an integer comparison that always returns +the same value (e.g., x <= Integer.MAX_VALUE). +

    + + +

    MTIA: Class extends Servlet class and uses instance variables (MTIA_SUSPECT_SERVLET_INSTANCE_FIELD)

    + + +

    + This class extends from a Servlet class, and uses an instance member variable. Since only + one instance of a Servlet class is created by the J2EE framework, and used in a + multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider + only using method local variables. +

    + + +

    MTIA: Class extends Struts Action class and uses instance variables (MTIA_SUSPECT_STRUTS_INSTANCE_FIELD)

    + + +

    + This class extends from a Struts Action class, and uses an instance member variable. Since only + one instance of a struts Action class is created by the Struts framework, and used in a + multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider + only using method local variables. Only instance fields that are written outside of a monitor + are reported. +

    + + +

    NP: Dereference of the result of readLine() without nullcheck (NP_DEREFERENCE_OF_READLINE_VALUE)

    + + +

    The result of invoking readLine() is dereferenced without checking to see if the result is null. If there are no more lines of text +to read, readLine() will return null and dereferencing that will generate a null pointer exception. +

    + + +

    NP: Immediate dereference of the result of readLine() (NP_IMMEDIATE_DEREFERENCE_OF_READLINE)

    + + +

    The result of invoking readLine() is immediately dereferenced. If there are no more lines of text +to read, readLine() will return null and dereferencing that will generate a null pointer exception. +

    + + +

    NP: Load of known null value (NP_LOAD_OF_KNOWN_NULL_VALUE)

    + + +

    The variable referenced at this point is known to be null due to an earlier + check against null. Although this is valid, it might be a mistake (perhaps you +intended to refer to a different variable, or perhaps the earlier check to see if the +variable is null should have been a check to see if it was nonnull). +

    + + +

    NP: Method tightens nullness annotation on parameter (NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION)

    + +

    + A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter + that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull. + Doing so violates the contract that the method should handle a null parameter. +

    + +

    NP: Method relaxes nullness annotation on return value (NP_METHOD_RETURN_RELAXING_ANNOTATION)

    + +

    + A method should always implement the contract of a method it overrides. Thus, if a method takes is annotated + as returning a @Nonnull value, + you shouldn't override that method in a subclass with a method annotated as returning a @Nullable or @CheckForNull value. + Doing so violates the contract that the method shouldn't return null. +

    + +

    NP: Possible null pointer dereference due to return value of called method (NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE)

    + + +

    The return value from a method is dereferenced without a null check, +and the return value of that method is one that should generally be checked +for null. This may lead to a NullPointerException when the code is executed. +

    + + +

    NP: Possible null pointer dereference on branch that might be infeasible (NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE)

    + + +

    There is a branch of statement that, if executed, guarantees that +a null value will be dereferenced, which +would generate a NullPointerException when the code is executed. +Of course, the problem might be that the branch or statement is infeasible and that +the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs. +Due to the fact that this value had been previously tested for nullness, +this is a definite possibility. +

    + + +

    NP: Parameter must be nonnull but is marked as nullable (NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE)

    + + +

    This parameter is always used in a way that requires it to be nonnull, +but the parameter is explicitly annotated as being Nullable. Either the use +of the parameter or the annotation is wrong. +

    + + +

    NP: Read of unwritten public or protected field (NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)

    + + +

    The program is dereferencing a public or protected +field that does not seem to ever have a non-null value written to it. +Unless the field is initialized via some mechanism not seen by the analysis, +dereferencing this value will generate a null pointer exception. +

    + + +

    NS: Potentially dangerous use of non-short-circuit logic (NS_DANGEROUS_NON_SHORT_CIRCUIT)

    + + +

    This code seems to be using non-short-circuit logic (e.g., & +or |) +rather than short-circuit logic (&& or ||). In addition, +it seem possible that, depending on the value of the left hand side, you might not +want to evaluate the right hand side (because it would have side effects, could cause an exception +or could be expensive.

    +

    +Non-short-circuit logic causes both sides of the expression +to be evaluated even when the result can be inferred from +knowing the left-hand side. This can be less efficient and +can result in errors if the left-hand side guards cases +when evaluating the right-hand side can generate an error. +

    + +

    See the Java +Language Specification for details + +

    + + +

    NS: Questionable use of non-short-circuit logic (NS_NON_SHORT_CIRCUIT)

    + + +

    This code seems to be using non-short-circuit logic (e.g., & +or |) +rather than short-circuit logic (&& or ||). +Non-short-circuit logic causes both sides of the expression +to be evaluated even when the result can be inferred from +knowing the left-hand side. This can be less efficient and +can result in errors if the left-hand side guards cases +when evaluating the right-hand side can generate an error. + +

    See the Java +Language Specification for details + +

    + + +

    PZLA: Consider returning a zero length array rather than null (PZLA_PREFER_ZERO_LENGTH_ARRAYS)

    + + +

    It is often a better design to +return a length zero array rather than a null reference to indicate that there +are no results (i.e., an empty list of results). +This way, no explicit check for null is needed by clients of the method.

    + +

    On the other hand, using null to indicate +"there is no answer to this question" is probably appropriate. +For example, File.listFiles() returns an empty list +if given a directory containing no files, and returns null if the file +is not a directory.

    + + +

    QF: Complicated, subtle or wrong increment in for-loop (QF_QUESTIONABLE_FOR_LOOP)

    + + +

    Are you sure this for loop is incrementing the correct variable? + It appears that another variable is being initialized and checked + by the for loop. +

    + + +

    RCN: Redundant comparison of non-null value to null (RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE)

    + + +

    This method contains a reference known to be non-null with another reference +known to be null.

    + + +

    RCN: Redundant comparison of two null values (RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES)

    + + +

    This method contains a redundant comparison of two references known to +both be definitely null.

    + + +

    RCN: Redundant nullcheck of value known to be non-null (RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE)

    + + +

    This method contains a redundant check of a known non-null value against +the constant null.

    + + +

    RCN: Redundant nullcheck of value known to be null (RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE)

    + + +

    This method contains a redundant check of a known null value against +the constant null.

    + + +

    REC: Exception is caught when Exception is not thrown (REC_CATCH_EXCEPTION)

    + + +

    + This method uses a try-catch block that catches Exception objects, but Exception is not + thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to + say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception + each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, + masking potential bugs. +

    +

    A better approach is to either explicitly catch the specific exceptions that are thrown, + or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

    +
    +  try {
    +    ...
    +  } catch (RuntimeException e) {
    +    throw e;
    +  } catch (Exception e) {
    +    ... deal with all non-runtime exceptions ...
    +  }
    + + +

    RI: Class implements same interface as superclass (RI_REDUNDANT_INTERFACES)

    + + +

    + This class declares that it implements an interface that is also implemented by a superclass. + This is redundant because once a superclass implements an interface, all subclasses by default also + implement this interface. It may point out that the inheritance hierarchy has changed since + this class was created, and consideration should be given to the ownership of + the interface's implementation. +

    + + +

    RV: Method checks to see if result of String.indexOf is positive (RV_CHECK_FOR_POSITIVE_INDEXOF)

    + + +

    The method invokes String.indexOf and checks to see if the result is positive or non-positive. + It is much more typical to check to see if the result is negative or non-negative. It is + positive only if the substring checked for occurs at some place other than at the beginning of + the String.

    + + +

    RV: Method discards result of readLine after checking if it is nonnull (RV_DONT_JUST_NULL_CHECK_READLINE)

    + + +

    The value returned by readLine is discarded after checking to see if the return +value is non-null. In almost all situations, if the result is non-null, you will want +to use that non-null value. Calling readLine again will give you a different line.

    + + +

    RV: Remainder of hashCode could be negative (RV_REM_OF_HASHCODE)

    + + +

    This code computes a hashCode, and then computes +the remainder of that value modulo another value. Since the hashCode +can be negative, the result of the remainder operation +can also be negative.

    +

    Assuming you want to ensure that the result of your computation is nonnegative, +you may need to change your code. +If you know the divisor is a power of 2, +you can use a bitwise and operator instead (i.e., instead of +using x.hashCode()%n, use x.hashCode()&(n-1). +This is probably faster than computing the remainder as well. +If you don't know that the divisor is a power of 2, take the absolute +value of the result of the remainder operation (i.e., use +Math.abs(x.hashCode()%n) +

    + + +

    RV: Remainder of 32-bit signed random integer (RV_REM_OF_RANDOM_INT)

    + + +

    This code generates a random signed integer and then computes +the remainder of that value modulo another value. Since the random +number can be negative, the result of the remainder operation +can also be negative. Be sure this is intended, and strongly +consider using the Random.nextInt(int) method instead. +

    + + +

    RV: Method ignores return value, is this OK? (RV_RETURN_VALUE_IGNORED_INFERRED)

    + + +

    This code calls a method and ignores the return value. The return value +is the same type as the type the method is invoked on, and from our analysis it looks +like the return value might be important (e.g., like ignoring the +return value of String.toLowerCase()). +

    +

    We are guessing that ignoring the return value might be a bad idea just from +a simple analysis of the body of the method. You can use a @CheckReturnValue annotation +to instruct FindBugs as to whether ignoring the return value of this method +is important or acceptable. +

    +

    Please investigate this closely to decide whether it is OK to ignore the return value. +

    + + +

    SA: Double assignment of field (SA_FIELD_DOUBLE_ASSIGNMENT)

    + + +

    This method contains a double assignment of a field; e.g. +

    +
    +  int x,y;
    +  public void foo() {
    +    x = x = 17;
    +  }
    +
    +

    Assigning to a field twice is useless, and may indicate a logic error or typo.

    + + +

    SA: Double assignment of local variable (SA_LOCAL_DOUBLE_ASSIGNMENT)

    + + +

    This method contains a double assignment of a local variable; e.g. +

    +
    +  public void foo() {
    +    int x,y;
    +    x = x = 17;
    +  }
    +
    +

    Assigning the same value to a variable twice is useless, and may indicate a logic error or typo.

    + + +

    SA: Self assignment of local variable (SA_LOCAL_SELF_ASSIGNMENT)

    + + +

    This method contains a self assignment of a local variable; e.g.

    +
    +  public void foo() {
    +    int x = 3;
    +    x = x;
    +  }
    +
    +

    +Such assignments are useless, and may indicate a logic error or typo. +

    + + +

    SF: Switch statement found where one case falls through to the next case (SF_SWITCH_FALLTHROUGH)

    + + +

    This method contains a switch statement where one case branch will fall through to the next case. + Usually you need to end this case with a break or return.

    + + +

    SF: Switch statement found where default case is missing (SF_SWITCH_NO_DEFAULT)

    + + +

    This method contains a switch statement where default case is missing. + Usually you need to provide a default case.

    +

    Because the analysis only looks at the generated bytecode, this warning can be incorrect triggered if +the default case is at the end of the switch statement and doesn't end with a break statement. + + +

    ST: Write to static field from instance method (ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD)

    + + +

    This instance method writes to a static field. This is tricky to get +correct if multiple instances are being manipulated, +and generally bad practice. +

    + + +

    Se: Private readResolve method not inherited by subclasses (SE_PRIVATE_READ_RESOLVE_NOT_INHERITED)

    + + +

    This class defines a private readResolve method. Since it is private, it won't be inherited by subclasses. +This might be intentional and OK, but should be reviewed to ensure it is what is intended. +

    + + +

    Se: Transient field of class that isn't Serializable. (SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS)

    + + +

    The field is marked as transient, but the class isn't Serializable, so marking it as transient +has absolutely no effect. +This may be leftover marking from a previous version of the code in which the class was transient, or +it may indicate a misunderstanding of how serialization works. +

    + + +

    TQ: Value required to have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK)

    + + +

    + A value is used in a way that requires it to be always be a value denoted by a type qualifier, but + there is an explicit annotation stating that it is not known where the value is required to have that type qualifier. + Either the usage or the annotation is incorrect. +

    + + +

    TQ: Value required to not have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK)

    + + +

    + A value is used in a way that requires it to be never be a value denoted by a type qualifier, but + there is an explicit annotation stating that it is not known where the value is prohibited from having that type qualifier. + Either the usage or the annotation is incorrect. +

    + + +

    UCF: Useless control flow (UCF_USELESS_CONTROL_FLOW)

    + + +

    This method contains a useless control flow statement, where +control flow continues onto the same place regardless of whether or not +the branch is taken. For example, +this is caused by having an empty statement +block for an if statement:

    +
    +    if (argv.length == 0) {
    +    // TODO: handle this case
    +    }
    +
    + + +

    UCF: Useless control flow to next line (UCF_USELESS_CONTROL_FLOW_NEXT_LINE)

    + + +

    This method contains a useless control flow statement in which control +flow follows to the same or following line regardless of whether or not +the branch is taken. +Often, this is caused by inadvertently using an empty statement as the +body of an if statement, e.g.:

    +
    +    if (argv.length == 1);
    +        System.out.println("Hello, " + argv[0]);
    +
    + + +

    UrF: Unread public/protected field (URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD)

    + + +

    This field is never read.  +The field is public or protected, so perhaps + it is intended to be used with classes not seen as part of the analysis. If not, +consider removing it from the class.

    + + +

    UuF: Unused public or protected field (UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD)

    + + +

    This field is never used.  +The field is public or protected, so perhaps + it is intended to be used with classes not seen as part of the analysis. If not, +consider removing it from the class.

    + + +

    UwF: Field not initialized in constructor but dereferenced without null check (UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)

    + + +

    This field is never initialized within any constructor, and is therefore could be null after +the object is constructed. Elsewhere, it is loaded and dereferenced without a null check. +This could be a either an error or a questionable design, since +it means a null pointer exception will be generated if that field is dereferenced +before being initialized. +

    + + +

    UwF: Unwritten public or protected field (UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)

    + + +

    No writes were seen to this public/protected field.  All reads of it will return the default +value. Check for errors (should it have been initialized?), or remove it if it is useless.

    + + +

    XFB: Method directly allocates a specific implementation of xml interfaces (XFB_XML_FACTORY_BYPASS)

    + + +

    + This method allocates a specific implementation of an xml interface. It is preferable to use + the supplied factory classes to create these objects so that the implementation can be + changed at runtime. See +

    +
      +
    • javax.xml.parsers.DocumentBuilderFactory
    • +
    • javax.xml.parsers.SAXParserFactory
    • +
    • javax.xml.transform.TransformerFactory
    • +
    • org.w3c.dom.Document.createXXXX
    • +
    +

    for details.

    + + + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo +

  • + diff --git a/doc/buggy-sm.png b/doc/buggy-sm.png new file mode 100644 index 0000000..7f5fc50 Binary files /dev/null and b/doc/buggy-sm.png differ diff --git a/doc/contributing.html b/doc/contributing.html new file mode 100644 index 0000000..a22b3ab --- /dev/null +++ b/doc/contributing.html @@ -0,0 +1,121 @@ + + +Contributing to FindBugs + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    Contributing to FindBugs

    + +

    If you have a bug fix or feature enhancement you would like to contribute, +we would be happy to consider it for inclusion.

    + +

    Import FindBugs code as Eclipse projects

    + +

    The preferred way to get the FindBugs source code and create the patch is to use Eclipse + SVN. +You can easily import FindBugs code into Eclipse by following the steps described +here: Import Eclipse projects +. +

    + +

    Preparing a patch

    + +

    The best way to +send an enhancement is to create a patch against the latest code +in the FindBugs Subversion repository +at http://findbugs.googlecode.com/svn/trunk/ +(those people who have been given commit priviledges should use +https://findbugs.googlecode.com/svn/trunk/). +

    + +

    To create a patch from Eclipse, please right click the [findbugs] or [findBugsEclipsePlugin] project +and choose [Team | Create Patch...] context menu. +

    + +

    Please follow these guidelines when preparing your patch:

    +
      +
    • Use the same indentation style as the source file(s) you + are modifying.  In particular, please use tabs (not spaces) + to indent your code; one tab per indent level. +
    • If at all possible, avoid making whitespace modifications. +
    • Small patches are appreciated. +
    • If you are submitting a new bug detector, please submit a small + standalone source file that contains an instance of the + kind of bug the detector looks for. +
    + +

    Following these guidelines makes it much easier for us +to incorporate new code. + +

    How to submit a patch

    + +

    Patches may be submitted through the +Patches tracker on the +sourceforge project page. + + +


    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/customers/ITAsoftware.png b/doc/customers/ITAsoftware.png new file mode 100644 index 0000000..3ec79c0 Binary files /dev/null and b/doc/customers/ITAsoftware.png differ diff --git a/doc/customers/geoLocation.png b/doc/customers/geoLocation.png new file mode 100644 index 0000000..0fe6ba8 Binary files /dev/null and b/doc/customers/geoLocation.png differ diff --git a/doc/customers/geoMap.png b/doc/customers/geoMap.png new file mode 100644 index 0000000..0d58eef Binary files /dev/null and b/doc/customers/geoMap.png differ diff --git a/doc/customers/glassfish.png b/doc/customers/glassfish.png new file mode 100644 index 0000000..3ec28be Binary files /dev/null and b/doc/customers/glassfish.png differ diff --git a/doc/customers/google.png b/doc/customers/google.png new file mode 100644 index 0000000..e42ab09 Binary files /dev/null and b/doc/customers/google.png differ diff --git a/doc/customers/logo_umd.png b/doc/customers/logo_umd.png new file mode 100644 index 0000000..7d8ed11 Binary files /dev/null and b/doc/customers/logo_umd.png differ diff --git a/doc/customers/nsf.png b/doc/customers/nsf.png new file mode 100644 index 0000000..98531a0 Binary files /dev/null and b/doc/customers/nsf.png differ diff --git a/doc/customers/sat4j.png b/doc/customers/sat4j.png new file mode 100644 index 0000000..6454e21 Binary files /dev/null and b/doc/customers/sat4j.png differ diff --git a/doc/customers/sleepycat.png b/doc/customers/sleepycat.png new file mode 100644 index 0000000..23911f3 Binary files /dev/null and b/doc/customers/sleepycat.png differ diff --git a/doc/customers/sun.png b/doc/customers/sun.png new file mode 100644 index 0000000..dc0cae7 Binary files /dev/null and b/doc/customers/sun.png differ diff --git a/doc/demo.html b/doc/demo.html new file mode 100644 index 0000000..83ce7a3 --- /dev/null +++ b/doc/demo.html @@ -0,0 +1,219 @@ + + +FindBugs™ 1.2 Demo and Results + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    +

    +FindBugs 1.2 demo and results +

    + +

    If you just want to try running FindBugs against your +own code, you can +run FindBugs using Java Webstart. +This will use our new gui under Java 1.5+ and our old gui under Java 1.4. +The new gui provides a number of new features, but requires Java 1.5+. +Both use exactly the same analysis engine. + +

    This web page provides results of running FindBugs 1.2.0 +against several open source applications. We provide a summary +of the number of bugs we found, as well as a generated HTML listing +of the bugs and +a Java +WebStart demo of the new GUI we've introduced in FindBugs version 1.1, +displaying the warnings and the relevant source. + + +

    The applications and versions of them we report on +are somewhat arbitrary. In some cases, they are release versions, +in other cases nightly builds. We find lots of bugs in every large code +base we examine; these applications are certainly not the worst we have seen. +I have been allowed to confidentially examine the results of running FindBugs +against several closed commercial code bases by well respected companies; +the results I've seen there are not significantly different from +what I've observed in open source code bases. + + +

    Experimental details: These results are from running +FindBugs 1.2.0 at standard effort level. Our results do not include +any low priority warnings or any warnings about vulnerabilities to +malicious code. Although we have (repeatedly) manually audited the results, +we haven't manually filtered out false positives from these warnings, +so that you can get a feeling for the quality of the warnings generated +by FindBugs. +

    Some of the bugs contain audit comments: they are marked as to whether +we thought the warning indicated a bug that should or must be fixed, or whether it was not, in fact, a bug. +

    In the webstart versions, we've only included the bugs for which +we were able to identify source files. The number of lines of non-commenting source +statements in the table below (KNCSS) is derived from the same files +that we analyzed and in which we report bugs; we actually compute +KNCSS from the classfiles, not the source files. + +

    Vulnerability disclosure: Thankfully, Java isn't C or C++. Dereferencing +a null pointer or accessing outside the bounds of an array generates a runtime +exception rather than a shell exploit. We do not believe that any of the +warnings here represents a security vulnerability, although we have not audited +them to verify that. These projects are all aware of the existence of +FindBugs, and FindBugs is already open source and available +for use both by developers and attackers, we don't believe that making +these results available constitutes a reckless disclosure. + + +

    Recommendations: First, review the correctness warnings. + We feel confident that developers +would want to fix most of the high and medium priority correctness warnings we report. +Once you've reviewed those, +you might want to look at some of the other categories. +

    +In other categories, +such as Bad practice and Dodgy code, we accept more false positives. You +might decide that a pattern bug pattern isn't relevant for your code +base (e.g., you never use Serialization for persistent storage, +so you never care about the fact that you didn't define a serializationUID), +and even for the bug patterns relevant to your code base, +perhaps only a minority will reflect problems serious enough to +convince you to change your code. + +

    Please be patient The Web start versions not only have to download the applications, + they need to download about 10 megabytes of data and source files. Please + be patient. Sorry we don't have a progress bar for the data and source download; + the ability to remotely download a data and source archive is a little bit of + a hack. We've provided small versions of some of the data sets that include + only the correctness bugs and the source files containing those warnings. The small + datasets are about a quarter of the sizes of the full datasets. +

    +

    +

    +
    ApplicationDetailsCorrectness bugsBad PracticeDodgyKNCSS +
    HTMLWebStartNP bugsOther +
    Sun JDK 1.7.0-b12 + All + + All + Small + 68180954654597 + +
    eclipse-SDK-3.3M7-solaris-gtk + All + + All + Small + 1462591,0796431,447 + +
    netbeans-6_0-m8 + All + + All + Small + 1893053,0101,1121,022 + +
    glassfish-v2-b43 + All + + All + Small + 1461549641,2222,176 + +
    jboss-4.0.5 + All + + All + Small + 3057263214178 + +
    +

    KNCSS - Thousands of lines of non-commenting source statements + +

    Bug categories

    +
    +
    Correctness bug +
    Probable bug - an apparent coding mistake + resulting in code that was probably not what the + developer intended. We strive for a low false positive rate. +
    Bad Practice +
    +Violations of recommended and essential + coding practice. Examples include hash code and equals + problems, cloneable idiom, dropped exceptions, + serializable problems, and misuse of finalize. + We strive to make this analysis accurate, + although some groups may + not care about some of the bad practices. +
    Dodgy +
    +Code that is confusing, anomalous, or + written in a way that leads itself to errors. + Examples include dead local stores, switch fall through, + unconfirmed casts, and redundant null check of value + known to be null. + More false positives accepted. + In previous versions of FindBugs, this category was known as Style. +
    + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo

    + + + + + + + diff --git a/doc/downloads.html b/doc/downloads.html new file mode 100644 index 0000000..28bd639 --- /dev/null +++ b/doc/downloads.html @@ -0,0 +1,118 @@ + + +FindBugs Downloads + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    FindBugs downloads

    + +

    This page contains links to downloads +of FindBugs version 2.0.3, +released on 17:16:15 EST, 22 November, 2013. Download links +for all FindBugs versions and files +are available +on the sourceforge download page. + +

    + +The Eclipse plugin may also be obtained from one of the FindBugs Eclipse plugin update sites: + + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/eclipse-filters-icon.png b/doc/eclipse-filters-icon.png new file mode 100644 index 0000000..1ea0247 Binary files /dev/null and b/doc/eclipse-filters-icon.png differ diff --git a/doc/factSheet.html b/doc/factSheet.html new file mode 100644 index 0000000..029cd18 --- /dev/null +++ b/doc/factSheet.html @@ -0,0 +1,128 @@ + + +FindBugs™ Fact Sheet + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    FindBugs™ Fact Sheet

    + +

    FindBugs looks for bugs in Java programs.  It is based +on the concept of bug patterns.  A bug pattern is a code +idiom that is often an error.  Bug patterns arise for a variety +of reasons: +

    + +
      +
    • Difficult language features +
    • Misunderstood API methods +
    • Misunderstood invariants when code is modified during maintenance +
    • Garden variety mistakes: typos, use of the wrong boolean operator +
    + +

    FindBugs uses static analysis to inspect Java bytecode +for occurrences of bug patterns.  +Static analysis means that FindBugs can find bugs by simply inspecting +a program's code: executing the program is not necessary.  +This makes FindBugs very easy to use: in general, you should be +able to use it to look for bugs in your code within a few minutes of downloading it.  +FindBugs works by analyzing Java bytecode (compiled class files), +so you don't even need the program's source code to use it.  +Because its analysis is +sometimes imprecise, FindBugs can report false warnings, +which are warnings that do not indicate real errors.  +In practice, the rate of false warnings reported by FindBugs +is less than 50%. +

    + +

    +FindBugs supports a plugin architecture allowing anyone to add new +bug detectors.  The publications page +contains links to articles describing how to write a new detector +for FindBugs.  If you are familiar with Java bytecode +you can write a new FindBugs detector in as little as a few minutes. +

    + +

    FindBugs is free software, available under the terms of the +Lesser GNU Public License.  +It is written in Java, and can be run with any virtual machine compatible +with Sun's JDK 1.5.  It can analyze programs written for any version +of Java.  FindBugs was originally developed by Bill Pugh and David Hovemeyer.  +It is maintained by Bill Pugh, and +a team of volunteers. +

    + +

    FindBugs uses BCEL to +analyze Java bytecode.  +As of version 1.1, FindBugs also supports bug detectors written using +the ASM bytecode framework.  +FindBugs uses dom4j +for XML manipulation. +

    + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/findbugs.css b/doc/findbugs.css new file mode 100644 index 0000000..e201695 --- /dev/null +++ b/doc/findbugs.css @@ -0,0 +1,15 @@ +BODY { + background: white; +} + +A.plain { + text-decoration: none; +} + +A.sidebar { + text-decoration: none; +} + +A.sidebar:hover, A.sidebar:active { + text-decoration: underline; +} diff --git a/doc/findbugs2.html b/doc/findbugs2.html new file mode 100644 index 0000000..fc4066d --- /dev/null +++ b/doc/findbugs2.html @@ -0,0 +1,283 @@ + + +FindBugs 2™ - Find Bugs in Java Programs + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    + + + + + +
    FindBugs logo UMD logo
    + +

    FindBugs 2

    + +

    This page describes the major changes in FindBugs 2. We are well aware that the documentation on + the new features in FindBugs 2.0 have not kept up with the implementation. We will be working to + improve the documentation, but don't want to hold up the release any longer to improve the + documentation.

    +

    Anyone currently using FindBugs 1.3.9 should find FindBugs 2.0 to largely be a drop-in + replacement that offers better accuracy and performance.

    + + +

    + Also check out http://code.google.com/p/findbugs/w/list + for more information about some recent features/changes in FindBugs. +

    + +

    The major new features in FindBugs 2 are as follows:

    +
      +
    • Bug Rank - bugs are given a rank 1-20, and grouped into the categories scariest (rank 1-4), + scary (rank 5-9), troubling (rank 10-14), and of concern (rank 15-20). +
        +
      • priority renamed confidence - many people were confused by the priority reported by + FindBugs, and considered all HIGH priority issues to be important. To reflect the + actually meaning of this attribute of issues, it has been renamed confidence. Issues of + different bug patterns should be compared by there rank, not their confidence.
      • +
      + +
    • +
    • Cloud storage - having a convent way for developers to share + information about when an issue was first seen, and whether it is believed to be a serious + problem, is important to successful and cost-effective deployment of static analysis in a large + software project.
    • +
    • update checks - FindBugs will check for releases of new + versions of FindBugs. Note: we leverage this capability to count the number of FindBugs users. + These update checks can easily be disabled.
    • +
    • Plugins - FindBugs 2.0 makes it much easier to define plugins that + provide various capabilities, and install these plugins either on a per user or per installation + basis.
    • +
    • fb command - rather than using the rather haphazard collection of command line + scripts developed over the years for running various FindBugs commands, you can now use just + one: fb. +
        +
      • fb analyze - invokes the FindBugs analysis
      • +
      • fb gui - launches the FindBugs GUI +
      • fb list - lists the issues from a FindBugs analysis file
      • +
      • fb help - lists the command available.
      • +
      +

      + Plugins can be used to extend the commands that can be invoked via + fb. +

      +
    • +
    • New bug patterns and detectors, + and improved accuracy +
    • +
    • Improved performance: overall, we've seen an average 10% + performance improvement over a large range of benchmarks, although a few users have experienced + performance regressions we are still trying to understand.
    • +
    • Guava support - working with Kevin Bourrillion, we have provided additional support for the + Guava library, recognizing many common + misuse patterns. +
    • +
    • JSR-305 support - improved detection of problems identified by JSR-305 annotations. In + particular, we've significantly improved both the accuracy and performance of the analysis of + type qualifiers.
    • +
    + +

    Cloud storage of issue evaluations

    +

    For many years, you could store evaluations of FindBugs issues within the XML containing the + analysis results. However, this approach did not work well for a team of distributed developers. + Instead, we now provide a cloud based mechanism for storing this information. We are providing a + free communal cloud (hostied by Google appengine) for storing evaluations of FindBugs issues. You + can set up your own private cloud for storing issues, but at the moment this checking out a copy of + FindBugs, making some modifications and building the cloud storage plugin from source. We hope to + make it easier to have your own private cloud in FindBugs 2.0.1.

    +

    We have analyzed several large open source projects, and provide Java web start links to allow + you to view the results. We'd be happy to work with projects to make the results available from a + continuous build:

    + + +

    FindBugs update checks

    +

    + FindBugs now checks to see if a new version of FindBugs or a plugin has been released. We make use + of this check to collect statistics on the operating system, java version, locale and FindBugs entry + point (e.g., ant, command line, GUI). More information is + available, including information about how to disable update checks if your organization has a + policy against allowing the collection of such information. No information about the code being + analyzed is reported. + +

    + +

    Plugins

    +

    FindBugs 2.0 makes it much easier to customize FindBugs with plugins.

    +

    FindBugs looks for plugins in two places: your personal home directory, and in FindBugs home + (plugins installed in your home directory take precedence). In both places, it looks in two places: + the plugin directory, which contains plugins that are enabled by default, and the optionalPlugin + directory, which contains plugins that are disabled by default but can be enabled for a particular + project.

    +

    The FindBugs project includes several plugins:

    +
      +
    • Cloud plugins: These plugins provide ways to persist and share information about + issues seen in an analysis (e.g., when was this issue first seen, and any evaluations as to + whether this is harmless or a must fix issue, as well as comments about the issue from + developers) +
        +
      • bugCollectionCloud - stores issue evaluations in the XML. The way + issue evaluations were always stored before FindBugs 2.0. Distributed in the + optionalPlugin directory.
      • +
      • findbugsCommunalCloud Stores issue evaluations in the communal cloud + hosted at findbugs.appspot.com. Distributed in the plugin directory.
      • +
      • jdbcCloudClient an older, deprecated cloud that stored information in + an SQL database. Not distributed, most be built from source.
      • +
    • +
    • noUpdateChecks - Disables checks for updated versions and usage counting. + Distributed in the optionalPlugin directory.
    • +
    • poweruser - provides a number of additional commands for the fb + command. It is believed most of these commands are used by few people outside of the FindBugs + development team. Distributed in the optionalPlugin directory.
    • +
    • Bug filing plugins: these plugins assist in the filing of FindBugs issues in built + trackers. The bug filing framework is designed to be extensible to other bug filing systems. At + the moment, these plugins are not supported, and must be built from source. +
        +
      • jira
      • +
      • google code
      • +
    • +
    +

    Performance Improvements/regressions

    +

    + In our own testing, we've seen an overall improvement of 9% in + FindBugs performance from 1.3.9 to 2.0.0, with the majority of benchmarks seeing improvements. A + few users have reported significant performance regressions and we are asking + for more information from anyone seeing significant performance regressions. + +

    +

    New Bug patterns

    + + +
    + + + diff --git a/doc/guaranteedDereference.png b/doc/guaranteedDereference.png new file mode 100644 index 0000000..d0676f0 Binary files /dev/null and b/doc/guaranteedDereference.png differ diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..111f6ef --- /dev/null +++ b/doc/index.html @@ -0,0 +1,340 @@ + + +FindBugs™ - Find Bugs in Java Programs + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    + + + + + +
    FindBugs logo UMD logo
    + +

    FindBugs™ - Find Bugs in Java Programs

    + +

    + This is the web page for FindBugs, a program which uses static analysis to look for bugs in Java + code.  It is free software, distributed under the terms of the Lesser GNU Public License. The name + FindBugs™ and the FindBugs logo are trademarked by The University of Maryland. FindBugs has been downloaded more than + a million times. +

    + +

    The current version of FindBugs is 2.0.3.

    + +

    + FindBugs requires JRE (or JDK) 1.5.0 or later to run.  However, it can analyze programs + compiled for any version of Java, from 1.0 to 1.7. Some classfiles compiled for Java 1.8 give + FindBugs problems, the next major release of FindBugs will handle Java 1.8 classfiles. + +

    The current version of FindBugs is 2.0.3, + + released on 17:16:15 EST, 22 November, 2013. We are very interested in getting + feedback on how to improve FindBugs. File bug reports on our + sourceforge bug tracker +

    +

    The current version of FindBugs may encounter errors when analyzing + Java 1.8 bytecode, due to changes in the classfile format. After FindBugs 2.0.3 + is released, work will start on the next major release of FindBugs, which will + be able to analyze Java 1.8 (and will require Java 1.7 to compile and run). + + +

    + Changes | Talks | Papers | Sponsors | Support +

    + +

    FindBugs 2.0.3 Release

    +

    FindBugs 2.0.3 is intended to be a minor bug fix release over + FindBugs 2.0.2. Although than some improvements to existing bug detectors + and analysis engines, and a few new bug patterns, and some + important bug fixes to the Eclipse plugin, no significant changes + should be observed. Consult the Change log + for more details.

    + +

    + Also check out http://code.google.com/p/findbugs/w/list + for more information about some recent features/changes in FindBugs. +

    + + +

    + Major changes in FindBugs 2.0 (from FindBugs 1.3.x) +

    + + + +

    Ways to run FindBugs

    +

    Here are various ways to run FindBugs. For plugins not supported by the FindBugs team, check to + see what version of FindBugs they provide; it might take a little while for the plugins to update to + FindBugs 2.0.

    +
    +
    Command line, ant, GUI
    +
    Provided in FindBugs download
    +
    + Eclipse +
    +
    + Update site for Eclipse plugin: http://findbugs.cs.umd.edu/eclipse. + Supported by the FindBugs project. +
    +
    + Maven +
    +
    + http://mojo.codehaus.org/findbugs-maven-plugin/ +
    +
    + Netbeans +
    +
    + SQE: Software Quality Environment +
    +
    Jenkins
    +
    Jenkins FindBugs Plugin + +
    + Hudson +
    +
    + HUDSON FindBugs Plugin +
    +
    + IntelliJ +
    +
    + Several plugins, see http://code.google.com/p/findbugs/wiki/IntellijFindBugsPlugins + for a description. + +
    +
    + + +

    New

    +
      + +
    • jFormatString library republished at + http://code.google.com/p/j-format-string. + This is the library we use for compile time checking of format strings. It is separately published to + +
    • We're releasing FindBugs 2.0.3. + + Mostly small changes to address false positives, with one important fix to the Eclipse plugin + to fix a problem that had prevented the plugin from running in some versions of Eclipse. + Check the change log for more details. + +
    • We've released FindBugs 2.0 +
    • +
    • FindBugs communal cloud and Java web start links:. We have analyzed several large open + source projects, and provide Java web start links to allow you to view the results. We'd be + happy to work with projects to make the results available from a continuous build: +

      + +
    • +
    + + + +

    Experience with FindBugs

    +
      +
    • Google FindBugs Fixit: Google has a tradition of engineering fixits, special days where + they try to get all of their engineers focused on some specific problem or technique for improving + the systems at Google. A fixit might work to improve web accessibility, internal testing, removing + TODO's from internal software, etc. + +

      In 2009, Google held a global fixit for UMD's FindBugs tool a static analysis tool for + finding coding mistakes in Java software. The focus of the fixit was to get feedback on the + 4,000 highest confidence issues found by FindBugs at Google, and let Google engineers decide + which issues, if any, needed fixing.

      +

      More than 700 engineers ran FindBugs from dozens of offices. More than 250 of them entered + more than 8,000 reviews of the issues. A review is a classification of an issue as must-fix, + should-fix, mostly-harmless, not-a-bug, and several other categories. More than 75% of the + reviews classified issues as must fix, should fix or I will fix. Many of the scariest issues + received more than 10 reviews each.

      +

      Engineers have already submitted changes that made more than 1,100 of the 3,800 issues go + away. Engineers filed more than 1,700 bug reports, of which 600 have already been marked as + fixed Work continues on addressing the issues raised by the fixit, and on supporting the + integration of FindBugs into the software development process at Google.

      +

      The fixit at Google showcased new capabilities of FindBugs that provide a cloud computing / + social networking backdrop. Reviews of issues are immediately persisted into a central store, + where they can be seen by other developers, and FindBugs is integrated into the internal Google + tools for filing and viewing bug reports and for viewing the version control history of source + files. For the Fixit, FindBugs was configured in a mode where engineers could not see reviews + from other engineers until they had entered their own; after the fixit, the configuration will + be changed to a more open configuration where engineers can see reviews from others without + having to provide their own review first. These capabilities have all been contributed to UMD's + open source FindBugs tool, although a fair bit of engineering remains to prepare the + capabilities for general release and make sure they can integrate into systems outside of + Google. The new capabilities are expected to be ready for general release in Fall 2009.

      +
    • +
    + +

    + Talks about FindBugs +

    + +

    + Papers about FindBugs +

    + + +

    + Contributors and Sponsors +

    +

    + The current development team consists of Bill Pugh and Andrey Loskutov. +

    +

    The most recent funding for FindBugs comes from a Google Faculty Research Awards.

    +

    + Additional Support +

    +

    + Numerous people have made significant contributions to the FindBugs + project, including founding work by David Hovemeyer + and the web cloud infrastructure by Keith Lea. +

    +

    + YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC + is creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look + at YourKit's leading software products: YourKit + Java Profiler and YourKit .NET + Profiler. +

    +

    + The FindBugs project also uses FishEye and + Clover, which are generously provided by Cenqua/Atlassian. +

    +

    + Additional financial support for the FindBugs project was provided by National + Science Foundation grants ASC9720199 and CCR-0098162, +

    +

    Any opinions, findings and conclusions or recommendations expressed in this material are those of + the author(s) and do not necessarily reflect the views of the National Science Foundation (NSF). +

    + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo +

    + + + diff --git a/doc/infiniteRecursiveLoops.png b/doc/infiniteRecursiveLoops.png new file mode 100644 index 0000000..7cacd6b Binary files /dev/null and b/doc/infiniteRecursiveLoops.png differ diff --git a/doc/informal.png b/doc/informal.png new file mode 100644 index 0000000..c8ba6b3 Binary files /dev/null and b/doc/informal.png differ diff --git a/doc/ja/manual/acknowledgments.html b/doc/ja/manual/acknowledgments.html new file mode 100644 index 0000000..744ee58 --- /dev/null +++ b/doc/ja/manual/acknowledgments.html @@ -0,0 +1,123 @@ + + + 第14章 謝辞

    第14章 謝辞

    1. 貢献者

    FindBugs was originally written by Bill Pugh (). +David Hovemeyer () implemented some of the +detectors, added the Swing GUI, and is a co-maintainer.

    Mike Fagan () contributed the Ant build script, +the Ant task, and several enhancements and bug fixes to the GUI.

    Germano Leichsenring contributed Japanese translations of the bug +summaries.

    David Li contributed the Emacs bug report format.

    Peter D. Stout contributed recursive detection of Class-Path +attributes in analyzed Jar files, German translations of +text used in the Swing GUI, and other fixes.

    Peter Friese wrote the FindBugs Eclipse plugin.

    Rohan Lloyd contributed several Mac OS X enhancements, +bug detector improvements, +and maintains the Fink package for FindBugs.

    Hiroshi Okugawa translated the FindBugs manual and +more of the bug summaries into Japanese.

    Phil Crosby enhanced the Eclipse plugin to add a view +to display the bug details.

    Dave Brosius fixed a number of bugs, added user preferences +to the Swing GUI, improved several bug detectors, and +contributed the string concatenation detector.

    Thomas Klaeger contributed a number of bug fixes and +bug detector improvements.

    Andrei Loskutov made a number of improvements to the +Eclipse plugin.

    Brian Goetz contributed a major refactoring of the +visitor classes to improve readability and understandability.

    Pete Angstadt fixed several problems in the Swing GUI.

    Francis Lalonde provided a task resource file for the +FindBugs Ant task.

    Garvin LeClaire contributed support for output in +Xdocs format, for use by Maven.

    Holger Stenzhorn contributed improved German translations of items +in the Swing GUI.

    Juha Knuutila contributed Finnish translations of items +in the Swing GUI.

    Tanel Lebedev contributed Estonian translations of items +in the Swing GUI.

    Hanai Shisei (ruimo) contributed full Japanese translations of +bug messages, and text used in the Swing GUI.

    David Cotton contributed Fresh translations for bug +messages and for the Swing GUI.

    Michael Tamm contributed support for the "errorProperty" attribute +in the Ant task.

    Thomas Kuehne improved the German translation of the Swing GUI.

    Len Trigg improved source file support for the Emacs output mode.

    Greg Bentz provided a fix for the hashcode/equals detector.

    K. Hashimoto contributed internationalization fixes and several other + bug fixes.

    + Glenn Boysko contributed support for ignoring specified local + variables in the dead local store detector. +

    + Jay Dunning contributed a detector to find equality comparisons + of floating-point values, and overhauled the analysis summary + report and its representation in the saved XML format. +

    + Olivier Parent contributed updated French translations for bug descriptions and + Swing GUI. +

    + Chris Nappin contributed the plain.xsl + stylesheet. +

    + Etienne Giraudy contributed the fancy.xsl and fancy-hist.xsl + stylesheets, and made improvements to the -xml:withMessages + option. +

    + Takashi Okamoto fixed bugs in the project preferences dialog + in the Eclipse plugin, and contributed to its internationalization and localization. +

    Thomas Einwaller fixed bugs in the project preferences dialog in the Eclipse plugin.

    Jeff Knox contributed support for the warningsProperty attribute +in the Ant task.

    Peter Hendriks extended the Eclipse plugin preferences, +and fixed a bug related to renaming the Eclipse plugin ID.

    Mark McKay contributed an Ant task to launch the findbugs frame.

    Dieter von Holten (dvholten) contributed +some German improvements to findbugs_de.properties.

    If you have contributed to FindBugs, but aren't mentioned above, +please send email to (and also accept +our humble apologies).

    2. 使用しているソフトウェア

    FindBugs は、いくつかのオープンソースソフトウェアパッケージを使用しています。これらがなければ、 FindBugs の開発は、より一層困難なものになったことでしょう。

    2.1. BCEL

    FindBugs includes software developed by the Apache Software Foundation +(http://www.apache.org/). +Specifically, it uses the Byte Code +Engineering Library.

    2.2. ASM

    FindBugs uses the ASM +bytecode framework, which is distributed under the following license:

    +Copyright (c) 2000-2005 INRIA, France Telecom +All rights reserved. +

    +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +

    1. + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +

    2. + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +

    3. + Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. +

    +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +

    2.3. DOM4J

    FindBugs uses DOM4J, which is +distributed under the following license:

    +Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. +

    +Redistribution and use of this software and associated documentation +("Software"), with or without modification, are permitted provided that +the following conditions are met: +

    1. + Redistributions of source code must retain copyright statements and + notices. Redistributions must also contain a copy of this document. +

    2. + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +

    3. + The name "DOM4J" must not be used to endorse or promote products + derived from this Software without prior written permission + of MetaStuff, Ltd. For written permission, please contact + . +

    4. + Products derived from this Software may not be called "DOM4J" nor may + "DOM4J" appear in their names without prior written permission of + MetaStuff, Ltd. DOM4J is a registered trademark of MetaStuff, Ltd. +

    5. + Due credit should be given to the DOM4J Project (http://dom4j.org/). +

    +THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +

    \ No newline at end of file diff --git a/doc/ja/manual/analysisprops.html b/doc/ja/manual/analysisprops.html new file mode 100644 index 0000000..d4cdc3f --- /dev/null +++ b/doc/ja/manual/analysisprops.html @@ -0,0 +1,6 @@ + + + 第9章 分析プロパティー

    第9章 分析プロパティー

    FindBugs は分析する場合にいくつかの観点を持っています。そして、観点をカスタマイズして実行することができます。システムプロパティーを使って、それらのオプションを設定します。この章では、分析オプションの設定方法を説明します。

    分析オプションの主な目的は、 2 つあります。1 番目は、 FindBugs に対して分析されるアプリケーションのメソッドの意味を伝えることです。そうすることで FindBugs がより正確な結果を出すことができ、誤検出を減らすことができます。2 番目に、分析を行うに当たりその精度を設定できるようにすることです。分析の精度を落とすことで、メモリ使用量と分析時間を減らすことができます。ただし、本当のバグを見逃したり、誤検出の数が増えるという代償があります。

    コマンドラインオプション -property を使って、分析オプションを設定することができます。次に、例を示します:

    +$ findbugs -textui -property "cfg.noprune=true" myApp.jar
    +

    +

    設定することができる分析オプションの一覧を 表9.1「設定可能な分析プロパティー」 に示します。

    表9.1 設定可能な分析プロパティー

    プロパティー名設定値目的
    findbugs.assertionmethodsコンマ区切りの完全修飾メソッド名リスト : 例、 "com.foo.MyClass.checkAssertion"このプロパティーには、プログラムが正しいことをチェックするために使われるメソッドを指定します。これらのメソッドを指定することで、 チェックメソッドで確認した値に対する null 参照アクセスディテクタの誤検出を回避できます。
    findbugs.de.commenttrue または falsetrue に設定すると、 DroppedException (無視された例外) ディテクタは空の catch ブロック にコメントが無いか探します。そして、コメントがみつかった場合には警告が報告されません。
    findbugs.maskedfields.localstrue または falsetrue に設定すると、フィールドを隠蔽しているローカル変数に対して優先度(低)の警告が発行されます。デフォルトは、 false です。
    findbugs.nullderef.assumensptrue または false使用されません。 (意図 : true に設定すると、null 参照アクセスディテクタはメソッドからの戻り値、または、メソッドに受け渡される引数を null であると仮定します。デフォルトは、 false です。このプロパティーを有効にすると、大量の誤検出が生成されるであろうことに注意してください。)
    findbugs.refcomp.reportAlltrue または falsetrue に設定すると、 == および != 演算子を使っている疑わしい参照比較がすべて報告されます。 false に設定すると、同様の警告は 1 メソッドにつき 1 つしか発行されません。デフォルトは、 false です。
    findbugs.sf.commenttrue または falsetrue に設定すると、 SwitchFallthrough ディテクタはソースコードに「fall」または「nobreak」という単語を含んだコメントを記載していない caseラベル に限り警告を報告します。(この機能が正しく動作するためには、正確なソースパスが必要です。) これにより、意図的ではない switch 文の fallthrough を発見し易くなります。

    \ No newline at end of file diff --git a/doc/ja/manual/annotations.html b/doc/ja/manual/annotations.html new file mode 100644 index 0000000..9a44cc6 --- /dev/null +++ b/doc/ja/manual/annotations.html @@ -0,0 +1,67 @@ + + + 第10章 アノテーション

    第10章 アノテーション

    FindBugs はいくつかのアノテーションをサポートしています。開発者の意図を明確にすることで、 FindBugs はより的確に警告を発行することができます。アノテーションを使用するためには Java 5 が必要であり、 annotations.jar および jsr305.jar ファイルをコンパイル時のクラスパスに含める必要があります。

    edu.umd.cs.findbugs.annotations.CheckForNull
    [Target] Field, Method, Parameter +

    アノテーションをつけた要素は、 null である可能性があります。したがって、当該要素を使用する際は null チェックをするべきです。このアノテーションをメソッドに適用すると、メソッドの戻り値に適用されます。

    edu.umd.cs.findbugs.annotations.CheckReturnValue
    [Target] Method, Constructor +
    [Parameter]

    + priority: 警告の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。

    + explanation:戻り値をチェックしなけばならない理由をテキストで説明します。デフォルト値 :""。

    このアノテーションを使用して、呼出し後に戻り値をチェックすべきメソッドを表すことができます。

    edu.umd.cs.findbugs.annotations.DefaultAnnotation
    [Target] Type, Package +
    [Parameter]

    + value:アノテーションクラスのclassオブジェクト。複数のクラスを指定することができます。

    + priority:省略時の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。

    +Indicates that all members of the class or package should be annotated with the default +value of the supplied annotation classes. This would be used for behavior annotations +such as @NonNull, @CheckForNull, or @CheckReturnValue. In particular, you can use +@DefaultAnnotation(NonNull.class) on a class or package, and then use @Nullable only +on those parameters, methods or fields that you want to allow to be null. +

    edu.umd.cs.findbugs.annotations.DefaultAnnotationForFields
    [Target] Type, Package +
    [Parameter]

    + value:アノテーションクラスのclassオブジェクト。複数のクラスを指定することができます。

    + priority:省略時の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。

    +This is same as the DefaultAnnotation except it only applys to fields. +

    edu.umd.cs.findbugs.annotations.DefaultAnnotationForMethods
    [Target] Type, Package +
    [Parameter]

    + value:アノテーションクラスのclassオブジェクト。複数のクラスを指定することができます。

    + priority:省略時の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。

    +This is same as the DefaultAnnotation except it only applys to methods. +

    edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters
    [Target] Type, Package +
    [Parameter]

    + value:アノテーションクラスのclassオブジェクト。複数のクラスを指定することができます。

    + priority:省略時の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。

    +This is same as the DefaultAnnotation except it only applys to method parameters. +

    edu.umd.cs.findbugs.annotations.NonNull
    [Target] Field, Method, Parameter +

    アノテーションをつけた要素は、 null であってはいけません。アノテーションをつけたフィールドは、構築完了後 null であってはいけません。アノテーションをつけたメソッドは、 null ではない値を戻り値としなければなりません。

    edu.umd.cs.findbugs.annotations.Nullable
    [Target] Field, Method, Parameter +

    アノテーションをつけた要素は、 null であってはいけません。In general, this means developers will have to read the documentation to determine when a null value is acceptable and whether it is neccessary to check for a null value. FindBugs will treat the annotated items as though they had no annotation.

    +In pratice this annotation is useful only for overriding an overarching NonNull +annotation. +

    edu.umd.cs.findbugs.annotations.OverrideMustInvoke
    [Target] Method +
    [Parameter]

    + value:Specify when the super invocation should be + performed (FIRST, ANYTIME, LAST). Default value:ANYTIME. +

    +Used to annotate a method that, if overridden, must (or should) be invoke super +in the overriding method. Examples of such methods include finalize() and clone(). +The argument to the method indicates when the super invocation should occur: +at any time, at the beginning of the overriding method, or at the end of the overriding method. +(This anotation is not implmemented in FindBugs as of September 8, 2006). +

    edu.umd.cs.findbugs.annotations.PossiblyNull

    +This annotation is deprecated. Use CheckForNull instead. +

    edu.umd.cs.findbugs.annotations.SuppressWarnings
    [Target] Type, Field, Method, Parameter, Constructor, Package +
    [Parameter]

    + value:The name of the warning. More than one name can be specified. +

    + justification:Reason why the warning should be ignored. デフォルト値 :""。

    +The set of warnings that are to be suppressed by the compiler in the annotated element. +Duplicate names are permitted. The second and successive occurrences of a name are ignored. +The presence of unrecognized warning names is not an error: Compilers +must ignore any warning names they do not recognize. They are, however, free to emit a +warning if an annotation contains an unrecognized warning name. Compiler vendors should +document the warning names they support in conjunction with this annotation type. They +are encouraged to cooperate to ensure that the same names work across multiple compilers. +

    edu.umd.cs.findbugs.annotations.UnknownNullness
    [Target] Field, Method, Parameter +

    +Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. +

    edu.umd.cs.findbugs.annotations.UnknownNullness
    [Target] Field, Method, Parameter +

    +Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. +

    また、 FindBugs 次に示すアノテーションもサポートしています。 :

    • net.jcip.annotations.GuardedBy
    • net.jcip.annotations.Immutable
    • net.jcip.annotations.NotThreadSafe
    • net.jcip.annotations.ThreadSafe

    +

    Java Concurrency in Practice API ドキュメント を参照してください。

    \ No newline at end of file diff --git a/doc/ja/manual/anttask.html b/doc/ja/manual/anttask.html new file mode 100644 index 0000000..259019e --- /dev/null +++ b/doc/ja/manual/anttask.html @@ -0,0 +1,40 @@ + + + 第6章 FindBugs™ Ant タスクの使用方法

    第6章 FindBugsAnt タスクの使用方法

    この章では、 FindBugsAnt のビルドスクリプトに組み入れる方法について説明します。 Ant は、ビルドや配備を行うことができる Java でよく使用されるツールです。FindBugs Ant タスクを使用すると、 ビルドスクリプトを作成して機械的に FindBugs による Java コードの分析を実行することができます。

    この Ant タスクは、 Mike Fagan 氏の多大な貢献によるものです。

    1. Ant タスクのインストール

    Ant タスクのインストールは、 $FINDBUGS_HOME/lib/findbugs-ant.jarAnt インストールディレクトリーのlib サブディレクトリーにコピーするだけです。

    [注記]注記

    使用する Ant タスクと FindBugs 本体は、同梱されていた同じバージョンのものを使用することを強く推奨します。別のバージョンの FindBugs に含まれていた Ant タスク Jar ファイルでの動作は保証しません。

    +

    2. build.xml の書き方

    FindBugsbuild.xml (Ant ビルドスクリプト) に組み入れるためにはまず、タスク定義を記述する必要があります。タスク定義は次のように記述します。:

    +  <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
    +

    タスク定義は、 findbugs 要素を build.xml 上に記述したとき、そのタスクの実行に使用されるクラスを指定します。

    タスク定義の記述をすれば、findbugs タスクを使ってターゲットを定義できます。次に示すのは、 Apache BCEL ライブラリーを分析する場合を想定した build.xml の記述例です。

    +  <property name="findbugs.home" value="/export/home/daveho/work/findbugs" />
    +
    +  <target name="findbugs" depends="jar">
    +    <findbugs home="${findbugs.home}"
    +              output="xml"
    +              outputFile="bcel-fb.xml" >
    +      <auxClasspath path="${basedir}/lib/Regex.jar" />
    +      <sourcePath path="${basedir}/src/java" />
    +      <class location="${basedir}/bin/bcel.jar" />
    +    </findbugs>
    +  </target>
    +

    findbugs 要素には、 home 属性が必須です。 FindBugs のインストールディレクトリーすなわち $FINDBUGS_HOME の値を設定します。2章FindBugs™ のインストール を参照してください。

    このターゲットは bcel.jar に対して FindBugs を実行します。この Jar ファイルは、 BCEL ビルドスクリプトによって作成されるものです。(上記のターゲットが「jar」ターゲットに依存している (depends) と設定することにより、 FindBugs が実行される前に当該ライブラリーが完全にコンパイルされていることを保証しています。) FindBugs の出力は、 XML 形式で bcel-fb.xml ファイルに保存されます。補助 Jar ファイル Regex.jar を aux classpath に記述しています。なぜなら、当該 Jar ファイルが BCEL メイン・ライブラリーから参照されるからです。source path を指定することで、保存されるバグデータに BCEL ソースコードへの正確な参照が記述されます。

    3. タスクの実行

    コマンドラインから Ant を起動する例を次に示します。前述の findbugs ターゲットを使用しています。

    +  [daveho@noir]$ ant findbugs
    +  Buildfile: build.xml
    +
    +  init:
    +
    +  compile:
    +
    +  examples:
    +
    +  jar:
    +
    +  findbugs:
    +   [findbugs] Running FindBugs...
    +   [findbugs] Bugs were found
    +   [findbugs] Output saved to bcel-fb.xml
    +
    +  BUILD SUCCESSFUL
    +  Total time: 35 seconds
    +

    この事例においては、XML ファイルでバグ検索結果を保存しているので、 FindBugs GUI を使って結果を参照することができます。 4章FindBugs™ の実行 を参照してください。

    4. パラメーター

    このセクションでは、 FindBugs タスクを使用する際に、指定することができるパラメーターについて説明します。

    class

    分析の対象となるクラス群を指定するためのネストされる要素です。class 要素には location 属性の指定が必須です。分析対象となるアーカイブファイル (jar, zip, 他)、ディレクトリーまたはクラスファイルの名前を記述します。1 つの findbugs 要素に対して、複数の class 子要素を指定することができます。

    auxClasspath

    任意指定のネストされる要素です。分析対象のライブラリーまたはアプリケーションによって使用されているが分析の対象にはしたくないクラスを含んでいるクラスパス (Jar ファイルまたはディレクトリー) を指定します。 Ant の Java タスクにある classpath 要素 と同じ方法で指定することができます。

    sourcePath

    任意指定のネストされる要素です。分析対象 Java コードのコンパイル時に使用したソースファイルを含んでいるソースディレクトリーへのパスを指定します。ソースパスを指定することにより、生成される XML のバグ出力結果に完全なソース情報をもたせることができ、後になって GUI で参照することができます。

    home

    必須属性です。FindBugs がインストールされているディレクトリー名を設定します。

    quietErrors

    任意指定のブール値属性です。true を設定すると、深刻な分析エラー発生やクラスがみつからないといった情報が FindBugs 出力に記録されません。デフォルトは、 false です。

    reportLevel

    任意指定の属性です。報告されるバグの優先度のしきい値を指定します。「low」に設定すると、すべてのバグが報告されます。「medium」 (デフォルト) に設定すると、優先度 (中)および優先度 (高)のバグが報告されます。「high」に設定すると、優先度 (高) のバグのみが報告されます。

    output

    任意指定の属性です。出力形式を指定します。「xml」 (デフォルト) に設定すると、出力は XML 形式になります。「xml:withMessages」 に設定すると、出力は人間が読めるメッセージ が追加された XML 形式になります。(XSL スタイルシートを使ってレポートを作成することを計画している場合はこの形式を使用してください。) 「html」に設定すると、出力は HTML 形式(デフォルトのスタイルシートは default.xsl) になります。 「text」に設定すると、出力は特別なテキスト形式になります。「emacs」に設定すると、出力は Emacs エラーメッセージ形式になります。「xdocs」に設定すると、出力は Apache Maven で使用できる xdoc XML になります。

    stylesheet

    任意指定の属性です。output 属性 に html を指定した場合に、 HTML 出力作成に使用されるスタイルシートを指定します。FindBugs 配布物に含まれているスタイルシートは、 default.xsl、 fancy.xsl 、 fancy-hist.xsl 、 plain.xsl および summary.xsl です。デフォルト値は default.xsl です。

    sort

    任意指定の属性です。output 属性に「text」を指定した場合に、バグの報告をクラス順にソートするかどうかを sort 属性で指定します。デフォルトは、 true です。

    outputFile

    任意指定の属性です。指定した場合、FindBugs の出力はその名前のファイルへと保存されます。省略時、出力は Ant によって直接表示されます。

    debug

    任意指定のブール値属性です。true に設定すると、 FindBugs は 診断情報を出力します。どのクラスを分析しているか、どのパグパターンディテクタが実行されているか、という情報が表示されます。デフォルトは、 false です。

    effort

    分析の活動レベルを設定します。mindefault または max のいずれかの値を設定してください。分析レベルの設定に関する詳細情報は、 「コマンドラインオプション」 を参照してください。

    conserveSpace

    effort="min" と同義です。

    workHard

    effort="max" と同義です。

    visitors

    任意指定の属性です。どのバグディテクタを実行するかをコンマ区切りのリストで指定します。バグディテクタはパッケージ指定なしのクラス名で指定します。省略時、デフォルトで無効化されているものを除くすべてのディテクタが実行されます。

    omitVisitors

    任意指定の属性です。visitors 属性と似ていますが、こちらは 実行されない ディテクタを指定します。

    excludeFilter

    任意指定の属性です。フィルターファイル名を指定します。報告から除外されるバグを指定します。8章フィルターファイル を参照してください。

    includeFilter

    任意指定の属性です。フィルターファイル名を指定します。報告されるバグを指定します。8章フィルターファイル を参照してください。

    projectFile

    任意指定の属性です。プロジェクトファイル名を指定します。プロジェクトファイルは、 FindBugs GUI で作成します。分析されるクラス、および、補助クラスパス、ソースディレクトリーが記入されてます。プロジェクトファイルを指定した場合は、 class 要素・ auxClasspath 属性および sourcePath 属性を設定する必要はありません。プロジェクトの作成方法は、 4章FindBugs™ の実行 を参照してください。

    jvmargs

    任意指定の属性です。FindBugs を実行している Java 仮想マシンに対して受け渡される引数を指定します。巨大なプログラムを分析する場合に、 JVM が使用するメモリ容量を増やす指定をするためにこの引数を利用する必要があるかもしれません。

    systemProperty

    任意指定のネストされる要素です。指定した場合、Java システムプロパティーを定義します。name 属性にはシステムプロパティーの名前を指定します。そして、 value 属性にはシステムプロパティの値を指定します。

    timeout

    任意指定の属性です。FindBugs を実行している Java プロセス の実行許容時間をミリ秒単位で指定します。時間を超過するとハングアップしていると判断してプロセスが終了されます。デフォルトは、 600,000 ミリ秒 (10 分) です。巨大なプログラムの場合は、 FindBugs が分析を完了するまでに 10 分 以上掛かる可能性があることに注意してください。

    failOnError

    任意指定のブール値属性です。FindBugs の実行中にエラーがあった場合に、ビルドプロセス自体を打ち切って異常終了させるかどうかを指定します。デフォルトは、「false」です。

    errorProperty

    任意指定の属性です。FindBugs の実行中にエラーが発生した場合に、「true」が設定されるプロパティーの名前を指定します。

    warningsProperty

    任意指定の属性です。FindBugs が分析したプログラムにバグ報告が 1 件でもある場合に、「true」が設定されるプロパティーの名前を指定します。

    + + +

    \ No newline at end of file diff --git a/doc/ja/manual/building.html b/doc/ja/manual/building.html new file mode 100644 index 0000000..299264f --- /dev/null +++ b/doc/ja/manual/building.html @@ -0,0 +1,40 @@ + + + 第3章 FindBugs™ のソールからのビルド

    第3章 FindBugs™ のソールからのビルド

    この章では、 FindBugs をソースコードからビルドする方法を説明します。FindBugs を修正することに興味がないのであれば、 次の章 に進んでください。

    1. 前提条件

    ソースから FindBugs をコンパイルするためには、以下のものが必要です。

    +

    [警告]警告

    Redhat Linux システムの /usr/bin/ant に同梱されている Ant のバージョンでは、 FindBugs のコンパイルはうまくできませんAnt web サイトからバイナリ配布物をダウンロードしてインストールすることを推奨します。Ant を実行する場合は、 環境変数 JAVA_HOME が JDK 1.5 (またはそれ以降)をインストールしたディレクトリーを指していることを確認してください。

    体裁の整った FindBugs のドキュメントを生成したい場合は、以下のソフトウェアも必要となります:

    +

    2. ソース配布物の展開

    ソース配布物をダウンロードした後に、それを作業用ディレクトリーに展開する必要があります。通常は、次のようなコマンドで展開を行います:

    +$ unzip findbugs-2.0.3-source.zip
    +

    + +

    3. local.properties の修正

    FindBugs のドキュメントをビルドするためには、 local.properties ファイルを修正する必要があります。このファイルは、 FindBugs をビルドする際に Ant build.xml ファイルが参照します。FindBugs のドキュメントをビルドしない場合は、このファイルは無視してもかまいません。

    local.properties での定義は、 build.properties ファイルでの定義に優先します。build.properties は次のような内容です:

    +
    +# User Configuration:
    +# This section must be modified to reflect your system.
    +
    +local.software.home     =/export/home/daveho/linux
    +
    +# Set this to the directory containing the DocBook Modular XSL Stylesheets
    +#  from http://docbook.sourceforge.net/projects/xsl/
    +
    +xsl.stylesheet.home     =${local.software.home}/docbook/docbook-xsl-1.71.1
    +
    +# Set this to the directory where Saxon (http://saxon.sourceforge.net/)
    +# is installed.
    +
    +saxon.home              =${local.software.home}/java/saxon-6.5.5
    +
    +

    +

    xsl.stylesheet.home プロパティーには、DocBook Modular XSL スタイルシートがインストールしてあるディレクトリーの絶対パスを指定します。FindBugs ドキュメントを生成しようと考えている場合にのみ、このプロパティーを指定する必要があります。

    saxon.home プロパティーには、Saxon XSLT プロセッサーがインストールしてあるディレクトリーの絶対パスを指定します。FindBugs ドキュメントを生成しようと考えている場合にのみ、このプロパティーを指定する必要があります。

    4. Ant の実行

    ソース配布物の展開、 Ant のインストール、build.properties(local.properties) の修正 (これは任意) およびツール (Saxon など)の環境構築ができれば、 FindBugs をビルドするための準備は完了です。Ant の起動する方法は、単にコマンドを実行するだけです。

    +$ ant target
    +

    target には以下のいずれかを指定します:

    build

    このターゲットは、 FindBugs のコードをコンパイルします。これは、デフォルトのターゲットです。

    docs

    このターゲットは、ドキュメントの整形を行います(また、副作用としていくつかのソースのコンパイルも行います。)

    runjunit

    このターゲットは、コンパイルを行い FindBugs が持っている JUnit テストを実行します。ユニットテストが失敗した場合は、エラーメッセージが表示されます。

    bindist

    FindBugs のバイナリ配布物を構築します。このターゲットは、 .zip および .tar.gz のアーカイブをそれぞれ作成します。

    +

    Ant コマンドの実行後、次のような出力が表示されるはずです。 (この前に Ant が実行したタスクに関するメッセージもいくらか出力されます。):

    +
    +BUILD SUCCESSFUL
    +Total time: 17 seconds
    +
    +

    +

    5. ソースディレクトリーからの FindBugs™ の実行

    build ターゲットの実行が終了すると、バイナリ配布物と同様の状態が作業ディレクトリーに構築されるように FindBugsAnt ビルドスクリプトは記述されています。したがって、4章FindBugs™ の実行FindBugs の実行に関する情報はソース配布物の場合にも応用できます。

    \ No newline at end of file diff --git a/doc/ja/manual/datamining.html b/doc/ja/manual/datamining.html new file mode 100644 index 0000000..31b97f9 --- /dev/null +++ b/doc/ja/manual/datamining.html @@ -0,0 +1,280 @@ + + + 第12章 FindBugs™ によるデータ・マイニング

    第12章 FindBugs™ によるデータ・マイニング

    バグデータベースへの高機能の問い合わせ機能、および、調査対象のコードの複数のバージョンにわたる警告の追跡記録機能を、 FindBugs は内蔵しています。これらを使って次のようなことができます。すなわち、いつバグが最初持ち込まれたかを捜し出すこと、最終リリース以後持ち込まれた警告の分析を行うこと、または、無限再起ループの数を時間軸でグラフにすることです。

    これらの技術は、 FindBugs が警告の保存に使う XML 書式を使用します。これらの XML ファイルは、通常、特定の 1 分析に対する警告が入れられています。しかしそれらには、一連のソフトウェアのビルドやバージョンに対する分析結果を格納することもできます。

    すべての FindBugs XML バグデータベースには、バージョン名とタイム・スタンプ が入れられています。FindBugs は分析が行われるファイルの更新時刻からタイム・スタンプを計算します (例えば、タイム・スタンプはクラスファイルの生成時刻になるようになっています。分析が行われた時刻ではありません) 。各々のバグデータベースには、バージョン名も入れられています。バージョン名とタイム・スタンプは、 setBugDatabaseInfo (「setBugDatabaseInfo」) コマンドを使用して手動で設定することもできます。

    複数バージョンを格納するバグデータベースにおいては、分析されるコードの各バージョンごとにシーケンス番号が割り当てられます。これらのシーケンス番号は単に 0 から始まる連続する整数値です (例えば、 4 つのコードバージョンを格納するバグデータベースには、バージョン 0~3 が入れられます) 。バグデータベースにはまた、各バージョンの名前とタイム・スタンプがそれぞれ記録されます。filterBugs コマンドを使用すると、シーケンス番号、バージョン名またはタイム・スタンプからバージョンを参照することができます。

    1 バージョンを格納するバグデータベースの集合から、 1 個の複数バージョンバグデータベースを作成することができます。また、複数バージョンバグデータベースに対して、それ以後に作成された 1 バージョンのバグデータベースを結合することができます。

    これらのコマンドのいくつかは、 ant タスクとして実行することができます。コマンドの実行方法および属性・引数の詳細は、以下を参照してください。以下のすべての例においては、 findbugs.lib refid が正しく設定されていることを前提としています。設定方法の一例を次に示します :

    +
    +   <!-- findbugs タスク定義 -->
    +   <property name="findbugs.home" value="/your/path/to/findbugs" />
    +   <path id="findbugs.lib">
    +      <fileset dir="${findbugs.home}/lib">
    +         <include name="findbugs-ant.jar"/>
    +      </fileset>
    +   </path>
    +
    +

    1. コマンド

    FindBugs データ・マイニング ツールはすべてコマンドラインから実行することができます。また、いくつかのより有用なコマンドは、 ant ビルドファイルから実行することができます。

    コマンドラインツールについて簡単に説明します :

    unionBugs

    別のクラスに対する別個の分析結果を結合します。

    computeBugHistory

    複数バージョンから得られた複数のバグ警告を、マージして 1 個の複数バージョンバグデータベースにします。これを使って、既存の複数バージョンバグデータベースに更にバージョンを追加したり、 1 バージョンを格納するバグデータベースの集合から 1 個の複数バージョンバグデータベースを作成したり、できます。

    setBugDatabaseInfo

    リビジョン名やタイム・スタンプなどの情報を XML データベースに設定します。

    listBugDatabaseInfo

    XML データベースにあるリビジョン名やタイム・スタンプなどの情報を一覧表示します。

    filterBugs

    バグデータベースの部分集合を選択します。

    mineBugHistory

    複数バージョンバグデータベースの各バージョン毎の警告数を一覧にした表を作成します。

    defectDensity

    プロジェクト全体およびクラス毎・パッケージ毎の不良密度 (1000 NCSS 毎の警告数) に関する情報を一覧表示します。

    convertXmlToText

    XML 形式のバグ警告を、 1 行 1 バグのテキスト形式、または、HTML形式に変換します。

    1.1. unionBugs

    分析するのにアプリケーションの jar ファイルを分割している場合、このコマンドを使用することで、別個に生成された XML バグ警告ファイルをすべての警告を含んでいる 1 つの ファイルにすることができます。

    同じファイルの異なるバージョンを分析した結果を結合する場合は、このコマンドを使用しないでください。代わりに computeBugHistory を使用してください。

    XML ファイルは、コマンドラインで指定してください。結果は、標準出力に送られます。

    1.2. computeBugHistory

    このコマンドを使用することで、分析するソフトウェアの異なるビルドまたはバージョンの情報を含むバグデータベースを生成することができます入力として提供したファイルの 1 番目のファイルから履歴が取得されます。後に続くファイルは 1 バージョンのバグデータベースであるようにしてください (もし、履歴を持っていたとしても無視されます) 。

    デフォルトでは、結果は標準出力に送られます。

    この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに computeBugHistory を taskdef で定義します :

    +
    +<taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    この ant タスクに指定できる属性を、下表に一覧で示します。入力ファイルを指定するには、 <datafile> 要素を入れ子にして入れてください。次に、例を示します:

    +
    +<computeBugHistory home="${findbugs.home}" ...>
    +    <datafile name="analyze1.xml"/>
    +    <datafile name="analyze2.xml"/>
    +</computeBugHistory>
    +
    +

    表12.1 computeBugHistory コマンドのオプション一覧

    コマンドラインオプションAnt 属性目的
    -output <file>output="<file>"出力結果を保存するファイル名を指定します。 (同時に入力ファイルにもなりえます)
    -overrideRevisionNames[:truth]overrideRevisionNames="[true|false]"ファイル名から算出されるそれぞれのバージョン名を指定変更します。
    -noPackageMoves[:truth]noPackageMoves="[true|false]"パッケージを移動したクラスがある場合、当該クラスの警告は別の存在として扱われます。
    -preciseMatch[:truth]preciseMatch="[true|false]"バグパターンが正確に一致することを要求します。
    -precisePriorityMatch[:truth]precisePriorityMatch="[true|false]"優先度が正確に一致した場合のみ警告が同一であると判断されます。
    -quiet[:truth]quiet="[true|false]"エラーが発生しない限り、標準出力には何も表示されません。
    -withMessages[:truth]withMessages="[true|false]"出力 XML に人間が読むことができるバグメッセージが含まれます。

    1.3. filterBugs

    このコマンドを使用することで、 FindBugs XML 警告ファイルから一部分を選び出して新規 FindBugs 警告ファイルに選択された部分を書き込むことができます。

    このコマンドには、オプション群に続いて 0 個から 2 個の findbugs xml バグファイルを指定することができます。

    ファイル名をひとつも指定しない場合は、標準入力から読んで標準出力に出力されます。ファイル名を 1 個 指定した場合は、指定したファイルから読んで標準出力に出力されます。ファイル名を 2 個 指定した場合は、 1 番目に指定したファイルから読んで 2 番目に指定したファイルに出力されます。

    この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに filterBugs を taskdef で定義します :

    +
    +<taskdef name="filterBugs" classname="edu.umd.cs.findbugs.anttask.FilterBugsTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    この ant タスクに指定できる属性を、下表に一覧で示します。入力ファイルを指定するには、 input 属性を使用するか、 <datafile> 要素を入れ子にして入れてください。次に、例を示します:

    +
    +<filterBugs home="${findbugs.home}" ...>
    +    <datafile name="analyze.xml"/>
    +</filterBugs>
    +
    +

    表12.2 filterBugs コマンドのオプション一覧

    コマンドラインオプションAnt 属性目的
     input="<file>"入力ファイルを指定します。
     output="<file>"出力ファイルを指定します。
    -notnot="[true|false]"フィルターのスイッチを反転します。
    -withSource[:truth]withSource="[true|false]"ソースが入手可能な警告のみ出力されます。
    -exclude <filter file>exclude="<filter file>"フィルターに一致するバグが除外されます。
    -include <filter file>include="<filter file>"フィルターに一致するバグのみを含まれます。
    -annotation <text>annotation="<text>"手で入力した注釈に指定した文言を含む警告のみ出力されます。
    -after <when>after="<when>"指定したバージョンより後に初めて出現した警告のみ出力されます。
    -before <when>before="<when>"指定したバージョンより前に初めて出現した警告のみ出力されます。
    -first <when>first="<when>"指定したバージョンに初めて出現した警告のみ出力されます。
    -last <when>last="<when>"指定したバージョンが出現した最後である警告のみ出力されます。
    -fixed <when>fixed="<when>"指定したバージョンの前回のバージョンが出現した最後である警告のみ出力されます。 (-last に優先します)。
    -present <when>present="<when>"指定したバージョンに存在する警告のみ出力されます。
    -absent <when>absent="<when>"指定したバージョンに存在しない警告のみ出力されます。
    -active[:truth]active="[true|false]"最終通番に存在する警告のみ出力されます。
    -introducedByChange[:truth]introducedByChange="[true|false]"存在するクラスの変更によってもたらされた警告のみ出力されます。
    -removedByChange[:truth]removedByChange="[true|false]"存在するクラスの変更によって除去された警告のみ出力されます。
    -newCode[:truth]newCode="[true|false]"新クラスの追加によってもたらされた警告のみ出力されます。
    -removedCode[:truth]removedCode="[true|false]"クラスの削除によって除去された警告のみ出力されます。
    -priority <level>priority="<level>"指定した優先度以上の優先度をもつ警告のみ出力されます。
    -class <pattern>class="<class>"指定したパターンに一致する主クラスをもつ警告のみ出力されます。
    -bugPattern <pattern>bugPattern="<pattern>"指定したパターンに一致するバグ種別をもつ警告のみ出力されます。
    -category <category>category="<category>"指定した文字列で始まるカテゴリーの警告のみ出力されます。
    -designation <designation>designation="<designation>"指定したバグ分類指定をもつ警告のみ出力されます。 (例、 -designation SHOULD_FIX)
    -withMessages[:truth] withMessages="[true|false]"テキストメッセージを含んだ XML が生成されます。

    1.4. mineBugHistory

    このコマンドを使用することで、複数バージョンバグデータベースの各バージョン毎の警告数を一覧にした表を作成することができます。

    この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに mineBugHistory を taskdef で定義します :

    +
    +<taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    この ant タスクに指定できる属性を、下表に一覧で示します。入力ファイルを指定するには、 input 属性を使用するか、 <datafile> 要素を入れ子にして入れてください。次に、例を示します:

    +
    +<mineBugHistory home="${findbugs.home}" ...>
    +    <datafile name="analyze.xml"/>
    +</mineBugHistory>
    +
    +

    表12.3 mineBugHistory コマンドのオプション一覧

    コマンドラインオプションAnt 属性目的
     input="<file>"入力ファイルを指定します。
     output="<file>"出力ファイルを指定します。
    -formatDatesformatDates="[true|false]"データがテキスト形式で描画されます。
    -noTabsnoTabs="[true|false]"タブの代わりに複数スペースでカラムが区切られます (下記参照)。
    -summarysummary="[true|false]"最新 10 件の変更の要約が出力されます。

    -noTabs 出力を使うことで、固定幅フォントのシェルで読み易くなります。数値カラムは右寄せされるので、スペースがカラム値の前に挿入されます。また、このオプションを使用した場合、 -formatDates を指定したときに要約の日付を描画するのに空白が埋め込まれなくなります。

    出力される表は、 (-noTabs が無ければ) タブ区切りで次に示すカラムから成ります :

    表12.4 mineBugHistory 出力のカラム一覧

    表題目的
    seqシーケンス番号 (0 始まりの連続した整数値)
    versionバージョン名
    timeリリースされた日時
    classes分析されたクラス数
    NCSSコメント文を除いた命令数 (Non Commenting Source Statements)
    added前回のバージョンに存在したクラスにおける新規警告数
    newCode前回のバージョンに存在しなかったクラスにおける新規警告数
    fixed現在のバージョンに存在するクラスにおける除去された警告数
    removed現在のバージョンに存在しないクラスの前回のバージョンにおける警告数
    retained現在のバージョンと前回のバージョンの両方に存在する警告の数
    dead以前のバージョンに存在したが現在のバージョンにも直前のバージョンにも存在しない警告の数
    active現在のバージョンに存在する警告総数

    1.5. defectDensity

    このコマンドを使用することで、プロジェクト全体およびクラス毎・パッケージ毎の不良密度 (1000 NCSS 毎の警告数) に関する情報を一覧表示できます。標準入力から読み込む場合はファイル指定なしで、そうでなければ、コマンドラインでファイルを指定して、このコマンドを実行します。

    出力される表は、次に示すカラムから成ります。また、プロジェクト全体情報の行、および、4 個以上の警告を含んでいる各パッケージ情報または各クラス情報の行も出力されます。

    表12.5 defectDensity 出力のカラム一覧

    表題目的
    kindプロジェクト (project)、パッケージ (package) またはクラス (class)
    nameプロジェクト、パッケージまたはクラスの名前
    density 1000 NCSS 毎の警告数
    bugs警告数
    NCSSコメント文を除いた命令数 (Non Commenting Source Statements)

    1.6. convertXmlToText

    このコマンドを使用することで、XML 形式のバグ警告を、 1 行 1 バグのテキスト形式、または、HTML形式に変換することができます。

    この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに convertXmlToText を taskdef で定義します :

    +
    +<taskdef name="convertXmlToText" classname="edu.umd.cs.findbugs.anttask.ConvertXmlToTextTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    この ant タスクに指定できる属性を、下表に一覧で示します。

    表12.6 convertXmlToText コマンドのオプション一覧

    コマンドラインオプションAnt 属性目的
     input="<filename>"入力ファイルを指定します。
     output="<filename>"出力ファイルを指定します。
    -longBugCodeslongBugCodes="[true|false]"2 文字のバグ略称の代わりに、省略なしのバグパターンコードを使用します。
     format="text"プレーンテキストの出力が作成されます。1 行につき 1 つのバグが出力されます。コマンドライン時のデフォルトです。
    -html[:stylesheet]format="html:<stylesheet>"指定されたスタイルシートを使用して出力が作成されます (下記参照) 。省略した場合は、 default.xsl が使用されます。

    -html/format オプションには、plain.xsl 、 default.xsl 、 fancy.xsl 、 fancy-hist.xsl または ユーザ自身が作成した XSL スタイルシートのいずれかを指定することができます。オプション名をよそに、 html 以外の形式を出力するスタイルシートを指定することもできます。FindBugs に含まれているスタイルシート(上述)以外のスタイルシートを使用する場合は、オプション -html/format で当該スタイルシートへのパスまたは URL を指定してください。

    1.7. setBugDatabaseInfo

    このコマンドを使用することで、指定したバグ警告にメタ情報を設定することができます。このコマンドには次に示すオプションがあります:

    この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに setBugDatabaseInfo を taskdef で定義します :

    +
    +<taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    この ant タスクに指定できる属性を、下表に一覧で示します。入力ファイルを指定するには、 input 属性を使用するか、 <datafile> 要素を入れ子にして入れてください。次に、例を示します:

    +
    +<setBugDatabaseInfo home="${findbugs.home}" ...>
    +    <datafile name="analyze.xml"/>
    +</setBugDatabaseInfo>
    +
    +

    表12.7 setBugDatabaseInfo オプション一覧

    コマンドラインオプションAnt 属性目的
     input="<file>"入力ファイルを指定します。
     output="<file>"出力ファイルを指定します。
    -name <name>name="<name>"最新リビジョンの名前を設定します。
    -timestamp <when>timestamp="<when>"最新リビジョンのタイム・スタンプを設定します。
    -source <directory>source="<directory>"ソースを検索するディレクトリーを追加指定します。
    -findSource <directory>findSource="<directory>"指定したディレクトリー内を検索して関連するソースの場所を追加します。
    -suppress <filter file>suppress="<filter file>"指定したファイルに一致する警告を抑止します (以前に指定した抑止設定は置き換えられます)。
    -withMessageswithMessages="[true|false]"XMLにテキストメッセージを追加します。
    -resetSourceresetSource="[true|false]"ソース検索パスをすべて削除します。

    1.8. listBugDatabaseInfo

    このコマンドの実行においては、コマンドラインで 0 個以上の xml バグデータベースファイル名を指定します。ファイル名を1つも指定しなければ、標準出力から読み込みを行いテーブルのヘッダーは生成されません。

    このコマンドには 1 つだけオプションがあります : -formatDates を指定するとテキスト形式でデータが描画されます。

    出力される表は、各バグデータベースごとに行を持ち、次に示すカラムから成ります :

    表12.8 listBugDatabaseInfo カラム一覧

    カラム目的
    versionバージョン名
    timeリリースされた日時
    classes分析されたクラス数
    NCSSコメント文を除いた命令数 (Non Commenting Source Statements)
    total全警告数
    high優先度(高)の警告の総数
    medium優先度(中)の警告の総数
    low優先度(低)の警告の総数
    filenameデータベースのファイル名

    2. 例

    2.1. 提供されたシェル・スクリプトを使用しての履歴マイニング

    以下はすべて、 jdk1.6.0-b12, jdk1.6.0-b13, ..., jdk1.6.0-b60 のディレクトリに対してコマンドを実行しています。

    以下のコマンドを実行してみます :

    +computeBugHistory jdk1.6.0-b* | filterBugs -bugPattern IL_ | mineBugHistory -formatDates
    +

    すると、次のような出力が行われます :

    +seq	version	time	classes	NCSS	added	newCode	fixed	removed	retained	dead	active
    +0	jdk1.6.0-b12	"Thu Nov 11 09:07:20 EST 2004"	13128	811569	0	4	0	0	0	0	4
    +1	jdk1.6.0-b13	"Thu Nov 18 06:02:06 EST 2004"	13128	811570	0	0	0	0	4	0	4
    +2	jdk1.6.0-b14	"Thu Dec 02 06:12:26 EST 2004"	13145	811786	0	0	2	0	2	0	2
    +3	jdk1.6.0-b15	"Thu Dec 09 06:07:04 EST 2004"	13174	811693	0	0	1	0	1	2	1
    +4	jdk1.6.0-b16	"Thu Dec 16 06:21:28 EST 2004"	13175	811715	0	0	0	0	1	3	1
    +5	jdk1.6.0-b17	"Thu Dec 23 06:27:22 EST 2004"	13176	811974	0	0	0	0	1	3	1
    +6	jdk1.6.0-b19	"Thu Jan 13 06:41:16 EST 2005"	13176	812011	0	0	0	0	1	3	1
    +7	jdk1.6.0-b21	"Thu Jan 27 05:57:52 EST 2005"	13177	812173	0	0	0	0	1	3	1
    +8	jdk1.6.0-b23	"Thu Feb 10 05:44:36 EST 2005"	13179	812188	0	0	0	0	1	3	1
    +9	jdk1.6.0-b26	"Thu Mar 03 06:04:02 EST 2005"	13199	811770	0	0	0	0	1	3	1
    +10	jdk1.6.0-b27	"Thu Mar 10 04:48:38 EST 2005"	13189	812440	0	0	0	0	1	3	1
    +11	jdk1.6.0-b28	"Thu Mar 17 02:54:22 EST 2005"	13185	812056	0	0	0	0	1	3	1
    +12	jdk1.6.0-b29	"Thu Mar 24 03:09:20 EST 2005"	13117	809468	0	0	0	0	1	3	1
    +13	jdk1.6.0-b30	"Thu Mar 31 02:53:32 EST 2005"	13118	809501	0	0	0	0	1	3	1
    +14	jdk1.6.0-b31	"Thu Apr 07 03:00:14 EDT 2005"	13117	809572	0	0	0	0	1	3	1
    +15	jdk1.6.0-b32	"Thu Apr 14 02:56:56 EDT 2005"	13169	811096	0	0	0	0	1	3	1
    +16	jdk1.6.0-b33	"Thu Apr 21 02:46:22 EDT 2005"	13187	811942	0	0	0	0	1	3	1
    +17	jdk1.6.0-b34	"Thu Apr 28 02:49:00 EDT 2005"	13195	813488	0	1	0	0	1	3	2
    +18	jdk1.6.0-b35	"Thu May 05 02:49:04 EDT 2005"	13457	829837	0	0	0	0	2	3	2
    +19	jdk1.6.0-b36	"Thu May 12 02:59:46 EDT 2005"	13462	831278	0	0	0	0	2	3	2
    +20	jdk1.6.0-b37	"Thu May 19 02:55:08 EDT 2005"	13464	831971	0	0	0	0	2	3	2
    +21	jdk1.6.0-b38	"Thu May 26 03:08:16 EDT 2005"	13564	836565	0	0	0	0	2	3	2
    +22	jdk1.6.0-b39	"Fri Jun 03 03:10:48 EDT 2005"	13856	849992	0	1	0	0	2	3	3
    +23	jdk1.6.0-b40	"Thu Jun 09 03:30:28 EDT 2005"	15972	959619	0	2	0	0	3	3	5
    +24	jdk1.6.0-b41	"Thu Jun 16 03:19:22 EDT 2005"	15972	959619	0	0	0	0	5	3	5
    +25	jdk1.6.0-b42	"Fri Jun 24 03:38:54 EDT 2005"	15966	958581	0	0	0	0	5	3	5
    +26	jdk1.6.0-b43	"Thu Jul 14 03:09:34 EDT 2005"	16041	960544	0	0	0	0	5	3	5
    +27	jdk1.6.0-b44	"Thu Jul 21 03:05:54 EDT 2005"	16041	960547	0	0	0	0	5	3	5
    +28	jdk1.6.0-b45	"Thu Jul 28 03:26:10 EDT 2005"	16037	960606	0	0	1	0	4	3	4
    +29	jdk1.6.0-b46	"Thu Aug 04 03:02:48 EDT 2005"	15936	951355	0	0	0	0	4	4	4
    +30	jdk1.6.0-b47	"Thu Aug 11 03:18:56 EDT 2005"	15964	952387	0	0	1	0	3	4	3
    +31	jdk1.6.0-b48	"Thu Aug 18 08:10:40 EDT 2005"	15970	953421	0	0	0	0	3	5	3
    +32	jdk1.6.0-b49	"Thu Aug 25 03:24:38 EDT 2005"	16048	958940	0	0	0	0	3	5	3
    +33	jdk1.6.0-b50	"Thu Sep 01 01:52:40 EDT 2005"	16287	974937	1	0	0	0	3	5	4
    +34	jdk1.6.0-b51	"Thu Sep 08 01:55:36 EDT 2005"	16362	979377	0	0	0	0	4	5	4
    +35	jdk1.6.0-b52	"Thu Sep 15 02:04:08 EDT 2005"	16477	979399	0	0	0	0	4	5	4
    +36	jdk1.6.0-b53	"Thu Sep 22 02:00:28 EDT 2005"	16019	957900	0	0	1	0	3	5	3
    +37	jdk1.6.0-b54	"Thu Sep 29 01:54:34 EDT 2005"	16019	957900	0	0	0	0	3	6	3
    +38	jdk1.6.0-b55	"Thu Oct 06 01:54:14 EDT 2005"	16051	959014	0	0	0	0	3	6	3
    +39	jdk1.6.0-b56	"Thu Oct 13 01:54:12 EDT 2005"	16211	970835	0	0	0	0	3	6	3
    +40	jdk1.6.0-b57	"Thu Oct 20 01:55:26 EDT 2005"	16279	971627	0	0	0	0	3	6	3
    +41	jdk1.6.0-b58	"Thu Oct 27 01:56:30 EDT 2005"	16283	971945	0	0	0	0	3	6	3
    +42	jdk1.6.0-b59	"Thu Nov 03 01:56:58 EST 2005"	16232	972193	0	0	0	0	3	6	3
    +43	jdk1.6.0-b60	"Thu Nov 10 01:54:18 EST 2005"	16235	972346	0	0	0	0	3	6	3
    +

    次に示すコマンドを実行すると、db.xml 中間ファイルを生成することなく直接同じ情報を作成できます。

    +computeBugHistory  jdk1.6.0-b*/jre/lib/rt.xml | filterBugs -bugPattern IL_ db.xml | mineBugHistory -formatDates
    +

    この情報を使って、 Sun JDK1.6.0 の各ビルドにおいて FindBugs によって発見された無限再起ループの数を表すグラフを表示します。青色の領域は、当該ビルドにおける無限再起ループの数を表しています。その上に描かれている赤色の領域は、以前のバージョンには存在したが当該バージョンでは除去された無限再起ループの数を表しています。 (したがって、赤色の領域と青色の領域を足し合わせた高さは決して減少しないことが保証されています。そして、新たに無限再起ループのバグが持ち込まれた時点で増加します) 。赤色の領域の高さは、当該バージョンにおいて修正または削除されたバグ数の合計で算出されます。バージョン 13 および 14 において見られる減少は、 FindBugs を使用して見つかった JDK のバグの報告を Sun が受け取ったことによるものです。

    db.xml ファイルは、 jdk1.6.0 のすべてのビルドに対する検索結果を保持しています。したがって、次に示すコマンドを実行することで、優先度(高)または優先度(低)の正確性に関する警告の履歴が表示されます :

    +filterBugs -priority M -category C db.xml | mineBugHistory -formatDates
    +

    作成される表の例 :

    +seq	version	time	classes	NCSS	added	newCode	fixed	removed	retained	dead	active
    +0	jdk1.6.0-b12	"Thu Nov 11 09:07:20 EST 2004"	13128	811569	0	1075	0	0	0	0	1075
    +1	jdk1.6.0-b13	"Thu Nov 18 06:02:06 EST 2004"	13128	811570	0	0	0	0	1075	0	1075
    +2	jdk1.6.0-b14	"Thu Dec 02 06:12:26 EST 2004"	13145	811786	3	0	6	0	1069	0	1072
    +3	jdk1.6.0-b15	"Thu Dec 09 06:07:04 EST 2004"	13174	811693	2	1	3	0	1069	6	1072
    +4	jdk1.6.0-b16	"Thu Dec 16 06:21:28 EST 2004"	13175	811715	0	0	1	0	1071	9	1071
    +5	jdk1.6.0-b17	"Thu Dec 23 06:27:22 EST 2004"	13176	811974	0	0	1	0	1070	10	1070
    +6	jdk1.6.0-b19	"Thu Jan 13 06:41:16 EST 2005"	13176	812011	0	0	0	0	1070	11	1070
    +7	jdk1.6.0-b21	"Thu Jan 27 05:57:52 EST 2005"	13177	812173	0	0	1	0	1069	11	1069
    +8	jdk1.6.0-b23	"Thu Feb 10 05:44:36 EST 2005"	13179	812188	0	0	0	0	1069	12	1069
    +9	jdk1.6.0-b26	"Thu Mar 03 06:04:02 EST 2005"	13199	811770	0	0	2	1	1066	12	1066
    +10	jdk1.6.0-b27	"Thu Mar 10 04:48:38 EST 2005"	13189	812440	1	0	1	1	1064	15	1065
    +11	jdk1.6.0-b28	"Thu Mar 17 02:54:22 EST 2005"	13185	812056	0	0	0	0	1065	17	1065
    +12	jdk1.6.0-b29	"Thu Mar 24 03:09:20 EST 2005"	13117	809468	3	0	8	26	1031	17	1034
    +13	jdk1.6.0-b30	"Thu Mar 31 02:53:32 EST 2005"	13118	809501	0	0	0	0	1034	51	1034
    +14	jdk1.6.0-b31	"Thu Apr 07 03:00:14 EDT 2005"	13117	809572	0	0	0	0	1034	51	1034
    +15	jdk1.6.0-b32	"Thu Apr 14 02:56:56 EDT 2005"	13169	811096	1	1	0	1	1033	51	1035
    +16	jdk1.6.0-b33	"Thu Apr 21 02:46:22 EDT 2005"	13187	811942	3	0	2	1	1032	52	1035
    +17	jdk1.6.0-b34	"Thu Apr 28 02:49:00 EDT 2005"	13195	813488	0	1	0	0	1035	55	1036
    +18	jdk1.6.0-b35	"Thu May 05 02:49:04 EDT 2005"	13457	829837	0	36	2	0	1034	55	1070
    +19	jdk1.6.0-b36	"Thu May 12 02:59:46 EDT 2005"	13462	831278	0	0	0	0	1070	57	1070
    +20	jdk1.6.0-b37	"Thu May 19 02:55:08 EDT 2005"	13464	831971	0	1	1	0	1069	57	1070
    +21	jdk1.6.0-b38	"Thu May 26 03:08:16 EDT 2005"	13564	836565	1	7	2	6	1062	58	1070
    +22	jdk1.6.0-b39	"Fri Jun 03 03:10:48 EDT 2005"	13856	849992	6	39	5	0	1065	66	1110
    +23	jdk1.6.0-b40	"Thu Jun 09 03:30:28 EDT 2005"	15972	959619	7	147	11	0	1099	71	1253
    +24	jdk1.6.0-b41	"Thu Jun 16 03:19:22 EDT 2005"	15972	959619	0	0	0	0	1253	82	1253
    +25	jdk1.6.0-b42	"Fri Jun 24 03:38:54 EDT 2005"	15966	958581	3	0	1	2	1250	82	1253
    +26	jdk1.6.0-b43	"Thu Jul 14 03:09:34 EDT 2005"	16041	960544	5	11	15	8	1230	85	1246
    +27	jdk1.6.0-b44	"Thu Jul 21 03:05:54 EDT 2005"	16041	960547	0	0	0	0	1246	108	1246
    +28	jdk1.6.0-b45	"Thu Jul 28 03:26:10 EDT 2005"	16037	960606	19	0	2	0	1244	108	1263
    +29	jdk1.6.0-b46	"Thu Aug 04 03:02:48 EDT 2005"	15936	951355	13	1	1	32	1230	110	1244
    +30	jdk1.6.0-b47	"Thu Aug 11 03:18:56 EDT 2005"	15964	952387	163	8	7	20	1217	143	1388
    +31	jdk1.6.0-b48	"Thu Aug 18 08:10:40 EDT 2005"	15970	953421	0	0	0	0	1388	170	1388
    +32	jdk1.6.0-b49	"Thu Aug 25 03:24:38 EDT 2005"	16048	958940	1	11	1	0	1387	170	1399
    +33	jdk1.6.0-b50	"Thu Sep 01 01:52:40 EDT 2005"	16287	974937	19	27	16	7	1376	171	1422
    +34	jdk1.6.0-b51	"Thu Sep 08 01:55:36 EDT 2005"	16362	979377	1	15	3	0	1419	194	1435
    +35	jdk1.6.0-b52	"Thu Sep 15 02:04:08 EDT 2005"	16477	979399	0	0	1	1	1433	197	1433
    +36	jdk1.6.0-b53	"Thu Sep 22 02:00:28 EDT 2005"	16019	957900	13	12	16	20	1397	199	1422
    +37	jdk1.6.0-b54	"Thu Sep 29 01:54:34 EDT 2005"	16019	957900	0	0	0	0	1422	235	1422
    +38	jdk1.6.0-b55	"Thu Oct 06 01:54:14 EDT 2005"	16051	959014	1	4	7	0	1415	235	1420
    +39	jdk1.6.0-b56	"Thu Oct 13 01:54:12 EDT 2005"	16211	970835	6	8	37	0	1383	242	1397
    +40	jdk1.6.0-b57	"Thu Oct 20 01:55:26 EDT 2005"	16279	971627	0	0	0	0	1397	279	1397
    +41	jdk1.6.0-b58	"Thu Oct 27 01:56:30 EDT 2005"	16283	971945	0	1	1	0	1396	279	1397
    +42	jdk1.6.0-b59	"Thu Nov 03 01:56:58 EST 2005"	16232	972193	6	0	5	0	1392	280	1398
    +43	jdk1.6.0-b60	"Thu Nov 10 01:54:18 EST 2005"	16235	972346	0	0	0	0	1398	285	1398
    +44	jdk1.6.0-b61	"Thu Nov 17 01:58:42 EST 2005"	16202	971134	2	0	4	0	1394	285	1396
    +

    2.2. 増分履歴メンテナンス

    仮に、 db.xml がビルド b12 - b60 に対する findbugs 実行結果を保持している場合、次に示すコマンドを実行することで、 db.xml に b61 に対する実行結果を追加することができます :

    +computeBugHistory -output db.xml db.xml jdk1.6.0-b61/jre/lib/rt.xml
    +

    3. Ant の例

    findbugs の実行とその後のデータ・マイニングツールの活用の両方を実行している ant スクリプトの完全な例を以下に示します :

    +
    +<project name="analyze_asm_util" default="findbugs">
    +   <!-- findbugs タスク定義 -->
    +   <property name="findbugs.home" value="/Users/ben/Documents/workspace/findbugs/findbugs" />
    +   <property name="jvmargs" value="-server -Xss1m -Xmx800m -Duser.language=en -Duser.region=EN -Dfindbugs.home=${findbugs.home}" />
    +
    +    <path id="findbugs.lib">
    +      <fileset dir="${findbugs.home}/lib">
    +         <include name="findbugs-ant.jar"/>
    +      </fileset>
    +   </path>
    +
    +   <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
    +      <classpath refid="findbugs.lib" />
    +   </taskdef>
    +
    +   <taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask">
    +      <classpath refid="findbugs.lib" />
    +   </taskdef>
    +
    +   <taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask">
    +      <classpath refid="findbugs.lib" />
    +   </taskdef>
    +
    +   <taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask">
    +      <classpath refid="findbugs.lib" />
    +   </taskdef>
    +
    +   <!-- findbugs タスク定義 -->
    +   <target name="findbugs">
    +      <antcall target="analyze" />
    +      <antcall target="mine" />
    +   </target>
    +
    +   <!-- 分析を行うタスク-->
    +   <target name="analyze">
    +      <!-- asm-util に対して findbugs を実行する -->
    +      <findbugs home="${findbugs.home}"
    +                output="xml:withMessages"
    +                timeout="90000000"
    +                reportLevel="experimental"
    +                workHard="true"
    +                effort="max"
    +                adjustExperimental="true"
    +                jvmargs="${jvmargs}"
    +                failOnError="true"
    +                outputFile="out.xml"
    +                projectName="Findbugs"
    +                debug="false">
    +         <class location="asm-util-3.0.jar" />
    +      </findbugs>
    +   </target>
    +
    +   <target name="mine">
    +
    +      <!-- 最新の分析結果に情報を設定する -->
    +      <setBugDatabaseInfo home="${findbugs.home}"
    +                            withMessages="true"
    +                            name="asm-util-3.0.jar"
    +                            input="out.xml"
    +                            output="out-rel.xml"/>
    +
    +      <!-- 履歴ファイル (out-hist.xml) が既に存在するかどうかを確認する -->
    +      <condition property="mining.historyfile.available">
    +         <available file="out-hist.xml"/>
    +      </condition>
    +      <condition property="mining.historyfile.notavailable">
    +         <not>
    +            <available file="out-hist.xml"/>
    +         </not>
    +      </condition>
    +
    +      <!-- このターゲットは、履歴ファイルが存在しないとき (初回) だけ実行されます -->
    +      <antcall target="history-init">
    +        <param name="data.file" value="out-rel.xml" />
    +        <param name="hist.file" value="out-hist.xml" />
    +      </antcall>
    +      <!-- 上記以外の場合に実行されます -->
    +      <antcall target="history">
    +        <param name="data.file"         value="out-rel.xml" />
    +        <param name="hist.file"         value="out-hist.xml" />
    +        <param name="hist.summary.file" value="out-hist.txt" />
    +      </antcall>
    +   </target>
    +
    +   <!-- 履歴ファイルを初期化します -->
    +   <target name="history-init" if="mining.historyfile.notavailable">
    +      <copy file="${data.file}" tofile="${hist.file}" />
    +   </target>
    +
    +   <!-- バグ履歴を算出します -->
    +   <target name="history" if="mining.historyfile.available">
    +      <!-- ${data.file} を ${hist.file} にマージします -->
    +      <computeBugHistory home="${findbugs.home}"
    +                           withMessages="true"
    +                           output="${hist.file}">
    +            <dataFile name="${hist.file}"/>
    +            <dataFile name="${data.file}"/>
    +      </computeBugHistory>
    +
    +      <!-- 履歴を算出して ${hist.summary.file} に出力します -->
    +      <mineBugHistory home="${findbugs.home}"
    +                        formatDates="true"
    +                      noTabs="true"
    +                        input="${hist.file}"
    +                        output="${hist.summary.file}"/>
    +   </target>
    +
    +</project>
    +
    +
    \ No newline at end of file diff --git a/doc/ja/manual/eclipse.html b/doc/ja/manual/eclipse.html new file mode 100644 index 0000000..d1bc7f1 --- /dev/null +++ b/doc/ja/manual/eclipse.html @@ -0,0 +1,3 @@ + + + 第7章 FindBugs™ Eclipse プラグインの使用方法

    第7章 FindBugs™ Eclipse プラグインの使用方法

    FindBugs Eclipse プラグインを使用することによって、 FindBugsEclipse IDE で使用することができるようになります。このFindBugs Eclipse プラグインは、 Peter Friese 氏の多大な貢献によるものです。Phil Crosby 氏 と Andrei Loskutov 氏は、プラグインの重要な改良に貢献しました。

    1. 必要条件

    FindBugs Eclipse Plugin を使用するためには、 Eclipse 3.3 あるいはそれ以降のバージョン、また、 JRE/JDK 1.5 あるいはそれ以降のバージョンが必要です。

    2. インストール

    更新サイトが提供されています。更新サイトを利用して、機械的に FindBugs を Eclipse にインストールできます。また自動的に、最新版のアップデートを照会してインストールすることもできます。内容の異なる 3 つの更新サイトが存在します。

    FindBugs Eclipse 更新サイト一覧

    http://findbugs.cs.umd.edu/eclipse/

    FindBugs の公式リリース物を提供します。

    http://findbugs.cs.umd.edu/eclips-candidate/

    FindBugsの公式リリース物に加えて、公式リリース候補版を提供します。

    http://findbugs.cs.umd.edu/eclipse-daily/

    FindBugsの日次ビルド物を提供します。コンパイルができること以上のテストは行われていません。

    また、次に示すリンクから手動でプラグインをダウンロードすることもできます : http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download. 展開して Eclipse の「plugins」サブディレクトリーに入れてください。(そうすると、 <eclipse インストールディレクトリー >/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png が FindBugs のロゴファイルへのパスになるはずです。)

    プラグインの展開ができたら、 Eclipse を起動して HelpAbout Eclipse PlatformPlug-in Details を選択してください。「FindBugs Project」から提供された「FindBugs Plug-in」というプラグインがあることを確認してください。

    3. プラグインの使用方法

    実行するには、 Java プロジェクト上で右クリックして「Find Bugs」を選択します。FindBugs が実行されて、バグパターンの実例の可能性があると識別されたコード箇所に問題マーカーがつきます。 (ソース画面および Eclipse 問題ビューに表示されます。)

    Java プロジェクトのプロパティーダイアログを開いて「Findbugs」プロパティーページを選択することで、 FindBugs の動作をカスタマイズすることができます。選択できる項目には次のようなものがあります :

    • 「Run FindBugs Automatically」チェックボックスの設定。チェックすると、プロジェクト内の Java クラスが修正されるたびに FindBugs が実行されます。

    • 優先度とバグカテゴリーの選択。これらのオプションは、どの警告を表示するかを選択します。例えば、優先度で 「Medium」 を選択すると、優先度 (中) および優先度 (高) の警告のみが表示されます。同様に、「Style」チェックボックスのチェックマークを外すと、Style カテゴリーに属する警告は表示されません。

    • ディテクタの選択。表からプロジェクトで有効にしたいディテクタを選択することができます。

    4. トラブルシューティング

    FindBugs Eclipse プラグインは、まだ実験段階です。このセクションでは、プラグインに関する一般的な問題と (判明していれば) それらの問題の解決方法を記述します。

    • FindBugs 問題マーカーが (ソース画面および問題ビューに) 表示されない場合は、問題ビューのフィルター設定を変更してください。詳細情報は http://findbugs.sourceforge.net/FAQ.html#q7 を参照してください。

    \ No newline at end of file diff --git a/doc/ja/manual/example-code.png b/doc/ja/manual/example-code.png new file mode 100644 index 0000000..fe01f31 Binary files /dev/null and b/doc/ja/manual/example-code.png differ diff --git a/doc/ja/manual/example-details.png b/doc/ja/manual/example-details.png new file mode 100644 index 0000000..1addf93 Binary files /dev/null and b/doc/ja/manual/example-details.png differ diff --git a/doc/ja/manual/example.png b/doc/ja/manual/example.png new file mode 100644 index 0000000..289b897 Binary files /dev/null and b/doc/ja/manual/example.png differ diff --git a/doc/ja/manual/filter.html b/doc/ja/manual/filter.html new file mode 100644 index 0000000..491deed --- /dev/null +++ b/doc/ja/manual/filter.html @@ -0,0 +1,168 @@ + + + 第8章 フィルターファイル

    第8章 フィルターファイル

    フィルターファイルを使用することで、特定のクラスやメソッドをバグ報告に含めたりバグ報告から除外したりすることができます。この章では、フィルターファイルの使用方法を説明します。

    [注記]計画されている機能

    フィルターは現在、コマンドラインインタフェースでのみサポートされています。最終的には、フィルターのサポートは GUI にも追加される予定です。

    +

    1. フィルターファイルの概要

    概念的に言えば、フィルターはバグ検索結果をある基準と照合します。フィルターを定義することで、 特別な取り扱いをするバグ検索結果を選択することができます。例えば、あるバグ検索結果をバグ報告に含めたり、バグ報告から除外したりすることができます。

    フィルターファイルは、 XML 文書です。最上位要素が FindBugsFilter 要素 であり、その子要素として Match 要素を複数個定義します。それぞれの Match 要素は、生成されたバグ検索結果に適用される述部にあたります。通常、フィルターはバグ検索結果を除外するために使用します。次に、例を示します:

    +$ findbugs -textui -exclude myExcludeFilter.xml myApp.jar
    +

    また一方で、的をしぼった報告を得るためにバグ報告結果を選択するためにフィルターを使用することも考えられます :

    +$ findbugs -textui -include myIncludeFilter.xml myApp.jar
    +

    +

    +Match 要素は子要素を持ちます。それらの子要素は論理積で述部になります。つまり、述部が真であるためには、すべての子要素が真である必要があります。

    2. マッチング条件の種類

    <Bug>

    この要素は、バグパターンを指定して照合します。pattern 属性には、コンマ区切りでバグパターン類型のリストを指定します。どの警告がどのバグパターン類型にあたるかは、 -xml オプションをつかって出力されたもの (BugInstance 要素の type 属性) を見るか、または、 バグ解説ドキュメントを参照してください。

    もっと粒度の粗い照合を行いたいときは、 code 属性を使用してください。バグ略称のコンマ区切りのリストで指定できます。さらに粒度の粗い照合を行いたいときは、 category 属性を使用してください。次に示す、バグカテゴリー名のコンマ区切りのリストで指定できます : CORRECTNESS, MT_CORRECTNESS, BAD_PRACTICICE, PERFORMANCE, STYLE.

    同じ <Bug> 要素に上記の属性を複数指定した場合は、バグパターン名、バグ略称、バグカテゴリーのいずれか1つでも該当すれば、バグパターンは合致すると判定されます。

    下位互換性を持たせたい場合は、 <Bug> 要素の代わりに <BugPattern> 要素および <BugCode> 要素を使用してください。これらの要素はそれぞれ、 name 属性で値のリストを指定します。これらの要素は、将来サポートされなくなる可能性があります。

    <Priority>

    この要素は、特定の優先度をもつ警告を照合します。value 属性には、整数値を指定します : 1 は優先度(高)、また、 2 は優先度(中) 、 3 は優先度(低) を示します。

    <Package>

    この要素は、 name 属性で指定した特定のパッケージ内にあるクラスに関連した警告を照合します。入れ子のパッケージは含まれません (Java import 文に従っています) 。しかしながら、正規表現を使うと複数パッケージにマッチさせることは簡単にできます。

    <Class>

    この要素は、特定のクラスに関連した警告を照合します。name 属性を使用して、照合するクラス名をクラス名そのものか、または、正規表現で指定します。

    下位互換性を持たせたい場合は、この要素の代わりに Match 要素を使用してください。クラス名そのものの指定は class 属性を、クラス名を正規表現で指定する場合は classregex 属性をそれぞれ使用してください

    もし Match 要素に Class 要素が無かったり、 class / classregex 属性が無かったりした場合は、すべてのクラスに適用されます。その場合、想定外に多くのバグ検索結果が一致してしまうことがあり得ます。その場合は、適当なメソッドやフィールドで絞り込んでください。

    <Method>

    この要素は、メソッドを指定します。name 属性を使用して、照合するメソッド名をメソッド名そのものか、または、正規表現で指定します。params 属性には、コンマ区切りでメソッド引数の型のリストを指定します。returns 属性にはメソッドの戻り値の型を指定します。params および returns においては、クラス名は完全修飾名である必要があります。(例えば、単に "String" ではなく "java.lang.String" としてください。) params returns のどちらか一方を指定した場合は、もう一方の属性の指定も必須です。なぜならば、メソッドシグニチャーを構築のために必要だからです。name 属性、params 属性 および returns 属性または 3 つの 属性すべて、のどれかを条件とすることできることを意味しています。このように、名前とシグニチャーに基づく様々な種類の条件を規定できます。

    <Field>

    この要素は、フィールドを指定します。name 属性を使用して、照合するフィールド名をフィールド名そのものか、または、正規表現で指定します。また、フィールドのシグニチャーに照らしたフィルタリングをすることができます。 type 属性を使用して、フィールドの型を完全修飾名で指定してください。名前とシグニチャーに基づく条件を規定するために、その2つの属性を両方とも指定することができます。

    <Local>

    この要素は、ローカル変数を指定します。name 属性を使用して、照合するローカル変数名をローカル変数名そのものか、または、正規表現で指定します。ローカル変数とは、メソッド内で定義した変数です。

    <Or>

    この要素は、論理和として Match 条項を結合します。すなわち、2つの Method 要素を Or 条項に入れることで、どちらか一方のメソッドでマッチさせることができます。

    3. Java 要素名マッチング

    ClassMethod または Fieldname 属性が文字 ~ で始まっている場合は、属性値の残りの部分を Java の正規表現として解釈します。そうして、当該 Java 要素の名前に対しての照合が行われます。

    パターンの照合は要素の名前全体に対して行われることに注意してください。そのため、部分一致照合を行いたい場合はパターン文字列の前後に .* を付加して使用する必要があります。

    パターンの構文規則に関しては、 java.util.regex.Pattern のドキュメントを参照してください。

    4. 留意事項

    +Match 条項は、バグ検索結果に実際に含まれている情報にのみ一致します。すべてのバグ検索結果はクラスを持っています。したがって、一般的に言って、バグを除外するためにはクラスを用いて行うとうまくいくことが多いです。

    バグ検索結果の中には、2個以上のクラスを保持しているものもあります。例えば、 DE (dropped exception : 例外の無視) バグは、 例外の無視が発生したメソッドを持っているクラスと、 無視された例外の型を表すクラスの両方を含んだ形で報告されます。Match 条項とは、 1番目 (主) のクラスのみが照合されます。したがって、例えば、クラス "com.foobar.A" 、 "com.foobar.B" 間での IC (initialization circularity : 初期化時の処理循環) バグ報告を抑止したい場合、以下に示すように 2つの Match 条項を使用します :

    +   <Match>
    +      <Class name="com.foobar.A" />
    +      <Bug code="IC" />
    +   </Match>
    +
    +   <Match>
    +      <Class name="com.foobar.B" />
    +      <Bug code="IC" />
    +   </Match>
    +

    明示的に両方のクラスで照合することによって、循環しているどちらのクラスがバグ検索結果の 1 番目になっているかに関係なく一致させることができます。(もちろんこの方法は、処理循環が "com.foobar.A" 、 "com.foobar.B" に加えて3番目のクラスも含んでいる場合は図らずも失敗してしまう恐れがあります。)

    多くの種類のバグ報告は、自身が出現したメソッドを報告します。それらのバグ検索結果に対しては、 Method 条項を Match 要素に加えると期待通りの動作をするでしょう。

    5. 例

    1. 特定のクラスに対するすべてのバグ報告に一致させます。

    +
    +     <Match>
    +       <Class name="com.foobar.MyClass" />
    +     </Match>
    +
    +

    + +

    2. バグ略称を指定して、特定のクラスに対する特定の検査項目に一致させます。

    +
    +     <Match>
    +       <Class name="com.foobar.MyClass"/ >
    +       <Bug code="DE,UrF,SIC" />
    +     </Match>
    +
    +

    +

    3. バグ略称を指定して、すべてのクラスに対する特定の検査項目に一致させます。

    +
    +     <Match>
    +       <Bug code="DE,UrF,SIC" />
    +     </Match>
    +
    +

    +

    4. バグカテゴリーを指定して、すべてのクラスに対する特定の検査項目に一致させます。

    +
    +     <Match>
    +       <Bug category="PERFORMANCE" />
    +     </Match>
    +
    +

    +

    5. バグ略称を指定して、特定のクラスの指定されたメソッドに対する特定のバグ種別に一致させます。

    +
    +     <Match>
    +       <Class name="com.foobar.MyClass" />
    +       <Or>
    +         <Method name="frob" params="int,java.lang.String" returns="void" />
    +         <Method name="blat" params="" returns="boolean" />
    +       </Or>
    +       <Bug code="DC" />
    +     </Match>
    +
    +

    +

    6. 特定のメソッドに対する特定のバグパターンに一致させます。

    +
    +    <!-- open stream に関する誤検出があるメソッド。-->
    +    <Match>
    +      <Class name="com.foobar.MyClass" />
    +      <Method name="writeDataToFile" />
    +      <Bug pattern="OS_OPEN_STREAM" />
    +    </Match>
    +
    +

    +

    7. 特定のメソッドに対する特定の優先度を付与された特定のバグパターンに一致させます。

    +
    +    <!-- dead local store (優先度 (中)) に関する誤検出があるメソッド。-->
    +    <Match>
    +      <Class name="com.foobar.MyClass" />
    +      <Method name="someMethod" />
    +      <Bug pattern="DLS_DEAD_LOCAL_STORE" />
    +      <Priority value="2" />
    +    </Match>
    +
    +

    +

    8. AspectJ コンパイラーによって引き起こされるマイナーバグに一致させます (AspectJ の開発者でもない限り、それらのバグに関心を持つことはないと考えます)。

    +
    +    <Match>
    +      <Class name="~.*\$AjcClosure\d+" />
    +      <Bug pattern="DLS_DEAD_LOCAL_STORE" />
    +      <Method name="run" />
    +    </Match>
    +    <Match>
    +      <Bug pattern="UUF_UNUSED_FIELD" />
    +      <Field name="~ajc\$.*" />
    +    </Match>
    +
    +

    +

    9. 基盤コードの特定の部分に対するバグに一致させます

    +
    +    <!-- すべてのパッケージにある Messages クラスに対する unused fields 警告に一致。 -->
    +    <Match>
    +      <Class name="~.*\.Messages" />
    +      <Bug code="UUF" />
    +    </Match>
    +    <!-- すべての internal パッケージ内の mutable statics 警告に一致。 -->
    +    <Match>
    +      <Package name="~.*\.internal" />
    +      <Bug code="MS" />
    +    </Match>
    +    <!-- ui パッケージ階層内の anonymoous inner classes 警告に一致。 -->
    +    <Match>
    +      <Package name="~com\.foobar\.fooproject\.ui.*" />
    +      <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" />
    +    </Match>
    +
    +

    +

    10. 特定のシグニチャーを持つフィールドまたはメソッドのバグに一致させます。

    +
    +    <!-- すべてのクラスの main(String[]) メソッドに対する System.exit(...) usage 警告に一致。 -->
    +    <Match>
    +      <Method returns="void" name="main" params="java.lang.String[]" />
    +      <Method pattern="DM_EXIT" />
    +    </Match>
    +    <!-- すべてのクラスの com.foobar.DebugInfo 型のフィールドに対する UuF 警告に一致。 -->
    +    <Match>
    +      <Field type="com.foobar.DebugInfo" />
    +      <Bug code="UuF" />
    +    </Match>
    +
    +

    + +

    6. 完全な例

    +
    +<FindBugsFilter>
    +     <Match>
    +       <Class name="com.foobar.ClassNotToBeAnalyzed" />
    +     </Match>
    +
    +     <Match>
    +       <Class name="com.foobar.ClassWithSomeBugsMatched" />
    +       <Bug code="DE,UrF,SIC" />
    +     </Match>
    +
    +     <!-- XYZ 違反に一致。-->
    +     <Match>
    +       <Bug code="XYZ" />
    +     </Match>
    +
    +     <!-- "AnotherClass" の特定のメソッドの doublecheck 違反に一致。-->
    +     <Match>
    +       <Class name="com.foobar.AnotherClass" />
    +       <Or>
    +         <Method name="nonOverloadedMethod" />
    +         <Method name="frob" params="int,java.lang.String" returns="void" />
    +         <Method name="blat" params="" returns="boolean" />
    +       </Or>
    +       <Bug code="DC" />
    +     </Match>
    +
    +     <!-- dead local store (優先度 (中)) に関する誤検出があるメソッド。-->
    +     <Match>
    +       <Class name="com.foobar.MyClass" />
    +       <Method name="someMethod" />
    +       <Bug pattern="DLS_DEAD_LOCAL_STORE" />
    +       <Priority value="2" />
    +     </Match>
    +</FindBugsFilter>
    +
    +
    \ No newline at end of file diff --git a/doc/ja/manual/gui.html b/doc/ja/manual/gui.html new file mode 100644 index 0000000..8c7088f --- /dev/null +++ b/doc/ja/manual/gui.html @@ -0,0 +1,5 @@ + + + 第5章 FindBugs GUI の使用方法

    第5章 FindBugs GUI の使用方法

    この章では、FindBugs グラフィカルユーザーインタフェース (GUI) の使用方法を説明します。

    1. プロジェクトの作成

    findbugs コマンドで FindBugs を起動してから、メニューで FileNew Project を選択してください。そうすると、次のようなダイアログが表示されます:

    +

    「Class archives and directories to analyze」テキストフィールドの横にある 「Add」ボタンを押すと、バグを分析する java クラスを含んでいる Java アーカイブファイル (zip, jar, ear, or war file) を選択して指定できます。複数の アーカイブ/ディレクトリーを追加することが可能です。

    また、分析を行う Java アーカイブのソースコードを含んだソースディレクトリーを指定することもできます。そうすると、バグの可能性があるソースコードの場所が、FindBugs 上でハイライトして表示されます。ソースディレクトリーは、Java パッケージ階層のルートディレクトリーを指定する必要があります。例えば、ユーザのアプリケーションが org.foobar.myapp パッケージの中にある場合は、 org ディレクトリーの親ディレクトリーをソースディレクトリーリストに指定する必要があります。

    もうひとつ、任意指定の手順があります。それは、補助用の Jar ファイルおよびディレクトリーを 「Auxiliary classpath locations」のエントリーに追加することです。分析するアーカイブ/ディレクトリーにも標準の実行時クラスパスにも含まれていないクラスを、分析するアーカイブ/ディレクトリーが参照している場合は、この項目を設定した方がいいでしょう。クラス階層に関する情報を使用するバグディテクタが、 FindBugs にはいくつかあります。したがって、FindBugs が分析を行うクラスの完全なクラス階層を参照できれば、より正確な分析結果を取得することができます。

    2. 分析の実行

    アーカイブ、ディレクトリーおよびソースディレクトリーの指定ができれば、「Finish」ボタンを押して Jar ファイルに含まれるクラスに対する分析を実行します。巨大なプロジェクトを古いコンピュータ上で実行すると、かなりの時間(数十分)がかかることに注意してください。大容量メモリである最近のコンピュータなら、大きなプログラムであっても数分程度で分析できます。

    3. 結果の閲覧

    分析が完了すると、次のような画面が表示されます :

    +

    左上のペインにはバグ階層ツリーが表示されます。これは、分析でみつかったバグの検索結果が階層的に表示されたものです。

    上部のペインでバグ検索結果を選択すると、下部の「Details」ペインにバグの詳細説明が表示されます。更に、ソースがみつかれば、右上のソースコードペインにバグの出現箇所に該当するソースコードが表示されます。上図の例で表示されているバグは、ストリームオブジェクトがクローズされていないというものです。ソースコード・ウィンドウにおいて当該ストリームオブジェクトを生成している行がハイライトされています。

    バグの検索結果に対してテキストで注釈を入れることができます。階層ツリー図のすぐ下にあるテキストボックスに注釈を入力してください。記録しておきたい情報を何でも自由に入力することができます。バグ結果ファイルの保存および読み込みを行ったときに、注釈も保存されます。

    4. 保存と読み込み

    メニュー項目から FileSave as... を選択すると、ユーザーの作業結果を保存することができます。「Save as...」ダイアログにあるドロップダウン・リストの中から「FindBugs analysis results (.xml)」を選択ことで、ユーザーが指定した jar ファイルリストやバグ検索結果などの作業結果を保存することができます。また、jar ファイルリストのみを保存する選択肢 (「FindBugs project file (.fbp)」) やバグ検索結果のみを保存する選択肢 (「FindBugs analysis file (.fba)」) もあります。保存したファイルは、メニュー項目から FileOpen... を選択することで、読み込むことができます。

    \ No newline at end of file diff --git a/doc/ja/manual/important.png b/doc/ja/manual/important.png new file mode 100644 index 0000000..12c90f6 Binary files /dev/null and b/doc/ja/manual/important.png differ diff --git a/doc/ja/manual/index.html b/doc/ja/manual/index.html new file mode 100644 index 0000000..b039130 --- /dev/null +++ b/doc/ja/manual/index.html @@ -0,0 +1,3 @@ + + + FindBugs™ マニュアル

    FindBugs™ マニュアル

    Hovemeyer David [FAMILY Given]

    Pugh William [FAMILY Given]

    このマニュアルは、クリエイティブ・コモンズ表示-非営利-継承に基づく使用許諾がなされています。使用許諾書をご覧になる場合は、 http://creativecommons.org/licenses/by-nc-sa/1.0/ にアクセスするか、クリエイティブ・コモンズ(559 Nathan Abbott Way, Stanford, California 94305, USA)に書簡を送付してください。

    名称「FindBugs」および FindBugs のロゴは、メリーランド大学の登録商標です。

    17:16:15 EST, 22 November, 2013


    \ No newline at end of file diff --git a/doc/ja/manual/infiniteRecursiveLoops.png b/doc/ja/manual/infiniteRecursiveLoops.png new file mode 100644 index 0000000..5430df2 Binary files /dev/null and b/doc/ja/manual/infiniteRecursiveLoops.png differ diff --git a/doc/ja/manual/installing.html b/doc/ja/manual/installing.html new file mode 100644 index 0000000..9f3f2b4 --- /dev/null +++ b/doc/ja/manual/installing.html @@ -0,0 +1,9 @@ + + + 第2章 FindBugs™ のインストール

    第2章 FindBugs™ のインストール

    この章では、 FindBugs のインストール方法を説明します。

    1. 配布物の展開

    FindBugs をインストールする最も簡単な方法は、バイナリ配布物をダウンロードすることです。 バイナリ配布物は、 gzipped tar 形式 および zip 形式 がそれぞれ入手可能です。バイナリ配布物をダウンロードしてきたら、それを任意のディレクトリーに展開します。

    gzipped tar 形式配布物の展開方法例:

    +$ gunzip -c findbugs-2.0.3.tar.gz | tar xvf -
    +

    +

    zip 形式配布物の展開方法例:

    +C:\Software>unzip findbugs-2.0.3.zip
    +

    +

    バイナリ配布物の展開すると、通常は findbugs-2.0.3 ディレクトリーが作成されます。例えば、ディレクトリー C:\Software でバイナリ配布物を展開すると、ディレクトリー C:\Software\findbugs-2.0.3FindBugs は展開されます。このディレクトリーが FindBugs のホームディレクトリーになります。このマニュアルでは、このホームディレクトリーを $FINDBUGS_HOME (Windowsでは %FINDBUGS_HOME%) を用いて参照します。

    \ No newline at end of file diff --git a/doc/ja/manual/introduction.html b/doc/ja/manual/introduction.html new file mode 100644 index 0000000..5ba4736 --- /dev/null +++ b/doc/ja/manual/introduction.html @@ -0,0 +1,3 @@ + + + 第1章 はじめに

    第1章 はじめに

    FindBugs™ は、Java プログラムの中のバグを見つけるプログラムです。このプログラムは、「バグ パターン」の実例を探します。「バグ パターン」とは、エラーとなる可能性の高いコードの事例です。

    この文書は、FindBugs バージョン 2.0.3 について説明してます。私たちは、 FindBugs に対するフィードバックを心待ちにしています。どうぞ、 FindBugs Web ページ にアクセスしてください。FindBugs についての最新情報、連絡先および FindBugs メーリングリストなどのサポート情報を入手することができます。

    1. 必要条件

    FindBugs を使用するには、 Java 2 Standard Edition, バージョン 1.5 以降のバージョンと互換性のあるランタイム環境が必要です。FindBugs は、プラットフォーム非依存であり、 GNU/Linux 、 Windows 、 MacOS X プラットフォーム上で動作することが知られています。

    FindBugs を使用するためには、少なくとも 512 MB のメモリが必要です。巨大なプロジェクトを解析するためには、それより多くのメモリが必要とされることがあります。

    \ No newline at end of file diff --git a/doc/ja/manual/license.html b/doc/ja/manual/license.html new file mode 100644 index 0000000..158dfc4 --- /dev/null +++ b/doc/ja/manual/license.html @@ -0,0 +1,3 @@ + + + 第13章 ライセンス

    第13章 ライセンス

    名称「FindBugs」および FindBugs のロゴは、メリーランド大学の登録商標です。FindBugs はフリーソフトウェアであり、 Lesser GNU Public License の条件で配布されています。使用承諾書を入手したい場合は、 FindBugs 配布物に含まれる LICENSE.txt ファイルを参照してください。

    最新バージョンの FindBugs および そのソースコードは FindBugs web ページ で入手できます。

    \ No newline at end of file diff --git a/doc/ja/manual/note.png b/doc/ja/manual/note.png new file mode 100644 index 0000000..d0c3c64 Binary files /dev/null and b/doc/ja/manual/note.png differ diff --git a/doc/ja/manual/project-dialog.png b/doc/ja/manual/project-dialog.png new file mode 100644 index 0000000..7a39783 Binary files /dev/null and b/doc/ja/manual/project-dialog.png differ diff --git a/doc/ja/manual/rejarForAnalysis.html b/doc/ja/manual/rejarForAnalysis.html new file mode 100644 index 0000000..4419ecf --- /dev/null +++ b/doc/ja/manual/rejarForAnalysis.html @@ -0,0 +1,3 @@ + + + 第11章 rejarForAnalysis の使用方法

    第11章 rejarForAnalysis の使用方法

    プロジェクトに多くの jar ファイル があったり、 jar ファイルが多くのディレクトリに点在したりする場合は、 rejarForAnalysis スクリプトを使用すると FindBugs の実行が比較的簡単になります。このスクリプトは、数多い jar ファイルを集めて 1 つの大きな jar ファイルに結合します。そうすると、分析時にFindBugs に jar ファイルを設定することが比較的簡単になります。このスクリプトは、 unix システムの 'find' コマンドと組み合わせるととりわけ有用になります ; 次に例を示します。 find . -name '*.jar' | xargs rejarForAnalysis .

    また、 rejarForAnalysis スクリプトは巨大なプロジェクトを複数の jar ファイルに分割することに使用できます。プロジェクトのクラスファイルは、複数の jar ファイルに均等に配分されます。これは、プロジェクト全体に対して FindBugs を実行すると時間とメモリ消費が著しい場合に有用です。プロジェクト全体に対して FindBugs を実行する代わりに、 rejarForAnalysis ですべてのクラスを含む大きな jar ファイルを構築します。続いて、 rejarForAnalysis を再び実行して複数の jar ファイルに分割します。そして、各々の jar ファイルに対して順に FindBugs を実行します。その際、 -auxclasspath に最初に 1 つにまとめた jar ファイルを指定してください。

    rejarForAnalysis スクリプトに指定することができるオプションを以下に示します :

    -maxAge 日数

    最後に更新された日からの経過時間を日単位で指定します (指定した日数より古い jar ファイルは無視されます)。

    -inputFileList ファイル名

    jar ファイル名を記載したテキストファイルを指定します。

    -maxClasses クラス数

    analysis*.jar ファイル 1 ファイルに対するクラスの最大数を指定します。

    -prefix プレフィックス

    分析するクラス名のプレフィックスを指定します (例、 edu.umd.cs.) 。

    \ No newline at end of file diff --git a/doc/ja/manual/running.html b/doc/ja/manual/running.html new file mode 100644 index 0000000..deed032 --- /dev/null +++ b/doc/ja/manual/running.html @@ -0,0 +1,22 @@ + + + 第4章 FindBugs™ の実行

    第4章 FindBugs™ の実行

    FindBugs には2つのユーザーインタフェースがあります。すなわち、グラフィカルユーザーインタフェース (GUI) および コマンドラインインタフェースです。この章では、それぞれのインタフェースの実行方法について説明します。

    [警告]警告

    この章は、現在書き直し中です。書き直しはまだ完了していません。

    1. クイック・スタート

    Windows システムで FindBugs を起動する場合は、 %FINDBUGS_HOME%\lib\findbugs.jar ファイルをダブルクリックしてください。 FindBugs GUI が起動します。

    Unix 、 Linux または Mac OS X システムの場合は、$FINDBUGS_HOME/bin/findbugs スクリプトを実行するか、以下のコマンドを実行します。

    +java -jar $FINDBUGS_HOME/lib/findbugs.jar

    これで、 FindBugs GUI が起動します。

    GUI の使用方法については、 5章FindBugs GUI の使用方法 を参照してください。

    2. FindBugs の起動

    このセクションでは、 FindBugs の起動方法を説明します。FindBugs を起動するには2つの方法があります。すなわち、直接起動する方法、および、ラップしているスクリプトを使用する方法です。

    2.1. FindBugs の直接起動

    最初に述べる FindBugs の起動方法は、 $FINDBUGS_HOME/lib/findbugs.jar を直接実行する方法です。JVM (java) 実行プログラムの -jar コマンドラインスイッチを使用します。(FindBugsのバージョンが 1.3.5 より前の場合は、ラップしているスクリプトを使用する必要があります。)

    FindBugs を直接起動するための、一般的な構文は以下のようになります。

    +    java [JVM 引数] -jar $FINDBUGS_HOME/lib/findbugs.jar オプション…
    +

    +

    2.1.1. ユーザーインタフェースの選択

    1 番目のコマンドラインオプションは、起動する FindBugs ユーザーインタフェースを選択するためのものです。指定可能な値は次の通りです:

    • + -gui: グラフィカルユーザーインタフェース (GUI) を起動します。

    • + -textui: コマンドラインインタフェースを起動します。

    • + -version: FindBugs のバージョン番号を表示します。

    • + -help: FindBugs コマンドラインインタフェースのヘルプ情報を表示します。

    • + -gui1: 最初に作成された FindBugs グラフィカルユーザーインタフェース(すでに廃止されサポートされていない)を起動します。

    2.1.2. Java 仮想マシン (JVM) 引数

    FindBugs を起動する際に有用な Java 仮想マシン 引数をいくつか紹介します。

    -XmxNNm

    Java ヒープサイズの最大値を NN メガバイトに設定します。FindBugs は一般的に大容量のメモリサイズを必要とします。大きなプロジェクトでは、 1500 メガバイトを使用することも珍しくありません。

    -Dname=value

    Java システムプロパティーを設定します。例えば、引数 -Duser.language=ja を使用すると GUI 文言が日本語で表示されます。

    2.2. ラップしているスクリプトを使用した FindBugs の起動

    FindBugs を起動するもうひとつの方法は、ラップしているスクリプトを使用する方法です。

    Unix 系のシステムにおいては、次のようなコマンドでラップしているスクリプトを起動します :

    +$ $FINDBUGS_HOME/bin/findbugs オプション…
    +

    +

    Windows システムにおいては、ラップしているスクリプトを起動するコマンドは次のようになります。

    +C:\My Directory>%FINDBUGS_HOME%\bin\findbugs.bat オプション…
    +

    +

    Unix 系システム および Windows システムのどちらにおいても、ディレクトリー $FINDBUGS_HOME/bin を環境変数 PATH に追加するだけで、 findbugs コマンドを使用して FindBugs を起動することができます。

    2.2.1. ラップしているスクリプトのコマンドラインオプション

    FindBugs のラップしているスクリプトは、次のようなコマンドラインオプションをサポートしています。これらのコマンドラインオプションは FindBugs プログラム 自体が操作するのではなく、どちらかといえば、ラップしているスクリプトの方が処理を行います。

    -jvmArgs 引数

    JVM に受け渡される引数を指定します。例えば、次のような JVM プロパティが設定できます:

    +$ findbugs -textui -jvmArgs "-Duser.language=ja" myApp.jar
    +

    +

    -javahome ディレクトリー

    FindBugs の実行に使用する JRE (Java ランタイム環境) がインストールされているディレクトリーを指定します。

    -maxHeap サイズ

    Java ヒープサイズの最大値をメガバイト単位で指定します。デフォルトは、 256 です。巨大なプログラムやライブラリを分析するには、もっと大きなメモリー容量が必要になる可能性があります。

    -debug

    ディテクタ実行およびクラス分析のトレース情報が標準出力に出力されます。分析が予期せず失敗した際の、トラブルシューティングに有用です。

    -property name=value

    このオプションを使用してシステムプロパティーを設定することができます。 FindBugs はシステムプロパティーを使用して分析特性の設定を行います。9章分析プロパティー を参照してください。このオプションを複数指定して、複数のシステムプロパティを設定することが可能です。注: Windows の多くのバージョンでは、 name=value 文字列を引用符で囲む必要があります。

    3. コマンドラインオプション

    このセクションでは、 FindBugs がサポートするコマンドラインオプションについて説明します。ここで示すコマンドラインオプションは、 FindBugs 直接起動、または、ラップしているスクリプトによる起動で使用できます。

    3.1. 共通のコマンドラインオプション

    ここで示すオプションは、 GUI および コマンドラインインタフェースの両方で使用できます。

    -effort:min

    このオプションを指定すると、精度を上げるために大量のメモリーを消費する分析が無効になります。FindBugs の実行時にメモリー不足になったり、分析を完了するまでに異常に長い時間がかかる場合に試してみてください。

    -effort:max

    精度が高く、より多くのバグを検出する分析を有効にします。ただし、多くのメモリー容量を必要とし、また、完了までの時間が多くかかる可能性があります。

    -project project

    分析するプロジェクトを指定します。指定するプロジェクトファイルには、 GUI を使って作成したものを使用してください。ファイルの拡張子は、一般的には .fb または .fbp です。

    3.2. GUI オプション

    ここで示すオプションは、グラフィカルユーザーインタフェースでのみ使用できます。

    -look:plastic|gtk|native

    Swing のルック・アンド・フィールを設定します。

    +

    3.3. テキストユーザーインタフェースオプション

    ここで示すオプションは、テキストユーザーインタフェースでのみ使用できます。

    -sortByClass

    報告されるバグ検索結果をクラス名でソートします。

    -include filterFile.xml

    filterFile.xml で指定したフィルターに一致したバグ検索結果のみ報告されます。8章フィルターファイル を参照してください。

    -exclude filterFile.xml

    filterFile.xml で指定したフィルターに一致したバグ検索結果は報告されません。8章フィルターファイル を参照してください。

    -onlyAnalyze com.foobar.MyClass,com.foobar.mypkg.*

    コンマ区切りで指定したクラスおよびパッケージのみに限定して、バグ検出の分析を行うようにします。フィルターと違って、このオプションを使うと一致しないクラスおよびパッケージに対する分析の実行を回避することができます。大きなプロジェクトにおいて、このオプションを活用すると分析にかかる時間を大きく削減することができる可能性があります。(しかしながら、アプリケーションの全体で実行していないために不正確な結果を出してしまうディテクタがある可能性もあります。) クラスはパッケージも含んだ完全な名前を指定する必要があります。また、パッケージは、 Java の import 文でパッケージ下のすべてのクラスをインポートするときと同じ方法で指定します。 (すなわち、パッケージの完全な名前に .* を付け加えた形です。).* の代わりに .- を指定すると、サブパッケージも含めてすべてが分析されます。

    -low

    すべてのバグが報告されます。

    -medium

    優先度 (中) および優先度 (高) のバグが報告されます。これは、デフォルトの設定値です。

    -high

    優先度 (高) のバグのみが報告されます。

    -relaxed

    手抜き報告モードです。このオプションを指定すると、多くのディテクタにおいて 誤検出を回避するためのヒューリスティック機能が抑止されます。

    -xml

    バグ報告が XML で作成されます。作成された XML データは 、後で GUI で見ることができます。このオプションは -xml:withMessages と指定することもできます。こうすると 出力 XML には 各バグに関して人間に読むことができるメッセージが含まれるようになります。このオプションで作成された XML ファイルは 報告書に変換するのが簡単です。

    -html

    HTML 出力が生成されます。デフォルトでは FindBugsdefault.xsl XSLT スタイルシートを使用して HTML 出力を生成します: このファイルは、 findbugs.jar の中、または、 FindBugs のソース配布物もしくはバイナリ配布物の中にあります。このオプションには、次のようなバリエーションも存在します。すなわち、 -html:plain.xsl-html:fancy.xsl および -html:fancy-hist.xsl です。plain.xsl スタイルシートは Javascript や DOM を利用しません。したがって、古いWeb ブラウザ使用時や印刷時にも比較的うまく表示されるでしょう。fancy.xsl スタイルシートは DOM と Javascript を利用してナビゲーションを行います。また、ビジュアル表示に CSS を使用します。fancy-hist.xslfancy.xsl スタイルシートを更に進化させたものです。DOM や Javascript をふんだんに駆使して、バグの一覧を動的にフィルタリングします。

    ユーザー自身の XSLT スタイルシートを用いて HTML への変換を行いたい場合は、 -html:myStylesheet.xsl のように指定してください。ここで、 myStylesheet.xsl はユーザーが使用したいスタイルシートのファイル名です。

    -emacs

    バグ報告が Emacs 形式で作成されます。

    -xdocs

    バグ報告が xdoc XML 形式で作成されます。Apache Mavenで使用できます。

    -output ファイル名

    指定したファイルに出力結果が作成されます。

    -outputFile ファイル名

    この引数は、使用すべきではありません。代わりに、 -output を使用してください。

    -nested[:true|false]

    このオプションは、ファイルやディレクトリーの中で入れ子になった jar および zip ファイルを分析するかどうかを指定します。デフォルトでは、入れ子になった jar および zip ファイルも分析します。入れ子になった jar および zip ファイルの分析するを無効にする場合は、 -nested:false をコマンドライン引数に追加してください。

    -auxclasspath クラスパス

    分析時に使用する補助クラスパスを設定します。分析するプログラムで使用するjarファイルやクラスディレクトリーをすべて指定してください。補助クラスパスに指定したクラスは分析の対象にはなりません。

    \ No newline at end of file diff --git a/doc/ja/manual/warning.png b/doc/ja/manual/warning.png new file mode 100644 index 0000000..1c33db8 Binary files /dev/null and b/doc/ja/manual/warning.png differ diff --git a/doc/links.html b/doc/links.html new file mode 100644 index 0000000..87884b8 --- /dev/null +++ b/doc/links.html @@ -0,0 +1,126 @@ + + +FindBugs Links + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    FindBugs Links

    + +

    This page contains links to related projects, +including tools that are similar to FindBugs. + +

    FindBugs Add-Ons

    + +
      +
    • fb-contrib: additional bug detectors for use with + FindBugs. The lead FindBugs team does not vouch for the relevance, accuracy or wisdom of the warnings + generated by any third-party plugin. +
    • FindBugs Eclipse plugin.  + This is now included as part of FindBugs. + + + + +
    • Maven2 FindBugs plugin.  + Maven2 is the latest version of the Java project management and project comprehension tool.  + The Maven2 FindBugs plugin allows FindBugs reports to be generated + from within Maven. +
    • QALab records and aggregates + the results of static analysis (including FindBugs results) + over time.  Features include charts of warnings over time + and summary reports showing hot spots in the source code.
    • +
    + +

    Similar Tools

    + +

    Open source tools

    + +
      +
    • JLint.  A static analysis tool + to find race conditions, locking errors, null pointer uses, + and a number of other problems in Java programs. +
    • PMD.  PMD scans Java + source code for potential problems. +
    • Checkstyle.  + Checkstyle is a style checker for Java. +
    + +

    Commercial tools and services

    + +
      +
    • lint4j: lint tool for Java programs +
    • JTest: automatically generates + JUnit tests for Java classes.  + Also checks for many kinds of coding errors. +
    • JiveLint.  Another + lint utility for Java programs.  Finds hashcode/equals problems, + string reference comparisons, and more.  Free 15 day demo. +
    + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/mailingLists.html b/doc/mailingLists.html new file mode 100644 index 0000000..4c619c9 --- /dev/null +++ b/doc/mailingLists.html @@ -0,0 +1,85 @@ + + +FindBugs Mailing Lists + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    FindBugs Mailing Lists

    + +

    There are two mailing lists for FindBugs. +

      +
    • Findbugs-announce +is a low volume (moderated) list for announcements of new releases. +
    • Findbugs-discuss +is for discussion of planned features, bugs, development issues, etc.  Note +that you must be a subscriber in order to post messages to the list. +
    • +
    + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/manual/acknowledgments.html b/doc/manual/acknowledgments.html new file mode 100644 index 0000000..c2ac454 --- /dev/null +++ b/doc/manual/acknowledgments.html @@ -0,0 +1,124 @@ + + + Chapter 14. Acknowledgments

    Chapter 14. Acknowledgments

    1. Contributors

    FindBugs was originally written by Bill Pugh (). +David Hovemeyer () implemented some of the +detectors, added the Swing GUI, and is a co-maintainer.

    Mike Fagan () contributed the Ant build script, +the Ant task, and several enhancements and bug fixes to the GUI.

    Germano Leichsenring contributed Japanese translations of the bug +summaries.

    David Li contributed the Emacs bug report format.

    Peter D. Stout contributed recursive detection of Class-Path +attributes in analyzed Jar files, German translations of +text used in the Swing GUI, and other fixes.

    Peter Friese wrote the FindBugs Eclipse plugin.

    Rohan Lloyd contributed several Mac OS X enhancements, +bug detector improvements, +and maintains the Fink package for FindBugs.

    Hiroshi Okugawa translated the FindBugs manual and +more of the bug summaries into Japanese.

    Phil Crosby enhanced the Eclipse plugin to add a view +to display the bug details.

    Dave Brosius fixed a number of bugs, added user preferences +to the Swing GUI, improved several bug detectors, and +contributed the string concatenation detector.

    Thomas Klaeger contributed a number of bug fixes and +bug detector improvements.

    Andrei Loskutov made a number of improvements to the +Eclipse plugin.

    Brian Goetz contributed a major refactoring of the +visitor classes to improve readability and understandability.

    Pete Angstadt fixed several problems in the Swing GUI.

    Francis Lalonde provided a task resource file for the +FindBugs Ant task.

    Garvin LeClaire contributed support for output in +Xdocs format, for use by Maven.

    Holger Stenzhorn contributed improved German translations of items +in the Swing GUI.

    Juha Knuutila contributed Finnish translations of items +in the Swing GUI.

    Tanel Lebedev contributed Estonian translations of items +in the Swing GUI.

    Hanai Shisei (ruimo) contributed full Japanese translations of +bug messages, and text used in the Swing GUI.

    David Cotton contributed Fresh translations for bug +messages and for the Swing GUI.

    Michael Tamm contributed support for the "errorProperty" attribute +in the Ant task.

    Thomas Kuehne improved the German translation of the Swing GUI.

    Len Trigg improved source file support for the Emacs output mode.

    Greg Bentz provided a fix for the hashcode/equals detector.

    K. Hashimoto contributed internationalization fixes and several other + bug fixes.

    + Glenn Boysko contributed support for ignoring specified local + variables in the dead local store detector. +

    + Jay Dunning contributed a detector to find equality comparisons + of floating-point values, and overhauled the analysis summary + report and its representation in the saved XML format. +

    + Olivier Parent contributed updated French translations for bug descriptions and + Swing GUI. +

    + Chris Nappin contributed the plain.xsl + stylesheet. +

    + Etienne Giraudy contributed the fancy.xsl and fancy-hist.xsl + stylesheets, and made improvements to the -xml:withMessages + option. +

    + Takashi Okamoto fixed bugs in the project preferences dialog + in the Eclipse plugin, and contributed to its internationalization and localization. +

    Thomas Einwaller fixed bugs in the project preferences dialog in the Eclipse plugin.

    Jeff Knox contributed support for the warningsProperty attribute +in the Ant task.

    Peter Hendriks extended the Eclipse plugin preferences, +and fixed a bug related to renaming the Eclipse plugin ID.

    Mark McKay contributed an Ant task to launch the findbugs frame.

    Dieter von Holten (dvholten) contributed +some German improvements to findbugs_de.properties.

    If you have contributed to FindBugs, but aren't mentioned above, +please send email to (and also accept +our humble apologies).

    2. Software Used

    FindBugs uses several open-source software packages, without which its +development would have been much more difficult.

    2.1. BCEL

    FindBugs includes software developed by the Apache Software Foundation +(http://www.apache.org/). +Specifically, it uses the Byte Code +Engineering Library.

    2.2. ASM

    FindBugs uses the ASM +bytecode framework, which is distributed under the following license:

    +Copyright (c) 2000-2005 INRIA, France Telecom +All rights reserved. +

    +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +

    1. + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +

    2. + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +

    3. + Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. +

    +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +

    2.3. DOM4J

    FindBugs uses DOM4J, which is +distributed under the following license:

    +Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. +

    +Redistribution and use of this software and associated documentation +("Software"), with or without modification, are permitted provided that +the following conditions are met: +

    1. + Redistributions of source code must retain copyright statements and + notices. Redistributions must also contain a copy of this document. +

    2. + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +

    3. + The name "DOM4J" must not be used to endorse or promote products + derived from this Software without prior written permission + of MetaStuff, Ltd. For written permission, please contact + . +

    4. + Products derived from this Software may not be called "DOM4J" nor may + "DOM4J" appear in their names without prior written permission of + MetaStuff, Ltd. DOM4J is a registered trademark of MetaStuff, Ltd. +

    5. + Due credit should be given to the DOM4J Project (http://dom4j.org/). +

    +THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +

    \ No newline at end of file diff --git a/doc/manual/analysisprops.html b/doc/manual/analysisprops.html new file mode 100644 index 0000000..83fe93c --- /dev/null +++ b/doc/manual/analysisprops.html @@ -0,0 +1,45 @@ + + + Chapter 9. Analysis Properties

    Chapter 9. Analysis Properties

    +FindBugs allows several aspects of the analyses it performs to be +customized. System properties are used to configure these options. +This chapter describes the configurable analysis options. +

    +The analysis options have two main purposes. First, they allow you +to inform FindBugs about the meaning of methods in your application, +so that it can produce more accurate results, or produce fewer +false warnings. Second, they allow you to configure the precision +of the analysis performed. Reducing analysis precision can save +memory and analysis time, at the expense of missing some real bugs, +or producing more false warnings. +

    +The analysis options are set using the -property +command line option. For example: +

    +$ findbugs -textui -property "cfg.noprune=true" myApp.jar
    +

    +

    +The list of configurable analysis properties is shown in +Table 9.1, “Configurable Analysis Properties”. +

    Table 9.1. Configurable Analysis Properties

    Property NameValueMeaning
    findbugs.assertionmethodsComma-separated list of fully qualified method names: + e.g., "com.foo.MyClass.checkAssertion"This property specifies the names of methods that are used + to check program assertions. Specifying these methods allows + the null pointer dereference bug detector to avoid reporting + false warnings for values which are checked by assertion + methods.
    findbugs.de.commenttrue or falseIf true, the DroppedException detector scans source code + for empty catch blocks for a comment, and if one is found, does + not report a warning.
    findbugs.maskedfields.localstrue or falseIf true, emit low priority warnings for local variables + which obscure fields. Default is false.
    findbugs.nullderef.assumensptrue or falsenot used + (intention: If true, the null dereference detector assumes that any + reference value returned from a method or passed to a method + in a parameter might be null. Default is false. Note that + enabling this property will very likely cause a large number + of false warnings to be produced.)
    findbugs.refcomp.reportAlltrue or falseIf true, all suspicious reference comparisons + using the == and != operators are reported.  If false, + only one such warning is issued per method.  Default + is false.
    findbugs.sf.commenttrue or falseIf true, the SwitchFallthrough detector will only report + warnings for cases where the source code does not have a comment + containing the words "fall" or "nobreak". (An accurate source + path must be used for this feature to work correctly.) + This helps find cases where the switch fallthrough is likely + to be unintentional.

    \ No newline at end of file diff --git a/doc/manual/annotations.html b/doc/manual/annotations.html new file mode 100644 index 0000000..a9909f9 --- /dev/null +++ b/doc/manual/annotations.html @@ -0,0 +1,101 @@ + + + Chapter 10. Annotations

    Chapter 10. Annotations

    +FindBugs supports several annotations to express the developer's intent +so that FindBugs can issue warnings more appropriately. You need to use +Java 5 to use annotations, and must place the annotations.jar and jsr305.jar +files in the classpath while compiling your program. +

    edu.umd.cs.findbugs.annotations.CheckForNull
    [Target] Field, Method, Parameter +

    +The annotated element might be null, and uses of the element should check for null. +When this annotation is applied to a method it applies to the method return value. +

    edu.umd.cs.findbugs.annotations.CheckReturnValue
    [Target] Method, Constructor +
    [Parameter]

    + priority:The priority of the warning (HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. +

    + explanation:A textual explaination of why the return value should be checked. Default value:"". +

    +This annotation is used to denote a method whose return value should always be checked after invoking the method. +

    edu.umd.cs.findbugs.annotations.DefaultAnnotation
    [Target] Type, Package +
    [Parameter]

    + value:Annotation class objects. More than one class can be specified. +

    + priority:Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. +

    +Indicates that all members of the class or package should be annotated with the default +value of the supplied annotation classes. This would be used for behavior annotations +such as @NonNull, @CheckForNull, or @CheckReturnValue. In particular, you can use +@DefaultAnnotation(NonNull.class) on a class or package, and then use @Nullable only +on those parameters, methods or fields that you want to allow to be null. +

    edu.umd.cs.findbugs.annotations.DefaultAnnotationForFields
    [Target] Type, Package +
    [Parameter]

    + value:Annotation class objects. More than one class can be specified. +

    + priority:Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. +

    +This is same as the DefaultAnnotation except it only applys to fields. +

    edu.umd.cs.findbugs.annotations.DefaultAnnotationForMethods
    [Target] Type, Package +
    [Parameter]

    + value:Annotation class objects. More than one class can be specified. +

    + priority:Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. +

    +This is same as the DefaultAnnotation except it only applys to methods. +

    edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters
    [Target] Type, Package +
    [Parameter]

    + value:Annotation class objects. More than one class can be specified. +

    + priority:Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. +

    +This is same as the DefaultAnnotation except it only applys to method parameters. +

    edu.umd.cs.findbugs.annotations.NonNull
    [Target] Field, Method, Parameter +

    +The annotated element must not be null. +Annotated fields must not be null after construction has completed. Annotated methods must have non-null return values. +

    edu.umd.cs.findbugs.annotations.Nullable
    [Target] Field, Method, Parameter +

    +The annotated element could be null under some circumstances. In general, this means +developers will have to read the documentation to determine when a null value is +acceptable and whether it is neccessary to check for a null value. FindBugs will +treat the annotated items as though they had no annotation. +

    +In pratice this annotation is useful only for overriding an overarching NonNull +annotation. +

    edu.umd.cs.findbugs.annotations.OverrideMustInvoke
    [Target] Method +
    [Parameter]

    + value:Specify when the super invocation should be + performed (FIRST, ANYTIME, LAST). Default value:ANYTIME. +

    +Used to annotate a method that, if overridden, must (or should) be invoke super +in the overriding method. Examples of such methods include finalize() and clone(). +The argument to the method indicates when the super invocation should occur: +at any time, at the beginning of the overriding method, or at the end of the overriding method. +(This anotation is not implmemented in FindBugs as of September 8, 2006). +

    edu.umd.cs.findbugs.annotations.PossiblyNull

    +This annotation is deprecated. Use CheckForNull instead. +

    edu.umd.cs.findbugs.annotations.SuppressWarnings
    [Target] Type, Field, Method, Parameter, Constructor, Package +
    [Parameter]

    + value:The name of the warning. More than one name can be specified. +

    + justification:Reason why the warning should be ignored. Default value:"". +

    +The set of warnings that are to be suppressed by the compiler in the annotated element. +Duplicate names are permitted. The second and successive occurrences of a name are ignored. +The presence of unrecognized warning names is not an error: Compilers +must ignore any warning names they do not recognize. They are, however, free to emit a +warning if an annotation contains an unrecognized warning name. Compiler vendors should +document the warning names they support in conjunction with this annotation type. They +are encouraged to cooperate to ensure that the same names work across multiple compilers. +

    edu.umd.cs.findbugs.annotations.UnknownNullness
    [Target] Field, Method, Parameter +

    +Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. +

    edu.umd.cs.findbugs.annotations.UnknownNullness
    [Target] Field, Method, Parameter +

    +Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. +

    + FindBugs also supports the following annotations: +

    • net.jcip.annotations.GuardedBy
    • net.jcip.annotations.Immutable
    • net.jcip.annotations.NotThreadSafe
    • net.jcip.annotations.ThreadSafe

    +

    +You can refer the JCIP annotation +API documentation at Java Concurrency in Practice. +

    \ No newline at end of file diff --git a/doc/manual/anttask.html b/doc/manual/anttask.html new file mode 100644 index 0000000..e601e1f --- /dev/null +++ b/doc/manual/anttask.html @@ -0,0 +1,214 @@ + + + Chapter 6. Using the FindBugs™ Ant task

    Chapter 6. Using the FindBugsAnt task

    +This chapter describes how to integrate FindBugs into a build script +for Ant, which is a popular Java build +and deployment tool. Using the FindBugs Ant task, your build script can +automatically run FindBugs on your Java code. +

    +The Ant task was generously contributed by Mike Fagan. +

    1. Installing the Ant task

    +To install the Ant task, simply copy $FINDBUGS_HOME/lib/findbugs-ant.jar +into the lib subdirectory of your Ant installation. + +

    [Note]Note

    It is strongly recommended that you use the Ant task with the version +of FindBugs it was included with. We do not guarantee that the Ant task Jar file +will work with any version of FindBugs other than the one it was included with.

    +

    2. Modifying build.xml

    +To incorporate FindBugs into build.xml (the build script +for Ant), you first need to add a task definition. This should appear as follows: + +

    +  <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
    +

    + +The task definition specifies that when a findbugs element is +seen in build.xml, it should use the indicated class to execute the task. +

    +After you have added the task definition, you can define a target +which uses the findbugs task. Here is an example +which could be added to the build.xml for the +Apache BCEL library. + +

    +  <property name="findbugs.home" value="/export/home/daveho/work/findbugs" />
    +
    +  <target name="findbugs" depends="jar">
    +    <findbugs home="${findbugs.home}"
    +              output="xml"
    +              outputFile="bcel-fb.xml" >
    +      <auxClasspath path="${basedir}/lib/Regex.jar" />
    +      <sourcePath path="${basedir}/src/java" />
    +      <class location="${basedir}/bin/bcel.jar" />
    +    </findbugs>
    +  </target>
    +

    + +The findbugs element must have the home +attribute set to the directory in which FindBugs is installed; in other words, +$FINDBUGS_HOME. See Chapter 2, Installing FindBugs. +

    +This target will execute FindBugs on bcel.jar, which is the +Jar file produced by BCEL's build script. (By making it depend on the "jar" +target, we ensure that the library is fully compiled before running FindBugs on it.) +The output of FindBugs will be saved in XML format to a file called +bcel-fb.xml. +An auxiliary Jar file, Regex.jar, is added to the aux classpath, +because it is referenced by the main BCEL library. A source path is specified +so that the saved bug data will have accurate references to the BCEL source code. +

    3. Executing the task

    +Here is an example of invoking Ant from the command line, using the findbugs +target defined above. + +

    +  [daveho@noir]$ ant findbugs
    +  Buildfile: build.xml
    +
    +  init:
    +
    +  compile:
    +
    +  examples:
    +
    +  jar:
    +
    +  findbugs:
    +   [findbugs] Running FindBugs...
    +   [findbugs] Bugs were found
    +   [findbugs] Output saved to bcel-fb.xml
    +
    +  BUILD SUCCESSFUL
    +  Total time: 35 seconds
    +

    + +In this case, because we saved the bug results in an XML file, we can +use the FindBugs GUI to view the results; see Chapter 4, Running FindBugs. +

    4. Parameters

    This section describes the parameters that may be specified when +using the FindBugs task. + +

    class

    + A optional nested element specifying which classes to analyze. The class + element must specify a location attribute which names the + archive file (jar, zip, etc.), directory, or class file to be analyzed. Multiple class + elements may be specified as children of a single findbugs element. +

    In addition to or instead of specifying a class element, + the FindBugs task can contain one or more fileset element(s) that + specify files to be analyzed. + For example, you might use a fileset to specify that all of the jar files in a directory + should be analyzed. +

    auxClasspath

    + An optional nested element which specifies a classpath (Jar files or directories) + containing classes used by the analyzed library or application, but which + you don't want to analyze. It is specified the same way as + Ant's classpath element for the Java task. +

    sourcePath

    + An optional nested element which specifies a source directory path + containing source files used to compile the Java code being analyzed. + By specifying a source path, any generated XML bug output will have + complete source information, which allows later viewing in the + GUI. +

    home

    + A required attribute. + It must be set to the name of the directory where FindBugs is installed. +

    quietErrors

    + An optional boolean attribute. + If true, reports of serious analysis errors and missing classes will + be suppressed in the FindBugs output. Default is false. +

    reportLevel

    + An optional attribute. It specifies + the confidence/priority threshold for reporting issues. If set to "low", confidence is not used to filter bugs. + If set to "medium" (the default), low confidence issues are supressed. + If set to "high", only high confidence bugs are reported. +

    output

    + Optional attribute. + It specifies the output format. If set to "xml" (the default), output + is in XML format. + If set to "xml:withMessages", output is in XML format augmented with + human-readable messages. (You should use this format if you plan + to generate a report using an XSL stylesheet.) + If set to "html", output is in HTML formatted (default stylesheet is default.xsl). + If set to "text", output is in ad-hoc text format. + If set to "emacs", output is in Emacs error message format. + If set to "xdocs", output is xdoc XML for use with Apache Maven. +

    stylesheet

    + Optional attribute. + It specifies the stylesheet to use to generate html output when the output is set to html. + Stylesheets included in the FindBugs distribution include default.xsl, fancy.xsl, fancy-hist.xsl, plain.xsl, and summary.xsl. + The default value, if no stylesheet attribute is provided, is default.xsl. + +

    sort

    + Optional attribute. If the output attribute + is set to "text", then the sort attribute specifies + whether or not reported bugs are sorted by class. Default is true. +

    outputFile

    + Optional attribute. If specified, names the output file in which the + FindBugs output will be saved. By default, the output is displayed + directly by Ant. +

    debug

    + Optional boolean attribute. If set to true, FindBugs prints diagnostic + information about which classes are being analyzed, and which bug pattern + detectors are being run. Default is false. +

    effort

    + Set the analysis effort level. The value specified should be + one of min, default, + or max. See Section 3, “Command-line Options” + for more information about setting the analysis level. +

    conserveSpace

    Synonym for effort="min".

    workHard

    Synonym for effort="max".

    visitors

    + Optional attribute. It specifies a comma-separated list of bug detectors + which should be run. The bug detectors are specified by their class names, + without any package qualification. By default, all detectors which are + not disabled by default are run. +

    omitVisitors

    + Optional attribute. It is like the visitors attribute, + except it specifies detectors which will not be run. +

    excludeFilter

    + Optional attribute. It specifies the filename of a filter specifying bugs + to exclude from being reported. See Chapter 8, Filter Files. +

    includeFilter

    + Optional attribute. It specifies the filename of a filter specifying + which bugs are reported. See Chapter 8, Filter Files. +

    projectFile

    + Optional attribute. It specifies the name of a project file. + Project files are created by the FindBugs GUI, and specify classes, + aux classpath entries, and source directories. By naming a project, + you don't need to specify any class elements, + nor do you need to specify auxClasspath or + sourcePath attributes. + See Chapter 4, Running FindBugs for how to create a project. +

    jvmargs

    + Optional attribute. It specifies any arguments that should be passed + to the Java virtual machine used to run FindBugs. You may need to + use this attribute to specify flags to increase the amount of memory + the JVM may use if you are analyzing a very large program. +

    systemProperty

    + Optional nested element. If specified, defines a system property. + The name attribute specifies the name of the + system property, and the value attribute specifies + the value of the system property. +

    timeout

    + Optional attribute. It specifies the amount of time, in milliseconds, + that the Java process executing FindBugs may run before it is + assumed to be hung and is terminated. The default is 600,000 + milliseconds, which is ten minutes. Note that for very large + programs, FindBugs may require more than ten minutes to complete its + analysis. +

    failOnError

    + Optional boolean attribute. Whether to abort the build process if there is an + error running FindBugs. Defaults to "false" +

    errorProperty

    + Optional attribute which specifies the name of a property that + will be set to "true" if an error occurs while running FindBugs. +

    warningsProperty

    + Optional attribute which specifies the name of a property + that will be set to "true" if any warnings are reported by + FindBugs on the analyzed program. +

    userPreferencesFile

    + Optional attribute. Set the path of the user preferences file to use, which might override some of the options abobe. + Specifying userPreferencesFile as first argument would mean some later + options will override them, as last argument would mean they will override some previous options). + This rationale behind this option is to reuse FindBugs Eclipse project settings for command + line execution. +

    + + +

    \ No newline at end of file diff --git a/doc/manual/building.html b/doc/manual/building.html new file mode 100644 index 0000000..ed3fcb2 --- /dev/null +++ b/doc/manual/building.html @@ -0,0 +1,123 @@ + + + Chapter 3. Building FindBugs™ from Source

    Chapter 3. Building FindBugs™ from Source

    +This chapter describes how to build FindBugs from source code. Unless you are +interesting in modifying FindBugs, you will probably want to skip to the +next chapter. +

    1. Prerequisites

    +To compile FindBugs from source, you will need the following: +

    +

    [Warning]Warning

    + The version of Ant included as /usr/bin/ant on + Redhat Linux systems will not work for compiling + FindBugs. We recommend you install a binary distribution of Ant + downloaded from the Ant website. + Make sure that when you run Ant your JAVA_HOME + environment variable points to the directory in which you installed + JDK 1.5 (or later). +

    +If you want to be able to generate formatted versions of the FindBugs documentation, +you will also need the following software: +

    +

    2. Extracting the Source Distribution

    +After you download the source distribution, you'll need to extract it into +a working directory. A typical command to do this is: + +

    +$ unzip findbugs-2.0.3-source.zip
    +

    + +

    3. Modifying local.properties

    +If you intend to build the FindBugs documentation, +you will need to modify the local.properties file +used by the Ant +build.xml file to build FindBugs. +If you do not want to build the FindBugs documentation, then you +can ignore this file. +

    +The local.properties overrides definitions +in the build.properties file. +The build.properties file looks something like this: +

    +
    +# User Configuration:
    +# This section must be modified to reflect your system.
    +
    +local.software.home     =/export/home/daveho/linux
    +
    +# Set this to the directory containing the DocBook Modular XSL Stylesheets
    +#  from http://docbook.sourceforge.net/projects/xsl/
    +
    +xsl.stylesheet.home     =${local.software.home}/docbook/docbook-xsl-1.71.1
    +
    +# Set this to the directory where Saxon (http://saxon.sourceforge.net/)
    +# is installed.
    +
    +saxon.home              =${local.software.home}/java/saxon-6.5.5
    +
    +

    +

    +The xsl.stylesheet.home property specifies the full +path to the directory where you have installed the +DocBook Modular XSL +Stylesheets. You only need to specify this property if you will be +generating the FindBugs documentation. +

    +The saxon.home property is the full path to the +directory where you installed the Saxon XSLT Processor. +You only need to specify this property if you will be +generating the FindBugs documentation. +

    4. Running Ant

    +Once you have extracted the source distribution, +made sure that Ant is installed, +modified build.properties (optional), +and configured the tools (such as Saxon), +you are ready to build FindBugs. Invoking Ant is a simple matter +of running the command +

    +$ ant target
    +

    +where target is one of the following: +

    build

    + This target compiles the code for FindBugs. It is the default target. +

    docs

    + This target formats the documentation. (It also compiles some of + the source code as a side-effect.) +

    runjunit

    + This target compiles and runs the internal JUnit tests included + in FindBugs. It will print an error message if any unit + tests fail. +

    bindist

    + Builds a binary distribution of FindBugs. + The target creates both .zip and + .tar.gz archives. +

    +

    +After running an Ant command, you should see output similar to +the following (after some other messages regarding the tasks that +Ant is running): +

    +
    +BUILD SUCCESSFUL
    +Total time: 17 seconds
    +
    +

    +

    5. Running FindBugs™ from a source directory

    +The Ant build script for FindBugs is written such that after +building the build target, the working directory +is set up just like a binary distribution. So, the information about +running FindBugs in Chapter 4, Running FindBugs +applies to source distributions, too. +

    \ No newline at end of file diff --git a/doc/manual/datamining.html b/doc/manual/datamining.html new file mode 100644 index 0000000..134801a --- /dev/null +++ b/doc/manual/datamining.html @@ -0,0 +1,421 @@ + + + Chapter 12. Data mining of bugs with FindBugs™

    Chapter 12. Data mining of bugs with FindBugs

    +FindBugs incorporates an ability to perform sophisticated queries on bug +databases and track warnings across multiple versions of code being +studied, allowing you to do things such as seeing when a bug was first introduced, examining +just the warnings that have been introduced since the last release, or graphing the number +of infinite recursive loops in your code over time.

    +These techniques all depend upon the XML format used by FindBugs for storing warnings. +These XML files usually contain just the warnings from one particular analysis run, but +they can also store the results from analyzing a sequence of software builds or versions. +

    +Any FindBugs XML bug database contains a version name and timestamp. +FindBugs tries to compute a timestamp from the timestamps of the files that +are analyzed (e.g., the timestamp is intended to be the time the class files +were generated, not analyzed). Each bug database also contains a version name. +Both the version name and timestamp can be set manually using the +setBugDatabaseInfo (Section 1.7, “setBugDatabaseInfo”) command. +

    A multiversion bug database assigns a sequence number to each version of +the analyzed code. These sequence numbers are simply successive integers, +starting at 0 (e.g., a bug database for 4 versions of the code will contain +versions 0..3). The bug database will also record the name and timestamp for +each version. The filterBugs command allows you to refer +to a version by sequence number, name or timestamp.

    +You can take a sequence (or pair) of single version bug databases and create +from them a multiversion bug database, or combine a multiversion bug database +with a sequence of later single-version bug databases.

    +Some of these commands can be invoked as ant tasks. See below for specifics +on how to invoke them and what attributes and arguments they take. All of +the examples assume that the findbugs.lib +refid is set correctly. Here is one way to set it: +

    +
    +   <!-- findbugs task definition -->
    +   <property name="findbugs.home" value="/your/path/to/findbugs" />
    +   <path id="findbugs.lib">
    +      <fileset dir="${findbugs.home}/lib">
    +         <include name="findbugs-ant.jar"/>
    +      </fileset>
    +   </path>
    +
    +

    1. Commands

    +All tools for FindBugs data mining are can be invoked from the command line, +and some of the more useful tools can also be invoked from an +ant build file.

    +Briefly, the command-line tools are:

    unionBugs

    + combine the results from separate analysis of disjoint + classes +

    computeBugHistory

    Merge bug warnings from multiple versions of + analyzed code into + a single multiversion bug database. This can either be used + to add more versions to an existing multiversion database, + or to create a multiversion database from a sequence of single version + bug warning databases.

    setBugDatabaseInfo

    Set information such as the revision name or +timestamp in an XML bug database

    listBugDatabaseInfo

    List information such as the revision name and +timestamp for a list of XML bug databases

    filterBugs

    Select a subset of a bug database

    mineBugHistory

    Generate a tabular listing of the number of warnings in each + version of a multiversion bug database

    defectDensity

    List information about defect density + (warnings per 1000 NCSS) + for the entire project and each class and package

    convertXmlToText

    Convert bug warnings in XML format to + a textual one-line-per-bug format, or to HTML

    1.1. unionBugs

    + If you have, for example, separately analyzing each jar file used in an application, + you can use this command to combine the separately generated xml bug warning files into + a single file containing all of the warnings.

    Do not use this command to combine results from analyzing different versions of the same + file; use computeBugHistory instead.

    Specify the xml files on the command line. The result is sent to standard output.

    1.2. computeBugHistory

    Use this command to generate a bug database containing information from different builds or versions +of software you are analyzing. +History is taken from the first file provided as input; any following +files should be single version bug databases (if they contain history, the history in those +files will be ignored).

    By default, output is written to the standard output. +

    This functionality may also can be accessed from ant. +First create a taskdef for computeBugHistory in your +build file: +

    +
    +<taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    Attributes for this ant task are listed in the following table. +To specify input files, nest them inside with a +<datafile> element. For example: +

    +
    +<computeBugHistory home="${findbugs.home}" ...>
    +    <datafile name="analyze1.xml"/>
    +    <datafile name="analyze2.xml"/>
    +</computeBugHistory>
    +
    +

    Table 12.1. Options for computeBugHistory command

    Command-line optionAnt attributeMeaning
    -output <file>output="<file>"save output in the named file (may also be an input file)
    -overrideRevisionNames[:truth]overrideRevisionNames="[true|false]"override revision names for each version with names computed from the filenames
    -noPackageMoves[:truth]noPackageMoves="[true|false]"if a class has moved to another package, treat warnings in that class as seperate
    -preciseMatch[:truth]preciseMatch="[true|false]"require bug patterns to match precisely
    -precisePriorityMatch[:truth]precisePriorityMatch="[true|false]"consider two warnings as the same only if priorities match exactly
    -quiet[:truth]quiet="[true|false]"don't generate any output to standard out unless there is an error
    -withMessages[:truth]withMessages="[true|false]"include human-readable messages describing the warnings in XML output

    1.3. filterBugs

    This command is used to select a subset of warnings from a FindBugs XML warning file +and write the selected subset to a new FindBugs warning file.

    +This command takes a sequence of options, and either zero, one or two +filenames of findbugs xml bug files on the command line.

    If no file names are provided, the command reads from standard input +and writes to standard output. If one file name is provided, +it reads from the file and writes to standard output. +If two file names are provided, it reads from the first and writes the output +to the second file name.

    This functionality may also can be accessed from ant. +First create a taskdef for filterBugs in your +build file: +

    +
    +<taskdef name="filterBugs" classname="edu.umd.cs.findbugs.anttask.FilterBugsTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    Attributes for this ant task are listed in the following table. +To specify an input file either use the input attribute or nest it inside +the ant call with a <datafile> element. For example: +

    +
    +<filterBugs home="${findbugs.home}" ...>
    +    <datafile name="analyze.xml"/>
    +</filterBugs>
    +
    +

    Table 12.2. Options for filterBugs command

    Command-line optionAnt attributeMeaning
     input="<file>"use file as input
     output="<file>"output results to file
    -notnot="[true|false]"reverse (all) switches for the filter
    -withSource[:truth]withSource="[true|false]"only warnings for switch source is available
    -exclude <filter file>exclude="<filter file>"exclude bugs matching given filter
    -include <filter file>include="<filter file>"include only bugs matching given filter
    -annotation <text>annotation="<text>"allow only warnings containing this text in a manual annotation
    -after <when>after="<when>"allow only warnings that first occurred after this version
    -before <when>before="<when>"allow only warnings that first occurred before this version
    -first <when>first="<when>"allow only warnings that first occurred in this version
    -last <when>last="<when>"allow only warnings that last occurred in this version
    -fixed <when>fixed="<when>"allow only warnings that last occurred in the previous version (clobbers -last)
    -present <when>present="<when>"allow only warnings present in this version
    -absent <when>absent="<when>"allow only warnings absent in this version
    -active[:truth]active="[true|false]"allow only warnings alive in the last sequence number
    -introducedByChange[:truth]introducedByChange="[true|false]"allow only warnings introduced by a change of an existing class
    -removedByChange[:truth]removedByChange="[true|false]"allow only warnings removed by a change of a persisting class
    -newCode[:truth]newCode="[true|false]"allow only warnings introduced by the addition of a new class
    -removedCode[:truth]removedCode="[true|false]"allow only warnings removed by removal of a class
    -priority <level>priority="<level>"allow only warnings with this priority or higher
    -maxRank <rank>rank="[1..20]"allow only warnings with this rank or lower
    -class <pattern>class="<class>"allow only bugs whose primary class name matches this pattern
    -bugPattern <pattern>bugPattern="<pattern>"allow only bugs whose type matches this pattern
    -category <category>category="<category>"allow only warnings with a category that starts with this string
    -designation <designation>designation="<designation>"allow only warnings with this designation (e.g., -designation SHOULD_FIX)
    -withMessages[:truth] withMessages="[true|false]"the generated XML should contain textual messages

    1.4. mineBugHistory

    This command generates a table containing counts of the numbers of warnings +in each version of a multiversion bug database.

    This functionality may also can be accessed from ant. +First create a taskdef for mineBugHistory in your +build file: +

    +
    +<taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    Attributes for this ant task are listed in the following table. +To specify an input file either use the input +attribute or nest it inside the ant call with a +<datafile> element. For example: +

    +
    +<mineBugHistory home="${findbugs.home}" ...>
    +    <datafile name="analyze.xml"/>
    +</mineBugHistory>
    +
    +

    Table 12.3. Options for mineBugHistory command

    Command-line optionAnt attributeMeaning
     input="<file>"use file as input
     output="<file>"write output to file
    -formatDatesformatDates="[true|false]"render dates in textual form
    -noTabsnoTabs="[true|false]"delimit columns with groups of spaces instead of tabs (see below)
    -summarysummary="[true|false]"output terse summary of changes over the last ten entries

    + The -noTabs output can be easier to read from a shell + with a fixed-width font. + Because numeric columns are right-justified, spaces may precede the + first column value. This option also causes -formatDates + to render dates in terser format without embedded whitespace. +

    The table is a tab-separated (barring -noTabs) + table with the following columns:

    Table 12.4. Columns in mineBugHistory output

    TitleMeaning
    seqSequence number (successive integers, starting at 0)
    versionVersion name
    timeRelease timestamp
    classesNumber of classes analyzed
    NCSSNon Commenting Source Statements
    addedCount of new warnings for a class that existed in the previous version
    newCodeCount of new warnings for a class that did not exist in the previous version
    fixedCount of warnings removed from a class that remains in the current version
    removedCount of warnings in the previous version for a class that is not present in the current version
    retainedCount of warnings that were in both the previous and current version
    deadWarnings that were present in earlier versions but in neither the current version or the immediately preceeding version
    activeTotal warnings present in the current version

    1.5. defectDensity

    +This command lists information about defect density (warnings per 1000 NCSS) for the entire project and each class and package. +It can either be invoked with no files specified on the command line (in which case it reads from standard input) +or with one file specified on the command line.

    It generates a table with the following columns, and with one +row for the entire project, and one row for each package or class that contains at least +4 warnings.

    Table 12.5. Columns in defectDensity output

    TitleMeaning
    kindproject, package or class
    nameThe name of the project, package or class
    densityNumber of warnings generated per 1000 lines of NCSS.
    bugsNumber of warnings
    NCSSCalculated number of NCSS

    1.6. convertXmlToText

    + This command converts a warning collection in XML format to a text + format with one line per warning, or to HTML. +

    This functionality may also can be accessed from ant. +First create a taskdef for convertXmlToText in your +build file: +

    +
    +<taskdef name="convertXmlToText" classname="edu.umd.cs.findbugs.anttask.ConvertXmlToTextTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    Attributes for this ant task are listed in the following table.

    Table 12.6. Options for convertXmlToText command

    Command-line optionAnt attributeMeaning
     input="<filename>"use file as input
     output="<filename>"output results to file
    -longBugCodeslongBugCodes="[true|false]"use the full bug pattern code instead of two-letter abbreviation
     format="text"generate plain text output with one bug per line (command-line default)
    -html[:stylesheet]format="html:<stylesheet>"generate output with specified stylesheet (see below), or default.xsl if unspecified

    + You may specify plain.xsl, default.xsl, fancy.xsl, fancy-hist.xsl, + or your own XSL stylesheet for the -html/format option. + Despite the name of this option, you may specify + a stylesheet that emits something other than html. + When applying a stylesheet other than those included + with FindBugs (listed above), the -html/format option should be used + with a path or URL to the stylesheet. +

    1.7. setBugDatabaseInfo

    + This command sets meta-information in a specified warning collection. + It takes the following options: +

    This functionality may also can be accessed from ant. +First create a taskdef for setBugDatabaseInfo in your +build file: +

    +
    +<taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask">
    +    <classpath refid="findbugs.lib" />
    +</taskdef>
    +
    +

    Attributes for this ant task are listed in the following table. +To specify an input file either use the input +attribute or nest it inside the ant call with a +<datafile> element. For example: +

    +
    +<setBugDatabaseInfo home="${findbugs.home}" ...>
    +    <datafile name="analyze.xml"/>
    +</setBugDatabaseInfo>
    +
    +

    Table 12.7. setBugDatabaseInfo Options

    Command-line optionAnt attributeMeaning
     input="<file>"use file as input
     output="<file>"write output to file
    -name <name>name="<name>"set name for (last) revision
    -timestamp <when>timestamp="<when>"set timestamp for (last) revision
    -source <directory>source="<directory>"add specified directory to the source search path
    -findSource <directory>findSource="<directory>"find and add all relevant source directions contained within specified directory
    -suppress <filter file>suppress="<filter file>"suppress warnings matched by this file (replaces previous suppressions)
    -withMessageswithMessages="[true|false]"add textual messages to XML
    -resetSourceresetSource="[true|false]"remove all source search paths

    1.8. listBugDatabaseInfo

    This command takes a list of zero or more xml bug database filenames on the command line. +If zero file names are provided, it reads from standard input and does not generate +a table header.

    There is only one option: -formatDates renders dates + in textual form. +

    The output is a table one row per bug database and the following columns:

    Table 12.8. listBugDatabaseInfo Columns

    ColumnMeaning
    versionversion name
    timeRelease timestamp
    classesNumber of classes analyzed
    NCSSNon Commenting Source Statements analyzed
    totalTotal number of warnings of all kinds
    highTotal number of high priority warnings of all kinds
    mediumTotal number of medium/normal priority warnings of all kinds
    lowTotal number of low priority warnings of all kinds
    filenamefilename of database

    2. Examples

    2.1. Mining history using proveded shell scrips

    In all of the following, the commands are given in a directory that contains +directories jdk1.6.0-b12, jdk1.6.0-b13, ..., jdk1.6.0-b60.

    You can use the command:

    +computeBugHistory jdk1.6.0-b* | filterBugs -bugPattern IL_ | mineBugHistory -formatDates
    +

    to generate the following output:

    +seq	version	time	classes	NCSS	added	newCode	fixed	removed	retained	dead	active
    +0	jdk1.6.0-b12	"Thu Nov 11 09:07:20 EST 2004"	13128	811569	0	4	0	0	0	0	4
    +1	jdk1.6.0-b13	"Thu Nov 18 06:02:06 EST 2004"	13128	811570	0	0	0	0	4	0	4
    +2	jdk1.6.0-b14	"Thu Dec 02 06:12:26 EST 2004"	13145	811786	0	0	2	0	2	0	2
    +3	jdk1.6.0-b15	"Thu Dec 09 06:07:04 EST 2004"	13174	811693	0	0	1	0	1	2	1
    +4	jdk1.6.0-b16	"Thu Dec 16 06:21:28 EST 2004"	13175	811715	0	0	0	0	1	3	1
    +5	jdk1.6.0-b17	"Thu Dec 23 06:27:22 EST 2004"	13176	811974	0	0	0	0	1	3	1
    +6	jdk1.6.0-b19	"Thu Jan 13 06:41:16 EST 2005"	13176	812011	0	0	0	0	1	3	1
    +7	jdk1.6.0-b21	"Thu Jan 27 05:57:52 EST 2005"	13177	812173	0	0	0	0	1	3	1
    +8	jdk1.6.0-b23	"Thu Feb 10 05:44:36 EST 2005"	13179	812188	0	0	0	0	1	3	1
    +9	jdk1.6.0-b26	"Thu Mar 03 06:04:02 EST 2005"	13199	811770	0	0	0	0	1	3	1
    +10	jdk1.6.0-b27	"Thu Mar 10 04:48:38 EST 2005"	13189	812440	0	0	0	0	1	3	1
    +11	jdk1.6.0-b28	"Thu Mar 17 02:54:22 EST 2005"	13185	812056	0	0	0	0	1	3	1
    +12	jdk1.6.0-b29	"Thu Mar 24 03:09:20 EST 2005"	13117	809468	0	0	0	0	1	3	1
    +13	jdk1.6.0-b30	"Thu Mar 31 02:53:32 EST 2005"	13118	809501	0	0	0	0	1	3	1
    +14	jdk1.6.0-b31	"Thu Apr 07 03:00:14 EDT 2005"	13117	809572	0	0	0	0	1	3	1
    +15	jdk1.6.0-b32	"Thu Apr 14 02:56:56 EDT 2005"	13169	811096	0	0	0	0	1	3	1
    +16	jdk1.6.0-b33	"Thu Apr 21 02:46:22 EDT 2005"	13187	811942	0	0	0	0	1	3	1
    +17	jdk1.6.0-b34	"Thu Apr 28 02:49:00 EDT 2005"	13195	813488	0	1	0	0	1	3	2
    +18	jdk1.6.0-b35	"Thu May 05 02:49:04 EDT 2005"	13457	829837	0	0	0	0	2	3	2
    +19	jdk1.6.0-b36	"Thu May 12 02:59:46 EDT 2005"	13462	831278	0	0	0	0	2	3	2
    +20	jdk1.6.0-b37	"Thu May 19 02:55:08 EDT 2005"	13464	831971	0	0	0	0	2	3	2
    +21	jdk1.6.0-b38	"Thu May 26 03:08:16 EDT 2005"	13564	836565	0	0	0	0	2	3	2
    +22	jdk1.6.0-b39	"Fri Jun 03 03:10:48 EDT 2005"	13856	849992	0	1	0	0	2	3	3
    +23	jdk1.6.0-b40	"Thu Jun 09 03:30:28 EDT 2005"	15972	959619	0	2	0	0	3	3	5
    +24	jdk1.6.0-b41	"Thu Jun 16 03:19:22 EDT 2005"	15972	959619	0	0	0	0	5	3	5
    +25	jdk1.6.0-b42	"Fri Jun 24 03:38:54 EDT 2005"	15966	958581	0	0	0	0	5	3	5
    +26	jdk1.6.0-b43	"Thu Jul 14 03:09:34 EDT 2005"	16041	960544	0	0	0	0	5	3	5
    +27	jdk1.6.0-b44	"Thu Jul 21 03:05:54 EDT 2005"	16041	960547	0	0	0	0	5	3	5
    +28	jdk1.6.0-b45	"Thu Jul 28 03:26:10 EDT 2005"	16037	960606	0	0	1	0	4	3	4
    +29	jdk1.6.0-b46	"Thu Aug 04 03:02:48 EDT 2005"	15936	951355	0	0	0	0	4	4	4
    +30	jdk1.6.0-b47	"Thu Aug 11 03:18:56 EDT 2005"	15964	952387	0	0	1	0	3	4	3
    +31	jdk1.6.0-b48	"Thu Aug 18 08:10:40 EDT 2005"	15970	953421	0	0	0	0	3	5	3
    +32	jdk1.6.0-b49	"Thu Aug 25 03:24:38 EDT 2005"	16048	958940	0	0	0	0	3	5	3
    +33	jdk1.6.0-b50	"Thu Sep 01 01:52:40 EDT 2005"	16287	974937	1	0	0	0	3	5	4
    +34	jdk1.6.0-b51	"Thu Sep 08 01:55:36 EDT 2005"	16362	979377	0	0	0	0	4	5	4
    +35	jdk1.6.0-b52	"Thu Sep 15 02:04:08 EDT 2005"	16477	979399	0	0	0	0	4	5	4
    +36	jdk1.6.0-b53	"Thu Sep 22 02:00:28 EDT 2005"	16019	957900	0	0	1	0	3	5	3
    +37	jdk1.6.0-b54	"Thu Sep 29 01:54:34 EDT 2005"	16019	957900	0	0	0	0	3	6	3
    +38	jdk1.6.0-b55	"Thu Oct 06 01:54:14 EDT 2005"	16051	959014	0	0	0	0	3	6	3
    +39	jdk1.6.0-b56	"Thu Oct 13 01:54:12 EDT 2005"	16211	970835	0	0	0	0	3	6	3
    +40	jdk1.6.0-b57	"Thu Oct 20 01:55:26 EDT 2005"	16279	971627	0	0	0	0	3	6	3
    +41	jdk1.6.0-b58	"Thu Oct 27 01:56:30 EDT 2005"	16283	971945	0	0	0	0	3	6	3
    +42	jdk1.6.0-b59	"Thu Nov 03 01:56:58 EST 2005"	16232	972193	0	0	0	0	3	6	3
    +43	jdk1.6.0-b60	"Thu Nov 10 01:54:18 EST 2005"	16235	972346	0	0	0	0	3	6	3
    +

    +We could also generate that information directly, without creating an intermediate db.xml file, using the command +

    +computeBugHistory  jdk1.6.0-b*/jre/lib/rt.xml | filterBugs -bugPattern IL_ db.xml | mineBugHistory -formatDates
    +

    We can then use that information to display a graph showing the number of infinite recursive loops +found by FindBugs in each build of Sun's JDK1.6.0. The blue area indicates the number of infinite +recursive loops in that build, the red area above it indicates the number of infinite recursive loops that existed +in some previous version but not in the current version (thus, the combined height of the red and blue areas +is guaranteed to never decrease, and goes up whenever a new infinite recursive loop bug is introduced). The height +of the red area is computed as the sum of the fixed, removed and dead values for each version. +The reductions in builds 13 and 14 came after Sun was notified about the bugs found by FindBugs in the JDK. +

    +Given 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: +

    +filterBugs -priority M -category C db.xml | mineBugHistory -formatDates
    +

    +generating the table: +

    +seq	version	time	classes	NCSS	added	newCode	fixed	removed	retained	dead	active
    +0	jdk1.6.0-b12	"Thu Nov 11 09:07:20 EST 2004"	13128	811569	0	1075	0	0	0	0	1075
    +1	jdk1.6.0-b13	"Thu Nov 18 06:02:06 EST 2004"	13128	811570	0	0	0	0	1075	0	1075
    +2	jdk1.6.0-b14	"Thu Dec 02 06:12:26 EST 2004"	13145	811786	3	0	6	0	1069	0	1072
    +3	jdk1.6.0-b15	"Thu Dec 09 06:07:04 EST 2004"	13174	811693	2	1	3	0	1069	6	1072
    +4	jdk1.6.0-b16	"Thu Dec 16 06:21:28 EST 2004"	13175	811715	0	0	1	0	1071	9	1071
    +5	jdk1.6.0-b17	"Thu Dec 23 06:27:22 EST 2004"	13176	811974	0	0	1	0	1070	10	1070
    +6	jdk1.6.0-b19	"Thu Jan 13 06:41:16 EST 2005"	13176	812011	0	0	0	0	1070	11	1070
    +7	jdk1.6.0-b21	"Thu Jan 27 05:57:52 EST 2005"	13177	812173	0	0	1	0	1069	11	1069
    +8	jdk1.6.0-b23	"Thu Feb 10 05:44:36 EST 2005"	13179	812188	0	0	0	0	1069	12	1069
    +9	jdk1.6.0-b26	"Thu Mar 03 06:04:02 EST 2005"	13199	811770	0	0	2	1	1066	12	1066
    +10	jdk1.6.0-b27	"Thu Mar 10 04:48:38 EST 2005"	13189	812440	1	0	1	1	1064	15	1065
    +11	jdk1.6.0-b28	"Thu Mar 17 02:54:22 EST 2005"	13185	812056	0	0	0	0	1065	17	1065
    +12	jdk1.6.0-b29	"Thu Mar 24 03:09:20 EST 2005"	13117	809468	3	0	8	26	1031	17	1034
    +13	jdk1.6.0-b30	"Thu Mar 31 02:53:32 EST 2005"	13118	809501	0	0	0	0	1034	51	1034
    +14	jdk1.6.0-b31	"Thu Apr 07 03:00:14 EDT 2005"	13117	809572	0	0	0	0	1034	51	1034
    +15	jdk1.6.0-b32	"Thu Apr 14 02:56:56 EDT 2005"	13169	811096	1	1	0	1	1033	51	1035
    +16	jdk1.6.0-b33	"Thu Apr 21 02:46:22 EDT 2005"	13187	811942	3	0	2	1	1032	52	1035
    +17	jdk1.6.0-b34	"Thu Apr 28 02:49:00 EDT 2005"	13195	813488	0	1	0	0	1035	55	1036
    +18	jdk1.6.0-b35	"Thu May 05 02:49:04 EDT 2005"	13457	829837	0	36	2	0	1034	55	1070
    +19	jdk1.6.0-b36	"Thu May 12 02:59:46 EDT 2005"	13462	831278	0	0	0	0	1070	57	1070
    +20	jdk1.6.0-b37	"Thu May 19 02:55:08 EDT 2005"	13464	831971	0	1	1	0	1069	57	1070
    +21	jdk1.6.0-b38	"Thu May 26 03:08:16 EDT 2005"	13564	836565	1	7	2	6	1062	58	1070
    +22	jdk1.6.0-b39	"Fri Jun 03 03:10:48 EDT 2005"	13856	849992	6	39	5	0	1065	66	1110
    +23	jdk1.6.0-b40	"Thu Jun 09 03:30:28 EDT 2005"	15972	959619	7	147	11	0	1099	71	1253
    +24	jdk1.6.0-b41	"Thu Jun 16 03:19:22 EDT 2005"	15972	959619	0	0	0	0	1253	82	1253
    +25	jdk1.6.0-b42	"Fri Jun 24 03:38:54 EDT 2005"	15966	958581	3	0	1	2	1250	82	1253
    +26	jdk1.6.0-b43	"Thu Jul 14 03:09:34 EDT 2005"	16041	960544	5	11	15	8	1230	85	1246
    +27	jdk1.6.0-b44	"Thu Jul 21 03:05:54 EDT 2005"	16041	960547	0	0	0	0	1246	108	1246
    +28	jdk1.6.0-b45	"Thu Jul 28 03:26:10 EDT 2005"	16037	960606	19	0	2	0	1244	108	1263
    +29	jdk1.6.0-b46	"Thu Aug 04 03:02:48 EDT 2005"	15936	951355	13	1	1	32	1230	110	1244
    +30	jdk1.6.0-b47	"Thu Aug 11 03:18:56 EDT 2005"	15964	952387	163	8	7	20	1217	143	1388
    +31	jdk1.6.0-b48	"Thu Aug 18 08:10:40 EDT 2005"	15970	953421	0	0	0	0	1388	170	1388
    +32	jdk1.6.0-b49	"Thu Aug 25 03:24:38 EDT 2005"	16048	958940	1	11	1	0	1387	170	1399
    +33	jdk1.6.0-b50	"Thu Sep 01 01:52:40 EDT 2005"	16287	974937	19	27	16	7	1376	171	1422
    +34	jdk1.6.0-b51	"Thu Sep 08 01:55:36 EDT 2005"	16362	979377	1	15	3	0	1419	194	1435
    +35	jdk1.6.0-b52	"Thu Sep 15 02:04:08 EDT 2005"	16477	979399	0	0	1	1	1433	197	1433
    +36	jdk1.6.0-b53	"Thu Sep 22 02:00:28 EDT 2005"	16019	957900	13	12	16	20	1397	199	1422
    +37	jdk1.6.0-b54	"Thu Sep 29 01:54:34 EDT 2005"	16019	957900	0	0	0	0	1422	235	1422
    +38	jdk1.6.0-b55	"Thu Oct 06 01:54:14 EDT 2005"	16051	959014	1	4	7	0	1415	235	1420
    +39	jdk1.6.0-b56	"Thu Oct 13 01:54:12 EDT 2005"	16211	970835	6	8	37	0	1383	242	1397
    +40	jdk1.6.0-b57	"Thu Oct 20 01:55:26 EDT 2005"	16279	971627	0	0	0	0	1397	279	1397
    +41	jdk1.6.0-b58	"Thu Oct 27 01:56:30 EDT 2005"	16283	971945	0	1	1	0	1396	279	1397
    +42	jdk1.6.0-b59	"Thu Nov 03 01:56:58 EST 2005"	16232	972193	6	0	5	0	1392	280	1398
    +43	jdk1.6.0-b60	"Thu Nov 10 01:54:18 EST 2005"	16235	972346	0	0	0	0	1398	285	1398
    +44	jdk1.6.0-b61	"Thu Nov 17 01:58:42 EST 2005"	16202	971134	2	0	4	0	1394	285	1396
    +

    2.2. Incremental history maintenance

    +If 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: +

    +computeBugHistory -output db.xml db.xml jdk1.6.0-b61/jre/lib/rt.xml
    +

    3. Ant example

    +Here is a complete ant script example for both running findbugs and running a chain of data-mining tools afterward: +

    +
    +<project name="analyze_asm_util" default="findbugs">
    +   <!-- findbugs task definition -->
    +   <property name="findbugs.home" value="/Users/ben/Documents/workspace/findbugs/findbugs" />
    +   <property name="jvmargs" value="-server -Xss1m -Xmx800m -Duser.language=en -Duser.region=EN -Dfindbugs.home=${findbugs.home}" />
    +
    +    <path id="findbugs.lib">
    +      <fileset dir="${findbugs.home}/lib">
    +         <include name="findbugs-ant.jar"/>
    +      </fileset>
    +   </path>
    +
    +   <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
    +      <classpath refid="findbugs.lib" />
    +   </taskdef>
    +
    +   <taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask">
    +      <classpath refid="findbugs.lib" />
    +   </taskdef>
    +
    +   <taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask">
    +      <classpath refid="findbugs.lib" />
    +   </taskdef>
    +
    +   <taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask">
    +      <classpath refid="findbugs.lib" />
    +   </taskdef>
    +
    +   <!-- findbugs task definition -->
    +   <target name="findbugs">
    +      <antcall target="analyze" />
    +      <antcall target="mine" />
    +   </target>
    +
    +   <!-- analyze task -->
    +   <target name="analyze">
    +      <!-- run findbugs against asm-util -->
    +      <findbugs home="${findbugs.home}"
    +                output="xml:withMessages"
    +                timeout="90000000"
    +                reportLevel="experimental"
    +                workHard="true"
    +                effort="max"
    +                adjustExperimental="true"
    +                jvmargs="${jvmargs}"
    +                failOnError="true"
    +                outputFile="out.xml"
    +                projectName="Findbugs"
    +                debug="false">
    +         <class location="asm-util-3.0.jar" />
    +      </findbugs>
    +   </target>
    +
    +   <target name="mine">
    +
    +      <!-- Set info to the latest analysis -->
    +      <setBugDatabaseInfo home="${findbugs.home}"
    +                            withMessages="true"
    +                            name="asm-util-3.0.jar"
    +                            input="out.xml"
    +                            output="out-rel.xml"/>
    +
    +      <!-- Checking if history file already exists (out-hist.xml) -->
    +      <condition property="mining.historyfile.available">
    +         <available file="out-hist.xml"/>
    +      </condition>
    +      <condition property="mining.historyfile.notavailable">
    +         <not>
    +            <available file="out-hist.xml"/>
    +         </not>
    +      </condition>
    +
    +      <!-- this target is executed if the history file do not exist (first run) -->
    +      <antcall target="history-init">
    +        <param name="data.file" value="out-rel.xml" />
    +        <param name="hist.file" value="out-hist.xml" />
    +      </antcall>
    +      <!-- else this one is executed -->
    +      <antcall target="history">
    +        <param name="data.file"         value="out-rel.xml" />
    +        <param name="hist.file"         value="out-hist.xml" />
    +        <param name="hist.summary.file" value="out-hist.txt" />
    +      </antcall>
    +   </target>
    +
    +   <!-- Initializing history file -->
    +   <target name="history-init" if="mining.historyfile.notavailable">
    +      <copy file="${data.file}" tofile="${hist.file}" />
    +   </target>
    +
    +   <!-- Computing bug history -->
    +   <target name="history" if="mining.historyfile.available">
    +      <!-- Merging ${data.file} into ${hist.file} -->
    +      <computeBugHistory home="${findbugs.home}"
    +                           withMessages="true"
    +                           output="${hist.file}">
    +            <dataFile name="${hist.file}"/>
    +            <dataFile name="${data.file}"/>
    +      </computeBugHistory>
    +
    +      <!-- Compute history into ${hist.summary.file} -->
    +      <mineBugHistory home="${findbugs.home}"
    +                        formatDates="true"
    +                      noTabs="true"
    +                        input="${hist.file}"
    +                        output="${hist.summary.file}"/>
    +   </target>
    +
    +</project>
    +
    +
    \ No newline at end of file diff --git a/doc/manual/eclipse.html b/doc/manual/eclipse.html new file mode 100644 index 0000000..52ac8e9 --- /dev/null +++ b/doc/manual/eclipse.html @@ -0,0 +1,112 @@ + + + Chapter 7. Using the FindBugs™ Eclipse plugin

    Chapter 7. Using the FindBugs™ Eclipse plugin

    +The FindBugs Eclipse plugin allows FindBugs to be used within +the Eclipse IDE. +The FindBugs Eclipse plugin was generously contributed by Peter Friese. +Phil Crosby and Andrei Loskutov contributed major improvements +to the plugin. +

    1. Requirements

    +To use the FindBugs Plugin for Eclipse, you need Eclipse 3.3 or later, +and JRE/JDK 1.5 or later. +

    2. Installation

    + We provide update sites that allow you to automatically install FindBugs into Eclipse and also query and install updates. + There are three different update sites

    FindBugs Eclipse update sites

    http://findbugs.cs.umd.edu/eclipse/

    + Only provides official releases of FindBugs. +

    http://findbugs.cs.umd.edu/eclipse-candidate/

    + Provides official releases and release candidates of FindBugs. +

    http://findbugs.cs.umd.edu/eclipse-daily/

    + Provides the daily build of FindBugs. No testing other than that it compiles. +

    You can also manually +download the plugin from the following link: +http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download. +Extract it in Eclipse's "plugins" subdirectory. +(So <eclipse_install_dir>/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png +should be the path to the FindBugs logo.) + +

    +Once the plugin is extracted, start Eclipse and choose +HelpAbout Eclipse PlatformPlug-in Details. +You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project". +

    3. Using the Plugin

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

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

    +You may customize how FindBugs runs by opening the Properties +dialog for a Java project, and choosing the "Findbugs" property page. +Options you may choose include: +

    • + Enable or disable the "Run FindBugs Automatically" checkbox. + When enabled, FindBugs will run every time you modify a Java class + within the project. +

    • + Choose minimum warning priority and enabled bug categories. + These options will choose which warnings are shown. + For example, if you select the "Medium" warning priority, + only Medium and High priority warnings will be shown. + Similarly, if you uncheck the "Style" checkbox, no warnings + in the Style category will be displayed. +

    • + Select detectors. The table allows you to select which detectors + you want to enable for your project. +

    4. Extending the Eclipse Plugin (since 2.0.0)

    +Eclipse plugin supports contribution of custom FindBugs detectors (see also +AddingDetectors.txt +for more information). There are two ways to contribute custom plugins to the Eclipse: +

    • + Existing standard FindBugs detector packages can be configured via + WindowPreferencesJavaFindBugsMisc. SettingsCustom Detectors. + Simply specify there locations of any additional plugin libraries. +

      + The benefit of this solution is that already existing detector packages can be + used "as is", and that you can quickly verify the quality of third party detectors. + The drawback is that you have to apply this settings in each + new Eclipse workspace, and this settings can't be shared between team members. +

    • + It is possible to contribute custom detectors via standard Eclipse extensions mechanism. +

      + Please check the documentation of the + + findBugsEclipsePlugin/schema/detectorPlugins.exsd + extension point how to update the plugin.xml. Existing FindBugs detector plugins can + be easily "extended" to be full featured FindBugs AND Eclipse detector plugins. + Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and + update your build scripts to not to override the MANIFEST.MF during the build. +

      + The benefit of this solution is that for given (shared) Eclipse installation + each team member has exactly same detectors set, and there is no need to configure + anything anymore. The (really small) precondition + is that you have to convert your existing detectors package to the valid + Eclipse plugin. You can do this even for third-party detector packages. + Another major differentiator is the ability to extend the default FindBugs + classpath at runtime with required third party libraries (see + AddingDetectors.txt + for more information). +

    5. Troubleshooting

    +This section lists common problems with the plugin and (if known) how to resolve them. +

    • + If you see OutOfMemory error dialogs after starting FindBugs analysis in Eclipse, + please increase JVM available memory: change eclipse.ini and add the lines below + to the end of the file: +

      +    -vmargs
      +    -Xmx1000m
      +    

      + Important: the configuration arguments starting with the line "-vmargs" must + be last lines in the eclipse.ini file, and only one argument per line is allowed! +

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

    \ No newline at end of file diff --git a/doc/manual/example-code.png b/doc/manual/example-code.png new file mode 100644 index 0000000..fe01f31 Binary files /dev/null and b/doc/manual/example-code.png differ diff --git a/doc/manual/example-details.png b/doc/manual/example-details.png new file mode 100644 index 0000000..1addf93 Binary files /dev/null and b/doc/manual/example-details.png differ diff --git a/doc/manual/example.png b/doc/manual/example.png new file mode 100644 index 0000000..289b897 Binary files /dev/null and b/doc/manual/example.png differ diff --git a/doc/manual/filter.html b/doc/manual/filter.html new file mode 100644 index 0000000..98b264f --- /dev/null +++ b/doc/manual/filter.html @@ -0,0 +1,363 @@ + + + Chapter 8. Filter Files

    Chapter 8. Filter Files

    +Filter files may be used to include or exclude bug reports for particular classes +and methods. This chapter explains how to use filter files. + +

    [Note]Planned Features

    + Filters are currently only supported by the Command Line interface. + Eventually, filter support will be added to the GUI. +

    +

    1. Introduction to Filter Files

    +Conceptually, a filter matches bug instances against a set of criteria. +By defining a filter, you can select bug instances for special treatment; +for example, to exclude or include them in a report. +

    +A filter file is an XML document with a top-level FindBugsFilter element +which has some number of Match elements as children. Each Match +element represents a predicate which is applied to generated bug instances. +Usually, a filter will be used to exclude bug instances. For example: + +

    +$ findbugs -textui -exclude myExcludeFilter.xml myApp.jar
    +

    + +However, a filter could also be used to select bug instances to specifically +report: + +

    +$ findbugs -textui -include myIncludeFilter.xml myApp.jar
    +

    +

    +Match elements contain children, which are conjuncts of the predicate. +In other words, each of the children must be true for the predicate to be true. +

    2. Types of Match clauses

    <Bug>

    + This element specifies a particular bug pattern or patterns to match. + The pattern attribute is a comma-separated list of + bug pattern types. You can find the bug pattern types for particular + warnings by looking at the output produced by the -xml + output option (the type attribute of BugInstance + elements), or from the bug + descriptions document. +

    + For more coarse-grained matching, use code attribute. It takes + a comma-separated list of bug abbreviations. For most-coarse grained matching use + category attriute, that takes a comma separated list of bug category names: + CORRECTNESS, MT_CORRECTNESS, + BAD_PRACTICICE, PERFORMANCE, STYLE. +

    + If more than one of the attributes mentioned above are specified on the same + <Bug> element, all bug patterns that match either one of specified + pattern names, or abreviations, or categories will be matched. +

    + As a backwards compatibility measure, <BugPattern> and + <BugCode> elements may be used instead of + <Bug> element. Each of these uses a + name attribute for specifying accepted values list. Support for these + elements may be removed in a future release. +

    <Confidence>

    + This element matches warnings with a particular bug confidence. + The value attribute should be an integer value: + 1 to match high-confidence warnings, 2 to match normal-confidence warnings, + or 3 to match low-confidence warnings. <Confidence> replaced + <Priority> in 2.0.0 release. +

    <Priority>

    + Same as <Confidence>, exists for backward compatibility. +

    <Rank>

    + This element matches warnings with a particular bug rank. + The value attribute should be an integer value + between 1 and 20, where 1 to 4 are scariest, 5 to 9 scary, 10 to 14 troubling, + and 15 to 20 of concern bugs. +

    <Package>

    + This element matches warnings associated with classes within the package specified + using name attribute. Nested packages are not included (along the + lines of Java import statement). However matching multiple packages can be achieved + easily using regex name match. +

    <Class>

    + This element matches warnings associated with a particular class. The + name attribute is used to specify the exact or regex match pattern + for the class name. +

    + As a backward compatibility measure, instead of element of this type, you can use + class attribute on a Match element to specify + exact an class name or classregex attribute to specify a regular + expression to match the class name against. +

    + If the Match element contains neither a Class element, + nor a class / classregex attribute, the predicate will apply + to all classes. Such predicate is likely to match more bug instances than you want, unless it is + refined further down with apropriate method or field predicates. +

    <Method>

    This element specifies a method. The name is used to specify + the exact or regex match pattern for the method name. + The params attribute is a comma-separated list + of the types of the method's parameters. The returns attribute is + the method's return type. In params and returns, class names + must be fully qualified. (E.g., "java.lang.String" instead of just + "String".) If one of the latter attributes is specified the other is required for creating a method signature. + Note that you can provide either name attribute or params + and returns attributes or all three of them. This way you can provide various kinds of + name and signature based matches. +

    <Field>

    This element specifies a field. The name attribute is is used to specify + the exact or regex match pattern for the field name. You can also filter fields according to their signature - + use type attribute to specify fully qualified type of the field. You can specify eiter or both + of these attributes in order to perform name / signature based matches. +

    <Local>

    This element specifies a local variable. The name attribute is is used to specify + the exact or regex match pattern for the local variable name. Local variables are variables defined within a method. +

    <Or>

    + This element combines Match clauses as disjuncts. I.e., you can put two + Method elements in an Or clause in order to match either method. +

    <And>

    + This element combines Match clauses which both must evaluate to true. I.e., you can put + Bug and Priority elements in an And clause in order + to match specific bugs with given priority only. +

    <Not>

    + This element inverts the included child Match. I.e., you can put a + Bug element in a Not clause in order to match any bug + excluding the given one. +

    3. Java element name matching

    +If the name attribute of Class, Method or +Field starts with the ~ character the rest of attribute content is interpreted as +a Java regular expression that is matched against the names of the Java element in question. +

    +Note that the pattern is matched against whole element name and therefore .* clauses need to be used +at pattern beginning and/or end to perform substring matching. +

    +See java.util.regex.Pattern +documentation for pattern syntax. +

    4. Caveats

    +Match clauses can only match information that is actually contained in the +bug instances. Every bug instance has a class, so in general, excluding +bugs by class will work. +

    +Some bug instances have two (or more) classes. For example, the DE (dropped exception) +bugs report both the class containing the method where the dropped exception +happens, and the class which represents the type of the dropped exception. +Only the first (primary) class is matched against Match clauses. +So, for example, if you want to suppress IC (initialization circularity) +reports for classes "com.foobar.A" and "com.foobar.B", you would use +two Match clauses: + +

    +   <Match>
    +      <Class name="com.foobar.A" />
    +      <Bug code="IC" />
    +   </Match>
    +
    +   <Match>
    +      <Class name="com.foobar.B" />
    +      <Bug code="IC" />
    +   </Match>
    +

    + +By explicitly matching both classes, you ensure that the IC bug instance will be +matched regardless of which class involved in the circularity happens to be +listed first in the bug instance. (Of course, this approach might accidentally +supress circularities involving "com.foobar.A" or "com.foobar.B" and a third +class.) +

    +Many kinds of bugs report what method they occur in. For those bug instances, +you can put Method clauses in the Match element and they should work +as expected. +

    5. Examples

    + 1. Match all bug reports for a class. + +

    +
    +     <Match>
    +       <Class name="com.foobar.MyClass" />
    +     </Match>
    +
    +

    + +

    + 2. Match certain tests from a class by specifying their abbreviations. +

    +
    +     <Match>
    +       <Class name="com.foobar.MyClass"/ >
    +       <Bug code="DE,UrF,SIC" />
    +     </Match>
    +
    +

    +

    + 3. Match certain tests from all classes by specifying their abbreviations. + +

    +
    +     <Match>
    +       <Bug code="DE,UrF,SIC" />
    +     </Match>
    +
    +

    +

    + 4. Match certain tests from all classes by specifying their category. + +

    +
    +     <Match>
    +       <Bug category="PERFORMANCE" />
    +     </Match>
    +
    +

    +

    + 5. Match bug types from specified methods of a class by their abbreviations. + +

    +
    +     <Match>
    +       <Class name="com.foobar.MyClass" />
    +       <Or>
    +         <Method name="frob" params="int,java.lang.String" returns="void" />
    +         <Method name="blat" params="" returns="boolean" />
    +       </Or>
    +       <Bug code="DC" />
    +     </Match>
    +
    +

    +

    + 6. Match a particular bug pattern in a particular method. + +

    +
    +    <!-- A method with an open stream false positive. -->
    +    <Match>
    +      <Class name="com.foobar.MyClass" />
    +      <Method name="writeDataToFile" />
    +      <Bug pattern="OS_OPEN_STREAM" />
    +    </Match>
    +
    +

    +

    + 7. Match a particular bug pattern with a given priority in a particular method. + +

    +
    +    <!-- A method with a dead local store false positive (medium priority). -->
    +    <Match>
    +      <Class name="com.foobar.MyClass" />
    +      <Method name="someMethod" />
    +      <Bug pattern="DLS_DEAD_LOCAL_STORE" />
    +      <Priority value="2" />
    +    </Match>
    +
    +

    +

    + 8. Match minor bugs introduced by AspectJ compiler (you are probably not interested in these unless + you are an AspectJ developer). + +

    +
    +    <Match>
    +      <Class name="~.*\$AjcClosure\d+" />
    +      <Bug pattern="DLS_DEAD_LOCAL_STORE" />
    +      <Method name="run" />
    +    </Match>
    +    <Match>
    +      <Bug pattern="UUF_UNUSED_FIELD" />
    +      <Field name="~ajc\$.*" />
    +    </Match>
    +
    +

    +

    + 9. Match bugs in specific parts of the code base + +

    +
    +    <!-- match unused fields warnings in Messages classes in all packages -->
    +    <Match>
    +      <Class name="~.*\.Messages" />
    +      <Bug code="UUF" />
    +    </Match>
    +    <!-- match mutable statics warnings in all internal packages -->
    +    <Match>
    +      <Package name="~.*\.internal" />
    +      <Bug code="MS" />
    +    </Match>
    +    <!-- match anonymoous inner classes warnings in ui package hierarchy -->
    +    <Match>
    +      <Package name="~com\.foobar\.fooproject\.ui.*" />
    +      <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" />
    +    </Match>
    +
    +

    +

    + 10. Match bugs on fields or methods with specific signatures +

    +
    +    <!-- match System.exit(...) usage warnings in void main(String[]) methods in all classes -->
    +    <Match>
    +      <Method returns="void" name="main" params="java.lang.String[]" />
    +      <Bug pattern="DM_EXIT" />
    +    </Match>
    +    <!-- match UuF warnings on fields of type com.foobar.DebugInfo on all classes -->
    +    <Match>
    +      <Field type="com.foobar.DebugInfo" />
    +      <Bug code="UuF" />
    +    </Match>
    +
    +

    +

    + 11. Match bugs using the Not filter operator +

    +
    +<!-- ignore all bugs in test classes, except for those bugs specifically relating to JUnit tests -->
    +<!-- i.e. filter bug if ( classIsJUnitTest && ! bugIsRelatedToJUnit ) -->
    +<Match>
    +  <!-- the Match filter is equivalent to a logical 'And' -->
    +
    +  <Class name="~.*\.*Test" />
    +  <!-- test classes are suffixed by 'Test' -->
    +
    +  <Not>
    +      <Bug code="IJU" /> <!-- 'IJU' is the code for bugs related to JUnit test code -->
    +  </Not>
    +</Match>
    +
    +

    +

    6. Complete Example

    +
    +<FindBugsFilter>
    +     <Match>
    +       <Class name="com.foobar.ClassNotToBeAnalyzed" />
    +     </Match>
    +
    +     <Match>
    +       <Class name="com.foobar.ClassWithSomeBugsMatched" />
    +       <Bug code="DE,UrF,SIC" />
    +     </Match>
    +
    +     <!-- Match all XYZ violations. -->
    +     <Match>
    +       <Bug code="XYZ" />
    +     </Match>
    +
    +     <!-- Match all doublecheck violations in these methods of "AnotherClass". -->
    +     <Match>
    +       <Class name="com.foobar.AnotherClass" />
    +       <Or>
    +         <Method name="nonOverloadedMethod" />
    +         <Method name="frob" params="int,java.lang.String" returns="void" />
    +         <Method name="blat" params="" returns="boolean" />
    +       </Or>
    +       <Bug code="DC" />
    +     </Match>
    +
    +     <!-- A method with a dead local store false positive (medium priority). -->
    +     <Match>
    +       <Class name="com.foobar.MyClass" />
    +       <Method name="someMethod" />
    +       <Bug pattern="DLS_DEAD_LOCAL_STORE" />
    +       <Priority value="2" />
    +     </Match>
    +
    +     <!-- All bugs in test classes, except for JUnit-specific bugs -->
    +     <Match>
    +      <Class name="~.*\.*Test" />
    +      <Not>
    +          <Bug code="IJU" />
    +      </Not>
    +     </Match>
    +
    +</FindBugsFilter>
    +
    +
    \ No newline at end of file diff --git a/doc/manual/gui.html b/doc/manual/gui.html new file mode 100644 index 0000000..122b074 --- /dev/null +++ b/doc/manual/gui.html @@ -0,0 +1,68 @@ + + + Chapter 5. Using the FindBugs GUI

    Chapter 5. Using the FindBugs GUI

    + This chapter describes how to use the FindBugs graphical user interface (GUI). +

    1. Creating a Project

    +After you have started FindBugs using the findbugs command, +choose the FileNew Project +menu item. You will see a dialog which looks like this: +

    +

    +Use the "Add" button next to "Classpath to analyze" to select a Java archive +file (zip, jar, ear, or war file) or directory containing java classes to analyze for bugs. You may add multiple +archives/directories. +

    +You can also add the source directories which contain +the source code for the Java archives you are analyzing. This will enable +FindBugs to highlight the source code which contains a possible error. +The source directories you add should be the roots of the Java +package hierarchy. For example, if your application is contained in the +org.foobar.myapp package, you should add the +parent directory of the org directory +to the source directory list for the project. +

    +Another optional step is to add additional Jar files or directories as +"Auxiliary classpath locations" entries. You should do this if the archives and directories you are analyzing +have references to other classes which are not included in the analyzed +archives/directories and are not in the standard runtime classpath. Some of the bug +pattern detectors in FindBugs make use of class hierarchy information, +so you will get more accurate results if the entire class hierarchy is +available which FindBugs performs its analysis. +

    2. Running the Analysis

    +Once you have added all of the archives, directories, and source directories, +click the "Analyze" button to analyze the classes contained in the +Jar files. Note that for a very large program on an older computer, +this may take quite a while (tens of minutes). A recent computer with +ample memory will typically be able to analyze a large program in only a +few minutes. +

    3. Browsing Results

    +When the analysis completes, you will see a screen like the following: +

    +

    +The upper left-hand pane of the window shows the bug tree; this is a hierarchical +representation of all of the potential bugs detected in the analyzed +Jar files. +

    +When you select a particular bug instance in the top pane, you will +see a description of the bug in the "Details" tab of the bottom pane. +In addition, the source code pane on the upper-right will show the +program source code where the potential bug occurs, if source is available. +In the above example, the bug is a stream object that is not closed. The +source code window highlights the line where the stream object is created. +

    +You may add a textual annotations to bug instances. To do so, type them +into the text box just below the hierarchical view. You can type any +information which you would like to record. When you load and save bug +results files, the annotations are preserved. +

    4. Saving and Opening

    +You may use the FileSave as... +menu option to save your work. To save your work, including the jar +file lists you specified and all bug results, choose +"FindBugs analysis results (.xml)" from the drop-down list in the +"Save as..." dialog. There are also options for saving just the jar +file lists ("FindBugs project file (.fbp)") or just the results +("FindBugs analysis file (.fba)"). +A saved file may be loaded with the +FileOpen... +menu option. +

    \ No newline at end of file diff --git a/doc/manual/important.png b/doc/manual/important.png new file mode 100644 index 0000000..12c90f6 Binary files /dev/null and b/doc/manual/important.png differ diff --git a/doc/manual/index.html b/doc/manual/index.html new file mode 100644 index 0000000..42924a6 --- /dev/null +++ b/doc/manual/index.html @@ -0,0 +1,10 @@ + + + FindBugs™ Manual

    FindBugs™ Manual

    David H. Hovemeyer

    William W. Pugh

    +This manual is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. +To view a copy of this license, visit +http://creativecommons.org/licenses/by-nc-sa/1.0/ +or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. +

    +The name FindBugs and the FindBugs logo are trademarked by the University of Maryland. +

    17:16:15 EST, 22 November, 2013


    \ No newline at end of file diff --git a/doc/manual/infiniteRecursiveLoops.png b/doc/manual/infiniteRecursiveLoops.png new file mode 100644 index 0000000..5430df2 Binary files /dev/null and b/doc/manual/infiniteRecursiveLoops.png differ diff --git a/doc/manual/installing.html b/doc/manual/installing.html new file mode 100644 index 0000000..b14a6eb --- /dev/null +++ b/doc/manual/installing.html @@ -0,0 +1,29 @@ + + + Chapter 2. Installing FindBugs™

    Chapter 2. Installing FindBugs

    +This chapter explains how to install FindBugs. +

    1. Extracting the Distribution

    +The easiest way to install FindBugs is to download a binary distribution. +Binary distributions are available in +gzipped tar format and +zip format. +Once you have downloaded a binary distribution, extract it into a directory of your choice. +

    +Extracting a gzipped tar format distribution: +

    +$ gunzip -c findbugs-2.0.3.tar.gz | tar xvf -
    +

    +

    +Extracting a zip format distribution: +

    +C:\Software>unzip findbugs-2.0.3.zip
    +

    +

    +Usually, extracting a binary distribution will create a directory ending in +findbugs-2.0.3. For example, if you extracted +the binary distribution from the C:\Software +directory, then the FindBugs software will be extracted into the directory +C:\Software\findbugs-2.0.3. +This directory is the FindBugs home directory. We'll refer to it as +$FINDBUGS_HOME (or %FINDBUGS_HOME% for Windows) throughout this manual. +

    \ No newline at end of file diff --git a/doc/manual/introduction.html b/doc/manual/introduction.html new file mode 100644 index 0000000..a65b499 --- /dev/null +++ b/doc/manual/introduction.html @@ -0,0 +1,12 @@ + + + Chapter 1. Introduction

    Chapter 1. Introduction

    Table of Contents

    1. Requirements

    FindBugs™ is a program to find bugs in Java programs. It looks for instances +of "bug patterns" --- code instances that are likely to be errors.

    This document describes version 2.0.3 of FindBugs.We +are very interested in getting your feedback on FindBugs. Please visit +the FindBugs web page for +the latest information on FindBugs, contact information, and support resources such +as information about the FindBugs mailing lists.

    1. Requirements

    To use FindBugs, you need a runtime environment compatible with +Java 2 Standard Edition, version 1.5 or later. +FindBugs is platform independent, and is known to run on GNU/Linux, Windows, and +MacOS X platforms.

    You should have at least 512 MB of memory to use FindBugs. +To analyze very large projects, more memory may be needed.

    \ No newline at end of file diff --git a/doc/manual/license.html b/doc/manual/license.html new file mode 100644 index 0000000..bfe9cb1 --- /dev/null +++ b/doc/manual/license.html @@ -0,0 +1,13 @@ + + + Chapter 13. License

    Chapter 13. License

    +The name FindBugs and the FindBugs logo is trademarked by the University +of Maryland. +FindBugs is free software distributed under the terms of the +Lesser GNU Public License. +You should have received a copy of the license in the file LICENSE.txt +in the FindBugs distribution. +

    +You can find the latest version of FindBugs, along with its source code, from the +FindBugs web page. +

    \ No newline at end of file diff --git a/doc/manual/note.png b/doc/manual/note.png new file mode 100644 index 0000000..d0c3c64 Binary files /dev/null and b/doc/manual/note.png differ diff --git a/doc/manual/project-dialog.png b/doc/manual/project-dialog.png new file mode 100644 index 0000000..7a39783 Binary files /dev/null and b/doc/manual/project-dialog.png differ diff --git a/doc/manual/rejarForAnalysis.html b/doc/manual/rejarForAnalysis.html new file mode 100644 index 0000000..e28241a --- /dev/null +++ b/doc/manual/rejarForAnalysis.html @@ -0,0 +1,33 @@ + + + Chapter 11. Using rejarForAnalysis

    Chapter 11. Using rejarForAnalysis

    +If your project consists of many jarfiles or the jarfiles are scattered +over many directories, you may wish to use the rejarForAnalysis + script to make +FindBugs invocation easier. The script collects many jarfiles and combines them +into a single, large jarfile that can then be easily passed to FindBugs for +analysis. This can be particularly useful in combination with the 'find' command +on unix systems; e.g. find . -name '*.jar' | xargs rejarForAnalysis +. +

    +The rejarForAnalysis script +can also be used to split a very large project up into a set of jarfiles with +the project classfiles evenly divided between them. This is useful when running +FindBugs on the entire project is not practical due to time or memory consumption. +Instead of running FindBugs on the entire project, you may use +rejarForAnalysis build one large, all-inclusive jarfile +containing all classes, invoke rejarForAnalysis +again to split the project into multiple jarfiles, then run FindBugs +on each divided jarfiles in turn, specifying the the all-inclusive jarfile in +the -auxclasspath. +

    +These are the options accepted by the rejarForAnalysis script: +

    -maxAge days

    + Maximum age in days (ignore jar files older than this). +

    -inputFileList filename

    + Text file containing names of jar files. +

    -maxClasses num

    + Maximum number of classes per analysis*.jar file. +

    -prefix class name prefix

    + Prefix of class names that should be analyzed (e.g., edu.umd.cs.). +

    \ No newline at end of file diff --git a/doc/manual/running.html b/doc/manual/running.html new file mode 100644 index 0000000..cf83c85 --- /dev/null +++ b/doc/manual/running.html @@ -0,0 +1,209 @@ + + + Chapter 4. Running FindBugs™

    Chapter 4. Running FindBugs

    +FindBugs has two user interfaces: a graphical user interface (GUI) and a +command line user interface. This chapter describes +how to run each of these user interfaces. +

    [Warning]Warning

    + This chapter is in the process of being re-written. + The rewrite is not complete yet. +

    1. Quick Start

    + If you are running FindBugs on a Windows system, + double-click on the file %FINDBUGS_HOME%\lib\findbugs.jar to start the FindBugs GUI. +

    + On a Unix, Linux, or Mac OS X system, run the $FINDBUGS_HOME/bin/findbugs + script, or run the command

    +java -jar $FINDBUGS_HOME/lib/findbugs.jar

    + to run the FindBugs GUI. +

    + Refer to Chapter 5, Using the FindBugs GUI for information on how to use the GUI. +

    2. Executing FindBugs

    + This section describes how to invoke the FindBugs program. + There are two ways to invoke FindBugs: directly, or using a + wrapper script. +

    2.1. Direct invocation of FindBugs

    + The preferred method of running FindBugs is to directly execute + $FINDBUGS_HOME/lib/findbugs.jar using the -jar + command line switch of the JVM (java) executable. + (Versions of FindBugs prior to 1.3.5 required a wrapper script + to invoke FindBugs.) +

    + The general syntax of invoking FindBugs directly is the following: +

    +    java [JVM arguments] -jar $FINDBUGS_HOME/lib/findbugs.jar options...
    +

    +

    2.1.1. Choosing the User Interface

    + The first command line option chooses the FindBugs user interface to execute. + Possible values are: +

    • + -gui: runs the graphical user interface (GUI) +

    • + -textui: runs the command line user interface +

    • + -version: displays the FindBugs version number +

    • + -help: displays help information for the + FindBugs command line user interface +

    • + -gui1: executes the original (obsolete) + FindBugs graphical user interface +

    2.1.2. Java Virtual Machine (JVM) arguments

    + Several Java Virtual Machine arguments are useful when invoking + FindBugs. +

    -XmxNNm

    + Set the maximum Java heap size to NN + megabytes. FindBugs generally requires a large amount of + memory. For a very large project, using 1500 megabytes + is not unusual. +

    -Dname=value

    + Set a Java system property. For example, you might use the + argument -Duser.language=ja to display + GUI messages in Japanese. +

    2.2. Invocation of FindBugs using a wrapper script

    + Another way to run FindBugs is to use a wrapper script. +

    +On Unix-like systems, use the following command to invoke the wrapper script: +

    +$ $FINDBUGS_HOME/bin/findbugs options...
    +

    +

    +On Windows systems, the command to invoke the wrapper script is +

    +C:\My Directory>%FINDBUGS_HOME%\bin\findbugs.bat options...
    +

    +

    +On both Unix-like and Windows systems, you can simply add the $FINDBUGS_HOME/bin +directory to your PATH environment variable and then invoke +FindBugs using the findbugs command. +

    2.2.1. Wrapper script command line options

    The FindBugs wrapper scripts support the following command-line options. + Note that these command line options are not handled by + the FindBugs program per se; rather, they are handled by the wrapper + script. +

    -jvmArgs args

    + Specifies arguments to pass to the JVM. For example, you might want + to set a JVM property: +

    +$ findbugs -textui -jvmArgs "-Duser.language=ja" myApp.jar
    +

    +

    -javahome directory

    + Specifies the directory containing the JRE (Java Runtime Environment) to + use to execute FindBugs. +

    -maxHeap size

    + Specifies the maximum Java heap size in megabytes. The default is 256. + More memory may be required to analyze very large programs or libraries. +

    -debug

    + Prints a trace of detectors run and classes analyzed to standard output. + Useful for troubleshooting unexpected analysis failures. +

    -property name=value

    + This option sets a system property.  FindBugs uses system properties + to configure analysis options. See Chapter 9, Analysis Properties. + You can use this option multiple times in order to set multiple properties. + Note: In most versions of Windows, the name=value + string must be in quotes. +

    3. Command-line Options

    + This section describes the command line options supported by FindBugs. + These command line options may be used when invoking FindBugs directly, + or when using a wrapper script. +

    3.1. Common command-line options

    +These options may be used with both the GUI and command-line interfaces. +

    -effort:min

    + This option disables analyses that increase precision but also + increase memory consumption. You may want to try this option if + you find that FindBugs runs out of memory, or takes an unusually + long time to complete its analysis. +

    -effort:max

    + Enable analyses which increase precision and find more bugs, but which + may require more memory and take more time to complete. +

    -project project

    + Specify a project to be analyzed. The project file you specify should + be one that was created using the GUI interface. It will typically end + in the extension .fb or .fbp. +

    3.2. GUI Options

    +These options are only accepted by the Graphical User Interface. + +

    -look:plastic|gtk|native

    + Set Swing look and feel. +

    +

    3.3. Text UI Options

    +These options are only accepted by the Text User Interface. +

    -sortByClass

    + Sort reported bug instances by class name. +

    -include filterFile.xml

    + Only report bug instances that match the filter specified by filterFile.xml. + See Chapter 8, Filter Files. +

    -exclude filterFile.xml

    + Report all bug instances except those matching the filter specified by filterFile.xml. + See Chapter 8, Filter Files. +

    -onlyAnalyze com.foobar.MyClass,com.foobar.mypkg.*

    + Restrict analysis to find bugs to given comma-separated list of + classes and packages. + Unlike filtering, this option avoids running analysis on + classes and packages that are not explicitly matched: + for large projects, this may greatly reduce the amount of time + needed to run the analysis. (However, some detectors may produce + inaccurate results if they aren't run on the entire application.) + Classes should be specified using their full classnames (including + package), and packages should be specified in the same way + they would in a Java import statement to + import all classes in the package (i.e., add .* + to the full name of the package). + Replace .* with .- to also + analyze all subpackages. +

    -low

    + Report all bugs. +

    -medium

    + Report medium and high priority bugs. This is the default setting. +

    -high

    + Report only high priority bugs. +

    -relaxed

    + Relaxed reporting mode. For many detectors, this option + suppresses the heuristics used to avoid reporting false positives. +

    -xml

    + Produce the bug reports as XML. The XML data produced may be + viewed in the GUI at a later time. You may also specify this + option as -xml:withMessages; when this variant + of the option is used, the XML output will contain human-readable + messages describing the warnings contained in the file. + XML files generated this way are easy to transform into reports. +

    -html

    + Generate HTML output. By default, FindBugs will use the default.xsl + XSLT + stylesheet to generate the HTML: you can find this file in findbugs.jar, + or in the FindBugs source or binary distributions. Variants of this option include + -html:plain.xsl, -html:fancy.xsl and -html:fancy-hist.xsl. + The plain.xsl stylesheet does not use Javascript or DOM, + and may work better with older web browsers, or for printing. The fancy.xsl + stylesheet uses DOM and Javascript for navigation and CSS for + visual presentation. The fancy-hist.xsl an evolution of fancy.xsl stylesheet. + It makes an extensive use of DOM and Javascript for dynamically filtering the lists of bugs. +

    + If you want to specify your own + XSLT stylesheet to perform the transformation to HTML, specify the option as + -html:myStylesheet.xsl, + where myStylesheet.xsl is the filename of the + stylesheet you want to use. +

    -emacs

    + Produce the bug reports in Emacs format. +

    -xdocs

    + Produce the bug reports in xdoc XML format for use with Apache Maven. +

    -output filename

    + Produce the output in the specified file. +

    -outputFile filename

    + This argument is deprecated. Use -output instead. +

    -nested[:true|false]

    + This option enables or disables scanning of nested jar and zip files found in + the list of files and directories to be analyzed. + By default, scanning of nested jar/zip files is enabled. + To disable it, add -nested:false to the command line + arguments. +

    -auxclasspath classpath

    + Set the auxiliary classpath for analysis. This classpath should include all + jar files and directories containing classes that are part of the program + being analyzed but you do not want to have analyzed for bugs. +

    -userPrefs edu.umd.cs.findbugs.core.prefs

    + Set the path of the user preferences file to use, which might override some of the options abobe. + Specifying userPrefs as first argument would mean some later + options will override them, as last argument would mean they will override some previous options). + This rationale behind this option is to reuse FindBugs Eclipse project settings for command + line execution. +

    \ No newline at end of file diff --git a/doc/manual/warning.png b/doc/manual/warning.png new file mode 100644 index 0000000..1c33db8 Binary files /dev/null and b/doc/manual/warning.png differ diff --git a/doc/manual-fo.xsl b/doc/manual-fo.xsl new file mode 100644 index 0000000..df29918 --- /dev/null +++ b/doc/manual-fo.xsl @@ -0,0 +1,30 @@ + + + + + + + +1 + + +1 + + +manual/ + + +manual/ + + +5in + + +1 + + diff --git a/doc/manual.xml b/doc/manual.xml new file mode 100644 index 0000000..e36db9d --- /dev/null +++ b/doc/manual.xml @@ -0,0 +1,3990 @@ + +FindBugs"> +Ant"> +Saxon"> +$FINDBUGS_HOME"> +%FINDBUGS_HOME%"> + +]> + + + + +&FindBugs;™ Manual + + + + David + H. + Hovemeyer + + + William + W. + Pugh + + + + + 2003 - 2012 + University of Maryland + + + + +This manual is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. +To view a copy of this license, visit +http://creativecommons.org/licenses/by-nc-sa/1.0/ +or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. + + +The name FindBugs and the FindBugs logo are trademarked by the University of Maryland. + + + +2.0.3 + +17:16:15 EST, 22 November, 2013 + + + + + + +Introduction + + &FindBugs;™ is a program to find bugs in Java programs. It looks for instances +of "bug patterns" --- code instances that are likely to be errors. + + This document describes version 2.0.3 of &FindBugs;.We +are very interested in getting your feedback on &FindBugs;. Please visit +the &FindBugs; web page for +the latest information on &FindBugs;, contact information, and support resources such +as information about the &FindBugs; mailing lists. + + +Requirements + To use &FindBugs;, you need a runtime environment compatible with +Java 2 Standard Edition, version 1.5 or later. +&FindBugs; is platform independent, and is known to run on GNU/Linux, Windows, and +MacOS X platforms. + +You should have at least 512 MB of memory to use &FindBugs;. +To analyze very large projects, more memory may be needed. + + + + + + + +Installing &FindBugs;™ + + +This chapter explains how to install &FindBugs;. + + + +Extracting the Distribution + + +The easiest way to install &FindBugs; is to download a binary distribution. +Binary distributions are available in +gzipped tar format and +zip format. +Once you have downloaded a binary distribution, extract it into a directory of your choice. + + + +Extracting a gzipped tar format distribution: + +$ gunzip -c findbugs-2.0.3.tar.gz | tar xvf - + + + + +Extracting a zip format distribution: + +C:\Software>unzip findbugs-2.0.3.zip + + + + +Usually, extracting a binary distribution will create a directory ending in +findbugs-2.0.3. For example, if you extracted +the binary distribution from the C:\Software +directory, then the &FindBugs; software will be extracted into the directory +C:\Software\findbugs-2.0.3. +This directory is the &FindBugs; home directory. We'll refer to it as +&FBHome; (or &FBHomeWin; for Windows) throughout this manual. + + + + + + + + +Building &FindBugs;™ from Source + + +This chapter describes how to build &FindBugs; from source code. Unless you are +interesting in modifying &FindBugs;, you will probably want to skip to the +next chapter. + + + +Prerequisites + + +To compile &FindBugs; from source, you will need the following: + + + + The &FindBugs; source distribution + + + + + JDK 1.5.0 or later + + + + + Apache &Ant;, version 1.6.3 or later + + + + + + + + The version of &Ant; included as /usr/bin/ant on + Redhat Linux systems will not work for compiling + &FindBugs;. We recommend you install a binary distribution of &Ant; + downloaded from the &Ant; website. + Make sure that when you run &Ant; your JAVA_HOME + environment variable points to the directory in which you installed + JDK 1.5 (or later). + + + + +If you want to be able to generate formatted versions of the &FindBugs; documentation, +you will also need the following software: + + + + The DocBook XSL Stylesheets. + These are required to convert the &FindBugs; manual into HTML format. + + + + + The &Saxon; XSLT Processor. + (Also required for converting the &FindBugs; manual to HTML.) + + + + + + + + + +Extracting the Source Distribution + +After you download the source distribution, you'll need to extract it into +a working directory. A typical command to do this is: + + +$ unzip findbugs-2.0.3-source.zip + + + + + + +Modifying <filename>local.properties</filename> + +If you intend to build the FindBugs documentation, +you will need to modify the local.properties file +used by the &Ant; +build.xml file to build &FindBugs;. +If you do not want to build the FindBugs documentation, then you +can ignore this file. + + + +The local.properties overrides definitions +in the build.properties file. +The build.properties file looks something like this: + + + + + + +The xsl.stylesheet.home property specifies the full +path to the directory where you have installed the +DocBook Modular XSL +Stylesheets. You only need to specify this property if you will be +generating the &FindBugs; documentation. + + + +The saxon.home property is the full path to the +directory where you installed the &Saxon; XSLT Processor. +You only need to specify this property if you will be +generating the &FindBugs; documentation. + + + + + +Running &Ant; + + +Once you have extracted the source distribution, +made sure that &Ant; is installed, +modified build.properties (optional), +and configured the tools (such as &Saxon;), +you are ready to build &FindBugs;. Invoking &Ant; is a simple matter +of running the command + +$ ant target + +where target is one of the following: + + + build + + + This target compiles the code for &FindBugs;. It is the default target. + + + + + + docs + + + This target formats the documentation. (It also compiles some of + the source code as a side-effect.) + + + + + + runjunit + + + This target compiles and runs the internal JUnit tests included + in &FindBugs;. It will print an error message if any unit + tests fail. + + + + + + bindist + + + Builds a binary distribution of &FindBugs;. + The target creates both .zip and + .tar.gz archives. + + + + + + + +After running an &Ant; command, you should see output similar to +the following (after some other messages regarding the tasks that +&Ant; is running): + + +BUILD SUCCESSFUL +Total time: 17 seconds + + + + + + + +Running &FindBugs;™ from a source directory + +The &Ant; build script for &FindBugs; is written such that after +building the build target, the working directory +is set up just like a binary distribution. So, the information about +running &FindBugs; in +applies to source distributions, too. + + + + + + + + + +Running &FindBugs;™ + + +&FindBugs; has two user interfaces: a graphical user interface (GUI) and a +command line user interface. This chapter describes +how to run each of these user interfaces. + + + + + This chapter is in the process of being re-written. + The rewrite is not complete yet. + + + + + + + Quick Start + + If you are running &FindBugs; on a Windows system, + double-click on the file &FBHomeWin;\lib\findbugs.jar to start the &FindBugs; GUI. + + + + On a Unix, Linux, or Mac OS X system, run the &FBHome;/bin/findbugs + script, or run the command +java -jar &FBHome;/lib/findbugs.jar + to run the &FindBugs; GUI. + + + + Refer to for information on how to use the GUI. + + + + + + Executing &FindBugs; + + + This section describes how to invoke the &FindBugs; program. + There are two ways to invoke &FindBugs;: directly, or using a + wrapper script. + + + + + Direct invocation of &FindBugs; + + + The preferred method of running &FindBugs; is to directly execute + &FBHome;/lib/findbugs.jar using the -jar + command line switch of the JVM (java) executable. + (Versions of &FindBugs; prior to 1.3.5 required a wrapper script + to invoke &FindBugs;.) + + + + The general syntax of invoking &FindBugs; directly is the following: + + java [JVM arguments] -jar &FBHome;/lib/findbugs.jar options... + + + + + + + Choosing the User Interface + + + The first command line option chooses the &FindBugs; user interface to execute. + Possible values are: + + + + + -gui: runs the graphical user interface (GUI) + + + + + + -textui: runs the command line user interface + + + + + + -version: displays the &FindBugs; version number + + + + + + -help: displays help information for the + &FindBugs; command line user interface + + + + + + -gui1: executes the original (obsolete) + &FindBugs; graphical user interface + + + + + + + + Java Virtual Machine (JVM) arguments + + + Several Java Virtual Machine arguments are useful when invoking + &FindBugs;. + + + + + -XmxNNm + + + Set the maximum Java heap size to NN + megabytes. &FindBugs; generally requires a large amount of + memory. For a very large project, using 1500 megabytes + is not unusual. + + + + + + -Dname=value + + + Set a Java system property. For example, you might use the + argument -Duser.language=ja to display + GUI messages in Japanese. + + + + + + + + + + + + Invocation of &FindBugs; using a wrapper script + + + Another way to run &FindBugs; is to use a wrapper script. + + + +On Unix-like systems, use the following command to invoke the wrapper script: + +$ &FBHome;/bin/findbugs options... + + + + +On Windows systems, the command to invoke the wrapper script is + +C:\My Directory>&FBHomeWin;\bin\findbugs.bat options... + + + + +On both Unix-like and Windows systems, you can simply add the $FINDBUGS_HOME/bin +directory to your PATH environment variable and then invoke +FindBugs using the findbugs command. + + + + Wrapper script command line options + The &FindBugs; wrapper scripts support the following command-line options. + Note that these command line options are not handled by + the &FindBugs; program per se; rather, they are handled by the wrapper + script. + + + + -jvmArgs args + + + Specifies arguments to pass to the JVM. For example, you might want + to set a JVM property: + +$ findbugs -textui -jvmArgs "-Duser.language=ja" myApp.jar + + + + + + + -javahome directory + + + Specifies the directory containing the JRE (Java Runtime Environment) to + use to execute &FindBugs;. + + + + + + -maxHeap size + + + Specifies the maximum Java heap size in megabytes. The default is 256. + More memory may be required to analyze very large programs or libraries. + + + + + + -debug + + + Prints a trace of detectors run and classes analyzed to standard output. + Useful for troubleshooting unexpected analysis failures. + + + + + + -property name=value + + + This option sets a system property.  &FindBugs; uses system properties + to configure analysis options. See . + You can use this option multiple times in order to set multiple properties. + Note: In most versions of Windows, the name=value + string must be in quotes. + + + + + + + + + + + + + +Command-line Options + + + + + This section describes the command line options supported by &FindBugs;. + These command line options may be used when invoking &FindBugs; directly, + or when using a wrapper script. + + + +Common command-line options + + +These options may be used with both the GUI and command-line interfaces. + + + + + + -effort:min + + + This option disables analyses that increase precision but also + increase memory consumption. You may want to try this option if + you find that &FindBugs; runs out of memory, or takes an unusually + long time to complete its analysis. + + + + + + + -effort:max + + + Enable analyses which increase precision and find more bugs, but which + may require more memory and take more time to complete. + + + + + + -project project + + + Specify a project to be analyzed. The project file you specify should + be one that was created using the GUI interface. It will typically end + in the extension .fb or .fbp. + + + + + + + + + + + +GUI Options + + +These options are only accepted by the Graphical User Interface. + + + + -look:plastic|gtk|native + + + Set Swing look and feel. + + + + + + + + + +Text UI Options + + +These options are only accepted by the Text User Interface. + + + + + -sortByClass + + + Sort reported bug instances by class name. + + + + + + -include filterFile.xml + + + Only report bug instances that match the filter specified by filterFile.xml. + See . + + + + + + -exclude filterFile.xml + + + Report all bug instances except those matching the filter specified by filterFile.xml. + See . + + + + + + -onlyAnalyze com.foobar.MyClass,com.foobar.mypkg.* + + + Restrict analysis to find bugs to given comma-separated list of + classes and packages. + Unlike filtering, this option avoids running analysis on + classes and packages that are not explicitly matched: + for large projects, this may greatly reduce the amount of time + needed to run the analysis. (However, some detectors may produce + inaccurate results if they aren't run on the entire application.) + Classes should be specified using their full classnames (including + package), and packages should be specified in the same way + they would in a Java import statement to + import all classes in the package (i.e., add .* + to the full name of the package). + Replace .* with .- to also + analyze all subpackages. + + + + + + -low + + + Report all bugs. + + + + + + -medium + + + Report medium and high priority bugs. This is the default setting. + + + + + + -high + + + Report only high priority bugs. + + + + + + -relaxed + + + Relaxed reporting mode. For many detectors, this option + suppresses the heuristics used to avoid reporting false positives. + + + + + + -xml + + + Produce the bug reports as XML. The XML data produced may be + viewed in the GUI at a later time. You may also specify this + option as -xml:withMessages; when this variant + of the option is used, the XML output will contain human-readable + messages describing the warnings contained in the file. + XML files generated this way are easy to transform into reports. + + + + + + -html + + + Generate HTML output. By default, &FindBugs; will use the default.xsl + XSLT + stylesheet to generate the HTML: you can find this file in findbugs.jar, + or in the &FindBugs; source or binary distributions. Variants of this option include + -html:plain.xsl, -html:fancy.xsl and -html:fancy-hist.xsl. + The plain.xsl stylesheet does not use Javascript or DOM, + and may work better with older web browsers, or for printing. The fancy.xsl + stylesheet uses DOM and Javascript for navigation and CSS for + visual presentation. The fancy-hist.xsl an evolution of fancy.xsl stylesheet. + It makes an extensive use of DOM and Javascript for dynamically filtering the lists of bugs. + + + + If you want to specify your own + XSLT stylesheet to perform the transformation to HTML, specify the option as + -html:myStylesheet.xsl, + where myStylesheet.xsl is the filename of the + stylesheet you want to use. + + + + + + -emacs + + + Produce the bug reports in Emacs format. + + + + + + -xdocs + + + Produce the bug reports in xdoc XML format for use with Apache Maven. + + + + + + -output filename + + + Produce the output in the specified file. + + + + + + -outputFile filename + + + This argument is deprecated. Use -output instead. + + + + + + -nested[:true|false] + + + This option enables or disables scanning of nested jar and zip files found in + the list of files and directories to be analyzed. + By default, scanning of nested jar/zip files is enabled. + To disable it, add -nested:false to the command line + arguments. + + + + + + -auxclasspath classpath + + + Set the auxiliary classpath for analysis. This classpath should include all + jar files and directories containing classes that are part of the program + being analyzed but you do not want to have analyzed for bugs. + + + + + + -userPrefs edu.umd.cs.findbugs.core.prefs + + + Set the path of the user preferences file to use, which might override some of the options abobe. + Specifying userPrefs as first argument would mean some later + options will override them, as last argument would mean they will override some previous options). + This rationale behind this option is to reuse FindBugs Eclipse project settings for command + line execution. + + + + + + + + + + + + + + + + Using the &FindBugs; GUI + + + This chapter describes how to use the &FindBugs; graphical user interface (GUI). + + + +Creating a Project + +After you have started &FindBugs; using the findbugs command, +choose the FileNew Project +menu item. You will see a dialog which looks like this: + + + + + + + + +Use the "Add" button next to "Classpath to analyze" to select a Java archive +file (zip, jar, ear, or war file) or directory containing java classes to analyze for bugs. You may add multiple +archives/directories. + + + +You can also add the source directories which contain +the source code for the Java archives you are analyzing. This will enable +&FindBugs; to highlight the source code which contains a possible error. +The source directories you add should be the roots of the Java +package hierarchy. For example, if your application is contained in the +org.foobar.myapp package, you should add the +parent directory of the org directory +to the source directory list for the project. + + + +Another optional step is to add additional Jar files or directories as +"Auxiliary classpath locations" entries. You should do this if the archives and directories you are analyzing +have references to other classes which are not included in the analyzed +archives/directories and are not in the standard runtime classpath. Some of the bug +pattern detectors in &FindBugs; make use of class hierarchy information, +so you will get more accurate results if the entire class hierarchy is +available which &FindBugs; performs its analysis. + + + + + +Running the Analysis + +Once you have added all of the archives, directories, and source directories, +click the "Analyze" button to analyze the classes contained in the +Jar files. Note that for a very large program on an older computer, +this may take quite a while (tens of minutes). A recent computer with +ample memory will typically be able to analyze a large program in only a +few minutes. + + + + +Browsing Results + + +When the analysis completes, you will see a screen like the following: + + + + + + + + +The upper left-hand pane of the window shows the bug tree; this is a hierarchical +representation of all of the potential bugs detected in the analyzed +Jar files. + + + +When you select a particular bug instance in the top pane, you will +see a description of the bug in the "Details" tab of the bottom pane. +In addition, the source code pane on the upper-right will show the +program source code where the potential bug occurs, if source is available. +In the above example, the bug is a stream object that is not closed. The +source code window highlights the line where the stream object is created. + + + +You may add a textual annotations to bug instances. To do so, type them +into the text box just below the hierarchical view. You can type any +information which you would like to record. When you load and save bug +results files, the annotations are preserved. + + + + + +Saving and Opening + + +You may use the FileSave as... +menu option to save your work. To save your work, including the jar +file lists you specified and all bug results, choose +"FindBugs analysis results (.xml)" from the drop-down list in the +"Save as..." dialog. There are also options for saving just the jar +file lists ("FindBugs project file (.fbp)") or just the results +("FindBugs analysis file (.fba)"). +A saved file may be loaded with the +FileOpen... +menu option. + + + + + + + + + + + +Using the &FindBugs;™ &Ant; task + + +This chapter describes how to integrate &FindBugs; into a build script +for &Ant;, which is a popular Java build +and deployment tool. Using the &FindBugs; &Ant; task, your build script can +automatically run &FindBugs; on your Java code. + + + +The &Ant; task was generously contributed by Mike Fagan. + + + +Installing the &Ant; task + + +To install the &Ant; task, simply copy &FBHome;/lib/findbugs-ant.jar +into the lib subdirectory of your &Ant; installation. + + +It is strongly recommended that you use the &Ant; task with the version +of &FindBugs; it was included with. We do not guarantee that the &Ant; task Jar file +will work with any version of &FindBugs; other than the one it was included with. + + + + + + +Modifying build.xml + + +To incorporate &FindBugs; into build.xml (the build script +for &Ant;), you first need to add a task definition. This should appear as follows: + + + <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/> + + +The task definition specifies that when a findbugs element is +seen in build.xml, it should use the indicated class to execute the task. + + + +After you have added the task definition, you can define a target +which uses the findbugs task. Here is an example +which could be added to the build.xml for the +Apache BCEL library. + + + <property name="findbugs.home" value="/export/home/daveho/work/findbugs" /> + + <target name="findbugs" depends="jar"> + <findbugs home="${findbugs.home}" + output="xml" + outputFile="bcel-fb.xml" > + <auxClasspath path="${basedir}/lib/Regex.jar" /> + <sourcePath path="${basedir}/src/java" /> + <class location="${basedir}/bin/bcel.jar" /> + </findbugs> + </target> + + +The findbugs element must have the home +attribute set to the directory in which &FindBugs; is installed; in other words, +&FBHome;. See . + + + +This target will execute &FindBugs; on bcel.jar, which is the +Jar file produced by BCEL's build script. (By making it depend on the "jar" +target, we ensure that the library is fully compiled before running &FindBugs; on it.) +The output of &FindBugs; will be saved in XML format to a file called +bcel-fb.xml. +An auxiliary Jar file, Regex.jar, is added to the aux classpath, +because it is referenced by the main BCEL library. A source path is specified +so that the saved bug data will have accurate references to the BCEL source code. + + + + +Executing the task + + +Here is an example of invoking &Ant; from the command line, using the findbugs +target defined above. + + + [daveho@noir]$ ant findbugs + Buildfile: build.xml + + init: + + compile: + + examples: + + jar: + + findbugs: + [findbugs] Running FindBugs... + [findbugs] Bugs were found + [findbugs] Output saved to bcel-fb.xml + + BUILD SUCCESSFUL + Total time: 35 seconds + + +In this case, because we saved the bug results in an XML file, we can +use the &FindBugs; GUI to view the results; see . + + + + + +Parameters + +This section describes the parameters that may be specified when +using the &FindBugs; task. + + + + + class + + + A optional nested element specifying which classes to analyze. The class + element must specify a location attribute which names the + archive file (jar, zip, etc.), directory, or class file to be analyzed. Multiple class + elements may be specified as children of a single findbugs element. + + In addition to or instead of specifying a class element, + the &FindBugs; task can contain one or more fileset element(s) that + specify files to be analyzed. + For example, you might use a fileset to specify that all of the jar files in a directory + should be analyzed. + + + + + + auxClasspath + + + An optional nested element which specifies a classpath (Jar files or directories) + containing classes used by the analyzed library or application, but which + you don't want to analyze. It is specified the same way as + &Ant;'s classpath element for the Java task. + + + + + + sourcePath + + + An optional nested element which specifies a source directory path + containing source files used to compile the Java code being analyzed. + By specifying a source path, any generated XML bug output will have + complete source information, which allows later viewing in the + GUI. + + + + + + home + + + A required attribute. + It must be set to the name of the directory where &FindBugs; is installed. + + + + + + quietErrors + + + An optional boolean attribute. + If true, reports of serious analysis errors and missing classes will + be suppressed in the &FindBugs; output. Default is false. + + + + + + reportLevel + + + An optional attribute. It specifies + the confidence/priority threshold for reporting issues. If set to "low", confidence is not used to filter bugs. + If set to "medium" (the default), low confidence issues are supressed. + If set to "high", only high confidence bugs are reported. + + + + + + output + + + Optional attribute. + It specifies the output format. If set to "xml" (the default), output + is in XML format. + If set to "xml:withMessages", output is in XML format augmented with + human-readable messages. (You should use this format if you plan + to generate a report using an XSL stylesheet.) + If set to "html", output is in HTML formatted (default stylesheet is default.xsl). + If set to "text", output is in ad-hoc text format. + If set to "emacs", output is in Emacs error message format. + If set to "xdocs", output is xdoc XML for use with Apache Maven. + + + + + stylesheet + + + Optional attribute. + It specifies the stylesheet to use to generate html output when the output is set to html. + Stylesheets included in the FindBugs distribution include default.xsl, fancy.xsl, fancy-hist.xsl, plain.xsl, and summary.xsl. + The default value, if no stylesheet attribute is provided, is default.xsl. + + + + + + + sort + + + Optional attribute. If the output attribute + is set to "text", then the sort attribute specifies + whether or not reported bugs are sorted by class. Default is true. + + + + + + outputFile + + + Optional attribute. If specified, names the output file in which the + &FindBugs; output will be saved. By default, the output is displayed + directly by &Ant;. + + + + + + debug + + + Optional boolean attribute. If set to true, &FindBugs; prints diagnostic + information about which classes are being analyzed, and which bug pattern + detectors are being run. Default is false. + + + + + + effort + + + Set the analysis effort level. The value specified should be + one of min, default, + or max. See + for more information about setting the analysis level. + + + + + + conserveSpace + + Synonym for effort="min". + + + + + workHard + + Synonym for effort="max". + + + + + visitors + + + Optional attribute. It specifies a comma-separated list of bug detectors + which should be run. The bug detectors are specified by their class names, + without any package qualification. By default, all detectors which are + not disabled by default are run. + + + + + + omitVisitors + + + Optional attribute. It is like the visitors attribute, + except it specifies detectors which will not be run. + + + + + + excludeFilter + + + Optional attribute. It specifies the filename of a filter specifying bugs + to exclude from being reported. See . + + + + + + includeFilter + + + Optional attribute. It specifies the filename of a filter specifying + which bugs are reported. See . + + + + + + projectFile + + + Optional attribute. It specifies the name of a project file. + Project files are created by the &FindBugs; GUI, and specify classes, + aux classpath entries, and source directories. By naming a project, + you don't need to specify any class elements, + nor do you need to specify auxClasspath or + sourcePath attributes. + See for how to create a project. + + + + + + jvmargs + + + Optional attribute. It specifies any arguments that should be passed + to the Java virtual machine used to run &FindBugs;. You may need to + use this attribute to specify flags to increase the amount of memory + the JVM may use if you are analyzing a very large program. + + + + + + systemProperty + + + Optional nested element. If specified, defines a system property. + The name attribute specifies the name of the + system property, and the value attribute specifies + the value of the system property. + + + + + + timeout + + + Optional attribute. It specifies the amount of time, in milliseconds, + that the Java process executing &FindBugs; may run before it is + assumed to be hung and is terminated. The default is 600,000 + milliseconds, which is ten minutes. Note that for very large + programs, &FindBugs; may require more than ten minutes to complete its + analysis. + + + + + + failOnError + + + Optional boolean attribute. Whether to abort the build process if there is an + error running &FindBugs;. Defaults to "false" + + + + + + errorProperty + + + Optional attribute which specifies the name of a property that + will be set to "true" if an error occurs while running &FindBugs;. + + + + + + warningsProperty + + + Optional attribute which specifies the name of a property + that will be set to "true" if any warnings are reported by + &FindBugs; on the analyzed program. + + + + + + userPreferencesFile + + + Optional attribute. Set the path of the user preferences file to use, which might override some of the options abobe. + Specifying userPreferencesFile as first argument would mean some later + options will override them, as last argument would mean they will override some previous options). + This rationale behind this option is to reuse FindBugs Eclipse project settings for command + line execution. + + + + + + + + + + + + + + + + + + +Using the &FindBugs;™ Eclipse plugin + + +The FindBugs Eclipse plugin allows &FindBugs; to be used within +the Eclipse IDE. +The FindBugs Eclipse plugin was generously contributed by Peter Friese. +Phil Crosby and Andrei Loskutov contributed major improvements +to the plugin. + + + +Requirements + + +To use the &FindBugs; Plugin for Eclipse, you need Eclipse 3.3 or later, +and JRE/JDK 1.5 or later. + + + + + +Installation + + + We provide update sites that allow you to automatically install FindBugs into Eclipse and also query and install updates. + There are three different update sites + + FindBugs Eclipse update sites + http://findbugs.cs.umd.edu/eclipse/ + + + + Only provides official releases of FindBugs. + + + + + http://findbugs.cs.umd.edu/eclipse-candidate/ + + + + Provides official releases and release candidates of FindBugs. + + + + + http://findbugs.cs.umd.edu/eclipse-daily/ + + + + Provides the daily build of FindBugs. No testing other than that it compiles. + + + + + +You can also manually +download the plugin from the following link: +http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download. +Extract it in Eclipse's "plugins" subdirectory. +(So <eclipse_install_dir>/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png +should be the path to the &FindBugs; logo.) + + + + +Once the plugin is extracted, start Eclipse and choose + + Help + About Eclipse Platform + Plug-in Details +. +You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project". + + + + +Using the Plugin + + +To get started, right click on a Java project in Package Explorer, +and select the option labeled "Find Bugs". +&FindBugs; will run, and problem markers (displayed in source +windows, and also in the Eclipse Problems view) will point to +locations in your code which have been identified as potential instances +of bug patterns. + + +You can also run &FindBugs; on existing java archives (jar, ear, zip, war etc). Simply +create an empty Java project and attach archives to the project classpath. Having that, you +can now right click the archive node in Package Explorer and select the option labeled +"Find Bugs". If you additionally configure the source code locations for the binaries, +&FindBugs; will also link the generated warnings to the right source files. + + +You may customize how &FindBugs; runs by opening the Properties +dialog for a Java project, and choosing the "Findbugs" property page. +Options you may choose include: + + + + + + Enable or disable the "Run FindBugs Automatically" checkbox. + When enabled, FindBugs will run every time you modify a Java class + within the project. + + + + + + Choose minimum warning priority and enabled bug categories. + These options will choose which warnings are shown. + For example, if you select the "Medium" warning priority, + only Medium and High priority warnings will be shown. + Similarly, if you uncheck the "Style" checkbox, no warnings + in the Style category will be displayed. + + + + + + Select detectors. The table allows you to select which detectors + you want to enable for your project. + + + + + + + +Extending the Eclipse Plugin (since 2.0.0) + +Eclipse plugin supports contribution of custom &FindBugs; detectors (see also +AddingDetectors.txt +for more information). There are two ways to contribute custom plugins to the Eclipse: + + + + + Existing standard &FindBugs; detector packages can be configured via + + Window + Preferences + Java + &FindBugs; + Misc. Settings + Custom Detectors + . + Simply specify there locations of any additional plugin libraries. + + + + The benefit of this solution is that already existing detector packages can be + used "as is", and that you can quickly verify the quality of third party detectors. + The drawback is that you have to apply this settings in each + new Eclipse workspace, and this settings can't be shared between team members. + + + + + + It is possible to contribute custom detectors via standard Eclipse extensions mechanism. + + + + Please check the documentation of the + + findBugsEclipsePlugin/schema/detectorPlugins.exsd + extension point how to update the plugin.xml. Existing &FindBugs; detector plugins can + be easily "extended" to be full featured &FindBugs; AND Eclipse detector plugins. + Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and + update your build scripts to not to override the MANIFEST.MF during the build. + + + + The benefit of this solution is that for given (shared) Eclipse installation + each team member has exactly same detectors set, and there is no need to configure + anything anymore. The (really small) precondition + is that you have to convert your existing detectors package to the valid + Eclipse plugin. You can do this even for third-party detector packages. + Another major differentiator is the ability to extend the default FindBugs + classpath at runtime with required third party libraries (see + AddingDetectors.txt + for more information). + + + + + + + + +Troubleshooting + + +This section lists common problems with the plugin and (if known) how to resolve them. + + + + + + If you see OutOfMemory error dialogs after starting &FindBugs; analysis in Eclipse, + please increase JVM available memory: change eclipse.ini and add the lines below + to the end of the file: + + -vmargs + -Xmx1000m + + Important: the configuration arguments starting with the line "-vmargs" must + be last lines in the eclipse.ini file, and only one argument per line is allowed! + + + + + If you do not see any &FindBugs; problem markers (in your source + windows or in the Problems View), you may need to change your + Problems View filter settings. See + http://findbugs.sourceforge.net/FAQ.html#q7 for more information. + + + + + + + + + + + + + + +Filter Files + + +Filter files may be used to include or exclude bug reports for particular classes +and methods. This chapter explains how to use filter files. + + +Planned Features + + Filters are currently only supported by the Command Line interface. + Eventually, filter support will be added to the GUI. + + + + + + +Introduction to Filter Files + + +Conceptually, a filter matches bug instances against a set of criteria. +By defining a filter, you can select bug instances for special treatment; +for example, to exclude or include them in a report. + + + +A filter file is an XML document with a top-level FindBugsFilter element +which has some number of Match elements as children. Each Match +element represents a predicate which is applied to generated bug instances. +Usually, a filter will be used to exclude bug instances. For example: + + +$ findbugs -textui -exclude myExcludeFilter.xml myApp.jar + + +However, a filter could also be used to select bug instances to specifically +report: + + +$ findbugs -textui -include myIncludeFilter.xml myApp.jar + + + + +Match elements contain children, which are conjuncts of the predicate. +In other words, each of the children must be true for the predicate to be true. + + + + + +Types of Match clauses + + + + <Bug> + + This element specifies a particular bug pattern or patterns to match. + The pattern attribute is a comma-separated list of + bug pattern types. You can find the bug pattern types for particular + warnings by looking at the output produced by the -xml + output option (the type attribute of BugInstance + elements), or from the bug + descriptions document. + + For more coarse-grained matching, use code attribute. It takes + a comma-separated list of bug abbreviations. For most-coarse grained matching use + category attriute, that takes a comma separated list of bug category names: + CORRECTNESS, MT_CORRECTNESS, + BAD_PRACTICICE, PERFORMANCE, STYLE. + + If more than one of the attributes mentioned above are specified on the same + <Bug> element, all bug patterns that match either one of specified + pattern names, or abreviations, or categories will be matched. + + As a backwards compatibility measure, <BugPattern> and + <BugCode> elements may be used instead of + <Bug> element. Each of these uses a + name attribute for specifying accepted values list. Support for these + elements may be removed in a future release. + + + + + <Confidence> + + + This element matches warnings with a particular bug confidence. + The value attribute should be an integer value: + 1 to match high-confidence warnings, 2 to match normal-confidence warnings, + or 3 to match low-confidence warnings. <Confidence> replaced + <Priority> in 2.0.0 release. + + + + + + <Priority> + + + Same as <Confidence>, exists for backward compatibility. + + + + + + <Rank> + + + This element matches warnings with a particular bug rank. + The value attribute should be an integer value + between 1 and 20, where 1 to 4 are scariest, 5 to 9 scary, 10 to 14 troubling, + and 15 to 20 of concern bugs. + + + + + + <Package> + + + This element matches warnings associated with classes within the package specified + using name attribute. Nested packages are not included (along the + lines of Java import statement). However matching multiple packages can be achieved + easily using regex name match. + + + + + + <Class> + + + This element matches warnings associated with a particular class. The + name attribute is used to specify the exact or regex match pattern + for the class name. + + + + As a backward compatibility measure, instead of element of this type, you can use + class attribute on a Match element to specify + exact an class name or classregex attribute to specify a regular + expression to match the class name against. + + + + If the Match element contains neither a Class element, + nor a class / classregex attribute, the predicate will apply + to all classes. Such predicate is likely to match more bug instances than you want, unless it is + refined further down with apropriate method or field predicates. + + + + + + <Method> + + This element specifies a method. The name is used to specify + the exact or regex match pattern for the method name. + The params attribute is a comma-separated list + of the types of the method's parameters. The returns attribute is + the method's return type. In params and returns, class names + must be fully qualified. (E.g., "java.lang.String" instead of just + "String".) If one of the latter attributes is specified the other is required for creating a method signature. + Note that you can provide either name attribute or params + and returns attributes or all three of them. This way you can provide various kinds of + name and signature based matches. + + + + + <Field> + + This element specifies a field. The name attribute is is used to specify + the exact or regex match pattern for the field name. You can also filter fields according to their signature - + use type attribute to specify fully qualified type of the field. You can specify eiter or both + of these attributes in order to perform name / signature based matches. + + + + + <Local> + + This element specifies a local variable. The name attribute is is used to specify + the exact or regex match pattern for the local variable name. Local variables are variables defined within a method. + + + + + <Or> + + This element combines Match clauses as disjuncts. I.e., you can put two + Method elements in an Or clause in order to match either method. + + + + <And> + + This element combines Match clauses which both must evaluate to true. I.e., you can put + Bug and Priority elements in an And clause in order + to match specific bugs with given priority only. + + + + <Not> + + This element inverts the included child Match. I.e., you can put a + Bug element in a Not clause in order to match any bug + excluding the given one. + + + + + + + +Java element name matching + + +If the name attribute of Class, Method or +Field starts with the ~ character the rest of attribute content is interpreted as +a Java regular expression that is matched against the names of the Java element in question. + + + +Note that the pattern is matched against whole element name and therefore .* clauses need to be used +at pattern beginning and/or end to perform substring matching. + + + +See java.util.regex.Pattern +documentation for pattern syntax. + + + + +Caveats + + +Match clauses can only match information that is actually contained in the +bug instances. Every bug instance has a class, so in general, excluding +bugs by class will work. + + + +Some bug instances have two (or more) classes. For example, the DE (dropped exception) +bugs report both the class containing the method where the dropped exception +happens, and the class which represents the type of the dropped exception. +Only the first (primary) class is matched against Match clauses. +So, for example, if you want to suppress IC (initialization circularity) +reports for classes "com.foobar.A" and "com.foobar.B", you would use +two Match clauses: + + + <Match> + <Class name="com.foobar.A" /> + <Bug code="IC" /> + </Match> + + <Match> + <Class name="com.foobar.B" /> + <Bug code="IC" /> + </Match> + + +By explicitly matching both classes, you ensure that the IC bug instance will be +matched regardless of which class involved in the circularity happens to be +listed first in the bug instance. (Of course, this approach might accidentally +supress circularities involving "com.foobar.A" or "com.foobar.B" and a third +class.) + + + +Many kinds of bugs report what method they occur in. For those bug instances, +you can put Method clauses in the Match element and they should work +as expected. + + + + + +Examples + + + 1. Match all bug reports for a class. + + + + +
    +]]> + + + + + + 2. Match certain tests from a class by specifying their abbreviations. + + + + + +]]> + + + + + 3. Match certain tests from all classes by specifying their abbreviations. + + + + + +]]> + + + + + 4. Match certain tests from all classes by specifying their category. + + + + + +]]> + + + + + 5. Match bug types from specified methods of a class by their abbreviations. + + + + + + + + + + +]]> + + + + + 6. Match a particular bug pattern in a particular method. + + + + + + + + +]]> + + + + + 7. Match a particular bug pattern with a given priority in a particular method. + + + + + + + + + +]]> + + + + + 8. Match minor bugs introduced by AspectJ compiler (you are probably not interested in these unless + you are an AspectJ developer). + + + + + + + + + + + +]]> + + + + + 9. Match bugs in specific parts of the code base + + + + + + + + + + + + + + + + + +]]> + + + + + 10. Match bugs on fields or methods with specific signatures + + + + + + + + + + + +]]> + + + + + + 11. Match bugs using the Not filter operator + + + + + + + + + + + + + +]]> + + + + + + +Complete Example + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + + + +Analysis Properties + + +&FindBugs; allows several aspects of the analyses it performs to be +customized. System properties are used to configure these options. +This chapter describes the configurable analysis options. + + + +The analysis options have two main purposes. First, they allow you +to inform &FindBugs; about the meaning of methods in your application, +so that it can produce more accurate results, or produce fewer +false warnings. Second, they allow you to configure the precision +of the analysis performed. Reducing analysis precision can save +memory and analysis time, at the expense of missing some real bugs, +or producing more false warnings. + + + +The analysis options are set using the -property +command line option. For example: + +$ findbugs -textui -property "cfg.noprune=true" myApp.jar + + + + +The list of configurable analysis properties is shown in +. + + + +Configurable Analysis Properties + + + + Property Name + Value + Meaning + + + + + + findbugs.assertionmethods + Comma-separated list of fully qualified method names: + e.g., "com.foo.MyClass.checkAssertion" + This property specifies the names of methods that are used + to check program assertions. Specifying these methods allows + the null pointer dereference bug detector to avoid reporting + false warnings for values which are checked by assertion + methods. + + + findbugs.de.comment + true or false + If true, the DroppedException detector scans source code + for empty catch blocks for a comment, and if one is found, does + not report a warning. + + + findbugs.maskedfields.locals + true or false + If true, emit low priority warnings for local variables + which obscure fields. Default is false. + + + findbugs.nullderef.assumensp + true or false + not used + (intention: If true, the null dereference detector assumes that any + reference value returned from a method or passed to a method + in a parameter might be null. Default is false. Note that + enabling this property will very likely cause a large number + of false warnings to be produced.) + + + findbugs.refcomp.reportAll + true or false + If true, all suspicious reference comparisons + using the == and != operators are reported.  If false, + only one such warning is issued per method.  Default + is false. + + + findbugs.sf.comment + true or false + If true, the SwitchFallthrough detector will only report + warnings for cases where the source code does not have a comment + containing the words "fall" or "nobreak". (An accurate source + path must be used for this feature to work correctly.) + This helps find cases where the switch fallthrough is likely + to be unintentional. + + + + +
    + +
    + + + + +Annotations + + +&FindBugs; supports several annotations to express the developer's intent +so that FindBugs can issue warnings more appropriately. You need to use +Java 5 to use annotations, and must place the annotations.jar and jsr305.jar +files in the classpath while compiling your program. + + + + + edu.umd.cs.findbugs.annotations.CheckForNull + +[Target] Field, Method, Parameter + + + +The annotated element might be null, and uses of the element should check for null. +When this annotation is applied to a method it applies to the method return value. + + + + + + edu.umd.cs.findbugs.annotations.CheckReturnValue + + [Target] Method, Constructor + + + + + [Parameter] + + + priority:The priority of the warning (HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. + + + + + explanation:A textual explaination of why the return value should be checked. Default value:"". + + + + + + + +This annotation is used to denote a method whose return value should always be checked after invoking the method. + + + + + + edu.umd.cs.findbugs.annotations.DefaultAnnotation + + [Target] Type, Package + + + + + [Parameter] + + + value:Annotation class objects. More than one class can be specified. + + + + + priority:Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. + + + + + + + +Indicates that all members of the class or package should be annotated with the default +value of the supplied annotation classes. This would be used for behavior annotations +such as @NonNull, @CheckForNull, or @CheckReturnValue. In particular, you can use +@DefaultAnnotation(NonNull.class) on a class or package, and then use @Nullable only +on those parameters, methods or fields that you want to allow to be null. + + + + + + edu.umd.cs.findbugs.annotations.DefaultAnnotationForFields + + [Target] Type, Package + + + + + [Parameter] + + + value:Annotation class objects. More than one class can be specified. + + + + + priority:Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. + + + + + + + +This is same as the DefaultAnnotation except it only applys to fields. + + + + + + edu.umd.cs.findbugs.annotations.DefaultAnnotationForMethods + + [Target] Type, Package + + + + + [Parameter] + + + value:Annotation class objects. More than one class can be specified. + + + + + priority:Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. + + + + + + + +This is same as the DefaultAnnotation except it only applys to methods. + + + + + + edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters + + [Target] Type, Package + + + + + [Parameter] + + + value:Annotation class objects. More than one class can be specified. + + + + + priority:Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM. + + + + + + + +This is same as the DefaultAnnotation except it only applys to method parameters. + + + + + + edu.umd.cs.findbugs.annotations.NonNull + + [Target] Field, Method, Parameter + + + +The annotated element must not be null. +Annotated fields must not be null after construction has completed. Annotated methods must have non-null return values. + + + + + + edu.umd.cs.findbugs.annotations.Nullable + + [Target] Field, Method, Parameter + + + +The annotated element could be null under some circumstances. In general, this means +developers will have to read the documentation to determine when a null value is +acceptable and whether it is neccessary to check for a null value. FindBugs will +treat the annotated items as though they had no annotation. + + +In pratice this annotation is useful only for overriding an overarching NonNull +annotation. + + + + + + edu.umd.cs.findbugs.annotations.OverrideMustInvoke + + [Target] Method + + + + + [Parameter] + + + value:Specify when the super invocation should be + performed (FIRST, ANYTIME, LAST). Default value:ANYTIME. + + + + + + + +Used to annotate a method that, if overridden, must (or should) be invoke super +in the overriding method. Examples of such methods include finalize() and clone(). +The argument to the method indicates when the super invocation should occur: +at any time, at the beginning of the overriding method, or at the end of the overriding method. +(This anotation is not implmemented in FindBugs as of September 8, 2006). + + + + + + edu.umd.cs.findbugs.annotations.PossiblyNull + + +This annotation is deprecated. Use CheckForNull instead. + + + + + + edu.umd.cs.findbugs.annotations.SuppressWarnings + + [Target] Type, Field, Method, Parameter, Constructor, Package + + + + + [Parameter] + + + value:The name of the warning. More than one name can be specified. + + + + + justification:Reason why the warning should be ignored. Default value:"". + + + + + + + +The set of warnings that are to be suppressed by the compiler in the annotated element. +Duplicate names are permitted. The second and successive occurrences of a name are ignored. +The presence of unrecognized warning names is not an error: Compilers +must ignore any warning names they do not recognize. They are, however, free to emit a +warning if an annotation contains an unrecognized warning name. Compiler vendors should +document the warning names they support in conjunction with this annotation type. They +are encouraged to cooperate to ensure that the same names work across multiple compilers. + + + + + + edu.umd.cs.findbugs.annotations.UnknownNullness + + [Target] Field, Method, Parameter + + + +Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. + + + + + + edu.umd.cs.findbugs.annotations.UnknownNullness + + [Target] Field, Method, Parameter + + + +Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. + + + + + + + &FindBugs; also supports the following annotations: + + net.jcip.annotations.GuardedBy + net.jcip.annotations.Immutable + net.jcip.annotations.NotThreadSafe + net.jcip.annotations.ThreadSafe + + + +You can refer the JCIP annotation +API documentation at Java Concurrency in Practice. + + + + + + +Using rejarForAnalysis + + +If your project consists of many jarfiles or the jarfiles are scattered +over many directories, you may wish to use the rejarForAnalysis + script to make +FindBugs invocation easier. The script collects many jarfiles and combines them +into a single, large jarfile that can then be easily passed to FindBugs for +analysis. This can be particularly useful in combination with the 'find' command +on unix systems; e.g. find . -name '*.jar' | xargs rejarForAnalysis +. + + + +The rejarForAnalysis script +can also be used to split a very large project up into a set of jarfiles with +the project classfiles evenly divided between them. This is useful when running +FindBugs on the entire project is not practical due to time or memory consumption. +Instead of running FindBugs on the entire project, you may use +rejarForAnalysis build one large, all-inclusive jarfile +containing all classes, invoke rejarForAnalysis +again to split the project into multiple jarfiles, then run FindBugs +on each divided jarfiles in turn, specifying the the all-inclusive jarfile in +the -auxclasspath. + + + +These are the options accepted by the rejarForAnalysis script: + + + + + -maxAge days + + + Maximum age in days (ignore jar files older than this). + + + + + -inputFileList filename + + + Text file containing names of jar files. + + + + + -maxClasses num + + + Maximum number of classes per analysis*.jar file. + + + + + -prefix class name prefix + + + Prefix of class names that should be analyzed (e.g., edu.umd.cs.). + + + + + + + + + + Data mining of bugs with &FindBugs;™ + + +FindBugs incorporates an ability to perform sophisticated queries on bug +databases and track warnings across multiple versions of code being +studied, allowing you to do things such as seeing when a bug was first introduced, examining +just the warnings that have been introduced since the last release, or graphing the number +of infinite recursive loops in your code over time. + + +These techniques all depend upon the XML format used by FindBugs for storing warnings. +These XML files usually contain just the warnings from one particular analysis run, but +they can also store the results from analyzing a sequence of software builds or versions. + + + +Any FindBugs XML bug database contains a version name and timestamp. +FindBugs tries to compute a timestamp from the timestamps of the files that +are analyzed (e.g., the timestamp is intended to be the time the class files +were generated, not analyzed). Each bug database also contains a version name. +Both the version name and timestamp can be set manually using the +setBugDatabaseInfo () command. + + +A multiversion bug database assigns a sequence number to each version of +the analyzed code. These sequence numbers are simply successive integers, +starting at 0 (e.g., a bug database for 4 versions of the code will contain +versions 0..3). The bug database will also record the name and timestamp for +each version. The filterBugs command allows you to refer +to a version by sequence number, name or timestamp. + + +You can take a sequence (or pair) of single version bug databases and create +from them a multiversion bug database, or combine a multiversion bug database +with a sequence of later single-version bug databases. + + +Some of these commands can be invoked as ant tasks. See below for specifics +on how to invoke them and what attributes and arguments they take. All of +the examples assume that the findbugs.lib +refid is set correctly. Here is one way to set it: + + + + + + + + + + +]]> + + + + Commands + + +All tools for FindBugs data mining are can be invoked from the command line, +and some of the more useful tools can also be invoked from an +ant build file. + + +Briefly, the command-line tools are: + + + + unionBugs + + + combine the results from separate analysis of disjoint + classes + + + + + computeBugHistory + + Merge bug warnings from multiple versions of + analyzed code into + a single multiversion bug database. This can either be used + to add more versions to an existing multiversion database, + or to create a multiversion database from a sequence of single version + bug warning databases. + + + + setBugDatabaseInfo + + Set information such as the revision name or +timestamp in an XML bug database + + + + listBugDatabaseInfo + + List information such as the revision name and +timestamp for a list of XML bug databases + + + + filterBugs + + Select a subset of a bug database + + + + mineBugHistory + + Generate a tabular listing of the number of warnings in each + version of a multiversion bug database + + + + defectDensity + + List information about defect density + (warnings per 1000 NCSS) + for the entire project and each class and package + + + + convertXmlToText + + Convert bug warnings in XML format to + a textual one-line-per-bug format, or to HTML + + + + + + + unionBugs + + + If you have, for example, separately analyzing each jar file used in an application, + you can use this command to combine the separately generated xml bug warning files into + a single file containing all of the warnings. + + Do not use this command to combine results from analyzing different versions of the same + file; use computeBugHistory instead. + + Specify the xml files on the command line. The result is sent to standard output. + + + + computeBugHistory + +Use this command to generate a bug database containing information from different builds or versions +of software you are analyzing. +History is taken from the first file provided as input; any following +files should be single version bug databases (if they contain history, the history in those +files will be ignored). +By default, output is written to the standard output. + + +This functionality may also can be accessed from ant. +First create a taskdef for computeBugHistory in your +build file: + + + + + + +]]> + + +Attributes for this ant task are listed in the following table. +To specify input files, nest them inside with a +<datafile> element. For example: + + + + + + + +]]> + + + + Options for computeBugHistory command + + + + Command-line option + Ant attribute + Meaning + + + +-output <file> output="<file>" save output in the named file (may also be an input file) +-overrideRevisionNames[:truth] overrideRevisionNames="[true|false]"override revision names for each version with names computed from the filenames +-noPackageMoves[:truth] noPackageMoves="[true|false]"if a class has moved to another package, treat warnings in that class as seperate +-preciseMatch[:truth] preciseMatch="[true|false]"require bug patterns to match precisely +-precisePriorityMatch[:truth] precisePriorityMatch="[true|false]"consider two warnings as the same only if priorities match exactly +-quiet[:truth] quiet="[true|false]"don't generate any output to standard out unless there is an error +-withMessages[:truth] withMessages="[true|false]"include human-readable messages describing the warnings in XML output + + +
    + +
    + + filterBugs +This command is used to select a subset of warnings from a FindBugs XML warning file +and write the selected subset to a new FindBugs warning file. + +This command takes a sequence of options, and either zero, one or two +filenames of findbugs xml bug files on the command line. +If no file names are provided, the command reads from standard input +and writes to standard output. If one file name is provided, +it reads from the file and writes to standard output. +If two file names are provided, it reads from the first and writes the output +to the second file name. + +This functionality may also can be accessed from ant. +First create a taskdef for filterBugs in your +build file: + + + + + + +]]> + + +Attributes for this ant task are listed in the following table. +To specify an input file either use the input attribute or nest it inside +the ant call with a <datafile> element. For example: + + + + + + +]]> + + + + Options for filterBugs command + + + + Command-line option + Ant attribute + Meaning + + + + input="<file>" use file as input + output="<file>" output results to file +-not not="[true|false]" reverse (all) switches for the filter +-withSource[:truth] withSource="[true|false]" only warnings for switch source is available +-exclude <filter file>exclude="<filter file>" exclude bugs matching given filter +-include <filter file>include="<filter file>" include only bugs matching given filter +-annotation <text> annotation="<text>" allow only warnings containing this text in a manual annotation +-after <when> after="<when>" allow only warnings that first occurred after this version +-before <when> before="<when>" allow only warnings that first occurred before this version +-first <when> first="<when>" allow only warnings that first occurred in this version +-last <when> last="<when>" allow only warnings that last occurred in this version +-fixed <when> fixed="<when>" allow only warnings that last occurred in the previous version (clobbers ) +-present <when> present="<when>" allow only warnings present in this version +-absent <when> absent="<when>" allow only warnings absent in this version +-active[:truth] active="[true|false]" allow only warnings alive in the last sequence number +-introducedByChange[:truth] introducedByChange="[true|false]"allow only warnings introduced by a change of an existing class +-removedByChange[:truth] removedByChange="[true|false]" allow only warnings removed by a change of a persisting class +-newCode[:truth] newCode="[true|false]" allow only warnings introduced by the addition of a new class +-removedCode[:truth] removedCode="[true|false]" allow only warnings removed by removal of a class +-priority <level> priority="<level>" allow only warnings with this priority or higher +-maxRank <rank> rank="[1..20]" allow only warnings with this rank or lower +-class <pattern> class="<class>" allow only bugs whose primary class name matches this pattern +-bugPattern <pattern> bugPattern="<pattern>" allow only bugs whose type matches this pattern +-category <category> category="<category>" allow only warnings with a category that starts with this string +-designation <designation> designation="<designation>" allow only warnings with this designation (e.g., -designation SHOULD_FIX) +-withMessages[:truth] withMessages="[true|false]" the generated XML should contain textual messages + + +
    + +
    + + + mineBugHistory +This command generates a table containing counts of the numbers of warnings +in each version of a multiversion bug database. + + +This functionality may also can be accessed from ant. +First create a taskdef for mineBugHistory in your +build file: + + + + + + +]]> + + +Attributes for this ant task are listed in the following table. +To specify an input file either use the input +attribute or nest it inside the ant call with a +<datafile> element. For example: + + + + + + +]]> + + + + Options for mineBugHistory command + + + + Command-line option + Ant attribute + Meaning + + + + input="<file>" use file as input + output="<file>" write output to file +-formatDates formatDates="[true|false]" render dates in textual form +-noTabs noTabs="[true|false]" delimit columns with groups of spaces instead of tabs (see below) +-summary summary="[true|false]" output terse summary of changes over the last ten entries + + +
    + + + The output can be easier to read from a shell + with a fixed-width font. + Because numeric columns are right-justified, spaces may precede the + first column value. This option also causes + to render dates in terser format without embedded whitespace. + + + The table is a tab-separated (barring ) + table with the following columns: + + + Columns in mineBugHistory output + + + + Title + Meaning + + + + seqSequence number (successive integers, starting at 0) + versionVersion name + timeRelease timestamp + classesNumber of classes analyzed + NCSSNon Commenting Source Statements + addedCount of new warnings for a class that existed in the previous version + newCodeCount of new warnings for a class that did not exist in the previous version + fixedCount of warnings removed from a class that remains in the current version + removedCount of warnings in the previous version for a class that is not present in the current version + retainedCount of warnings that were in both the previous and current version + deadWarnings that were present in earlier versions but in neither the current version or the immediately preceeding version + activeTotal warnings present in the current version + + +
    +
    + + + defectDensity + +This command lists information about defect density (warnings per 1000 NCSS) for the entire project and each class and package. +It can either be invoked with no files specified on the command line (in which case it reads from standard input) +or with one file specified on the command line. +It generates a table with the following columns, and with one +row for the entire project, and one row for each package or class that contains at least +4 warnings. + + Columns in defectDensity output + + + + Title + Meaning + + + + kindproject, package or class + nameThe name of the project, package or class + densityNumber of warnings generated per 1000 lines of NCSS. + bugsNumber of warnings + NCSSCalculated number of NCSS + + +
    +
    + + + convertXmlToText + + + This command converts a warning collection in XML format to a text + format with one line per warning, or to HTML. + + +This functionality may also can be accessed from ant. +First create a taskdef for convertXmlToText in your +build file: + + + + + + +]]> + + +Attributes for this ant task are listed in the following table. + + + Options for convertXmlToText command + + + + Command-line option + Ant attribute + Meaning + + + + input="<filename>" use file as input + output="<filename>" output results to file +-longBugCodes longBugCodes="[true|false]" use the full bug pattern code instead of two-letter abbreviation + format="text" generate plain text output with one bug per line (command-line default) +-html[:stylesheet] format="html:<stylesheet>" generate output with specified stylesheet (see below), or default.xsl if unspecified + + +
    + + + You may specify plain.xsl, default.xsl, fancy.xsl, fancy-hist.xsl, + or your own XSL stylesheet for the -html/format option. + Despite the name of this option, you may specify + a stylesheet that emits something other than html. + When applying a stylesheet other than those included + with FindBugs (listed above), the -html/format option should be used + with a path or URL to the stylesheet. + +
    + + + setBugDatabaseInfo + + + This command sets meta-information in a specified warning collection. + It takes the following options: + + +This functionality may also can be accessed from ant. +First create a taskdef for setBugDatabaseInfo in your +build file: + + + + + + +]]> + + +Attributes for this ant task are listed in the following table. +To specify an input file either use the input +attribute or nest it inside the ant call with a +<datafile> element. For example: + + + + + + +]]> + + + + setBugDatabaseInfo Options + + + + Command-line option + Ant attribute + Meaning + + + + input="<file>" use file as input + output="<file>" write output to file + -name <name> name="<name>" set name for (last) revision + -timestamp <when> timestamp="<when>" set timestamp for (last) revision + -source <directory> source="<directory>" add specified directory to the source search path + -findSource <directory> findSource="<directory>" find and add all relevant source directions contained within specified directory + -suppress <filter file> suppress="<filter file>" suppress warnings matched by this file (replaces previous suppressions) + -withMessages withMessages="[true|false]" add textual messages to XML + -resetSource resetSource="[true|false]" remove all source search paths + + +
    +
    + + + listBugDatabaseInfo + + This command takes a list of zero or more xml bug database filenames on the command line. +If zero file names are provided, it reads from standard input and does not generate +a table header. + +There is only one option: renders dates + in textual form. + + +The output is a table one row per bug database and the following columns: + + listBugDatabaseInfo Columns + + + + Column + Meaning + + + + versionversion name + timeRelease timestamp + classesNumber of classes analyzed + NCSSNon Commenting Source Statements analyzed + totalTotal number of warnings of all kinds + highTotal number of high priority warnings of all kinds + mediumTotal number of medium/normal priority warnings of all kinds + lowTotal number of low priority warnings of all kinds + filenamefilename of database + + + +
    + +
    + +
    + + + Examples + + Mining history using proveded shell scrips +In all of the following, the commands are given in a directory that contains +directories jdk1.6.0-b12, jdk1.6.0-b13, ..., jdk1.6.0-b60. + +You can use the command: + +computeBugHistory jdk1.6.0-b* | filterBugs -bugPattern IL_ | mineBugHistory -formatDates + +to generate the following output: + + +seq version time classes NCSS added newCode fixed removed retained dead active +0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 4 0 0 0 0 4 +1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 4 0 4 +2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 0 0 2 0 2 0 2 +3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 0 0 1 0 1 2 1 +4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 0 0 1 3 1 +5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 0 0 1 3 1 +6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1 3 1 +7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 0 0 1 3 1 +8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1 3 1 +9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 0 0 1 3 1 +10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 0 0 0 0 1 3 1 +11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1 3 1 +12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 0 0 0 0 1 3 1 +13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1 3 1 +14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1 3 1 +15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 0 0 0 0 1 3 1 +16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 0 0 0 0 1 3 1 +17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1 3 2 +18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 0 0 0 2 3 2 +19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 2 3 2 +20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 0 0 0 2 3 2 +21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 0 0 0 0 2 3 2 +22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 0 1 0 0 2 3 3 +23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 0 2 0 0 3 3 5 +24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 5 3 5 +25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 0 0 0 0 5 3 5 +26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 0 0 0 0 5 3 5 +27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 5 3 5 +28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 0 0 1 0 4 3 4 +29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 0 0 0 0 4 4 4 +30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 0 0 1 0 3 4 3 +31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 3 5 3 +32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 0 0 0 0 3 5 3 +33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 1 0 0 0 3 5 4 +34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 0 0 0 0 4 5 4 +35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 0 0 4 5 4 +36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 0 0 1 0 3 5 3 +37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 3 6 3 +38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 0 0 0 0 3 6 3 +39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 0 0 0 0 3 6 3 +40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 3 6 3 +41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 0 0 0 3 6 3 +42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 0 0 0 0 3 6 3 +43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 3 6 3 + + + +We could also generate that information directly, without creating an intermediate db.xml file, using the command + + + +computeBugHistory jdk1.6.0-b*/jre/lib/rt.xml | filterBugs -bugPattern IL_ db.xml | mineBugHistory -formatDates + + +We can then use that information to display a graph showing the number of infinite recursive loops +found by FindBugs in each build of Sun's JDK1.6.0. The blue area indicates the number of infinite +recursive loops in that build, the red area above it indicates the number of infinite recursive loops that existed +in some previous version but not in the current version (thus, the combined height of the red and blue areas +is guaranteed to never decrease, and goes up whenever a new infinite recursive loop bug is introduced). The height +of the red area is computed as the sum of the fixed, removed and dead values for each version. +The reductions in builds 13 and 14 came after Sun was notified about the bugs found by FindBugs in the JDK. + + + + + + + + +Given 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: + + + +filterBugs -priority M -category C db.xml | mineBugHistory -formatDates + + + +generating the table: + + + +seq version time classes NCSS added newCode fixed removed retained dead active +0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 1075 0 0 0 0 1075 +1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 1075 0 1075 +2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 3 0 6 0 1069 0 1072 +3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 2 1 3 0 1069 6 1072 +4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 1 0 1071 9 1071 +5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 1 0 1070 10 1070 +6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1070 11 1070 +7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 1 0 1069 11 1069 +8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1069 12 1069 +9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 2 1 1066 12 1066 +10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 1 0 1 1 1064 15 1065 +11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1065 17 1065 +12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 3 0 8 26 1031 17 1034 +13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1034 51 1034 +14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1034 51 1034 +15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 1 1 0 1 1033 51 1035 +16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 3 0 2 1 1032 52 1035 +17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1035 55 1036 +18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 36 2 0 1034 55 1070 +19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 1070 57 1070 +20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 1 1 0 1069 57 1070 +21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 1 7 2 6 1062 58 1070 +22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 6 39 5 0 1065 66 1110 +23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 7 147 11 0 1099 71 1253 +24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 1253 82 1253 +25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 3 0 1 2 1250 82 1253 +26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 5 11 15 8 1230 85 1246 +27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 1246 108 1246 +28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 19 0 2 0 1244 108 1263 +29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 13 1 1 32 1230 110 1244 +30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 163 8 7 20 1217 143 1388 +31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 1388 170 1388 +32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 1 11 1 0 1387 170 1399 +33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 19 27 16 7 1376 171 1422 +34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 1 15 3 0 1419 194 1435 +35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 1 1 1433 197 1433 +36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 13 12 16 20 1397 199 1422 +37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 1422 235 1422 +38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 1 4 7 0 1415 235 1420 +39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 6 8 37 0 1383 242 1397 +40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 1397 279 1397 +41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 1 1 0 1396 279 1397 +42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 6 0 5 0 1392 280 1398 +43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 1398 285 1398 +44 jdk1.6.0-b61 "Thu Nov 17 01:58:42 EST 2005" 16202 971134 2 0 4 0 1394 285 1396 + + + + + Incremental history maintenance + + +If 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: + + +computeBugHistory -output db.xml db.xml jdk1.6.0-b61/jre/lib/rt.xml + + + + + + + Ant example + +Here is a complete ant script example for both running findbugs and running a chain of data-mining tools afterward: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + +
    + + + + + +License + + +The name FindBugs and the FindBugs logo is trademarked by the University +of Maryland. +FindBugs is free software distributed under the terms of the +Lesser GNU Public License. +You should have received a copy of the license in the file LICENSE.txt +in the &FindBugs; distribution. + + + +You can find the latest version of FindBugs, along with its source code, from the +FindBugs web page. + + + + + + + +Acknowledgments + + +Contributors + +&FindBugs; was originally written by Bill Pugh (pugh@cs.umd.edu). +David Hovemeyer (daveho@cs.umd.edu) implemented some of the +detectors, added the Swing GUI, and is a co-maintainer. + +Mike Fagan (mfagan@tde.com) contributed the &Ant; build script, +the &Ant; task, and several enhancements and bug fixes to the GUI. + +Germano Leichsenring contributed Japanese translations of the bug +summaries. + +David Li contributed the Emacs bug report format. + +Peter D. Stout contributed recursive detection of Class-Path +attributes in analyzed Jar files, German translations of +text used in the Swing GUI, and other fixes. + +Peter Friese wrote the &FindBugs; Eclipse plugin. + +Rohan Lloyd contributed several Mac OS X enhancements, +bug detector improvements, +and maintains the Fink package for &FindBugs;. + +Hiroshi Okugawa translated the &FindBugs; manual and +more of the bug summaries into Japanese. + +Phil Crosby enhanced the Eclipse plugin to add a view +to display the bug details. + +Dave Brosius fixed a number of bugs, added user preferences +to the Swing GUI, improved several bug detectors, and +contributed the string concatenation detector. + +Thomas Klaeger contributed a number of bug fixes and +bug detector improvements. + +Andrei Loskutov made a number of improvements to the +Eclipse plugin. + +Brian Goetz contributed a major refactoring of the +visitor classes to improve readability and understandability. + + Pete Angstadt fixed several problems in the Swing GUI. + +Francis Lalonde provided a task resource file for the +FindBugs Ant task. + +Garvin LeClaire contributed support for output in +Xdocs format, for use by Maven. + +Holger Stenzhorn contributed improved German translations of items +in the Swing GUI. + +Juha Knuutila contributed Finnish translations of items +in the Swing GUI. + +Tanel Lebedev contributed Estonian translations of items +in the Swing GUI. + +Hanai Shisei (ruimo) contributed full Japanese translations of +bug messages, and text used in the Swing GUI. + +David Cotton contributed Fresh translations for bug +messages and for the Swing GUI. + +Michael Tamm contributed support for the "errorProperty" attribute +in the Ant task. + +Thomas Kuehne improved the German translation of the Swing GUI. + +Len Trigg improved source file support for the Emacs output mode. + +Greg Bentz provided a fix for the hashcode/equals detector. + +K. Hashimoto contributed internationalization fixes and several other + bug fixes. + + + Glenn Boysko contributed support for ignoring specified local + variables in the dead local store detector. + + + + Jay Dunning contributed a detector to find equality comparisons + of floating-point values, and overhauled the analysis summary + report and its representation in the saved XML format. + + + + Olivier Parent contributed updated French translations for bug descriptions and + Swing GUI. + + + + Chris Nappin contributed the plain.xsl + stylesheet. + + + + Etienne Giraudy contributed the fancy.xsl and fancy-hist.xsl + stylesheets, and made improvements to the -xml:withMessages + option. + + + + Takashi Okamoto fixed bugs in the project preferences dialog + in the Eclipse plugin, and contributed to its internationalization and localization. + + +Thomas Einwaller fixed bugs in the project preferences dialog in the Eclipse plugin. + +Jeff Knox contributed support for the warningsProperty attribute +in the Ant task. + +Peter Hendriks extended the Eclipse plugin preferences, +and fixed a bug related to renaming the Eclipse plugin ID. + +Mark McKay contributed an Ant task to launch the findbugs frame. + +Dieter von Holten (dvholten) contributed +some German improvements to findbugs_de.properties. + + +If you have contributed to &FindBugs;, but aren't mentioned above, +please send email to findbugs@cs.umd.edu (and also accept +our humble apologies). + + + + +Software Used + +&FindBugs; uses several open-source software packages, without which its +development would have been much more difficult. + + +BCEL +&FindBugs; includes software developed by the Apache Software Foundation +(http://www.apache.org/). +Specifically, it uses the Byte Code +Engineering Library. + + + +ASM +&FindBugs; uses the ASM +bytecode framework, which is distributed under the following license: + +
    + +Copyright (c) 2000-2005 INRIA, France Telecom +All rights reserved. + + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + + + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + +
    +
    + + +DOM4J +&FindBugs; uses DOM4J, which is +distributed under the following license: + +
    + +Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. + + + +Redistribution and use of this software and associated documentation +("Software"), with or without modification, are permitted provided that +the following conditions are met: + + + + + Redistributions of source code must retain copyright statements and + notices. Redistributions must also contain a copy of this document. + + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + The name "DOM4J" must not be used to endorse or promote products + derived from this Software without prior written permission + of MetaStuff, Ltd. For written permission, please contact + dom4j-info@metastuff.com. + + + Products derived from this Software may not be called "DOM4J" nor may + "DOM4J" appear in their names without prior written permission of + MetaStuff, Ltd. DOM4J is a registered trademark of MetaStuff, Ltd. + + + Due credit should be given to the DOM4J Project (http://dom4j.org/). + + + + +THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +
    + +
    + +
    + +
    + + + diff --git a/doc/manual.xsl b/doc/manual.xsl new file mode 100644 index 0000000..557b3b7 --- /dev/null +++ b/doc/manual.xsl @@ -0,0 +1,36 @@ + + + + + + + + + + + +0 + + +manual/ + + +1 + + +1 + + +1 + + + + + +1 + + diff --git a/doc/manual_ja.xml b/doc/manual_ja.xml new file mode 100644 index 0000000..966b6b4 --- /dev/null +++ b/doc/manual_ja.xml @@ -0,0 +1,2806 @@ + +FindBugs"> +Ant"> +Saxon"> +$FINDBUGS_HOME"> +%FINDBUGS_HOME%"> + +]> + + + +&FindBugs;™ マニュアル + + + + David + H. + Hovemeyer + + + William + W. + Pugh + + + + + 2003 + 2004 + 2005 + 2006 + 2008 + University of Maryland + + + +ã“ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã¯ã€ã‚¯ãƒªã‚¨ã‚¤ãƒ†ã‚£ãƒ–・コモンズ表示-éžå–¶åˆ©-継承ã«åŸºã¥ã使用許諾ãŒãªã•ã‚Œã¦ã„ã¾ã™ã€‚使用許諾書をã”覧ã«ãªã‚‹å ´åˆã¯ã€ http://creativecommons.org/licenses/by-nc-sa/1.0/ ã«ã‚¢ã‚¯ã‚»ã‚¹ã™ã‚‹ã‹ã€ã‚¯ãƒªã‚¨ã‚¤ãƒ†ã‚£ãƒ–・コモンズ(559 Nathan Abbott Way, Stanford, California 94305, USA)ã«æ›¸ç°¡ã‚’é€ä»˜ã—ã¦ãã ã•ã„。 +å称「FindBugsã€ãŠã‚ˆã³ FindBugs ã®ãƒ­ã‚´ã¯ã€ãƒ¡ãƒªãƒ¼ãƒ©ãƒ³ãƒ‰å¤§å­¦ã®ç™»éŒ²å•†æ¨™ã§ã™ã€‚ + + +2.0.3 + +17:16:15 EST, 22 November, 2013 + + + + + + +ã¯ã˜ã‚ã« + +&FindBugs;™ ã¯ã€Java プログラムã®ä¸­ã®ãƒã‚°ã‚’見ã¤ã‘るプログラムã§ã™ã€‚ã“ã®ãƒ—ログラムã¯ã€ã€Œãƒã‚° パターンã€ã®å®Ÿä¾‹ã‚’探ã—ã¾ã™ã€‚「ãƒã‚° パターンã€ã¨ã¯ã€ã‚¨ãƒ©ãƒ¼ã¨ãªã‚‹å¯èƒ½æ€§ã®é«˜ã„コードã®äº‹ä¾‹ã§ã™ã€‚ + +ã“ã®æ–‡æ›¸ã¯ã€&FindBugs; ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 2.0.3 ã«ã¤ã„ã¦èª¬æ˜Žã—ã¦ã¾ã™ã€‚ç§ãŸã¡ã¯ã€ &FindBugs; ã«å¯¾ã™ã‚‹ãƒ•ã‚£ãƒ¼ãƒ‰ãƒãƒƒã‚¯ã‚’心待ã¡ã«ã—ã¦ã„ã¾ã™ã€‚ã©ã†ãžã€ &FindBugs; Web ページ ã«ã‚¢ã‚¯ã‚»ã‚¹ã—ã¦ãã ã•ã„。&FindBugs; ã«ã¤ã„ã¦ã®æœ€æ–°æƒ…å ±ã€é€£çµ¡å…ˆãŠã‚ˆã³ &FindBugs; メーリングリストãªã©ã®ã‚µãƒãƒ¼ãƒˆæƒ…報を入手ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + +å¿…è¦æ¡ä»¶ +&FindBugs; を使用ã™ã‚‹ã«ã¯ã€ Java 2 Standard Edition, ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 1.5 以é™ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã¨äº’æ›æ€§ã®ã‚るランタイム環境ãŒå¿…è¦ã§ã™ã€‚&FindBugs; ã¯ã€ãƒ—ラットフォームéžä¾å­˜ã§ã‚り〠GNU/Linux 〠Windows 〠MacOS X プラットフォーム上ã§å‹•ä½œã™ã‚‹ã“ã¨ãŒçŸ¥ã‚‰ã‚Œã¦ã„ã¾ã™ã€‚ + +&FindBugs; を使用ã™ã‚‹ãŸã‚ã«ã¯ã€å°‘ãªãã¨ã‚‚ 512 MB ã®ãƒ¡ãƒ¢ãƒªãŒå¿…è¦ã§ã™ã€‚巨大ãªãƒ—ロジェクトを解æžã™ã‚‹ãŸã‚ã«ã¯ã€ãれより多ãã®ãƒ¡ãƒ¢ãƒªãŒå¿…è¦ã¨ã•ã‚Œã‚‹ã“ã¨ãŒã‚ã‚Šã¾ã™ã€‚ + + + + + + + +&FindBugs;™ ã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ« + +ã“ã®ç« ã§ã¯ã€ &FindBugs; ã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«æ–¹æ³•ã‚’説明ã—ã¾ã™ã€‚ + + +é…布物ã®å±•é–‹ + +&FindBugs; をインストールã™ã‚‹æœ€ã‚‚ç°¡å˜ãªæ–¹æ³•ã¯ã€ãƒã‚¤ãƒŠãƒªé…布物をダウンロードã™ã‚‹ã“ã¨ã§ã™ã€‚ ãƒã‚¤ãƒŠãƒªé…布物ã¯ã€ gzipped tar å½¢å¼ ãŠã‚ˆã³ zip å½¢å¼ ãŒãã‚Œãžã‚Œå…¥æ‰‹å¯èƒ½ã§ã™ã€‚ãƒã‚¤ãƒŠãƒªé…布物をダウンロードã—ã¦ããŸã‚‰ã€ãれを任æ„ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã«å±•é–‹ã—ã¾ã™ã€‚ + +gzipped tar å½¢å¼é…布物ã®å±•é–‹æ–¹æ³•ä¾‹: +$ gunzip -c findbugs-2.0.3.tar.gz | tar xvf - + + + +zip å½¢å¼é…布物ã®å±•é–‹æ–¹æ³•ä¾‹: +C:\Software>unzip findbugs-2.0.3.zip + + + +ãƒã‚¤ãƒŠãƒªé…布物ã®å±•é–‹ã™ã‚‹ã¨ã€é€šå¸¸ã¯ findbugs-2.0.3 ディレクトリーãŒä½œæˆã•ã‚Œã¾ã™ã€‚例ãˆã°ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ C:\Software ã§ãƒã‚¤ãƒŠãƒªé…布物を展開ã™ã‚‹ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ C:\Software\findbugs-2.0.3 ã« &FindBugs; ã¯å±•é–‹ã•ã‚Œã¾ã™ã€‚ã“ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ãŒ &FindBugs; ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã«ãªã‚Šã¾ã™ã€‚ã“ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã§ã¯ã€ã“ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã‚’ &FBHome; (Windowsã§ã¯ &FBHomeWin;) を用ã„ã¦å‚ç…§ã—ã¾ã™ã€‚ + + + + + + + +&FindBugs;™ ã®ã‚½ãƒ¼ãƒ«ã‹ã‚‰ã®ãƒ“ルド + +ã“ã®ç« ã§ã¯ã€ &FindBugs; をソースコードã‹ã‚‰ãƒ“ルドã™ã‚‹æ–¹æ³•ã‚’説明ã—ã¾ã™ã€‚&FindBugs; を修正ã™ã‚‹ã“ã¨ã«èˆˆå‘³ãŒãªã„ã®ã§ã‚ã‚Œã°ã€ 次ã®ç«  ã«é€²ã‚“ã§ãã ã•ã„。 + + +å‰ææ¡ä»¶ + +ソースã‹ã‚‰ &FindBugs; をコンパイルã™ã‚‹ãŸã‚ã«ã¯ã€ä»¥ä¸‹ã®ã‚‚ã®ãŒå¿…è¦ã§ã™ã€‚ + + &FindBugs; ã®ã‚½ãƒ¼ã‚¹é…布物 + + + + + JDK 1.5.0 ベータ ã¾ãŸã¯ãã‚Œä»¥é™ + + + + + Apache &Ant;, ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 1.6.3 ã¾ãŸã¯ãã‚Œä»¥é™ + + + + + + Redhat Linux システム㮠/usr/bin/ant ã«åŒæ¢±ã•ã‚Œã¦ã„ã‚‹ &Ant; ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯ã€ &FindBugs; ã®ã‚³ãƒ³ãƒ‘イルã¯ã†ã¾ãã§ãã¾ã›ã‚“。&Ant; web サイトã‹ã‚‰ãƒã‚¤ãƒŠãƒªé…布物をダウンロードã—ã¦ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã™ã‚‹ã“ã¨ã‚’推奨ã—ã¾ã™ã€‚&Ant; を実行ã™ã‚‹å ´åˆã¯ã€ 環境変数 JAVA_HOME ㌠JDK 1.5 (ã¾ãŸã¯ãれ以é™)をインストールã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã‚’指ã—ã¦ã„ã‚‹ã“ã¨ã‚’確èªã—ã¦ãã ã•ã„。 + + +体è£ã®æ•´ã£ãŸ &FindBugs; ã®ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã‚’生æˆã—ãŸã„å ´åˆã¯ã€ä»¥ä¸‹ã®ã‚½ãƒ•ãƒˆã‚¦ã‚§ã‚¢ã‚‚å¿…è¦ã¨ãªã‚Šã¾ã™: + + DocBook XSL スタイルシート。&FindBugs; ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã‚’ HTML ã«å¤‰æ›ã™ã‚‹ã®ã«å¿…è¦ã§ã™ã€‚ + + + &Saxon; XSLT プロセッサー。(åŒæ§˜ã«ã€ &FindBugs; ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã‚’ HTML ã«å¤‰æ›ã™ã‚‹ã®ã«å¿…è¦ã§ã™ã€‚) + + + + + + + + +ソースé…布物ã®å±•é–‹ +ソースé…布物をダウンロードã—ãŸå¾Œã«ã€ãれを作業用ディレクトリーã«å±•é–‹ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚通常ã¯ã€æ¬¡ã®ã‚ˆã†ãªã‚³ãƒžãƒ³ãƒ‰ã§å±•é–‹ã‚’è¡Œã„ã¾ã™: +$ unzip findbugs-2.0.3-source.zip + + + + + + +<filename>local.properties</filename> ã®ä¿®æ­£ +FindBugs ã®ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã‚’ビルドã™ã‚‹ãŸã‚ã«ã¯ã€ local.properties ファイルを修正ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ã“ã®ãƒ•ã‚¡ã‚¤ãƒ«ã¯ã€ &FindBugs; をビルドã™ã‚‹éš›ã« &Ant; build.xml ファイルãŒå‚ç…§ã—ã¾ã™ã€‚FindBugs ã®ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã‚’ビルドã—ãªã„å ´åˆã¯ã€ã“ã®ãƒ•ã‚¡ã‚¤ãƒ«ã¯ç„¡è¦–ã—ã¦ã‚‚ã‹ã¾ã„ã¾ã›ã‚“。 + +local.properties ã§ã®å®šç¾©ã¯ã€ build.properties ファイルã§ã®å®šç¾©ã«å„ªå…ˆã—ã¾ã™ã€‚build.properties ã¯æ¬¡ã®ã‚ˆã†ãªå†…容ã§ã™: + + + + +xsl.stylesheet.home プロパティーã«ã¯ã€DocBook Modular XSL スタイルシートãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã—ã¦ã‚るディレクトリーã®çµ¶å¯¾ãƒ‘スを指定ã—ã¾ã™ã€‚&FindBugs; ドキュメントを生æˆã—よã†ã¨è€ƒãˆã¦ã„ã‚‹å ´åˆã«ã®ã¿ã€ã“ã®ãƒ—ロパティーを指定ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ + +saxon.home プロパティーã«ã¯ã€&Saxon; XSLT プロセッサーãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã—ã¦ã‚るディレクトリーã®çµ¶å¯¾ãƒ‘スを指定ã—ã¾ã™ã€‚&FindBugs; ドキュメントを生æˆã—よã†ã¨è€ƒãˆã¦ã„ã‚‹å ´åˆã«ã®ã¿ã€ã“ã®ãƒ—ロパティーを指定ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ + + + + +&Ant; ã®å®Ÿè¡Œ + +ソースé…布物ã®å±•é–‹ã€ &Ant; ã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã€build.properties(local.properties) ã®ä¿®æ­£ (ã“ã‚Œã¯ä»»æ„) ãŠã‚ˆã³ãƒ„ール (&Saxon; ãªã©)ã®ç’°å¢ƒæ§‹ç¯‰ãŒã§ãã‚Œã°ã€ &FindBugs; をビルドã™ã‚‹ãŸã‚ã®æº–å‚™ã¯å®Œäº†ã§ã™ã€‚&Ant; ã®èµ·å‹•ã™ã‚‹æ–¹æ³•ã¯ã€å˜ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã ã‘ã§ã™ã€‚ +$ ant target +target ã«ã¯ä»¥ä¸‹ã®ã„ãšã‚Œã‹ã‚’指定ã—ã¾ã™: build + + ã“ã®ã‚¿ãƒ¼ã‚²ãƒƒãƒˆã¯ã€ &FindBugs; ã®ã‚³ãƒ¼ãƒ‰ã‚’コンパイルã—ã¾ã™ã€‚ã“ã‚Œã¯ã€ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã®ã‚¿ãƒ¼ã‚²ãƒƒãƒˆã§ã™ã€‚ + + + + + docs + + ã“ã®ã‚¿ãƒ¼ã‚²ãƒƒãƒˆã¯ã€ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã®æ•´å½¢ã‚’è¡Œã„ã¾ã™(ã¾ãŸã€å‰¯ä½œç”¨ã¨ã—ã¦ã„ãã¤ã‹ã®ã‚½ãƒ¼ã‚¹ã®ã‚³ãƒ³ãƒ‘イルも行ã„ã¾ã™ã€‚) + + + + + runjunit + + ã“ã®ã‚¿ãƒ¼ã‚²ãƒƒãƒˆã¯ã€ã‚³ãƒ³ãƒ‘イルを行ㄠ&FindBugs; ãŒæŒã£ã¦ã„ã‚‹ JUnit テストを実行ã—ã¾ã™ã€‚ユニットテストãŒå¤±æ•—ã—ãŸå ´åˆã¯ã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒè¡¨ç¤ºã•ã‚Œã¾ã™ã€‚ + + + + + bindist + + &FindBugs; ã®ãƒã‚¤ãƒŠãƒªé…布物を構築ã—ã¾ã™ã€‚ã“ã®ã‚¿ãƒ¼ã‚²ãƒƒãƒˆã¯ã€ .zip ãŠã‚ˆã³ .tar.gz ã®ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–ã‚’ãã‚Œãžã‚Œä½œæˆã—ã¾ã™ã€‚ + + + + + +&Ant; コマンドã®å®Ÿè¡Œå¾Œã€æ¬¡ã®ã‚ˆã†ãªå‡ºåŠ›ãŒè¡¨ç¤ºã•ã‚Œã‚‹ã¯ãšã§ã™ã€‚ (ã“ã®å‰ã« &Ant; ãŒå®Ÿè¡Œã—ãŸã‚¿ã‚¹ã‚¯ã«é–¢ã™ã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚‚ã„ãらã‹å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚): + +BUILD SUCCESSFUL +Total time: 17 seconds + + + + + + + +ソースディレクトリーã‹ã‚‰ã® &FindBugs;™ ã®å®Ÿè¡Œ +build ターゲットã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã¨ã€ãƒã‚¤ãƒŠãƒªé…布物ã¨åŒæ§˜ã®çŠ¶æ…‹ãŒä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã«æ§‹ç¯‰ã•ã‚Œã‚‹ã‚ˆã†ã« &FindBugs; ã®&Ant; ビルドスクリプトã¯è¨˜è¿°ã•ã‚Œã¦ã„ã¾ã™ã€‚ã—ãŸãŒã£ã¦ã€ ã® &FindBugs; ã®å®Ÿè¡Œã«é–¢ã™ã‚‹æƒ…å ±ã¯ã‚½ãƒ¼ã‚¹é…布物ã®å ´åˆã«ã‚‚応用ã§ãã¾ã™ã€‚ + + + + + + + + +&FindBugs;™ ã®å®Ÿè¡Œ + +&FindBugs; ã«ã¯2ã¤ã®ãƒ¦ãƒ¼ã‚¶ãƒ¼ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ãŒã‚ã‚Šã¾ã™ã€‚ã™ãªã‚ã¡ã€ã‚°ãƒ©ãƒ•ã‚£ã‚«ãƒ«ãƒ¦ãƒ¼ã‚¶ãƒ¼ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ (GUI) ãŠã‚ˆã³ コマンドラインインタフェースã§ã™ã€‚ã“ã®ç« ã§ã¯ã€ãã‚Œãžã‚Œã®ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã®å®Ÿè¡Œæ–¹æ³•ã«ã¤ã„ã¦èª¬æ˜Žã—ã¾ã™ã€‚ + + + ã“ã®ç« ã¯ã€ç¾åœ¨æ›¸ãç›´ã—中ã§ã™ã€‚書ãç›´ã—ã¯ã¾ã å®Œäº†ã—ã¦ã„ã¾ã›ã‚“。 + + + + + + クイック・スタート + Windows システム㧠&FindBugs; ã‚’èµ·å‹•ã™ã‚‹å ´åˆã¯ã€ &FBHomeWin;\lib\findbugs.jar ファイルをダブルクリックã—ã¦ãã ã•ã„。 &FindBugs; GUI ãŒèµ·å‹•ã—ã¾ã™ã€‚ + + Unix 〠Linux ã¾ãŸã¯ Mac OS X システムã®å ´åˆã¯ã€&FBHome;/bin/findbugs スクリプトを実行ã™ã‚‹ã‹ã€ä»¥ä¸‹ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ +java -jar &FBHome;/lib/findbugs.jarã“ã‚Œã§ã€ &FindBugs; GUI ãŒèµ·å‹•ã—ã¾ã™ã€‚ + + GUI ã®ä½¿ç”¨æ–¹æ³•ã«ã¤ã„ã¦ã¯ã€ ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + + &FindBugs; ã®èµ·å‹• + + ã“ã®ã‚»ã‚¯ã‚·ãƒ§ãƒ³ã§ã¯ã€ &FindBugs; ã®èµ·å‹•æ–¹æ³•ã‚’説明ã—ã¾ã™ã€‚&FindBugs; ã‚’èµ·å‹•ã™ã‚‹ã«ã¯2ã¤ã®æ–¹æ³•ãŒã‚ã‚Šã¾ã™ã€‚ã™ãªã‚ã¡ã€ç›´æŽ¥èµ·å‹•ã™ã‚‹æ–¹æ³•ã€ãŠã‚ˆã³ã€ãƒ©ãƒƒãƒ—ã—ã¦ã„るスクリプトを使用ã™ã‚‹æ–¹æ³•ã§ã™ã€‚ + + + + &FindBugs; ã®ç›´æŽ¥èµ·å‹• + + 最åˆã«è¿°ã¹ã‚‹ &FindBugs; ã®èµ·å‹•æ–¹æ³•ã¯ã€ &FBHome;/lib/findbugs.jar を直接実行ã™ã‚‹æ–¹æ³•ã§ã™ã€‚JVM (java) 実行プログラム㮠-jar コマンドラインスイッãƒã‚’使用ã—ã¾ã™ã€‚(&FindBugs;ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãŒ 1.3.5 よりå‰ã®å ´åˆã¯ã€ãƒ©ãƒƒãƒ—ã—ã¦ã„るスクリプトを使用ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚) + + &FindBugs; を直接起動ã™ã‚‹ãŸã‚ã®ã€ä¸€èˆ¬çš„ãªæ§‹æ–‡ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ + java [JVM 引数] -jar &FBHome;/lib/findbugs.jar オプション… + + + + + + + ユーザーインタフェースã®é¸æŠž + + 1 番目ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã‚ªãƒ—ションã¯ã€èµ·å‹•ã™ã‚‹ &FindBugs; ユーザーインタフェースをé¸æŠžã™ã‚‹ãŸã‚ã®ã‚‚ã®ã§ã™ã€‚指定å¯èƒ½ãªå€¤ã¯æ¬¡ã®é€šã‚Šã§ã™: + + + + -gui: グラフィカルユーザーインタフェース (GUI) ã‚’èµ·å‹•ã—ã¾ã™ã€‚ + + + + + -textui: コマンドラインインタフェースを起動ã—ã¾ã™ã€‚ + + + + + -version: &FindBugs; ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã‚’表示ã—ã¾ã™ã€‚ + + + + + -help: &FindBugs; コマンドラインインタフェースã®ãƒ˜ãƒ«ãƒ—情報を表示ã—ã¾ã™ã€‚ + + + + + -gui1: 最åˆã«ä½œæˆã•ã‚ŒãŸ &FindBugs; グラフィカルユーザーインタフェース(ã™ã§ã«å»ƒæ­¢ã•ã‚Œã‚µãƒãƒ¼ãƒˆã•ã‚Œã¦ã„ãªã„)ã‚’èµ·å‹•ã—ã¾ã™ã€‚ + + + + + + + Java 仮想マシン (JVM) 引数 + + &FindBugs; ã‚’èµ·å‹•ã™ã‚‹éš›ã«æœ‰ç”¨ãª Java 仮想マシン 引数をã„ãã¤ã‹ç´¹ä»‹ã—ã¾ã™ã€‚ + + + + -XmxNNm + + Java ヒープサイズã®æœ€å¤§å€¤ã‚’ NN メガãƒã‚¤ãƒˆã«è¨­å®šã—ã¾ã™ã€‚&FindBugs; ã¯ä¸€èˆ¬çš„ã«å¤§å®¹é‡ã®ãƒ¡ãƒ¢ãƒªã‚µã‚¤ã‚ºã‚’å¿…è¦ã¨ã—ã¾ã™ã€‚大ããªãƒ—ロジェクトã§ã¯ã€ 1500 メガãƒã‚¤ãƒˆã‚’使用ã™ã‚‹ã“ã¨ã‚‚çã—ãã‚ã‚Šã¾ã›ã‚“。 + + + + + -Dname=value + + Java システムプロパティーを設定ã—ã¾ã™ã€‚例ãˆã°ã€å¼•æ•° -Duser.language=ja を使用ã™ã‚‹ã¨ GUI 文言ãŒæ—¥æœ¬èªžã§è¡¨ç¤ºã•ã‚Œã¾ã™ã€‚ + + + + + + + + + + + ラップã—ã¦ã„るスクリプトを使用ã—㟠&FindBugs; ã®èµ·å‹• + + &FindBugs; ã‚’èµ·å‹•ã™ã‚‹ã‚‚ã†ã²ã¨ã¤ã®æ–¹æ³•ã¯ã€ãƒ©ãƒƒãƒ—ã—ã¦ã„るスクリプトを使用ã™ã‚‹æ–¹æ³•ã§ã™ã€‚ + +Unix ç³»ã®ã‚·ã‚¹ãƒ†ãƒ ã«ãŠã„ã¦ã¯ã€æ¬¡ã®ã‚ˆã†ãªã‚³ãƒžãƒ³ãƒ‰ã§ãƒ©ãƒƒãƒ—ã—ã¦ã„るスクリプトを起動ã—ã¾ã™ : +$ &FBHome;/bin/findbugs オプション… + + + +Windows システムã«ãŠã„ã¦ã¯ã€ãƒ©ãƒƒãƒ—ã—ã¦ã„るスクリプトを起動ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯æ¬¡ã®ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ +C:\My Directory>&FBHomeWin;\bin\findbugs.bat オプション… + + + +Unix 系システム ãŠã‚ˆã³ Windows システムã®ã©ã¡ã‚‰ã«ãŠã„ã¦ã‚‚ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ $FINDBUGS_HOME/bin を環境変数 PATH ã«è¿½åŠ ã™ã‚‹ã ã‘ã§ã€ findbugs コマンドを使用ã—㦠FindBugs ã‚’èµ·å‹•ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + ラップã—ã¦ã„るスクリプトã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã‚ªãƒ—ション + &FindBugs; ã®ãƒ©ãƒƒãƒ—ã—ã¦ã„るスクリプトã¯ã€æ¬¡ã®ã‚ˆã†ãªã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã‚ªãƒ—ションをサãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã™ã€‚ã“れらã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã‚ªãƒ—ション㯠&FindBugs; プログラム 自体ãŒæ“作ã™ã‚‹ã®ã§ã¯ãªãã€ã©ã¡ã‚‰ã‹ã¨ã„ãˆã°ã€ãƒ©ãƒƒãƒ—ã—ã¦ã„るスクリプトã®æ–¹ãŒå‡¦ç†ã‚’è¡Œã„ã¾ã™ã€‚ + + + -jvmArgs 引数 + + JVM ã«å—ã‘渡ã•ã‚Œã‚‹å¼•æ•°ã‚’指定ã—ã¾ã™ã€‚例ãˆã°ã€æ¬¡ã®ã‚ˆã†ãª JVM プロパティãŒè¨­å®šã§ãã¾ã™: +$ findbugs -textui -jvmArgs "-Duser.language=ja" myApp.jar + + + + + + + -javahome ディレクトリー + + &FindBugs; ã®å®Ÿè¡Œã«ä½¿ç”¨ã™ã‚‹ JRE (Java ランタイム環境) ãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•ã‚Œã¦ã„るディレクトリーを指定ã—ã¾ã™ã€‚ + + + + + -maxHeap サイズ + + Java ヒープサイズã®æœ€å¤§å€¤ã‚’メガãƒã‚¤ãƒˆå˜ä½ã§æŒ‡å®šã—ã¾ã™ã€‚デフォルトã¯ã€ 256 ã§ã™ã€‚巨大ãªãƒ—ログラムやライブラリを分æžã™ã‚‹ã«ã¯ã€ã‚‚ã£ã¨å¤§ããªãƒ¡ãƒ¢ãƒªãƒ¼å®¹é‡ãŒå¿…è¦ã«ãªã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚ + + + + + -debug + + ディテクタ実行ãŠã‚ˆã³ã‚¯ãƒ©ã‚¹åˆ†æžã®ãƒˆãƒ¬ãƒ¼ã‚¹æƒ…å ±ãŒæ¨™æº–出力ã«å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚分æžãŒäºˆæœŸã›ãšå¤±æ•—ã—ãŸéš›ã®ã€ãƒˆãƒ©ãƒ–ルシューティングã«æœ‰ç”¨ã§ã™ã€‚ + + + + + -property name=value + + ã“ã®ã‚ªãƒ—ションを使用ã—ã¦ã‚·ã‚¹ãƒ†ãƒ ãƒ—ロパティーを設定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ &FindBugs; ã¯ã‚·ã‚¹ãƒ†ãƒ ãƒ—ロパティーを使用ã—ã¦åˆ†æžç‰¹æ€§ã®è¨­å®šã‚’è¡Œã„ã¾ã™ã€‚ ã‚’å‚ç…§ã—ã¦ãã ã•ã„。ã“ã®ã‚ªãƒ—ションを複数指定ã—ã¦ã€è¤‡æ•°ã®ã‚·ã‚¹ãƒ†ãƒ ãƒ—ロパティを設定ã™ã‚‹ã“ã¨ãŒå¯èƒ½ã§ã™ã€‚注: Windows ã®å¤šãã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯ã€ name=value 文字列を引用符ã§å›²ã‚€å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ + + + + + + + + + + + + +コマンドラインオプション + + + +ã“ã®ã‚»ã‚¯ã‚·ãƒ§ãƒ³ã§ã¯ã€ &FindBugs; ãŒã‚µãƒãƒ¼ãƒˆã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã‚ªãƒ—ションã«ã¤ã„ã¦èª¬æ˜Žã—ã¾ã™ã€‚ã“ã“ã§ç¤ºã™ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã‚ªãƒ—ションã¯ã€ &FindBugs; 直接起動ã€ã¾ãŸã¯ã€ãƒ©ãƒƒãƒ—ã—ã¦ã„るスクリプトã«ã‚ˆã‚‹èµ·å‹•ã§ä½¿ç”¨ã§ãã¾ã™ã€‚ + + +共通ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã‚ªãƒ—ション + +ã“ã“ã§ç¤ºã™ã‚ªãƒ—ションã¯ã€ GUI ãŠã‚ˆã³ コマンドラインインタフェースã®ä¸¡æ–¹ã§ä½¿ç”¨ã§ãã¾ã™ã€‚ + + + + + -effort:min + + ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€ç²¾åº¦ã‚’上ã’ã‚‹ãŸã‚ã«å¤§é‡ã®ãƒ¡ãƒ¢ãƒªãƒ¼ã‚’消費ã™ã‚‹åˆ†æžãŒç„¡åŠ¹ã«ãªã‚Šã¾ã™ã€‚&FindBugs; ã®å®Ÿè¡Œæ™‚ã«ãƒ¡ãƒ¢ãƒªãƒ¼ä¸è¶³ã«ãªã£ãŸã‚Šã€åˆ†æžã‚’完了ã™ã‚‹ã¾ã§ã«ç•°å¸¸ã«é•·ã„時間ãŒã‹ã‹ã‚‹å ´åˆã«è©¦ã—ã¦ã¿ã¦ãã ã•ã„。 + + + + + + -effort:max + + 精度ãŒé«˜ãã€ã‚ˆã‚Šå¤šãã®ãƒã‚°ã‚’検出ã™ã‚‹åˆ†æžã‚’有効ã«ã—ã¾ã™ã€‚ãŸã ã—ã€å¤šãã®ãƒ¡ãƒ¢ãƒªãƒ¼å®¹é‡ã‚’å¿…è¦ã¨ã—ã€ã¾ãŸã€å®Œäº†ã¾ã§ã®æ™‚é–“ãŒå¤šãã‹ã‹ã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚ + + + + + -project project + + 分æžã™ã‚‹ãƒ—ロジェクトを指定ã—ã¾ã™ã€‚指定ã™ã‚‹ãƒ—ロジェクトファイルã«ã¯ã€ GUI を使ã£ã¦ä½œæˆã—ãŸã‚‚ã®ã‚’使用ã—ã¦ãã ã•ã„。ファイルã®æ‹¡å¼µå­ã¯ã€ä¸€èˆ¬çš„ã«ã¯ .fb ã¾ãŸã¯ .fbp ã§ã™ã€‚ + + + + + + + + + + +GUI オプション + +ã“ã“ã§ç¤ºã™ã‚ªãƒ—ションã¯ã€ã‚°ãƒ©ãƒ•ã‚£ã‚«ãƒ«ãƒ¦ãƒ¼ã‚¶ãƒ¼ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã§ã®ã¿ä½¿ç”¨ã§ãã¾ã™ã€‚ -look:plastic|gtk|native + + Swing ã®ãƒ«ãƒƒã‚¯ãƒ»ã‚¢ãƒ³ãƒ‰ãƒ»ãƒ•ã‚£ãƒ¼ãƒ«ã‚’設定ã—ã¾ã™ã€‚ + + + + + + + + +テキストユーザーインタフェースオプション + +ã“ã“ã§ç¤ºã™ã‚ªãƒ—ションã¯ã€ãƒ†ã‚­ã‚¹ãƒˆãƒ¦ãƒ¼ã‚¶ãƒ¼ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã§ã®ã¿ä½¿ç”¨ã§ãã¾ã™ã€‚ + + + + -sortByClass + + 報告ã•ã‚Œã‚‹ãƒã‚°æ¤œç´¢çµæžœã‚’クラスåã§ã‚½ãƒ¼ãƒˆã—ã¾ã™ã€‚ + + + + + -include filterFile.xml + + filterFile.xml ã§æŒ‡å®šã—ãŸãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ã«ä¸€è‡´ã—ãŸãƒã‚°æ¤œç´¢çµæžœã®ã¿å ±å‘Šã•ã‚Œã¾ã™ã€‚ ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + + -exclude filterFile.xml + + filterFile.xml ã§æŒ‡å®šã—ãŸãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ã«ä¸€è‡´ã—ãŸãƒã‚°æ¤œç´¢çµæžœã¯å ±å‘Šã•ã‚Œã¾ã›ã‚“。 ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + + -onlyAnalyze com.foobar.MyClass,com.foobar.mypkg.* + + コンマ区切りã§æŒ‡å®šã—ãŸã‚¯ãƒ©ã‚¹ãŠã‚ˆã³ãƒ‘ッケージã®ã¿ã«é™å®šã—ã¦ã€ãƒã‚°æ¤œå‡ºã®åˆ†æžã‚’è¡Œã†ã‚ˆã†ã«ã—ã¾ã™ã€‚フィルターã¨é•ã£ã¦ã€ã“ã®ã‚ªãƒ—ションを使ã†ã¨ä¸€è‡´ã—ãªã„クラスãŠã‚ˆã³ãƒ‘ッケージã«å¯¾ã™ã‚‹åˆ†æžã®å®Ÿè¡Œã‚’回é¿ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚大ããªãƒ—ロジェクトã«ãŠã„ã¦ã€ã“ã®ã‚ªãƒ—ションを活用ã™ã‚‹ã¨åˆ†æžã«ã‹ã‹ã‚‹æ™‚間を大ãã削減ã™ã‚‹ã“ã¨ãŒã§ãã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚(ã—ã‹ã—ãªãŒã‚‰ã€ã‚¢ãƒ—リケーションã®å…¨ä½“ã§å®Ÿè¡Œã—ã¦ã„ãªã„ãŸã‚ã«ä¸æ­£ç¢ºãªçµæžœã‚’出ã—ã¦ã—ã¾ã†ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ãŒã‚ã‚‹å¯èƒ½æ€§ã‚‚ã‚ã‚Šã¾ã™ã€‚) クラスã¯ãƒ‘ッケージもå«ã‚“ã å®Œå…¨ãªåå‰ã‚’指定ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ã¾ãŸã€ãƒ‘ッケージã¯ã€ Java ã® import æ–‡ã§ãƒ‘ッケージ下ã®ã™ã¹ã¦ã®ã‚¯ãƒ©ã‚¹ã‚’インãƒãƒ¼ãƒˆã™ã‚‹ã¨ãã¨åŒã˜æ–¹æ³•ã§æŒ‡å®šã—ã¾ã™ã€‚ (ã™ãªã‚ã¡ã€ãƒ‘ッケージã®å®Œå…¨ãªåå‰ã« .* を付ã‘加ãˆãŸå½¢ã§ã™ã€‚).* ã®ä»£ã‚ã‚Šã« .- を指定ã™ã‚‹ã¨ã€ã‚µãƒ–パッケージもå«ã‚ã¦ã™ã¹ã¦ãŒåˆ†æžã•ã‚Œã¾ã™ã€‚ + + + + + -low + + ã™ã¹ã¦ã®ãƒã‚°ãŒå ±å‘Šã•ã‚Œã¾ã™ã€‚ + + + + + -medium + + 優先度 (中) ãŠã‚ˆã³å„ªå…ˆåº¦ (高) ã®ãƒã‚°ãŒå ±å‘Šã•ã‚Œã¾ã™ã€‚ã“ã‚Œã¯ã€ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã®è¨­å®šå€¤ã§ã™ã€‚ + + + + + -high + + 優先度 (高) ã®ãƒã‚°ã®ã¿ãŒå ±å‘Šã•ã‚Œã¾ã™ã€‚ + + + + + -relaxed + + 手抜ã報告モードã§ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€å¤šãã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã«ãŠã„㦠誤検出を回é¿ã™ã‚‹ãŸã‚ã®ãƒ’ューリスティック機能ãŒæŠ‘æ­¢ã•ã‚Œã¾ã™ã€‚ + + + + + -xml + + ãƒã‚°å ±å‘ŠãŒ XML ã§ä½œæˆã•ã‚Œã¾ã™ã€‚作æˆã•ã‚ŒãŸ XML データ㯠ã€å¾Œã§ GUI ã§è¦‹ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®ã‚ªãƒ—ション㯠-xml:withMessages ã¨æŒ‡å®šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã“ã†ã™ã‚‹ã¨ 出力 XML ã«ã¯ å„ãƒã‚°ã«é–¢ã—ã¦äººé–“ã«èª­ã‚€ã“ã¨ãŒã§ãるメッセージãŒå«ã¾ã‚Œã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã§ä½œæˆã•ã‚ŒãŸ XML ファイル㯠報告書ã«å¤‰æ›ã™ã‚‹ã®ãŒç°¡å˜ã§ã™ã€‚ + + + + + -html + + HTML 出力ãŒç”Ÿæˆã•ã‚Œã¾ã™ã€‚デフォルトã§ã¯ &FindBugs; 㯠default.xsl XSLT スタイルシートを使用ã—㦠HTML 出力を生æˆã—ã¾ã™: ã“ã®ãƒ•ã‚¡ã‚¤ãƒ«ã¯ã€ findbugs.jar ã®ä¸­ã€ã¾ãŸã¯ã€ &FindBugs; ã®ã‚½ãƒ¼ã‚¹é…布物もã—ãã¯ãƒã‚¤ãƒŠãƒªé…布物ã®ä¸­ã«ã‚ã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã«ã¯ã€æ¬¡ã®ã‚ˆã†ãªãƒãƒªã‚¨ãƒ¼ã‚·ãƒ§ãƒ³ã‚‚存在ã—ã¾ã™ã€‚ã™ãªã‚ã¡ã€ -html:plain.xsl 〠-html:fancy.xsl ãŠã‚ˆã³ -html:fancy-hist.xsl ã§ã™ã€‚plain.xsl スタイルシート㯠Javascript ã‚„ DOM を利用ã—ã¾ã›ã‚“。ã—ãŸãŒã£ã¦ã€å¤ã„Web ブラウザ使用時やå°åˆ·æ™‚ã«ã‚‚比較的ã†ã¾ã表示ã•ã‚Œã‚‹ã§ã—ょã†ã€‚fancy.xsl スタイルシート㯠DOM 㨠Javascript を利用ã—ã¦ãƒŠãƒ“ゲーションを行ã„ã¾ã™ã€‚ã¾ãŸã€ãƒ“ジュアル表示㫠CSS を使用ã—ã¾ã™ã€‚fancy-hist.xsl 㯠fancy.xsl スタイルシートを更ã«é€²åŒ–ã•ã›ãŸã‚‚ã®ã§ã™ã€‚DOM ã‚„ Javascript ã‚’ãµã‚“ã ã‚“ã«é§†ä½¿ã—ã¦ã€ãƒã‚°ã®ä¸€è¦§ã‚’å‹•çš„ã«ãƒ•ã‚£ãƒ«ã‚¿ãƒªãƒ³ã‚°ã—ã¾ã™ã€‚ + + ユーザー自身㮠XSLT スタイルシートを用ã„㦠HTML ã¸ã®å¤‰æ›ã‚’è¡Œã„ãŸã„å ´åˆã¯ã€ -html:myStylesheet.xsl ã®ã‚ˆã†ã«æŒ‡å®šã—ã¦ãã ã•ã„。ã“ã“ã§ã€ myStylesheet.xsl ã¯ãƒ¦ãƒ¼ã‚¶ãƒ¼ãŒä½¿ç”¨ã—ãŸã„スタイルシートã®ãƒ•ã‚¡ã‚¤ãƒ«åã§ã™ã€‚ + + + + + -emacs + + ãƒã‚°å ±å‘ŠãŒ Emacs å½¢å¼ã§ä½œæˆã•ã‚Œã¾ã™ã€‚ + + + + + -xdocs + + ãƒã‚°å ±å‘ŠãŒ xdoc XML å½¢å¼ã§ä½œæˆã•ã‚Œã¾ã™ã€‚Apache Mavenã§ä½¿ç”¨ã§ãã¾ã™ã€‚ + + + + + -output ファイルå + + 指定ã—ãŸãƒ•ã‚¡ã‚¤ãƒ«ã«å‡ºåŠ›çµæžœãŒä½œæˆã•ã‚Œã¾ã™ã€‚ + + + + + -outputFile ファイルå + + ã“ã®å¼•æ•°ã¯ã€ä½¿ç”¨ã™ã¹ãã§ã¯ã‚ã‚Šã¾ã›ã‚“。代ã‚ã‚Šã«ã€ -output を使用ã—ã¦ãã ã•ã„。 + + + + + -nested[:true|false] + + ã“ã®ã‚ªãƒ—ションã¯ã€ãƒ•ã‚¡ã‚¤ãƒ«ã‚„ディレクトリーã®ä¸­ã§å…¥ã‚Œå­ã«ãªã£ãŸ jar ãŠã‚ˆã³ zip ファイルを分æžã™ã‚‹ã‹ã©ã†ã‹ã‚’指定ã—ã¾ã™ã€‚デフォルトã§ã¯ã€å…¥ã‚Œå­ã«ãªã£ãŸ jar ãŠã‚ˆã³ zip ファイルも分æžã—ã¾ã™ã€‚入れå­ã«ãªã£ãŸ jar ãŠã‚ˆã³ zip ファイルã®åˆ†æžã™ã‚‹ã‚’無効ã«ã™ã‚‹å ´åˆã¯ã€ -nested:false をコマンドライン引数ã«è¿½åŠ ã—ã¦ãã ã•ã„。 + + + + + -auxclasspath クラスパス + + 分æžæ™‚ã«ä½¿ç”¨ã™ã‚‹è£œåŠ©ã‚¯ãƒ©ã‚¹ãƒ‘スを設定ã—ã¾ã™ã€‚分æžã™ã‚‹ãƒ—ログラムã§ä½¿ç”¨ã™ã‚‹jarファイルやクラスディレクトリーをã™ã¹ã¦æŒ‡å®šã—ã¦ãã ã•ã„。補助クラスパスã«æŒ‡å®šã—ãŸã‚¯ãƒ©ã‚¹ã¯åˆ†æžã®å¯¾è±¡ã«ã¯ãªã‚Šã¾ã›ã‚“。 + + + + + + + + + + + + + + + &FindBugs; GUI ã®ä½¿ç”¨æ–¹æ³• + + ã“ã®ç« ã§ã¯ã€&FindBugs; グラフィカルユーザーインタフェース (GUI) ã®ä½¿ç”¨æ–¹æ³•ã‚’説明ã—ã¾ã™ã€‚ + + +プロジェクトã®ä½œæˆ +findbugs コマンド㧠&FindBugs; ã‚’èµ·å‹•ã—ã¦ã‹ã‚‰ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã§ FileNew Project ã‚’é¸æŠžã—ã¦ãã ã•ã„。ãã†ã™ã‚‹ã¨ã€æ¬¡ã®ã‚ˆã†ãªãƒ€ã‚¤ã‚¢ãƒ­ã‚°ãŒè¡¨ç¤ºã•ã‚Œã¾ã™: + + + + + + +「Class archives and directories to analyzeã€ãƒ†ã‚­ã‚¹ãƒˆãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã®æ¨ªã«ã‚ã‚‹ 「Addã€ãƒœã‚¿ãƒ³ã‚’押ã™ã¨ã€ãƒã‚°ã‚’分æžã™ã‚‹ java クラスをå«ã‚“ã§ã„ã‚‹ Java アーカイブファイル (zip, jar, ear, or war file) ã‚’é¸æŠžã—ã¦æŒ‡å®šã§ãã¾ã™ã€‚複数㮠アーカイブ/ディレクトリーを追加ã™ã‚‹ã“ã¨ãŒå¯èƒ½ã§ã™ã€‚ + +ã¾ãŸã€åˆ†æžã‚’行ㆠJava アーカイブã®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã‚’å«ã‚“ã ã‚½ãƒ¼ã‚¹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã‚’指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ãã†ã™ã‚‹ã¨ã€ãƒã‚°ã®å¯èƒ½æ€§ãŒã‚るソースコードã®å ´æ‰€ãŒã€&FindBugs; 上ã§ãƒã‚¤ãƒ©ã‚¤ãƒˆã—ã¦è¡¨ç¤ºã•ã‚Œã¾ã™ã€‚ソースディレクトリーã¯ã€Java パッケージ階層ã®ãƒ«ãƒ¼ãƒˆãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã‚’指定ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚例ãˆã°ã€ãƒ¦ãƒ¼ã‚¶ã®ã‚¢ãƒ—リケーション㌠org.foobar.myapp パッケージã®ä¸­ã«ã‚ã‚‹å ´åˆã¯ã€ org ディレクトリーã®è¦ªãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã‚’ソースディレクトリーリストã«æŒ‡å®šã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ + +ã‚‚ã†ã²ã¨ã¤ã€ä»»æ„指定ã®æ‰‹é †ãŒã‚ã‚Šã¾ã™ã€‚ãã‚Œã¯ã€è£œåŠ©ç”¨ã® Jar ファイルãŠã‚ˆã³ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã‚’ 「Auxiliary classpath locationsã€ã®ã‚¨ãƒ³ãƒˆãƒªãƒ¼ã«è¿½åŠ ã™ã‚‹ã“ã¨ã§ã™ã€‚分æžã™ã‚‹ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–/ディレクトリーã«ã‚‚標準ã®å®Ÿè¡Œæ™‚クラスパスã«ã‚‚å«ã¾ã‚Œã¦ã„ãªã„クラスをã€åˆ†æžã™ã‚‹ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–/ディレクトリーãŒå‚ç…§ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã“ã®é …目を設定ã—ãŸæ–¹ãŒã„ã„ã§ã—ょã†ã€‚クラス階層ã«é–¢ã™ã‚‹æƒ…報を使用ã™ã‚‹ãƒã‚°ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ãŒã€ &FindBugs; ã«ã¯ã„ãã¤ã‹ã‚ã‚Šã¾ã™ã€‚ã—ãŸãŒã£ã¦ã€&FindBugs; ãŒåˆ†æžã‚’è¡Œã†ã‚¯ãƒ©ã‚¹ã®å®Œå…¨ãªã‚¯ãƒ©ã‚¹éšŽå±¤ã‚’å‚ç…§ã§ãã‚Œã°ã€ã‚ˆã‚Šæ­£ç¢ºãªåˆ†æžçµæžœã‚’å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + +分æžã®å®Ÿè¡Œ +アーカイブã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ãŠã‚ˆã³ã‚½ãƒ¼ã‚¹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã®æŒ‡å®šãŒã§ãã‚Œã°ã€ã€ŒFinishã€ãƒœã‚¿ãƒ³ã‚’押ã—㦠Jar ファイルã«å«ã¾ã‚Œã‚‹ã‚¯ãƒ©ã‚¹ã«å¯¾ã™ã‚‹åˆ†æžã‚’実行ã—ã¾ã™ã€‚巨大ãªãƒ—ロジェクトをå¤ã„コンピュータ上ã§å®Ÿè¡Œã™ã‚‹ã¨ã€ã‹ãªã‚Šã®æ™‚é–“(æ•°å分)ãŒã‹ã‹ã‚‹ã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•ã„。大容é‡ãƒ¡ãƒ¢ãƒªã§ã‚る最近ã®ã‚³ãƒ³ãƒ”ュータãªã‚‰ã€å¤§ããªãƒ—ログラムã§ã‚ã£ã¦ã‚‚数分程度ã§åˆ†æžã§ãã¾ã™ã€‚ + + + +çµæžœã®é–²è¦§ + +分æžãŒå®Œäº†ã™ã‚‹ã¨ã€æ¬¡ã®ã‚ˆã†ãªç”»é¢ãŒè¡¨ç¤ºã•ã‚Œã¾ã™ : + + + + + + +左上ã®ãƒšã‚¤ãƒ³ã«ã¯ãƒã‚°éšŽå±¤ãƒ„リーãŒè¡¨ç¤ºã•ã‚Œã¾ã™ã€‚ã“ã‚Œã¯ã€åˆ†æžã§ã¿ã¤ã‹ã£ãŸãƒã‚°ã®æ¤œç´¢çµæžœãŒéšŽå±¤çš„ã«è¡¨ç¤ºã•ã‚ŒãŸã‚‚ã®ã§ã™ã€‚ + +上部ã®ãƒšã‚¤ãƒ³ã§ãƒã‚°æ¤œç´¢çµæžœã‚’é¸æŠžã™ã‚‹ã¨ã€ä¸‹éƒ¨ã®ã€ŒDetailsã€ãƒšã‚¤ãƒ³ã«ãƒã‚°ã®è©³ç´°èª¬æ˜ŽãŒè¡¨ç¤ºã•ã‚Œã¾ã™ã€‚æ›´ã«ã€ã‚½ãƒ¼ã‚¹ãŒã¿ã¤ã‹ã‚Œã°ã€å³ä¸Šã®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ãƒšã‚¤ãƒ³ã«ãƒã‚°ã®å‡ºç¾ç®‡æ‰€ã«è©²å½“ã™ã‚‹ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ãŒè¡¨ç¤ºã•ã‚Œã¾ã™ã€‚上図ã®ä¾‹ã§è¡¨ç¤ºã•ã‚Œã¦ã„ã‚‹ãƒã‚°ã¯ã€ã‚¹ãƒˆãƒªãƒ¼ãƒ ã‚ªãƒ–ジェクトãŒã‚¯ãƒ­ãƒ¼ã‚ºã•ã‚Œã¦ã„ãªã„ã¨ã„ã†ã‚‚ã®ã§ã™ã€‚ソースコード・ウィンドウã«ãŠã„ã¦å½“該ストリームオブジェクトを生æˆã—ã¦ã„ã‚‹è¡ŒãŒãƒã‚¤ãƒ©ã‚¤ãƒˆã•ã‚Œã¦ã„ã¾ã™ã€‚ + +ãƒã‚°ã®æ¤œç´¢çµæžœã«å¯¾ã—ã¦ãƒ†ã‚­ã‚¹ãƒˆã§æ³¨é‡ˆã‚’入れるã“ã¨ãŒã§ãã¾ã™ã€‚階層ツリー図ã®ã™ã下ã«ã‚るテキストボックスã«æ³¨é‡ˆã‚’入力ã—ã¦ãã ã•ã„。記録ã—ã¦ãŠããŸã„情報を何ã§ã‚‚自由ã«å…¥åŠ›ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ãƒã‚°çµæžœãƒ•ã‚¡ã‚¤ãƒ«ã®ä¿å­˜ãŠã‚ˆã³èª­ã¿è¾¼ã¿ã‚’è¡Œã£ãŸã¨ãã«ã€æ³¨é‡ˆã‚‚ä¿å­˜ã•ã‚Œã¾ã™ã€‚ + + + + +ä¿å­˜ã¨èª­ã¿è¾¼ã¿ + +メニュー項目ã‹ã‚‰ FileSave as... ã‚’é¸æŠžã™ã‚‹ã¨ã€ãƒ¦ãƒ¼ã‚¶ãƒ¼ã®ä½œæ¥­çµæžœã‚’ä¿å­˜ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚「Save as...ã€ãƒ€ã‚¤ã‚¢ãƒ­ã‚°ã«ã‚るドロップダウン・リストã®ä¸­ã‹ã‚‰ã€ŒFindBugs analysis results (.xml)ã€ã‚’é¸æŠžã“ã¨ã§ã€ãƒ¦ãƒ¼ã‚¶ãƒ¼ãŒæŒ‡å®šã—㟠jar ファイルリストやãƒã‚°æ¤œç´¢çµæžœãªã©ã®ä½œæ¥­çµæžœã‚’ä¿å­˜ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸã€jar ファイルリストã®ã¿ã‚’ä¿å­˜ã™ã‚‹é¸æŠžè‚¢ (「FindBugs project file (.fbp)ã€) ã‚„ãƒã‚°æ¤œç´¢çµæžœã®ã¿ã‚’ä¿å­˜ã™ã‚‹é¸æŠžè‚¢ (「FindBugs analysis file (.fba)ã€) ã‚‚ã‚ã‚Šã¾ã™ã€‚ä¿å­˜ã—ãŸãƒ•ã‚¡ã‚¤ãƒ«ã¯ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼é …ç›®ã‹ã‚‰ FileOpen... ã‚’é¸æŠžã™ã‚‹ã“ã¨ã§ã€èª­ã¿è¾¼ã‚€ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + + + + + + + +&FindBugs;™ &Ant; タスクã®ä½¿ç”¨æ–¹æ³• + +ã“ã®ç« ã§ã¯ã€ &FindBugs; ã‚’ &Ant; ã®ãƒ“ルドスクリプトã«çµ„ã¿å…¥ã‚Œã‚‹æ–¹æ³•ã«ã¤ã„ã¦èª¬æ˜Žã—ã¾ã™ã€‚ &Ant; ã¯ã€ãƒ“ルドやé…備を行ã†ã“ã¨ãŒã§ãã‚‹ Java ã§ã‚ˆã使用ã•ã‚Œã‚‹ãƒ„ールã§ã™ã€‚&FindBugs; &Ant; タスクを使用ã™ã‚‹ã¨ã€ ビルドスクリプトを作æˆã—ã¦æ©Ÿæ¢°çš„ã« &FindBugs; ã«ã‚ˆã‚‹ Java コードã®åˆ†æžã‚’実行ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + +ã“ã® &Ant; タスクã¯ã€ Mike Fagan æ°ã®å¤šå¤§ãªè²¢çŒ®ã«ã‚ˆã‚‹ã‚‚ã®ã§ã™ã€‚ + + +&Ant; タスクã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ« + +&Ant; タスクã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã¯ã€ &FBHome;/lib/findbugs-ant.jar ã‚’ &Ant; インストールディレクトリーã®lib サブディレクトリーã«ã‚³ãƒ”ーã™ã‚‹ã ã‘ã§ã™ã€‚ +使用ã™ã‚‹ &Ant; タスク㨠&FindBugs; 本体ã¯ã€åŒæ¢±ã•ã‚Œã¦ã„ãŸåŒã˜ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®ã‚‚ã®ã‚’使用ã™ã‚‹ã“ã¨ã‚’å¼·ã推奨ã—ã¾ã™ã€‚別ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã® &FindBugs; ã«å«ã¾ã‚Œã¦ã„㟠&Ant; タスク Jar ファイルã§ã®å‹•ä½œã¯ä¿è¨¼ã—ã¾ã›ã‚“。 + + + + + + +build.xml ã®æ›¸ãæ–¹ + +&FindBugs; ã‚’ build.xml (&Ant; ビルドスクリプト) ã«çµ„ã¿å…¥ã‚Œã‚‹ãŸã‚ã«ã¯ã¾ãšã€ã‚¿ã‚¹ã‚¯å®šç¾©ã‚’記述ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚タスク定義ã¯æ¬¡ã®ã‚ˆã†ã«è¨˜è¿°ã—ã¾ã™ã€‚: + <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/> +タスク定義ã¯ã€ findbugs è¦ç´ ã‚’ build.xml 上ã«è¨˜è¿°ã—ãŸã¨ãã€ãã®ã‚¿ã‚¹ã‚¯ã®å®Ÿè¡Œã«ä½¿ç”¨ã•ã‚Œã‚‹ã‚¯ãƒ©ã‚¹ã‚’指定ã—ã¾ã™ã€‚ + +タスク定義ã®è¨˜è¿°ã‚’ã™ã‚Œã°ã€findbugs タスクを使ã£ã¦ã‚¿ãƒ¼ã‚²ãƒƒãƒˆã‚’定義ã§ãã¾ã™ã€‚次ã«ç¤ºã™ã®ã¯ã€ Apache BCEL ライブラリーを分æžã™ã‚‹å ´åˆã‚’想定ã—㟠build.xml ã®è¨˜è¿°ä¾‹ã§ã™ã€‚ + <property name="findbugs.home" value="/export/home/daveho/work/findbugs" /> + + <target name="findbugs" depends="jar"> + <findbugs home="${findbugs.home}" + output="xml" + outputFile="bcel-fb.xml" > + <auxClasspath path="${basedir}/lib/Regex.jar" /> + <sourcePath path="${basedir}/src/java" /> + <class location="${basedir}/bin/bcel.jar" /> + </findbugs> + </target> +findbugs è¦ç´ ã«ã¯ã€ home 属性ãŒå¿…é ˆã§ã™ã€‚ &FindBugs; ã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã™ãªã‚ã¡ &FBHome; ã®å€¤ã‚’設定ã—ã¾ã™ã€‚ ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + +ã“ã®ã‚¿ãƒ¼ã‚²ãƒƒãƒˆã¯ bcel.jar ã«å¯¾ã—㦠&FindBugs; を実行ã—ã¾ã™ã€‚ã“ã® Jar ファイルã¯ã€ BCEL ビルドスクリプトã«ã‚ˆã£ã¦ä½œæˆã•ã‚Œã‚‹ã‚‚ã®ã§ã™ã€‚(上記ã®ã‚¿ãƒ¼ã‚²ãƒƒãƒˆãŒã€Œjarã€ã‚¿ãƒ¼ã‚²ãƒƒãƒˆã«ä¾å­˜ã—ã¦ã„ã‚‹ (depends) ã¨è¨­å®šã™ã‚‹ã“ã¨ã«ã‚ˆã‚Šã€ &FindBugs; ãŒå®Ÿè¡Œã•ã‚Œã‚‹å‰ã«å½“該ライブラリーãŒå®Œå…¨ã«ã‚³ãƒ³ãƒ‘イルã•ã‚Œã¦ã„ã‚‹ã“ã¨ã‚’ä¿è¨¼ã—ã¦ã„ã¾ã™ã€‚) &FindBugs; ã®å‡ºåŠ›ã¯ã€ XML å½¢å¼ã§ bcel-fb.xml ファイルã«ä¿å­˜ã•ã‚Œã¾ã™ã€‚補助 Jar ファイル Regex.jar ã‚’ aux classpath ã«è¨˜è¿°ã—ã¦ã„ã¾ã™ã€‚ãªãœãªã‚‰ã€å½“該 Jar ファイル㌠BCEL メイン・ライブラリーã‹ã‚‰å‚ç…§ã•ã‚Œã‚‹ã‹ã‚‰ã§ã™ã€‚source path を指定ã™ã‚‹ã“ã¨ã§ã€ä¿å­˜ã•ã‚Œã‚‹ãƒã‚°ãƒ‡ãƒ¼ã‚¿ã« BCEL ソースコードã¸ã®æ­£ç¢ºãªå‚ç…§ãŒè¨˜è¿°ã•ã‚Œã¾ã™ã€‚ + + + +タスクã®å®Ÿè¡Œ + +コマンドラインã‹ã‚‰ &Ant; ã‚’èµ·å‹•ã™ã‚‹ä¾‹ã‚’次ã«ç¤ºã—ã¾ã™ã€‚å‰è¿°ã® findbugs ターゲットを使用ã—ã¦ã„ã¾ã™ã€‚ + [daveho@noir]$ ant findbugs + Buildfile: build.xml + + init: + + compile: + + examples: + + jar: + + findbugs: + [findbugs] Running FindBugs... + [findbugs] Bugs were found + [findbugs] Output saved to bcel-fb.xml + + BUILD SUCCESSFUL + Total time: 35 seconds +ã“ã®äº‹ä¾‹ã«ãŠã„ã¦ã¯ã€XML ファイルã§ãƒã‚°æ¤œç´¢çµæžœã‚’ä¿å­˜ã—ã¦ã„ã‚‹ã®ã§ã€ &FindBugs; GUI を使ã£ã¦çµæžœã‚’å‚ç…§ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + +パラメーター + +ã“ã®ã‚»ã‚¯ã‚·ãƒ§ãƒ³ã§ã¯ã€ &FindBugs; タスクを使用ã™ã‚‹éš›ã«ã€æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãるパラメーターã«ã¤ã„ã¦èª¬æ˜Žã—ã¾ã™ã€‚ class + + 分æžã®å¯¾è±¡ã¨ãªã‚‹ã‚¯ãƒ©ã‚¹ç¾¤ã‚’指定ã™ã‚‹ãŸã‚ã®ãƒã‚¹ãƒˆã•ã‚Œã‚‹è¦ç´ ã§ã™ã€‚class è¦ç´ ã«ã¯ location 属性ã®æŒ‡å®šãŒå¿…é ˆã§ã™ã€‚分æžå¯¾è±¡ã¨ãªã‚‹ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–ファイル (jar, zip, ä»–)ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã¾ãŸã¯ã‚¯ãƒ©ã‚¹ãƒ•ã‚¡ã‚¤ãƒ«ã®åå‰ã‚’記述ã—ã¾ã™ã€‚1 ã¤ã® findbugs è¦ç´ ã«å¯¾ã—ã¦ã€è¤‡æ•°ã® class å­è¦ç´ ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + + auxClasspath + + ä»»æ„指定ã®ãƒã‚¹ãƒˆã•ã‚Œã‚‹è¦ç´ ã§ã™ã€‚分æžå¯¾è±¡ã®ãƒ©ã‚¤ãƒ–ラリーã¾ãŸã¯ã‚¢ãƒ—リケーションã«ã‚ˆã£ã¦ä½¿ç”¨ã•ã‚Œã¦ã„ã‚‹ãŒåˆ†æžã®å¯¾è±¡ã«ã¯ã—ãŸããªã„クラスをå«ã‚“ã§ã„るクラスパス (Jar ファイルã¾ãŸã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼) を指定ã—ã¾ã™ã€‚ &Ant; ã® Java タスクã«ã‚ã‚‹ classpath è¦ç´  ã¨åŒã˜æ–¹æ³•ã§æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + + sourcePath + + ä»»æ„指定ã®ãƒã‚¹ãƒˆã•ã‚Œã‚‹è¦ç´ ã§ã™ã€‚分æžå¯¾è±¡ Java コードã®ã‚³ãƒ³ãƒ‘イル時ã«ä½¿ç”¨ã—ãŸã‚½ãƒ¼ã‚¹ãƒ•ã‚¡ã‚¤ãƒ«ã‚’å«ã‚“ã§ã„るソースディレクトリーã¸ã®ãƒ‘スを指定ã—ã¾ã™ã€‚ソースパスを指定ã™ã‚‹ã“ã¨ã«ã‚ˆã‚Šã€ç”Ÿæˆã•ã‚Œã‚‹ XML ã®ãƒã‚°å‡ºåŠ›çµæžœã«å®Œå…¨ãªã‚½ãƒ¼ã‚¹æƒ…報をもãŸã›ã‚‹ã“ã¨ãŒã§ãã€å¾Œã«ãªã£ã¦ GUI ã§å‚ç…§ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + + home + + 必須属性ã§ã™ã€‚&FindBugs; ãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•ã‚Œã¦ã„るディレクトリーåを設定ã—ã¾ã™ã€‚ + + + + + quietErrors + + ä»»æ„指定ã®ãƒ–ール値属性ã§ã™ã€‚true を設定ã™ã‚‹ã¨ã€æ·±åˆ»ãªåˆ†æžã‚¨ãƒ©ãƒ¼ç™ºç”Ÿã‚„クラスãŒã¿ã¤ã‹ã‚‰ãªã„ã¨ã„ã£ãŸæƒ…報㌠&FindBugs; 出力ã«è¨˜éŒ²ã•ã‚Œã¾ã›ã‚“。デフォルトã¯ã€ false ã§ã™ã€‚ + + + + + reportLevel + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚報告ã•ã‚Œã‚‹ãƒã‚°ã®å„ªå…ˆåº¦ã®ã—ãã„値を指定ã—ã¾ã™ã€‚「lowã€ã«è¨­å®šã™ã‚‹ã¨ã€ã™ã¹ã¦ã®ãƒã‚°ãŒå ±å‘Šã•ã‚Œã¾ã™ã€‚「medium〠(デフォルト) ã«è¨­å®šã™ã‚‹ã¨ã€å„ªå…ˆåº¦ (中)ãŠã‚ˆã³å„ªå…ˆåº¦ (高)ã®ãƒã‚°ãŒå ±å‘Šã•ã‚Œã¾ã™ã€‚「highã€ã«è¨­å®šã™ã‚‹ã¨ã€å„ªå…ˆåº¦ (高) ã®ãƒã‚°ã®ã¿ãŒå ±å‘Šã•ã‚Œã¾ã™ã€‚ + + + + + output + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚出力形å¼ã‚’指定ã—ã¾ã™ã€‚「xml〠(デフォルト) ã«è¨­å®šã™ã‚‹ã¨ã€å‡ºåŠ›ã¯ XML å½¢å¼ã«ãªã‚Šã¾ã™ã€‚「xml:withMessages〠ã«è¨­å®šã™ã‚‹ã¨ã€å‡ºåŠ›ã¯äººé–“ãŒèª­ã‚るメッセージ ãŒè¿½åŠ ã•ã‚ŒãŸ XML å½¢å¼ã«ãªã‚Šã¾ã™ã€‚(XSL スタイルシートを使ã£ã¦ãƒ¬ãƒãƒ¼ãƒˆã‚’作æˆã™ã‚‹ã“ã¨ã‚’計画ã—ã¦ã„ã‚‹å ´åˆã¯ã“ã®å½¢å¼ã‚’使用ã—ã¦ãã ã•ã„。) 「htmlã€ã«è¨­å®šã™ã‚‹ã¨ã€å‡ºåŠ›ã¯ HTML å½¢å¼(デフォルトã®ã‚¹ã‚¿ã‚¤ãƒ«ã‚·ãƒ¼ãƒˆã¯ default.xsl) ã«ãªã‚Šã¾ã™ã€‚ 「textã€ã«è¨­å®šã™ã‚‹ã¨ã€å‡ºåŠ›ã¯ç‰¹åˆ¥ãªãƒ†ã‚­ã‚¹ãƒˆå½¢å¼ã«ãªã‚Šã¾ã™ã€‚「emacsã€ã«è¨­å®šã™ã‚‹ã¨ã€å‡ºåŠ›ã¯ Emacs エラーメッセージ形å¼ã«ãªã‚Šã¾ã™ã€‚「xdocsã€ã«è¨­å®šã™ã‚‹ã¨ã€å‡ºåŠ›ã¯ Apache Maven ã§ä½¿ç”¨ã§ãã‚‹ xdoc XML ã«ãªã‚Šã¾ã™ã€‚ + + + + stylesheet + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚output 属性 ã« html を指定ã—ãŸå ´åˆã«ã€ HTML 出力作æˆã«ä½¿ç”¨ã•ã‚Œã‚‹ã‚¹ã‚¿ã‚¤ãƒ«ã‚·ãƒ¼ãƒˆã‚’指定ã—ã¾ã™ã€‚FindBugs é…布物ã«å«ã¾ã‚Œã¦ã„るスタイルシートã¯ã€ default.xsl〠fancy.xsl 〠fancy-hist.xsl 〠plain.xsl ãŠã‚ˆã³ summary.xsl ã§ã™ã€‚デフォルト値㯠default.xsl ã§ã™ã€‚ + + + + + sort + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚output 属性ã«ã€Œtextã€ã‚’指定ã—ãŸå ´åˆã«ã€ãƒã‚°ã®å ±å‘Šã‚’クラス順ã«ã‚½ãƒ¼ãƒˆã™ã‚‹ã‹ã©ã†ã‹ã‚’ sort 属性ã§æŒ‡å®šã—ã¾ã™ã€‚デフォルトã¯ã€ true ã§ã™ã€‚ + + + + + outputFile + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚指定ã—ãŸå ´åˆã€&FindBugs; ã®å‡ºåŠ›ã¯ãã®åå‰ã®ãƒ•ã‚¡ã‚¤ãƒ«ã¸ã¨ä¿å­˜ã•ã‚Œã¾ã™ã€‚çœç•¥æ™‚ã€å‡ºåŠ›ã¯ &Ant; ã«ã‚ˆã£ã¦ç›´æŽ¥è¡¨ç¤ºã•ã‚Œã¾ã™ã€‚ + + + + + debug + + ä»»æ„指定ã®ãƒ–ール値属性ã§ã™ã€‚true ã«è¨­å®šã™ã‚‹ã¨ã€ &FindBugs; 㯠診断情報を出力ã—ã¾ã™ã€‚ã©ã®ã‚¯ãƒ©ã‚¹ã‚’分æžã—ã¦ã„ã‚‹ã‹ã€ã©ã®ãƒ‘グパターンディテクタãŒå®Ÿè¡Œã•ã‚Œã¦ã„ã‚‹ã‹ã€ã¨ã„ã†æƒ…å ±ãŒè¡¨ç¤ºã•ã‚Œã¾ã™ã€‚デフォルトã¯ã€ false ã§ã™ã€‚ + + + + + effort + + 分æžã®æ´»å‹•ãƒ¬ãƒ™ãƒ«ã‚’設定ã—ã¾ã™ã€‚min ã€default ã¾ãŸã¯ max ã®ã„ãšã‚Œã‹ã®å€¤ã‚’設定ã—ã¦ãã ã•ã„。分æžãƒ¬ãƒ™ãƒ«ã®è¨­å®šã«é–¢ã™ã‚‹è©³ç´°æƒ…å ±ã¯ã€ ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + + conserveSpace + + effort="min" ã¨åŒç¾©ã§ã™ã€‚ + + + + + workHard + + effort="max" ã¨åŒç¾©ã§ã™ã€‚ + + + + + visitors + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚ã©ã®ãƒã‚°ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã‚’実行ã™ã‚‹ã‹ã‚’コンマ区切りã®ãƒªã‚¹ãƒˆã§æŒ‡å®šã—ã¾ã™ã€‚ãƒã‚°ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ãƒ‘ッケージ指定ãªã—ã®ã‚¯ãƒ©ã‚¹åã§æŒ‡å®šã—ã¾ã™ã€‚çœç•¥æ™‚ã€ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã§ç„¡åŠ¹åŒ–ã•ã‚Œã¦ã„ã‚‹ã‚‚ã®ã‚’除ãã™ã¹ã¦ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ãŒå®Ÿè¡Œã•ã‚Œã¾ã™ã€‚ + + + + + omitVisitors + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚visitors 属性ã¨ä¼¼ã¦ã„ã¾ã™ãŒã€ã“ã¡ã‚‰ã¯ 実行ã•ã‚Œãªã„ ディテクタを指定ã—ã¾ã™ã€‚ + + + + + excludeFilter + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚フィルターファイルåを指定ã—ã¾ã™ã€‚報告ã‹ã‚‰é™¤å¤–ã•ã‚Œã‚‹ãƒã‚°ã‚’指定ã—ã¾ã™ã€‚ ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + + includeFilter + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚フィルターファイルåを指定ã—ã¾ã™ã€‚報告ã•ã‚Œã‚‹ãƒã‚°ã‚’指定ã—ã¾ã™ã€‚ ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + + projectFile + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚プロジェクトファイルåを指定ã—ã¾ã™ã€‚プロジェクトファイルã¯ã€ &FindBugs; GUI ã§ä½œæˆã—ã¾ã™ã€‚分æžã•ã‚Œã‚‹ã‚¯ãƒ©ã‚¹ã€ãŠã‚ˆã³ã€è£œåŠ©ã‚¯ãƒ©ã‚¹ãƒ‘スã€ã‚½ãƒ¼ã‚¹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ãŒè¨˜å…¥ã•ã‚Œã¦ã¾ã™ã€‚プロジェクトファイルを指定ã—ãŸå ´åˆã¯ã€ class è¦ç´ ãƒ» auxClasspath 属性ãŠã‚ˆã³ sourcePath 属性を設定ã™ã‚‹å¿…è¦ã¯ã‚ã‚Šã¾ã›ã‚“。プロジェクトã®ä½œæˆæ–¹æ³•ã¯ã€ ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + + jvmargs + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚&FindBugs; を実行ã—ã¦ã„ã‚‹ Java 仮想マシンã«å¯¾ã—ã¦å—ã‘渡ã•ã‚Œã‚‹å¼•æ•°ã‚’指定ã—ã¾ã™ã€‚巨大ãªãƒ—ログラムを分æžã™ã‚‹å ´åˆã«ã€ JVM ãŒä½¿ç”¨ã™ã‚‹ãƒ¡ãƒ¢ãƒªå®¹é‡ã‚’増やã™æŒ‡å®šã‚’ã™ã‚‹ãŸã‚ã«ã“ã®å¼•æ•°ã‚’利用ã™ã‚‹å¿…è¦ãŒã‚ã‚‹ã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。 + + + + + systemProperty + + ä»»æ„指定ã®ãƒã‚¹ãƒˆã•ã‚Œã‚‹è¦ç´ ã§ã™ã€‚指定ã—ãŸå ´åˆã€Java システムプロパティーを定義ã—ã¾ã™ã€‚name 属性ã«ã¯ã‚·ã‚¹ãƒ†ãƒ ãƒ—ロパティーã®åå‰ã‚’指定ã—ã¾ã™ã€‚ãã—ã¦ã€ value 属性ã«ã¯ã‚·ã‚¹ãƒ†ãƒ ãƒ—ロパティã®å€¤ã‚’指定ã—ã¾ã™ã€‚ + + + + + timeout + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚&FindBugs; を実行ã—ã¦ã„ã‚‹ Java プロセス ã®å®Ÿè¡Œè¨±å®¹æ™‚間をミリ秒å˜ä½ã§æŒ‡å®šã—ã¾ã™ã€‚時間を超éŽã™ã‚‹ã¨ãƒãƒ³ã‚°ã‚¢ãƒƒãƒ—ã—ã¦ã„ã‚‹ã¨åˆ¤æ–­ã—ã¦ãƒ—ロセスãŒçµ‚了ã•ã‚Œã¾ã™ã€‚デフォルトã¯ã€ 600,000 ミリ秒 (10 分) ã§ã™ã€‚巨大ãªãƒ—ログラムã®å ´åˆã¯ã€ &FindBugs; ãŒåˆ†æžã‚’完了ã™ã‚‹ã¾ã§ã« 10 分 以上掛ã‹ã‚‹å¯èƒ½æ€§ãŒã‚ã‚‹ã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•ã„。 + + + + + failOnError + + ä»»æ„指定ã®ãƒ–ール値属性ã§ã™ã€‚&FindBugs; ã®å®Ÿè¡Œä¸­ã«ã‚¨ãƒ©ãƒ¼ãŒã‚ã£ãŸå ´åˆã«ã€ãƒ“ルドプロセス自体を打ã¡åˆ‡ã£ã¦ç•°å¸¸çµ‚了ã•ã›ã‚‹ã‹ã©ã†ã‹ã‚’指定ã—ã¾ã™ã€‚デフォルトã¯ã€ã€Œfalseã€ã§ã™ã€‚ + + + + + errorProperty + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚&FindBugs; ã®å®Ÿè¡Œä¸­ã«ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã«ã€ã€Œtrueã€ãŒè¨­å®šã•ã‚Œã‚‹ãƒ—ロパティーã®åå‰ã‚’指定ã—ã¾ã™ã€‚ + + + + + warningsProperty + + ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚&FindBugs; ãŒåˆ†æžã—ãŸãƒ—ログラムã«ãƒã‚°å ±å‘ŠãŒ 1 件ã§ã‚‚ã‚ã‚‹å ´åˆã«ã€ã€Œtrueã€ãŒè¨­å®šã•ã‚Œã‚‹ãƒ—ロパティーã®åå‰ã‚’指定ã—ã¾ã™ã€‚ + + + + + + + + + + + + + + + + + +&FindBugs;™ Eclipse プラグインã®ä½¿ç”¨æ–¹æ³• + +FindBugs Eclipse プラグインを使用ã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦ã€ &FindBugs; ã‚’ Eclipse IDE ã§ä½¿ç”¨ã™ã‚‹ã“ã¨ãŒã§ãるよã†ã«ãªã‚Šã¾ã™ã€‚ã“ã®FindBugs Eclipse プラグインã¯ã€ Peter Friese æ°ã®å¤šå¤§ãªè²¢çŒ®ã«ã‚ˆã‚‹ã‚‚ã®ã§ã™ã€‚Phil Crosby æ° ã¨ Andrei Loskutov æ°ã¯ã€ãƒ—ラグインã®é‡è¦ãªæ”¹è‰¯ã«è²¢çŒ®ã—ã¾ã—ãŸã€‚ + + +å¿…è¦æ¡ä»¶ + +&FindBugs; Eclipse Plugin を使用ã™ã‚‹ãŸã‚ã«ã¯ã€ Eclipse 3.3 ã‚ã‚‹ã„ã¯ãれ以é™ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã€ã¾ãŸã€ JRE/JDK 1.5 ã‚ã‚‹ã„ã¯ãれ以é™ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãŒå¿…è¦ã§ã™ã€‚ + + + + +インストール + +更新サイトãŒæä¾›ã•ã‚Œã¦ã„ã¾ã™ã€‚更新サイトを利用ã—ã¦ã€æ©Ÿæ¢°çš„ã« FindBugs ã‚’ Eclipse ã«ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã§ãã¾ã™ã€‚ã¾ãŸè‡ªå‹•çš„ã«ã€æœ€æ–°ç‰ˆã®ã‚¢ãƒƒãƒ—デートを照会ã—ã¦ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚内容ã®ç•°ãªã‚‹ 3 ã¤ã®æ›´æ–°ã‚µã‚¤ãƒˆãŒå­˜åœ¨ã—ã¾ã™ã€‚ + + FindBugs Eclipse 更新サイト一覧 + http://findbugs.cs.umd.edu/eclipse/ + + + FindBugs ã®å…¬å¼ãƒªãƒªãƒ¼ã‚¹ç‰©ã‚’æä¾›ã—ã¾ã™ã€‚ + + + + http://findbugs.cs.umd.edu/eclips-candidate/ + + + FindBugsã®å…¬å¼ãƒªãƒªãƒ¼ã‚¹ç‰©ã«åŠ ãˆã¦ã€å…¬å¼ãƒªãƒªãƒ¼ã‚¹å€™è£œç‰ˆã‚’æä¾›ã—ã¾ã™ã€‚ + + + + http://findbugs.cs.umd.edu/eclipse-daily/ + + + FindBugsã®æ—¥æ¬¡ãƒ“ルド物をæä¾›ã—ã¾ã™ã€‚コンパイルãŒã§ãã‚‹ã“ã¨ä»¥ä¸Šã®ãƒ†ã‚¹ãƒˆã¯è¡Œã‚ã‚Œã¦ã„ã¾ã›ã‚“。 + + + + +ã¾ãŸã€æ¬¡ã«ç¤ºã™ãƒªãƒ³ã‚¯ã‹ã‚‰æ‰‹å‹•ã§ãƒ—ラグインをダウンロードã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ : http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download. 展開ã—㦠Eclipse ã®ã€Œpluginsã€ã‚µãƒ–ディレクトリーã«å…¥ã‚Œã¦ãã ã•ã„。(ãã†ã™ã‚‹ã¨ã€ <eclipse インストールディレクトリー >/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png ㌠&FindBugs; ã®ãƒ­ã‚´ãƒ•ã‚¡ã‚¤ãƒ«ã¸ã®ãƒ‘スã«ãªã‚‹ã¯ãšã§ã™ã€‚) + +プラグインã®å±•é–‹ãŒã§ããŸã‚‰ã€ Eclipse ã‚’èµ·å‹•ã—㦠Help About Eclipse Platform Plug-in Details ã‚’é¸æŠžã—ã¦ãã ã•ã„。「FindBugs Projectã€ã‹ã‚‰æä¾›ã•ã‚ŒãŸã€ŒFindBugs Plug-inã€ã¨ã„ã†ãƒ—ラグインãŒã‚ã‚‹ã“ã¨ã‚’確èªã—ã¦ãã ã•ã„。 + + + +プラグインã®ä½¿ç”¨æ–¹æ³• + +実行ã™ã‚‹ã«ã¯ã€ Java プロジェクト上ã§å³ã‚¯ãƒªãƒƒã‚¯ã—ã¦ã€ŒFind Bugsã€ã‚’é¸æŠžã—ã¾ã™ã€‚&FindBugs; ãŒå®Ÿè¡Œã•ã‚Œã¦ã€ãƒã‚°ãƒ‘ターンã®å®Ÿä¾‹ã®å¯èƒ½æ€§ãŒã‚ã‚‹ã¨è­˜åˆ¥ã•ã‚ŒãŸã‚³ãƒ¼ãƒ‰ç®‡æ‰€ã«å•é¡Œãƒžãƒ¼ã‚«ãƒ¼ãŒã¤ãã¾ã™ã€‚ (ソース画é¢ãŠã‚ˆã³ Eclipse å•é¡Œãƒ“ューã«è¡¨ç¤ºã•ã‚Œã¾ã™ã€‚) + +Java プロジェクトã®ãƒ—ロパティーダイアログを開ã„ã¦ã€ŒFindbugsã€ãƒ—ロパティーページをé¸æŠžã™ã‚‹ã“ã¨ã§ã€ &FindBugs; ã®å‹•ä½œã‚’カスタマイズã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚é¸æŠžã§ãã‚‹é …ç›®ã«ã¯æ¬¡ã®ã‚ˆã†ãªã‚‚ã®ãŒã‚ã‚Šã¾ã™ : + + + + 「Run FindBugs Automaticallyã€ãƒã‚§ãƒƒã‚¯ãƒœãƒƒã‚¯ã‚¹ã®è¨­å®šã€‚ãƒã‚§ãƒƒã‚¯ã™ã‚‹ã¨ã€ãƒ—ロジェクト内㮠Java クラスãŒä¿®æ­£ã•ã‚Œã‚‹ãŸã³ã« FindBugs ãŒå®Ÿè¡Œã•ã‚Œã¾ã™ã€‚ + + + + 優先度ã¨ãƒã‚°ã‚«ãƒ†ã‚´ãƒªãƒ¼ã®é¸æŠžã€‚ã“れらã®ã‚ªãƒ—ションã¯ã€ã©ã®è­¦å‘Šã‚’表示ã™ã‚‹ã‹ã‚’é¸æŠžã—ã¾ã™ã€‚例ãˆã°ã€å„ªå…ˆåº¦ã§ 「Medium〠をé¸æŠžã™ã‚‹ã¨ã€å„ªå…ˆåº¦ (中) ãŠã‚ˆã³å„ªå…ˆåº¦ (高) ã®è­¦å‘Šã®ã¿ãŒè¡¨ç¤ºã•ã‚Œã¾ã™ã€‚åŒæ§˜ã«ã€ã€ŒStyleã€ãƒã‚§ãƒƒã‚¯ãƒœãƒƒã‚¯ã‚¹ã®ãƒã‚§ãƒƒã‚¯ãƒžãƒ¼ã‚¯ã‚’外ã™ã¨ã€Style カテゴリーã«å±žã™ã‚‹è­¦å‘Šã¯è¡¨ç¤ºã•ã‚Œã¾ã›ã‚“。 + + + + ディテクタã®é¸æŠžã€‚表ã‹ã‚‰ãƒ—ロジェクトã§æœ‰åŠ¹ã«ã—ãŸã„ディテクタをé¸æŠžã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + + + +トラブルシューティング + +&FindBugs; Eclipse プラグインã¯ã€ã¾ã å®Ÿé¨“段階ã§ã™ã€‚ã“ã®ã‚»ã‚¯ã‚·ãƒ§ãƒ³ã§ã¯ã€ãƒ—ラグインã«é–¢ã™ã‚‹ä¸€èˆ¬çš„ãªå•é¡Œã¨ (判明ã—ã¦ã„ã‚Œã°) ãれらã®å•é¡Œã®è§£æ±ºæ–¹æ³•ã‚’記述ã—ã¾ã™ã€‚ + + + + &FindBugs; å•é¡Œãƒžãƒ¼ã‚«ãƒ¼ãŒ (ソース画é¢ãŠã‚ˆã³å•é¡Œãƒ“ューã«) 表示ã•ã‚Œãªã„å ´åˆã¯ã€å•é¡Œãƒ“ューã®ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼è¨­å®šã‚’変更ã—ã¦ãã ã•ã„。詳細情報㯠http://findbugs.sourceforge.net/FAQ.html#q7 ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + + + + + + + + + + +フィルターファイル + +フィルターファイルを使用ã™ã‚‹ã“ã¨ã§ã€ç‰¹å®šã®ã‚¯ãƒ©ã‚¹ã‚„メソッドをãƒã‚°å ±å‘Šã«å«ã‚ãŸã‚Šãƒã‚°å ±å‘Šã‹ã‚‰é™¤å¤–ã—ãŸã‚Šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®ç« ã§ã¯ã€ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ãƒ•ã‚¡ã‚¤ãƒ«ã®ä½¿ç”¨æ–¹æ³•ã‚’説明ã—ã¾ã™ã€‚ +計画ã•ã‚Œã¦ã„る機能 +フィルターã¯ç¾åœ¨ã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã§ã®ã¿ã‚µãƒãƒ¼ãƒˆã•ã‚Œã¦ã„ã¾ã™ã€‚最終的ã«ã¯ã€ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ã®ã‚µãƒãƒ¼ãƒˆã¯ GUI ã«ã‚‚追加ã•ã‚Œã‚‹äºˆå®šã§ã™ã€‚ + + + + + +フィルターファイルã®æ¦‚è¦ + +概念的ã«è¨€ãˆã°ã€ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ã¯ãƒã‚°æ¤œç´¢çµæžœã‚’ã‚る基準ã¨ç…§åˆã—ã¾ã™ã€‚フィルターを定義ã™ã‚‹ã“ã¨ã§ã€ 特別ãªå–り扱ã„ã‚’ã™ã‚‹ãƒã‚°æ¤œç´¢çµæžœã‚’é¸æŠžã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚例ãˆã°ã€ã‚ã‚‹ãƒã‚°æ¤œç´¢çµæžœã‚’ãƒã‚°å ±å‘Šã«å«ã‚ãŸã‚Šã€ãƒã‚°å ±å‘Šã‹ã‚‰é™¤å¤–ã—ãŸã‚Šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + +フィルターファイルã¯ã€ XML 文書ã§ã™ã€‚最上ä½è¦ç´ ãŒã€€FindBugsFilter è¦ç´  ã§ã‚ã‚Šã€ãã®å­è¦ç´ ã¨ã—㦠Match è¦ç´ ã‚’複数個定義ã—ã¾ã™ã€‚ãã‚Œãžã‚Œã® Match è¦ç´ ã¯ã€ç”Ÿæˆã•ã‚ŒãŸãƒã‚°æ¤œç´¢çµæžœã«é©ç”¨ã•ã‚Œã‚‹è¿°éƒ¨ã«ã‚ãŸã‚Šã¾ã™ã€‚通常ã€ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ã¯ãƒã‚°æ¤œç´¢çµæžœã‚’除外ã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã—ã¾ã™ã€‚次ã«ã€ä¾‹ã‚’示ã—ã¾ã™: +$ findbugs -textui -exclude myExcludeFilter.xml myApp.jar +ã¾ãŸä¸€æ–¹ã§ã€çš„ã‚’ã—ã¼ã£ãŸå ±å‘Šã‚’å¾—ã‚‹ãŸã‚ã«ãƒã‚°å ±å‘Šçµæžœã‚’é¸æŠžã™ã‚‹ãŸã‚ã«ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ã‚’使用ã™ã‚‹ã“ã¨ã‚‚考ãˆã‚‰ã‚Œã¾ã™ : +$ findbugs -textui -include myIncludeFilter.xml myApp.jar + + + + +Match è¦ç´ ã¯å­è¦ç´ ã‚’æŒã¡ã¾ã™ã€‚ãれらã®å­è¦ç´ ã¯è«–ç†ç©ã§è¿°éƒ¨ã«ãªã‚Šã¾ã™ã€‚ã¤ã¾ã‚Šã€è¿°éƒ¨ãŒçœŸã§ã‚ã‚‹ãŸã‚ã«ã¯ã€ã™ã¹ã¦ã®å­è¦ç´ ãŒçœŸã§ã‚ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ + + + + +マッãƒãƒ³ã‚°æ¡ä»¶ã®ç¨®é¡ž + + + + <Bug> + ã“ã®è¦ç´ ã¯ã€ãƒã‚°ãƒ‘ターンを指定ã—ã¦ç…§åˆã—ã¾ã™ã€‚pattern 属性ã«ã¯ã€ã‚³ãƒ³ãƒžåŒºåˆ‡ã‚Šã§ãƒã‚°ãƒ‘ターン類型ã®ãƒªã‚¹ãƒˆã‚’指定ã—ã¾ã™ã€‚ã©ã®è­¦å‘ŠãŒã©ã®ãƒã‚°ãƒ‘ターン類型ã«ã‚ãŸã‚‹ã‹ã¯ã€ -xml オプションをã¤ã‹ã£ã¦å‡ºåŠ›ã•ã‚ŒãŸã‚‚ã® (BugInstance è¦ç´ ã® type 属性) を見るã‹ã€ã¾ãŸã¯ã€ ãƒã‚°è§£èª¬ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã‚’å‚ç…§ã—ã¦ãã ã•ã„。もã£ã¨ç²’度ã®ç²—ã„ç…§åˆã‚’è¡Œã„ãŸã„ã¨ãã¯ã€ code 属性を使用ã—ã¦ãã ã•ã„。ãƒã‚°ç•¥ç§°ã®ã‚³ãƒ³ãƒžåŒºåˆ‡ã‚Šã®ãƒªã‚¹ãƒˆã§æŒ‡å®šã§ãã¾ã™ã€‚ã•ã‚‰ã«ç²’度ã®ç²—ã„ç…§åˆã‚’è¡Œã„ãŸã„ã¨ãã¯ã€ category 属性を使用ã—ã¦ãã ã•ã„。次ã«ç¤ºã™ã€ãƒã‚°ã‚«ãƒ†ã‚´ãƒªãƒ¼åã®ã‚³ãƒ³ãƒžåŒºåˆ‡ã‚Šã®ãƒªã‚¹ãƒˆã§æŒ‡å®šã§ãã¾ã™ : CORRECTNESS, MT_CORRECTNESS, BAD_PRACTICICE, PERFORMANCE, STYLE.åŒã˜ <Bug> è¦ç´ ã«ä¸Šè¨˜ã®å±žæ€§ã‚’複数指定ã—ãŸå ´åˆã¯ã€ãƒã‚°ãƒ‘ターンåã€ãƒã‚°ç•¥ç§°ã€ãƒã‚°ã‚«ãƒ†ã‚´ãƒªãƒ¼ã®ã„ãšã‚Œã‹1ã¤ã§ã‚‚該当ã™ã‚Œã°ã€ãƒã‚°ãƒ‘ターンã¯åˆè‡´ã™ã‚‹ã¨åˆ¤å®šã•ã‚Œã¾ã™ã€‚下ä½äº’æ›æ€§ã‚’æŒãŸã›ãŸã„å ´åˆã¯ã€ <Bug> è¦ç´ ã®ä»£ã‚ã‚Šã« <BugPattern> è¦ç´ ãŠã‚ˆã³ <BugCode> è¦ç´ ã‚’使用ã—ã¦ãã ã•ã„。ã“れらã®è¦ç´ ã¯ãã‚Œãžã‚Œã€ name 属性ã§å€¤ã®ãƒªã‚¹ãƒˆã‚’指定ã—ã¾ã™ã€‚ã“れらã®è¦ç´ ã¯ã€å°†æ¥ã‚µãƒãƒ¼ãƒˆã•ã‚Œãªããªã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚ + + + + <Priority> + + ã“ã®è¦ç´ ã¯ã€ç‰¹å®šã®å„ªå…ˆåº¦ã‚’ã‚‚ã¤è­¦å‘Šã‚’ç…§åˆã—ã¾ã™ã€‚value 属性ã«ã¯ã€æ•´æ•°å€¤ã‚’指定ã—ã¾ã™ : 1 ã¯å„ªå…ˆåº¦(高)ã€ã¾ãŸã€ 2 ã¯å„ªå…ˆåº¦(中) 〠3 ã¯å„ªå…ˆåº¦(低) を示ã—ã¾ã™ã€‚ + + + + + + <Package> + + ã“ã®è¦ç´ ã¯ã€ name 属性ã§æŒ‡å®šã—ãŸç‰¹å®šã®ãƒ‘ッケージ内ã«ã‚るクラスã«é–¢é€£ã—ãŸè­¦å‘Šã‚’ç…§åˆã—ã¾ã™ã€‚入れå­ã®ãƒ‘ッケージã¯å«ã¾ã‚Œã¾ã›ã‚“ (Java import æ–‡ã«å¾“ã£ã¦ã„ã¾ã™) 。ã—ã‹ã—ãªãŒã‚‰ã€æ­£è¦è¡¨ç¾ã‚’使ã†ã¨è¤‡æ•°ãƒ‘ッケージã«ãƒžãƒƒãƒã•ã›ã‚‹ã“ã¨ã¯ç°¡å˜ã«ã§ãã¾ã™ã€‚ + + + + + <Class> + + ã“ã®è¦ç´ ã¯ã€ç‰¹å®šã®ã‚¯ãƒ©ã‚¹ã«é–¢é€£ã—ãŸè­¦å‘Šã‚’ç…§åˆã—ã¾ã™ã€‚name 属性を使用ã—ã¦ã€ç…§åˆã™ã‚‹ã‚¯ãƒ©ã‚¹åをクラスåãã®ã‚‚ã®ã‹ã€ã¾ãŸã¯ã€æ­£è¦è¡¨ç¾ã§æŒ‡å®šã—ã¾ã™ã€‚ + + 下ä½äº’æ›æ€§ã‚’æŒãŸã›ãŸã„å ´åˆã¯ã€ã“ã®è¦ç´ ã®ä»£ã‚ã‚Šã« Match è¦ç´ ã‚’使用ã—ã¦ãã ã•ã„。クラスåãã®ã‚‚ã®ã®æŒ‡å®šã¯ class 属性をã€ã‚¯ãƒ©ã‚¹åã‚’æ­£è¦è¡¨ç¾ã§æŒ‡å®šã™ã‚‹å ´åˆã¯ classregex 属性をãã‚Œãžã‚Œä½¿ç”¨ã—ã¦ãã ã•ã„ + + ã‚‚ã— Match è¦ç´ ã« Class è¦ç´ ãŒç„¡ã‹ã£ãŸã‚Šã€ class / classregex 属性ãŒç„¡ã‹ã£ãŸã‚Šã—ãŸå ´åˆã¯ã€ã™ã¹ã¦ã®ã‚¯ãƒ©ã‚¹ã«é©ç”¨ã•ã‚Œã¾ã™ã€‚ãã®å ´åˆã€æƒ³å®šå¤–ã«å¤šãã®ãƒã‚°æ¤œç´¢çµæžœãŒä¸€è‡´ã—ã¦ã—ã¾ã†ã“ã¨ãŒã‚ã‚Šå¾—ã¾ã™ã€‚ãã®å ´åˆã¯ã€é©å½“ãªãƒ¡ã‚½ãƒƒãƒ‰ã‚„フィールドã§çµžã‚Šè¾¼ã‚“ã§ãã ã•ã„。 + + + + + <Method> + + ã“ã®è¦ç´ ã¯ã€ãƒ¡ã‚½ãƒƒãƒ‰ã‚’指定ã—ã¾ã™ã€‚name 属性を使用ã—ã¦ã€ç…§åˆã™ã‚‹ãƒ¡ã‚½ãƒƒãƒ‰åをメソッドåãã®ã‚‚ã®ã‹ã€ã¾ãŸã¯ã€æ­£è¦è¡¨ç¾ã§æŒ‡å®šã—ã¾ã™ã€‚params 属性ã«ã¯ã€ã‚³ãƒ³ãƒžåŒºåˆ‡ã‚Šã§ãƒ¡ã‚½ãƒƒãƒ‰å¼•æ•°ã®åž‹ã®ãƒªã‚¹ãƒˆã‚’指定ã—ã¾ã™ã€‚returns 属性ã«ã¯ãƒ¡ã‚½ãƒƒãƒ‰ã®æˆ»ã‚Šå€¤ã®åž‹ã‚’指定ã—ã¾ã™ã€‚params ãŠã‚ˆã³ returns ã«ãŠã„ã¦ã¯ã€ã‚¯ãƒ©ã‚¹åã¯å®Œå…¨ä¿®é£¾åã§ã‚ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚(例ãˆã°ã€å˜ã« "String" ã§ã¯ãªã "java.lang.String" ã¨ã—ã¦ãã ã•ã„。) params returns ã®ã©ã¡ã‚‰ã‹ä¸€æ–¹ã‚’指定ã—ãŸå ´åˆã¯ã€ã‚‚ã†ä¸€æ–¹ã®å±žæ€§ã®æŒ‡å®šã‚‚å¿…é ˆã§ã™ã€‚ãªãœãªã‚‰ã°ã€ãƒ¡ã‚½ãƒƒãƒ‰ã‚·ã‚°ãƒ‹ãƒãƒ£ãƒ¼ã‚’構築ã®ãŸã‚ã«å¿…è¦ã ã‹ã‚‰ã§ã™ã€‚name 属性ã€params 属性 ãŠã‚ˆã³ returns 属性ã¾ãŸã¯ 3 ã¤ã® 属性ã™ã¹ã¦ã€ã®ã©ã‚Œã‹ã‚’æ¡ä»¶ã¨ã™ã‚‹ã“ã¨ã§ãã‚‹ã“ã¨ã‚’æ„味ã—ã¦ã„ã¾ã™ã€‚ã“ã®ã‚ˆã†ã«ã€åå‰ã¨ã‚·ã‚°ãƒ‹ãƒãƒ£ãƒ¼ã«åŸºã¥ã様々ãªç¨®é¡žã®æ¡ä»¶ã‚’è¦å®šã§ãã¾ã™ã€‚ + + + + <Field> + + ã“ã®è¦ç´ ã¯ã€ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã‚’指定ã—ã¾ã™ã€‚name 属性を使用ã—ã¦ã€ç…§åˆã™ã‚‹ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰åをフィールドåãã®ã‚‚ã®ã‹ã€ã¾ãŸã¯ã€æ­£è¦è¡¨ç¾ã§æŒ‡å®šã—ã¾ã™ã€‚ã¾ãŸã€ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã®ã‚·ã‚°ãƒ‹ãƒãƒ£ãƒ¼ã«ç…§ã‚‰ã—ãŸãƒ•ã‚£ãƒ«ã‚¿ãƒªãƒ³ã‚°ã‚’ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ type 属性を使用ã—ã¦ã€ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã®åž‹ã‚’完全修飾åã§æŒ‡å®šã—ã¦ãã ã•ã„。åå‰ã¨ã‚·ã‚°ãƒ‹ãƒãƒ£ãƒ¼ã«åŸºã¥ãæ¡ä»¶ã‚’è¦å®šã™ã‚‹ãŸã‚ã«ã€ãã®2ã¤ã®å±žæ€§ã‚’両方ã¨ã‚‚指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + <Local> + + ã“ã®è¦ç´ ã¯ã€ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã‚’指定ã—ã¾ã™ã€‚name 属性を使用ã—ã¦ã€ç…§åˆã™ã‚‹ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°åをローカル変数åãã®ã‚‚ã®ã‹ã€ã¾ãŸã¯ã€æ­£è¦è¡¨ç¾ã§æŒ‡å®šã—ã¾ã™ã€‚ローカル変数ã¨ã¯ã€ãƒ¡ã‚½ãƒƒãƒ‰å†…ã§å®šç¾©ã—ãŸå¤‰æ•°ã§ã™ã€‚ + + + + <Or> + ã“ã®è¦ç´ ã¯ã€è«–ç†å’Œã¨ã—㦠Match æ¡é …ã‚’çµåˆã—ã¾ã™ã€‚ã™ãªã‚ã¡ã€2ã¤ã® Method è¦ç´ ã‚’ Or æ¡é …ã«å…¥ã‚Œã‚‹ã“ã¨ã§ã€ã©ã¡ã‚‰ã‹ä¸€æ–¹ã®ãƒ¡ã‚½ãƒƒãƒ‰ã§ãƒžãƒƒãƒã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + + + +Java è¦ç´ åマッãƒãƒ³ã‚° + +Class 〠Method ã¾ãŸã¯ Field ã® name 属性ãŒæ–‡å­— ~ ã§å§‹ã¾ã£ã¦ã„ã‚‹å ´åˆã¯ã€å±žæ€§å€¤ã®æ®‹ã‚Šã®éƒ¨åˆ†ã‚’ Java ã®æ­£è¦è¡¨ç¾ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚ãã†ã—ã¦ã€å½“該 Java è¦ç´ ã®åå‰ã«å¯¾ã—ã¦ã®ç…§åˆãŒè¡Œã‚ã‚Œã¾ã™ã€‚ + +パターンã®ç…§åˆã¯è¦ç´ ã®åå‰å…¨ä½“ã«å¯¾ã—ã¦è¡Œã‚れるã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•ã„。ãã®ãŸã‚ã€éƒ¨åˆ†ä¸€è‡´ç…§åˆã‚’è¡Œã„ãŸã„å ´åˆã¯ãƒ‘ターン文字列ã®å‰å¾Œã« .* を付加ã—ã¦ä½¿ç”¨ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ + +パターンã®æ§‹æ–‡è¦å‰‡ã«é–¢ã—ã¦ã¯ã€ java.util.regex.Pattern ã®ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + +ç•™æ„事項 + + +Match æ¡é …ã¯ã€ãƒã‚°æ¤œç´¢çµæžœã«å®Ÿéš›ã«å«ã¾ã‚Œã¦ã„る情報ã«ã®ã¿ä¸€è‡´ã—ã¾ã™ã€‚ã™ã¹ã¦ã®ãƒã‚°æ¤œç´¢çµæžœã¯ã‚¯ãƒ©ã‚¹ã‚’æŒã£ã¦ã„ã¾ã™ã€‚ã—ãŸãŒã£ã¦ã€ä¸€èˆ¬çš„ã«è¨€ã£ã¦ã€ãƒã‚°ã‚’除外ã™ã‚‹ãŸã‚ã«ã¯ã‚¯ãƒ©ã‚¹ã‚’用ã„ã¦è¡Œã†ã¨ã†ã¾ãã„ãã“ã¨ãŒå¤šã„ã§ã™ã€‚ + +ãƒã‚°æ¤œç´¢çµæžœã®ä¸­ã«ã¯ã€2個以上ã®ã‚¯ãƒ©ã‚¹ã‚’ä¿æŒã—ã¦ã„ã‚‹ã‚‚ã®ã‚‚ã‚ã‚Šã¾ã™ã€‚例ãˆã°ã€ DE (dropped exception : 例外ã®ç„¡è¦–) ãƒã‚°ã¯ã€ 例外ã®ç„¡è¦–ãŒç™ºç”Ÿã—ãŸãƒ¡ã‚½ãƒƒãƒ‰ã‚’æŒã£ã¦ã„るクラスã¨ã€ 無視ã•ã‚ŒãŸä¾‹å¤–ã®åž‹ã‚’表ã™ã‚¯ãƒ©ã‚¹ã®ä¸¡æ–¹ã‚’å«ã‚“ã å½¢ã§å ±å‘Šã•ã‚Œã¾ã™ã€‚Match æ¡é …ã¨ã¯ã€ 1番目 (主) ã®ã‚¯ãƒ©ã‚¹ã®ã¿ãŒç…§åˆã•ã‚Œã¾ã™ã€‚ã—ãŸãŒã£ã¦ã€ä¾‹ãˆã°ã€ã‚¯ãƒ©ã‚¹ "com.foobar.A" 〠"com.foobar.B" é–“ã§ã® IC (initialization circularity : åˆæœŸåŒ–時ã®å‡¦ç†å¾ªç’°) ãƒã‚°å ±å‘Šã‚’抑止ã—ãŸã„å ´åˆã€ä»¥ä¸‹ã«ç¤ºã™ã‚ˆã†ã« 2ã¤ã® Match æ¡é …を使用ã—ã¾ã™ : + <Match> + <Class name="com.foobar.A" /> + <Bug code="IC" /> + </Match> + + <Match> + <Class name="com.foobar.B" /> + <Bug code="IC" /> + </Match> +明示的ã«ä¸¡æ–¹ã®ã‚¯ãƒ©ã‚¹ã§ç…§åˆã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦ã€å¾ªç’°ã—ã¦ã„ã‚‹ã©ã¡ã‚‰ã®ã‚¯ãƒ©ã‚¹ãŒãƒã‚°æ¤œç´¢çµæžœã® 1 番目ã«ãªã£ã¦ã„ã‚‹ã‹ã«é–¢ä¿‚ãªã一致ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚(ã‚‚ã¡ã‚ã‚“ã“ã®æ–¹æ³•ã¯ã€å‡¦ç†å¾ªç’°ãŒ "com.foobar.A" 〠"com.foobar.B" ã«åŠ ãˆã¦3番目ã®ã‚¯ãƒ©ã‚¹ã‚‚å«ã‚“ã§ã„ã‚‹å ´åˆã¯å›³ã‚‰ãšã‚‚失敗ã—ã¦ã—ã¾ã†æã‚ŒãŒã‚ã‚Šã¾ã™ã€‚) + +多ãã®ç¨®é¡žã®ãƒã‚°å ±å‘Šã¯ã€è‡ªèº«ãŒå‡ºç¾ã—ãŸãƒ¡ã‚½ãƒƒãƒ‰ã‚’報告ã—ã¾ã™ã€‚ãれらã®ãƒã‚°æ¤œç´¢çµæžœã«å¯¾ã—ã¦ã¯ã€ Method æ¡é …ã‚’ Match è¦ç´ ã«åŠ ãˆã‚‹ã¨æœŸå¾…通りã®å‹•ä½œã‚’ã™ã‚‹ã§ã—ょã†ã€‚ + + + + +例 + +1. 特定ã®ã‚¯ãƒ©ã‚¹ã«å¯¾ã™ã‚‹ã™ã¹ã¦ã®ãƒã‚°å ±å‘Šã«ä¸€è‡´ã•ã›ã¾ã™ã€‚ + + + +]]> + + + + +2. ãƒã‚°ç•¥ç§°ã‚’指定ã—ã¦ã€ç‰¹å®šã®ã‚¯ãƒ©ã‚¹ã«å¯¾ã™ã‚‹ç‰¹å®šã®æ¤œæŸ»é …ç›®ã«ä¸€è‡´ã•ã›ã¾ã™ã€‚ + + + + +]]> + + + +3. ãƒã‚°ç•¥ç§°ã‚’指定ã—ã¦ã€ã™ã¹ã¦ã®ã‚¯ãƒ©ã‚¹ã«å¯¾ã™ã‚‹ç‰¹å®šã®æ¤œæŸ»é …ç›®ã«ä¸€è‡´ã•ã›ã¾ã™ã€‚ + + + +]]> + + + +4. ãƒã‚°ã‚«ãƒ†ã‚´ãƒªãƒ¼ã‚’指定ã—ã¦ã€ã™ã¹ã¦ã®ã‚¯ãƒ©ã‚¹ã«å¯¾ã™ã‚‹ç‰¹å®šã®æ¤œæŸ»é …ç›®ã«ä¸€è‡´ã•ã›ã¾ã™ã€‚ + + + +]]> + + + +5. ãƒã‚°ç•¥ç§°ã‚’指定ã—ã¦ã€ç‰¹å®šã®ã‚¯ãƒ©ã‚¹ã®æŒ‡å®šã•ã‚ŒãŸãƒ¡ã‚½ãƒƒãƒ‰ã«å¯¾ã™ã‚‹ç‰¹å®šã®ãƒã‚°ç¨®åˆ¥ã«ä¸€è‡´ã•ã›ã¾ã™ã€‚ + + + + + + + + +]]> + + + +6. 特定ã®ãƒ¡ã‚½ãƒƒãƒ‰ã«å¯¾ã™ã‚‹ç‰¹å®šã®ãƒã‚°ãƒ‘ターンã«ä¸€è‡´ã•ã›ã¾ã™ã€‚ + + + + + + +]]> + + + +7. 特定ã®ãƒ¡ã‚½ãƒƒãƒ‰ã«å¯¾ã™ã‚‹ç‰¹å®šã®å„ªå…ˆåº¦ã‚’付与ã•ã‚ŒãŸç‰¹å®šã®ãƒã‚°ãƒ‘ターンã«ä¸€è‡´ã•ã›ã¾ã™ã€‚ + + + + + + + +]]> + + + +8. AspectJ コンパイラーã«ã‚ˆã£ã¦å¼•ãèµ·ã“ã•ã‚Œã‚‹ãƒžã‚¤ãƒŠãƒ¼ãƒã‚°ã«ä¸€è‡´ã•ã›ã¾ã™ (AspectJ ã®é–‹ç™ºè€…ã§ã‚‚ãªã„é™ã‚Šã€ãれらã®ãƒã‚°ã«é–¢å¿ƒã‚’æŒã¤ã“ã¨ã¯ãªã„ã¨è€ƒãˆã¾ã™)。 + + + + + + + + + +]]> + + + +9. 基盤コードã®ç‰¹å®šã®éƒ¨åˆ†ã«å¯¾ã™ã‚‹ãƒã‚°ã«ä¸€è‡´ã•ã›ã¾ã™ + + + + + + + + + + + + + + + +]]> + + + +10. 特定ã®ã‚·ã‚°ãƒ‹ãƒãƒ£ãƒ¼ã‚’æŒã¤ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã¾ãŸã¯ãƒ¡ã‚½ãƒƒãƒ‰ã®ãƒã‚°ã«ä¸€è‡´ã•ã›ã¾ã™ã€‚ + + + + + + + + + + +]]> + + + + + + + +完全ãªä¾‹ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + + + +分æžãƒ—ロパティー + +&FindBugs; ã¯åˆ†æžã™ã‚‹å ´åˆã«ã„ãã¤ã‹ã®è¦³ç‚¹ã‚’æŒã£ã¦ã„ã¾ã™ã€‚ãã—ã¦ã€è¦³ç‚¹ã‚’カスタマイズã—ã¦å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚システムプロパティーを使ã£ã¦ã€ãれらã®ã‚ªãƒ—ションを設定ã—ã¾ã™ã€‚ã“ã®ç« ã§ã¯ã€åˆ†æžã‚ªãƒ—ションã®è¨­å®šæ–¹æ³•ã‚’説明ã—ã¾ã™ã€‚ + +分æžã‚ªãƒ—ションã®ä¸»ãªç›®çš„ã¯ã€ 2 ã¤ã‚ã‚Šã¾ã™ã€‚1 番目ã¯ã€ &FindBugs; ã«å¯¾ã—ã¦åˆ†æžã•ã‚Œã‚‹ã‚¢ãƒ—リケーションã®ãƒ¡ã‚½ãƒƒãƒ‰ã®æ„味をä¼ãˆã‚‹ã“ã¨ã§ã™ã€‚ãã†ã™ã‚‹ã“ã¨ã§ &FindBugs; ãŒã‚ˆã‚Šæ­£ç¢ºãªçµæžœã‚’出ã™ã“ã¨ãŒã§ãã€èª¤æ¤œå‡ºã‚’減らã™ã“ã¨ãŒã§ãã¾ã™ã€‚2 番目ã«ã€åˆ†æžã‚’è¡Œã†ã«å½“ãŸã‚Šãã®ç²¾åº¦ã‚’設定ã§ãるよã†ã«ã™ã‚‹ã“ã¨ã§ã™ã€‚分æžã®ç²¾åº¦ã‚’è½ã¨ã™ã“ã¨ã§ã€ãƒ¡ãƒ¢ãƒªä½¿ç”¨é‡ã¨åˆ†æžæ™‚間を減らã™ã“ã¨ãŒã§ãã¾ã™ã€‚ãŸã ã—ã€æœ¬å½“ã®ãƒã‚°ã‚’見逃ã—ãŸã‚Šã€èª¤æ¤œå‡ºã®æ•°ãŒå¢—ãˆã‚‹ã¨ã„ã†ä»£å„ŸãŒã‚ã‚Šã¾ã™ã€‚ + +コマンドラインオプション -property を使ã£ã¦ã€åˆ†æžã‚ªãƒ—ションを設定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚次ã«ã€ä¾‹ã‚’示ã—ã¾ã™: +$ findbugs -textui -property "cfg.noprune=true" myApp.jar + + + +設定ã™ã‚‹ã“ã¨ãŒã§ãる分æžã‚ªãƒ—ションã®ä¸€è¦§ã‚’ ã«ç¤ºã—ã¾ã™ã€‚ + + +設定å¯èƒ½ãªåˆ†æžãƒ—ロパティー + + + + プロパティーå + 設定値 + 目的 + + + + + + findbugs.assertionmethods + コンマ区切りã®å®Œå…¨ä¿®é£¾ãƒ¡ã‚½ãƒƒãƒ‰åリスト : 例〠"com.foo.MyClass.checkAssertion" + ã“ã®ãƒ—ロパティーã«ã¯ã€ãƒ—ログラムãŒæ­£ã—ã„ã“ã¨ã‚’ãƒã‚§ãƒƒã‚¯ã™ã‚‹ãŸã‚ã«ä½¿ã‚れるメソッドを指定ã—ã¾ã™ã€‚ã“れらã®ãƒ¡ã‚½ãƒƒãƒ‰ã‚’指定ã™ã‚‹ã“ã¨ã§ã€ ãƒã‚§ãƒƒã‚¯ãƒ¡ã‚½ãƒƒãƒ‰ã§ç¢ºèªã—ãŸå€¤ã«å¯¾ã™ã‚‹ null å‚照アクセスディテクタã®èª¤æ¤œå‡ºã‚’回é¿ã§ãã¾ã™ã€‚ + + + findbugs.de.comment + true ã¾ãŸã¯ false + true ã«è¨­å®šã™ã‚‹ã¨ã€ DroppedException (無視ã•ã‚ŒãŸä¾‹å¤–) ディテクタã¯ç©ºã® catch ブロック ã«ã‚³ãƒ¡ãƒ³ãƒˆãŒç„¡ã„ã‹æŽ¢ã—ã¾ã™ã€‚ãã—ã¦ã€ã‚³ãƒ¡ãƒ³ãƒˆãŒã¿ã¤ã‹ã£ãŸå ´åˆã«ã¯è­¦å‘ŠãŒå ±å‘Šã•ã‚Œã¾ã›ã‚“。 + + + findbugs.maskedfields.locals + true ã¾ãŸã¯ false + true ã«è¨­å®šã™ã‚‹ã¨ã€ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã‚’隠蔽ã—ã¦ã„るローカル変数ã«å¯¾ã—ã¦å„ªå…ˆåº¦(低)ã®è­¦å‘ŠãŒç™ºè¡Œã•ã‚Œã¾ã™ã€‚デフォルトã¯ã€ false ã§ã™ã€‚ + + + findbugs.nullderef.assumensp + true ã¾ãŸã¯ false + 使用ã•ã‚Œã¾ã›ã‚“。 (æ„図 : true ã«è¨­å®šã™ã‚‹ã¨ã€null å‚照アクセスディテクタã¯ãƒ¡ã‚½ãƒƒãƒ‰ã‹ã‚‰ã®æˆ»ã‚Šå€¤ã€ã¾ãŸã¯ã€ãƒ¡ã‚½ãƒƒãƒ‰ã«å—ã‘渡ã•ã‚Œã‚‹å¼•æ•°ã‚’ null ã§ã‚ã‚‹ã¨ä»®å®šã—ã¾ã™ã€‚デフォルトã¯ã€ false ã§ã™ã€‚ã“ã®ãƒ—ロパティーを有効ã«ã™ã‚‹ã¨ã€å¤§é‡ã®èª¤æ¤œå‡ºãŒç”Ÿæˆã•ã‚Œã‚‹ã§ã‚ã‚ã†ã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•ã„。) + + + findbugs.refcomp.reportAll + true ã¾ãŸã¯ false + true ã«è¨­å®šã™ã‚‹ã¨ã€ == ãŠã‚ˆã³ != 演算å­ã‚’使ã£ã¦ã„ã‚‹ç–‘ã‚ã—ã„å‚照比較ãŒã™ã¹ã¦å ±å‘Šã•ã‚Œã¾ã™ã€‚ false ã«è¨­å®šã™ã‚‹ã¨ã€åŒæ§˜ã®è­¦å‘Šã¯ 1 メソッドã«ã¤ã 1 ã¤ã—ã‹ç™ºè¡Œã•ã‚Œã¾ã›ã‚“。デフォルトã¯ã€ false ã§ã™ã€‚ + + + findbugs.sf.comment + true ã¾ãŸã¯ false + true ã«è¨­å®šã™ã‚‹ã¨ã€ SwitchFallthrough ディテクタã¯ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã«ã€Œfallã€ã¾ãŸã¯ã€Œnobreakã€ã¨ã„ã†å˜èªžã‚’å«ã‚“ã ã‚³ãƒ¡ãƒ³ãƒˆã‚’記載ã—ã¦ã„ãªã„ caseラベル ã«é™ã‚Šè­¦å‘Šã‚’報告ã—ã¾ã™ã€‚(ã“ã®æ©Ÿèƒ½ãŒæ­£ã—ã動作ã™ã‚‹ãŸã‚ã«ã¯ã€æ­£ç¢ºãªã‚½ãƒ¼ã‚¹ãƒ‘スãŒå¿…è¦ã§ã™ã€‚) ã“ã‚Œã«ã‚ˆã‚Šã€æ„図的ã§ã¯ãªã„ switch 文㮠fallthrough を発見ã—易ããªã‚Šã¾ã™ã€‚ + + + + +
    + +
    + + + + +アノテーション + +&FindBugs; ã¯ã„ãã¤ã‹ã®ã‚¢ãƒŽãƒ†ãƒ¼ã‚·ãƒ§ãƒ³ã‚’サãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã™ã€‚開発者ã®æ„図を明確ã«ã™ã‚‹ã“ã¨ã§ã€ FindBugs ã¯ã‚ˆã‚Šçš„確ã«è­¦å‘Šã‚’発行ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚アノテーションを使用ã™ã‚‹ãŸã‚ã«ã¯ Java 5 ãŒå¿…è¦ã§ã‚り〠annotations.jar ãŠã‚ˆã³ jsr305.jar ファイルをコンパイル時ã®ã‚¯ãƒ©ã‚¹ãƒ‘スã«å«ã‚ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ + + + + edu.umd.cs.findbugs.annotations.CheckForNull + +[Target] Field, Method, Parameter + + + アノテーションをã¤ã‘ãŸè¦ç´ ã¯ã€ null ã§ã‚ã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚ã—ãŸãŒã£ã¦ã€å½“該è¦ç´ ã‚’使用ã™ã‚‹éš›ã¯ null ãƒã‚§ãƒƒã‚¯ã‚’ã™ã‚‹ã¹ãã§ã™ã€‚ã“ã®ã‚¢ãƒŽãƒ†ãƒ¼ã‚·ãƒ§ãƒ³ã‚’メソッドã«é©ç”¨ã™ã‚‹ã¨ã€ãƒ¡ã‚½ãƒƒãƒ‰ã®æˆ»ã‚Šå€¤ã«é©ç”¨ã•ã‚Œã¾ã™ã€‚ + + + + + edu.umd.cs.findbugs.annotations.CheckReturnValue + + [Target] Method, Constructor + + + + + [Parameter] + + + priority: 警告ã®å„ªå…ˆåº¦ã‚’指定ã—ã¾ã™ (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。 + + + + explanation:戻り値をãƒã‚§ãƒƒã‚¯ã—ãªã‘ã°ãªã‚‰ãªã„ç†ç”±ã‚’テキストã§èª¬æ˜Žã—ã¾ã™ã€‚デフォルト値 :""。 + + + + + + ã“ã®ã‚¢ãƒŽãƒ†ãƒ¼ã‚·ãƒ§ãƒ³ã‚’使用ã—ã¦ã€å‘¼å‡ºã—後ã«æˆ»ã‚Šå€¤ã‚’ãƒã‚§ãƒƒã‚¯ã™ã¹ãメソッドを表ã™ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + + edu.umd.cs.findbugs.annotations.DefaultAnnotation + + [Target] Type, Package + + + + + [Parameter] + + + value:アノテーションクラスã®classオブジェクト。複数ã®ã‚¯ãƒ©ã‚¹ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + priority:çœç•¥æ™‚ã®å„ªå…ˆåº¦ã‚’指定ã—ã¾ã™ (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。 + + + + + + +Indicates that all members of the class or package should be annotated with the default +value of the supplied annotation classes. This would be used for behavior annotations +such as @NonNull, @CheckForNull, or @CheckReturnValue. In particular, you can use +@DefaultAnnotation(NonNull.class) on a class or package, and then use @Nullable only +on those parameters, methods or fields that you want to allow to be null. + + + + + + edu.umd.cs.findbugs.annotations.DefaultAnnotationForFields + + [Target] Type, Package + + + + + [Parameter] + + + value:アノテーションクラスã®classオブジェクト。複数ã®ã‚¯ãƒ©ã‚¹ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + priority:çœç•¥æ™‚ã®å„ªå…ˆåº¦ã‚’指定ã—ã¾ã™ (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。 + + + + + + +This is same as the DefaultAnnotation except it only applys to fields. + + + + + + edu.umd.cs.findbugs.annotations.DefaultAnnotationForMethods + + [Target] Type, Package + + + + + [Parameter] + + + value:アノテーションクラスã®classオブジェクト。複数ã®ã‚¯ãƒ©ã‚¹ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + priority:çœç•¥æ™‚ã®å„ªå…ˆåº¦ã‚’指定ã—ã¾ã™ (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。 + + + + + + +This is same as the DefaultAnnotation except it only applys to methods. + + + + + + edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters + + [Target] Type, Package + + + + + [Parameter] + + + value:アノテーションクラスã®classオブジェクト。複数ã®ã‚¯ãƒ©ã‚¹ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + + + priority:çœç•¥æ™‚ã®å„ªå…ˆåº¦ã‚’指定ã—ã¾ã™ (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。 + + + + + + +This is same as the DefaultAnnotation except it only applys to method parameters. + + + + + + edu.umd.cs.findbugs.annotations.NonNull + + [Target] Field, Method, Parameter + + + アノテーションをã¤ã‘ãŸè¦ç´ ã¯ã€ null ã§ã‚ã£ã¦ã¯ã„ã‘ã¾ã›ã‚“。アノテーションをã¤ã‘ãŸãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã¯ã€æ§‹ç¯‰å®Œäº†å¾Œ null ã§ã‚ã£ã¦ã¯ã„ã‘ã¾ã›ã‚“。アノテーションをã¤ã‘ãŸãƒ¡ã‚½ãƒƒãƒ‰ã¯ã€ null ã§ã¯ãªã„値を戻り値ã¨ã—ãªã‘ã‚Œã°ãªã‚Šã¾ã›ã‚“。 + + + + + edu.umd.cs.findbugs.annotations.Nullable + + [Target] Field, Method, Parameter + + + アノテーションをã¤ã‘ãŸè¦ç´ ã¯ã€ null ã§ã‚ã£ã¦ã¯ã„ã‘ã¾ã›ã‚“。In general, this means developers will have to read the documentation to determine when a null value is acceptable and whether it is neccessary to check for a null value. FindBugs will treat the annotated items as though they had no annotation. + +In pratice this annotation is useful only for overriding an overarching NonNull +annotation. + + + + + + edu.umd.cs.findbugs.annotations.OverrideMustInvoke + + [Target] Method + + + + + [Parameter] + + + value:Specify when the super invocation should be + performed (FIRST, ANYTIME, LAST). Default value:ANYTIME. + + + + + + + +Used to annotate a method that, if overridden, must (or should) be invoke super +in the overriding method. Examples of such methods include finalize() and clone(). +The argument to the method indicates when the super invocation should occur: +at any time, at the beginning of the overriding method, or at the end of the overriding method. +(This anotation is not implmemented in FindBugs as of September 8, 2006). + + + + + + edu.umd.cs.findbugs.annotations.PossiblyNull + + +This annotation is deprecated. Use CheckForNull instead. + + + + + + edu.umd.cs.findbugs.annotations.SuppressWarnings + + [Target] Type, Field, Method, Parameter, Constructor, Package + + + + + [Parameter] + + + value:The name of the warning. More than one name can be specified. + + + + + justification:Reason why the warning should be ignored. デフォルト値 :""。 + + + + + + +The set of warnings that are to be suppressed by the compiler in the annotated element. +Duplicate names are permitted. The second and successive occurrences of a name are ignored. +The presence of unrecognized warning names is not an error: Compilers +must ignore any warning names they do not recognize. They are, however, free to emit a +warning if an annotation contains an unrecognized warning name. Compiler vendors should +document the warning names they support in conjunction with this annotation type. They +are encouraged to cooperate to ensure that the same names work across multiple compilers. + + + + + + edu.umd.cs.findbugs.annotations.UnknownNullness + + [Target] Field, Method, Parameter + + + +Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. + + + + + + edu.umd.cs.findbugs.annotations.UnknownNullness + + [Target] Field, Method, Parameter + + + +Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses. + + + + + +ã¾ãŸã€ &FindBugs; 次ã«ç¤ºã™ã‚¢ãƒŽãƒ†ãƒ¼ã‚·ãƒ§ãƒ³ã‚‚サãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã™ã€‚ : + net.jcip.annotations.GuardedBy + net.jcip.annotations.Immutable + net.jcip.annotations.NotThreadSafe + net.jcip.annotations.ThreadSafe + + +Java Concurrency in Practice ã® API ドキュメント ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + + + + + +rejarForAnalysis ã®ä½¿ç”¨æ–¹æ³• + +プロジェクトã«å¤šãã® jar ファイル ãŒã‚ã£ãŸã‚Šã€ jar ファイルãŒå¤šãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«ç‚¹åœ¨ã—ãŸã‚Šã™ã‚‹å ´åˆã¯ã€ rejarForAnalysis スクリプトを使用ã™ã‚‹ã¨ FindBugs ã®å®Ÿè¡ŒãŒæ¯”較的簡å˜ã«ãªã‚Šã¾ã™ã€‚ã“ã®ã‚¹ã‚¯ãƒªãƒ—トã¯ã€æ•°å¤šã„ jar ファイルを集ã‚㦠1 ã¤ã®å¤§ã㪠jar ファイルã«çµåˆã—ã¾ã™ã€‚ãã†ã™ã‚‹ã¨ã€åˆ†æžæ™‚ã«FindBugs ã« jar ファイルを設定ã™ã‚‹ã“ã¨ãŒæ¯”較的簡å˜ã«ãªã‚Šã¾ã™ã€‚ã“ã®ã‚¹ã‚¯ãƒªãƒ—トã¯ã€ unix システム㮠'find' コマンドã¨çµ„ã¿åˆã‚ã›ã‚‹ã¨ã¨ã‚Šã‚ã‘有用ã«ãªã‚Šã¾ã™ ; 次ã«ä¾‹ã‚’示ã—ã¾ã™ã€‚ find . -name '*.jar' | xargs rejarForAnalysis . + +ã¾ãŸã€ rejarForAnalysis スクリプトã¯å·¨å¤§ãªãƒ—ロジェクトを複数㮠jar ファイルã«åˆ†å‰²ã™ã‚‹ã“ã¨ã«ä½¿ç”¨ã§ãã¾ã™ã€‚プロジェクトã®ã‚¯ãƒ©ã‚¹ãƒ•ã‚¡ã‚¤ãƒ«ã¯ã€è¤‡æ•°ã® jar ファイルã«å‡ç­‰ã«é…分ã•ã‚Œã¾ã™ã€‚ã“ã‚Œã¯ã€ãƒ—ロジェクト全体ã«å¯¾ã—㦠FindBugs を実行ã™ã‚‹ã¨æ™‚é–“ã¨ãƒ¡ãƒ¢ãƒªæ¶ˆè²»ãŒè‘—ã—ã„å ´åˆã«æœ‰ç”¨ã§ã™ã€‚プロジェクト全体ã«å¯¾ã—㦠FindBugs を実行ã™ã‚‹ä»£ã‚ã‚Šã«ã€ rejarForAnalysis ã§ã™ã¹ã¦ã®ã‚¯ãƒ©ã‚¹ã‚’å«ã‚€å¤§ã㪠jar ファイルを構築ã—ã¾ã™ã€‚続ã„ã¦ã€ rejarForAnalysis ã‚’å†ã³å®Ÿè¡Œã—ã¦è¤‡æ•°ã® jar ファイルã«åˆ†å‰²ã—ã¾ã™ã€‚ãã—ã¦ã€å„々㮠jar ファイルã«å¯¾ã—ã¦é †ã« FindBugs を実行ã—ã¾ã™ã€‚ãã®éš›ã€ -auxclasspath ã«æœ€åˆã« 1 ã¤ã«ã¾ã¨ã‚㟠jar ファイルを指定ã—ã¦ãã ã•ã„。 + +rejarForAnalysis スクリプトã«æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãるオプションを以下ã«ç¤ºã—ã¾ã™ : + + + + -maxAge 日数 + + 最後ã«æ›´æ–°ã•ã‚ŒãŸæ—¥ã‹ã‚‰ã®çµŒéŽæ™‚é–“ã‚’æ—¥å˜ä½ã§æŒ‡å®šã—ã¾ã™ (指定ã—ãŸæ—¥æ•°ã‚ˆã‚Šå¤ã„ jar ファイルã¯ç„¡è¦–ã•ã‚Œã¾ã™)。 + + + + -inputFileList ファイルå + + jar ファイルåを記載ã—ãŸãƒ†ã‚­ã‚¹ãƒˆãƒ•ã‚¡ã‚¤ãƒ«ã‚’指定ã—ã¾ã™ã€‚ + + + + -maxClasses クラス数 + + analysis*.jar ファイル 1 ファイルã«å¯¾ã™ã‚‹ã‚¯ãƒ©ã‚¹ã®æœ€å¤§æ•°ã‚’指定ã—ã¾ã™ã€‚ + + + + -prefix プレフィックス + + 分æžã™ã‚‹ã‚¯ãƒ©ã‚¹åã®ãƒ—レフィックスを指定ã—ã¾ã™ (例〠edu.umd.cs.) 。 + + + + + + + + + &FindBugs;™ ã«ã‚ˆã‚‹ãƒ‡ãƒ¼ã‚¿ãƒ»ãƒžã‚¤ãƒ‹ãƒ³ã‚° + +ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã¸ã®é«˜æ©Ÿèƒ½ã®å•ã„åˆã‚ã›æ©Ÿèƒ½ã€ãŠã‚ˆã³ã€èª¿æŸ»å¯¾è±¡ã®ã‚³ãƒ¼ãƒ‰ã®è¤‡æ•°ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«ã‚ãŸã‚‹è­¦å‘Šã®è¿½è·¡è¨˜éŒ²æ©Ÿèƒ½ã‚’〠FindBugs ã¯å†…蔵ã—ã¦ã„ã¾ã™ã€‚ã“れらを使ã£ã¦æ¬¡ã®ã‚ˆã†ãªã“ã¨ãŒã§ãã¾ã™ã€‚ã™ãªã‚ã¡ã€ã„ã¤ãƒã‚°ãŒæœ€åˆæŒã¡è¾¼ã¾ã‚ŒãŸã‹ã‚’æœã—出ã™ã“ã¨ã€æœ€çµ‚リリース以後æŒã¡è¾¼ã¾ã‚ŒãŸè­¦å‘Šã®åˆ†æžã‚’è¡Œã†ã“ã¨ã€ã¾ãŸã¯ã€ç„¡é™å†èµ·ãƒ«ãƒ¼ãƒ—ã®æ•°ã‚’時間軸ã§ã‚°ãƒ©ãƒ•ã«ã™ã‚‹ã“ã¨ã§ã™ã€‚ + +ã“れらã®æŠ€è¡“ã¯ã€ FindBugs ãŒè­¦å‘Šã®ä¿å­˜ã«ä½¿ã† XML 書å¼ã‚’使用ã—ã¾ã™ã€‚ã“れら㮠XML ファイルã¯ã€é€šå¸¸ã€ç‰¹å®šã® 1 分æžã«å¯¾ã™ã‚‹è­¦å‘ŠãŒå…¥ã‚Œã‚‰ã‚Œã¦ã„ã¾ã™ã€‚ã—ã‹ã—ãれらã«ã¯ã€ä¸€é€£ã®ã‚½ãƒ•ãƒˆã‚¦ã‚§ã‚¢ã®ãƒ“ルドやãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«å¯¾ã™ã‚‹åˆ†æžçµæžœã‚’æ ¼ç´ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ + +ã™ã¹ã¦ã® FindBugs XML ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã«ã¯ã€ãƒãƒ¼ã‚¸ãƒ§ãƒ³åã¨ã‚¿ã‚¤ãƒ ãƒ»ã‚¹ã‚¿ãƒ³ãƒ— ãŒå…¥ã‚Œã‚‰ã‚Œã¦ã„ã¾ã™ã€‚FindBugs ã¯åˆ†æžãŒè¡Œã‚れるファイルã®æ›´æ–°æ™‚刻ã‹ã‚‰ã‚¿ã‚¤ãƒ ãƒ»ã‚¹ã‚¿ãƒ³ãƒ—を計算ã—ã¾ã™ (例ãˆã°ã€ã‚¿ã‚¤ãƒ ãƒ»ã‚¹ã‚¿ãƒ³ãƒ—ã¯ã‚¯ãƒ©ã‚¹ãƒ•ã‚¡ã‚¤ãƒ«ã®ç”Ÿæˆæ™‚刻ã«ãªã‚‹ã‚ˆã†ã«ãªã£ã¦ã„ã¾ã™ã€‚分æžãŒè¡Œã‚ã‚ŒãŸæ™‚刻ã§ã¯ã‚ã‚Šã¾ã›ã‚“) 。å„々ã®ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã«ã¯ã€ãƒãƒ¼ã‚¸ãƒ§ãƒ³åも入れられã¦ã„ã¾ã™ã€‚ãƒãƒ¼ã‚¸ãƒ§ãƒ³åã¨ã‚¿ã‚¤ãƒ ãƒ»ã‚¹ã‚¿ãƒ³ãƒ—ã¯ã€ setBugDatabaseInfo () コマンドを使用ã—ã¦æ‰‹å‹•ã§è¨­å®šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ + +複数ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’æ ¼ç´ã™ã‚‹ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã«ãŠã„ã¦ã¯ã€åˆ†æžã•ã‚Œã‚‹ã‚³ãƒ¼ãƒ‰ã®å„ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã”ã¨ã«ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ç•ªå·ãŒå‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¾ã™ã€‚ã“れらã®ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ç•ªå·ã¯å˜ã« 0 ã‹ã‚‰å§‹ã¾ã‚‹é€£ç¶šã™ã‚‹æ•´æ•°å€¤ã§ã™ (例ãˆã°ã€ 4 ã¤ã®ã‚³ãƒ¼ãƒ‰ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’æ ¼ç´ã™ã‚‹ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã«ã¯ã€ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 0~3 ãŒå…¥ã‚Œã‚‰ã‚Œã¾ã™) 。ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã«ã¯ã¾ãŸã€å„ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®åå‰ã¨ã‚¿ã‚¤ãƒ ãƒ»ã‚¹ã‚¿ãƒ³ãƒ—ãŒãã‚Œãžã‚Œè¨˜éŒ²ã•ã‚Œã¾ã™ã€‚filterBugs コマンドを使用ã™ã‚‹ã¨ã€ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ç•ªå·ã€ãƒãƒ¼ã‚¸ãƒ§ãƒ³åã¾ãŸã¯ã‚¿ã‚¤ãƒ ãƒ»ã‚¹ã‚¿ãƒ³ãƒ—ã‹ã‚‰ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’å‚ç…§ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + +1 ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’æ ¼ç´ã™ã‚‹ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã®é›†åˆã‹ã‚‰ã€ 1 個ã®è¤‡æ•°ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã‚’作æˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸã€è¤‡æ•°ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã«å¯¾ã—ã¦ã€ãれ以後ã«ä½œæˆã•ã‚ŒãŸ 1 ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã‚’çµåˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + +ã“れらã®ã‚³ãƒžãƒ³ãƒ‰ã®ã„ãã¤ã‹ã¯ã€ ant タスクã¨ã—ã¦å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚コマンドã®å®Ÿè¡Œæ–¹æ³•ãŠã‚ˆã³å±žæ€§ãƒ»å¼•æ•°ã®è©³ç´°ã¯ã€ä»¥ä¸‹ã‚’å‚ç…§ã—ã¦ãã ã•ã„。以下ã®ã™ã¹ã¦ã®ä¾‹ã«ãŠã„ã¦ã¯ã€ findbugs.lib refid ãŒæ­£ã—ã設定ã•ã‚Œã¦ã„ã‚‹ã“ã¨ã‚’å‰æã¨ã—ã¦ã„ã¾ã™ã€‚設定方法ã®ä¸€ä¾‹ã‚’次ã«ç¤ºã—ã¾ã™ : + + + + + + + + + +]]> + + + + コマンド + + FindBugs データ・マイニング ツールã¯ã™ã¹ã¦ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã‹ã‚‰å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸã€ã„ãã¤ã‹ã®ã‚ˆã‚Šæœ‰ç”¨ãªã‚³ãƒžãƒ³ãƒ‰ã¯ã€ ant ビルドファイルã‹ã‚‰å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + +コマンドラインツールã«ã¤ã„ã¦ç°¡å˜ã«èª¬æ˜Žã—ã¾ã™ : + + + + unionBugs + + 別ã®ã‚¯ãƒ©ã‚¹ã«å¯¾ã™ã‚‹åˆ¥å€‹ã®åˆ†æžçµæžœã‚’çµåˆã—ã¾ã™ã€‚ + + + + computeBugHistory + + 複数ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‹ã‚‰å¾—られãŸè¤‡æ•°ã®ãƒã‚°è­¦å‘Šã‚’ã€ãƒžãƒ¼ã‚¸ã—㦠1 個ã®è¤‡æ•°ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã«ã—ã¾ã™ã€‚ã“れを使ã£ã¦ã€æ—¢å­˜ã®è¤‡æ•°ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã«æ›´ã«ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’追加ã—ãŸã‚Šã€ 1 ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’æ ¼ç´ã™ã‚‹ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã®é›†åˆã‹ã‚‰ 1 個ã®è¤‡æ•°ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã‚’作æˆã—ãŸã‚Šã€ã§ãã¾ã™ã€‚ + + + + setBugDatabaseInfo + + リビジョンåやタイム・スタンプãªã©ã®æƒ…報を XML データベースã«è¨­å®šã—ã¾ã™ã€‚ + + + + listBugDatabaseInfo + + XML データベースã«ã‚るリビジョンåやタイム・スタンプãªã©ã®æƒ…報を一覧表示ã—ã¾ã™ã€‚ + + + + filterBugs + + ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã®éƒ¨åˆ†é›†åˆã‚’é¸æŠžã—ã¾ã™ã€‚ + + + + mineBugHistory + + 複数ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã®å„ãƒãƒ¼ã‚¸ãƒ§ãƒ³æ¯Žã®è­¦å‘Šæ•°ã‚’一覧ã«ã—ãŸè¡¨ã‚’作æˆã—ã¾ã™ã€‚ + + + + defectDensity + + プロジェクト全体ãŠã‚ˆã³ã‚¯ãƒ©ã‚¹æ¯Žãƒ»ãƒ‘ッケージ毎ã®ä¸è‰¯å¯†åº¦ (1000 NCSS 毎ã®è­¦å‘Šæ•°) ã«é–¢ã™ã‚‹æƒ…報を一覧表示ã—ã¾ã™ã€‚ + + + + convertXmlToText + + XML å½¢å¼ã®ãƒã‚°è­¦å‘Šã‚’〠1 è¡Œ 1 ãƒã‚°ã®ãƒ†ã‚­ã‚¹ãƒˆå½¢å¼ã€ã¾ãŸã¯ã€HTMLå½¢å¼ã«å¤‰æ›ã—ã¾ã™ã€‚ + + + + + + + unionBugs + + 分æžã™ã‚‹ã®ã«ã‚¢ãƒ—リケーション㮠jar ファイルを分割ã—ã¦ã„ã‚‹å ´åˆã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã™ã‚‹ã“ã¨ã§ã€åˆ¥å€‹ã«ç”Ÿæˆã•ã‚ŒãŸ XML ãƒã‚°è­¦å‘Šãƒ•ã‚¡ã‚¤ãƒ«ã‚’ã™ã¹ã¦ã®è­¦å‘Šã‚’å«ã‚“ã§ã„ã‚‹ 1 ã¤ã® ファイルã«ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + åŒã˜ãƒ•ã‚¡ã‚¤ãƒ«ã®ç•°ãªã‚‹ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’分æžã—ãŸçµæžœã‚’çµåˆã™ã‚‹å ´åˆã¯ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã—ãªã„ã§ãã ã•ã„。代ã‚ã‚Šã« computeBugHistory を使用ã—ã¦ãã ã•ã„。 + + XML ファイルã¯ã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã§æŒ‡å®šã—ã¦ãã ã•ã„。çµæžœã¯ã€æ¨™æº–出力ã«é€ã‚‰ã‚Œã¾ã™ã€‚ + + + + computeBugHistory + +ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã™ã‚‹ã“ã¨ã§ã€åˆ†æžã™ã‚‹ã‚½ãƒ•ãƒˆã‚¦ã‚§ã‚¢ã®ç•°ãªã‚‹ãƒ“ルドã¾ãŸã¯ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®æƒ…報をå«ã‚€ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã‚’生æˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã™å…¥åŠ›ã¨ã—ã¦æä¾›ã—ãŸãƒ•ã‚¡ã‚¤ãƒ«ã® 1 番目ã®ãƒ•ã‚¡ã‚¤ãƒ«ã‹ã‚‰å±¥æ­´ãŒå–å¾—ã•ã‚Œã¾ã™ã€‚後ã«ç¶šãファイル㯠1 ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã§ã‚るよã†ã«ã—ã¦ãã ã•ã„ (ã‚‚ã—ã€å±¥æ­´ã‚’æŒã£ã¦ã„ãŸã¨ã—ã¦ã‚‚無視ã•ã‚Œã¾ã™) 。 +デフォルトã§ã¯ã€çµæžœã¯æ¨™æº–出力ã«é€ã‚‰ã‚Œã¾ã™ã€‚ + +ã“ã®æ©Ÿèƒ½ã¯ã€ ant ã‹ã‚‰ã‚‚使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãšæ¬¡ã«ç¤ºã™ã‚ˆã†ã«ã€ãƒ“ルドファイル㫠computeBugHistory ã‚’ taskdef ã§å®šç¾©ã—ã¾ã™ : + + + + + +]]> + + +ã“ã® ant タスクã«æŒ‡å®šã§ãる属性をã€ä¸‹è¡¨ã«ä¸€è¦§ã§ç¤ºã—ã¾ã™ã€‚入力ファイルを指定ã™ã‚‹ã«ã¯ã€ <datafile> è¦ç´ ã‚’入れå­ã«ã—ã¦å…¥ã‚Œã¦ãã ã•ã„。次ã«ã€ä¾‹ã‚’示ã—ã¾ã™: + + + + + + +]]> + + + + computeBugHistory コマンドã®ã‚ªãƒ—ション一覧 + + + + コマンドラインオプション + Ant 属性 + 目的 + + + +-output <file> output="<file>" 出力çµæžœã‚’ä¿å­˜ã™ã‚‹ãƒ•ã‚¡ã‚¤ãƒ«åを指定ã—ã¾ã™ã€‚ (åŒæ™‚ã«å…¥åŠ›ãƒ•ã‚¡ã‚¤ãƒ«ã«ã‚‚ãªã‚Šãˆã¾ã™) +-overrideRevisionNames[:truth] overrideRevisionNames="[true|false]"ファイルåã‹ã‚‰ç®—出ã•ã‚Œã‚‹ãã‚Œãžã‚Œã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³åを指定変更ã—ã¾ã™ã€‚ +-noPackageMoves[:truth] noPackageMoves="[true|false]"パッケージを移動ã—ãŸã‚¯ãƒ©ã‚¹ãŒã‚ã‚‹å ´åˆã€å½“該クラスã®è­¦å‘Šã¯åˆ¥ã®å­˜åœ¨ã¨ã—ã¦æ‰±ã‚ã‚Œã¾ã™ã€‚ +-preciseMatch[:truth] preciseMatch="[true|false]"ãƒã‚°ãƒ‘ターンãŒæ­£ç¢ºã«ä¸€è‡´ã™ã‚‹ã“ã¨ã‚’è¦æ±‚ã—ã¾ã™ã€‚ +-precisePriorityMatch[:truth] precisePriorityMatch="[true|false]"優先度ãŒæ­£ç¢ºã«ä¸€è‡´ã—ãŸå ´åˆã®ã¿è­¦å‘ŠãŒåŒä¸€ã§ã‚ã‚‹ã¨åˆ¤æ–­ã•ã‚Œã¾ã™ã€‚ +-quiet[:truth] quiet="[true|false]"エラーãŒç™ºç”Ÿã—ãªã„é™ã‚Šã€æ¨™æº–出力ã«ã¯ä½•ã‚‚表示ã•ã‚Œã¾ã›ã‚“。 +-withMessages[:truth] withMessages="[true|false]"出力 XML ã«äººé–“ãŒèª­ã‚€ã“ã¨ãŒã§ãã‚‹ãƒã‚°ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒå«ã¾ã‚Œã¾ã™ã€‚ + + +
    + +
    + + filterBugs +ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã™ã‚‹ã“ã¨ã§ã€ FindBugs XML 警告ファイルã‹ã‚‰ä¸€éƒ¨åˆ†ã‚’é¸ã³å‡ºã—ã¦æ–°è¦ FindBugs 警告ファイルã«é¸æŠžã•ã‚ŒãŸéƒ¨åˆ†ã‚’書ã込むã“ã¨ãŒã§ãã¾ã™ã€‚ +ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã¯ã€ã‚ªãƒ—ション群ã«ç¶šã„㦠0 個ã‹ã‚‰ 2 個㮠findbugs xml ãƒã‚°ãƒ•ã‚¡ã‚¤ãƒ«ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ +ファイルåã‚’ã²ã¨ã¤ã‚‚指定ã—ãªã„å ´åˆã¯ã€æ¨™æº–入力ã‹ã‚‰èª­ã‚“ã§æ¨™æº–出力ã«å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ファイルåã‚’ 1 個 指定ã—ãŸå ´åˆã¯ã€æŒ‡å®šã—ãŸãƒ•ã‚¡ã‚¤ãƒ«ã‹ã‚‰èª­ã‚“ã§æ¨™æº–出力ã«å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ファイルåã‚’ 2 個 指定ã—ãŸå ´åˆã¯ã€ 1 番目ã«æŒ‡å®šã—ãŸãƒ•ã‚¡ã‚¤ãƒ«ã‹ã‚‰èª­ã‚“㧠2 番目ã«æŒ‡å®šã—ãŸãƒ•ã‚¡ã‚¤ãƒ«ã«å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ + +ã“ã®æ©Ÿèƒ½ã¯ã€ ant ã‹ã‚‰ã‚‚使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãšæ¬¡ã«ç¤ºã™ã‚ˆã†ã«ã€ãƒ“ルドファイル㫠filterBugs ã‚’ taskdef ã§å®šç¾©ã—ã¾ã™ : + + + + + +]]> + + +ã“ã® ant タスクã«æŒ‡å®šã§ãる属性をã€ä¸‹è¡¨ã«ä¸€è¦§ã§ç¤ºã—ã¾ã™ã€‚入力ファイルを指定ã™ã‚‹ã«ã¯ã€ input 属性を使用ã™ã‚‹ã‹ã€ <datafile> è¦ç´ ã‚’入れå­ã«ã—ã¦å…¥ã‚Œã¦ãã ã•ã„。次ã«ã€ä¾‹ã‚’示ã—ã¾ã™: + + + + + +]]> + + + + filterBugs コマンドã®ã‚ªãƒ—ション一覧 + + + + コマンドラインオプション + Ant 属性 + 目的 + + + + input="<file>" 入力ファイルを指定ã—ã¾ã™ã€‚ + output="<file>" 出力ファイルを指定ã—ã¾ã™ã€‚ +-not not="[true|false]" フィルターã®ã‚¹ã‚¤ãƒƒãƒã‚’å転ã—ã¾ã™ã€‚ +-withSource[:truth] withSource="[true|false]" ソースãŒå…¥æ‰‹å¯èƒ½ãªè­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-exclude <filter file>exclude="<filter file>" フィルターã«ä¸€è‡´ã™ã‚‹ãƒã‚°ãŒé™¤å¤–ã•ã‚Œã¾ã™ã€‚ +-include <filter file>include="<filter file>" フィルターã«ä¸€è‡´ã™ã‚‹ãƒã‚°ã®ã¿ã‚’å«ã¾ã‚Œã¾ã™ã€‚ +-annotation <text> annotation="<text>" 手ã§å…¥åŠ›ã—ãŸæ³¨é‡ˆã«æŒ‡å®šã—ãŸæ–‡è¨€ã‚’å«ã‚€è­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-after <when> after="<when>" 指定ã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚ˆã‚Šå¾Œã«åˆã‚ã¦å‡ºç¾ã—ãŸè­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-before <when> before="<when>" 指定ã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚ˆã‚Šå‰ã«åˆã‚ã¦å‡ºç¾ã—ãŸè­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-first <when> first="<when>" 指定ã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«åˆã‚ã¦å‡ºç¾ã—ãŸè­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-last <when> last="<when>" 指定ã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ãŒå‡ºç¾ã—ãŸæœ€å¾Œã§ã‚る警告ã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-fixed <when> fixed="<when>" 指定ã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®å‰å›žã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãŒå‡ºç¾ã—ãŸæœ€å¾Œã§ã‚る警告ã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ ( ã«å„ªå…ˆã—ã¾ã™)。 +-present <when> present="<when>" 指定ã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«å­˜åœ¨ã™ã‚‹è­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-absent <when> absent="<when>" 指定ã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«å­˜åœ¨ã—ãªã„警告ã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-active[:truth] active="[true|false]" 最終通番ã«å­˜åœ¨ã™ã‚‹è­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-introducedByChange[:truth] introducedByChange="[true|false]"存在ã™ã‚‹ã‚¯ãƒ©ã‚¹ã®å¤‰æ›´ã«ã‚ˆã£ã¦ã‚‚ãŸã‚‰ã•ã‚ŒãŸè­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-removedByChange[:truth] removedByChange="[true|false]" 存在ã™ã‚‹ã‚¯ãƒ©ã‚¹ã®å¤‰æ›´ã«ã‚ˆã£ã¦é™¤åŽ»ã•ã‚ŒãŸè­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-newCode[:truth] newCode="[true|false]" 新クラスã®è¿½åŠ ã«ã‚ˆã£ã¦ã‚‚ãŸã‚‰ã•ã‚ŒãŸè­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-removedCode[:truth] removedCode="[true|false]" クラスã®å‰Šé™¤ã«ã‚ˆã£ã¦é™¤åŽ»ã•ã‚ŒãŸè­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-priority <level> priority="<level>" 指定ã—ãŸå„ªå…ˆåº¦ä»¥ä¸Šã®å„ªå…ˆåº¦ã‚’ã‚‚ã¤è­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-class <pattern> class="<class>" 指定ã—ãŸãƒ‘ターンã«ä¸€è‡´ã™ã‚‹ä¸»ã‚¯ãƒ©ã‚¹ã‚’ã‚‚ã¤è­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-bugPattern <pattern> bugPattern="<pattern>" 指定ã—ãŸãƒ‘ターンã«ä¸€è‡´ã™ã‚‹ãƒã‚°ç¨®åˆ¥ã‚’ã‚‚ã¤è­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-category <category> category="<category>" 指定ã—ãŸæ–‡å­—列ã§å§‹ã¾ã‚‹ã‚«ãƒ†ã‚´ãƒªãƒ¼ã®è­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ +-designation <designation> designation="<designation>" 指定ã—ãŸãƒã‚°åˆ†é¡žæŒ‡å®šã‚’ã‚‚ã¤è­¦å‘Šã®ã¿å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ (例〠-designation SHOULD_FIX) +-withMessages[:truth] withMessages="[true|false]" テキストメッセージをå«ã‚“ã  XML ãŒç”Ÿæˆã•ã‚Œã¾ã™ã€‚ + + +
    + +
    + + + mineBugHistory +ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã™ã‚‹ã“ã¨ã§ã€è¤‡æ•°ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã®å„ãƒãƒ¼ã‚¸ãƒ§ãƒ³æ¯Žã®è­¦å‘Šæ•°ã‚’一覧ã«ã—ãŸè¡¨ã‚’作æˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + + +ã“ã®æ©Ÿèƒ½ã¯ã€ ant ã‹ã‚‰ã‚‚使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãšæ¬¡ã«ç¤ºã™ã‚ˆã†ã«ã€ãƒ“ルドファイル㫠mineBugHistory ã‚’ taskdef ã§å®šç¾©ã—ã¾ã™ : + + + + + +]]> + + +ã“ã® ant タスクã«æŒ‡å®šã§ãる属性をã€ä¸‹è¡¨ã«ä¸€è¦§ã§ç¤ºã—ã¾ã™ã€‚入力ファイルを指定ã™ã‚‹ã«ã¯ã€ input 属性を使用ã™ã‚‹ã‹ã€ <datafile> è¦ç´ ã‚’入れå­ã«ã—ã¦å…¥ã‚Œã¦ãã ã•ã„。次ã«ã€ä¾‹ã‚’示ã—ã¾ã™: + + + + + +]]> + + + + mineBugHistory コマンドã®ã‚ªãƒ—ション一覧 + + + + コマンドラインオプション + Ant 属性 + 目的 + + + + input="<file>" 入力ファイルを指定ã—ã¾ã™ã€‚ + output="<file>" 出力ファイルを指定ã—ã¾ã™ã€‚ +-formatDates formatDates="[true|false]" データãŒãƒ†ã‚­ã‚¹ãƒˆå½¢å¼ã§æç”»ã•ã‚Œã¾ã™ã€‚ +-noTabs noTabs="[true|false]" タブã®ä»£ã‚ã‚Šã«è¤‡æ•°ã‚¹ãƒšãƒ¼ã‚¹ã§ã‚«ãƒ©ãƒ ãŒåŒºåˆ‡ã‚‰ã‚Œã¾ã™ (下記å‚ç…§)。 +-summary summary="[true|false]" 最新 10 件ã®å¤‰æ›´ã®è¦ç´„ãŒå‡ºåŠ›ã•ã‚Œã¾ã™ã€‚ + + +
    + + 出力を使ã†ã“ã¨ã§ã€å›ºå®šå¹…フォントã®ã‚·ã‚§ãƒ«ã§èª­ã¿æ˜“ããªã‚Šã¾ã™ã€‚数値カラムã¯å³å¯„ã›ã•ã‚Œã‚‹ã®ã§ã€ã‚¹ãƒšãƒ¼ã‚¹ãŒã‚«ãƒ©ãƒ å€¤ã®å‰ã«æŒ¿å…¥ã•ã‚Œã¾ã™ã€‚ã¾ãŸã€ã“ã®ã‚ªãƒ—ションを使用ã—ãŸå ´åˆã€ を指定ã—ãŸã¨ãã«è¦ç´„ã®æ—¥ä»˜ã‚’æç”»ã™ã‚‹ã®ã«ç©ºç™½ãŒåŸ‹ã‚è¾¼ã¾ã‚Œãªããªã‚Šã¾ã™ã€‚ + + 出力ã•ã‚Œã‚‹è¡¨ã¯ã€ ( ãŒç„¡ã‘ã‚Œã°) タブ区切りã§æ¬¡ã«ç¤ºã™ã‚«ãƒ©ãƒ ã‹ã‚‰æˆã‚Šã¾ã™ : + + + mineBugHistory 出力ã®ã‚«ãƒ©ãƒ ä¸€è¦§ + + + + 表題 + 目的 + + + + seqã‚·ãƒ¼ã‚±ãƒ³ã‚¹ç•ªå· (0 始ã¾ã‚Šã®é€£ç¶šã—ãŸæ•´æ•°å€¤) + versionãƒãƒ¼ã‚¸ãƒ§ãƒ³å + timeリリースã•ã‚ŒãŸæ—¥æ™‚ + classes分æžã•ã‚ŒãŸã‚¯ãƒ©ã‚¹æ•° + NCSSコメント文を除ã„ãŸå‘½ä»¤æ•° (Non Commenting Source Statements) + addedå‰å›žã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«å­˜åœ¨ã—ãŸã‚¯ãƒ©ã‚¹ã«ãŠã‘ã‚‹æ–°è¦è­¦å‘Šæ•° + newCodeå‰å›žã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«å­˜åœ¨ã—ãªã‹ã£ãŸã‚¯ãƒ©ã‚¹ã«ãŠã‘ã‚‹æ–°è¦è­¦å‘Šæ•° + fixedç¾åœ¨ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«å­˜åœ¨ã™ã‚‹ã‚¯ãƒ©ã‚¹ã«ãŠã‘る除去ã•ã‚ŒãŸè­¦å‘Šæ•° + removedç¾åœ¨ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«å­˜åœ¨ã—ãªã„クラスã®å‰å›žã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«ãŠã‘る警告数 + retainedç¾åœ¨ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã¨å‰å›žã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®ä¸¡æ–¹ã«å­˜åœ¨ã™ã‚‹è­¦å‘Šã®æ•° + dead以å‰ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«å­˜åœ¨ã—ãŸãŒç¾åœ¨ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«ã‚‚ç›´å‰ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«ã‚‚存在ã—ãªã„警告ã®æ•° + activeç¾åœ¨ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«å­˜åœ¨ã™ã‚‹è­¦å‘Šç·æ•° + + +
    +
    + + + defectDensity +ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã™ã‚‹ã“ã¨ã§ã€ãƒ—ロジェクト全体ãŠã‚ˆã³ã‚¯ãƒ©ã‚¹æ¯Žãƒ»ãƒ‘ッケージ毎ã®ä¸è‰¯å¯†åº¦ (1000 NCSS 毎ã®è­¦å‘Šæ•°) ã«é–¢ã™ã‚‹æƒ…報を一覧表示ã§ãã¾ã™ã€‚標準入力ã‹ã‚‰èª­ã¿è¾¼ã‚€å ´åˆã¯ãƒ•ã‚¡ã‚¤ãƒ«æŒ‡å®šãªã—ã§ã€ãã†ã§ãªã‘ã‚Œã°ã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã§ãƒ•ã‚¡ã‚¤ãƒ«ã‚’指定ã—ã¦ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ +出力ã•ã‚Œã‚‹è¡¨ã¯ã€æ¬¡ã«ç¤ºã™ã‚«ãƒ©ãƒ ã‹ã‚‰æˆã‚Šã¾ã™ã€‚ã¾ãŸã€ãƒ—ロジェクト全体情報ã®è¡Œã€ãŠã‚ˆã³ã€4 個以上ã®è­¦å‘Šã‚’å«ã‚“ã§ã„ã‚‹å„パッケージ情報ã¾ãŸã¯å„クラス情報ã®è¡Œã‚‚出力ã•ã‚Œã¾ã™ã€‚ + + defectDensity 出力ã®ã‚«ãƒ©ãƒ ä¸€è¦§ + + + + 表題 + 目的 + + + + kindプロジェクト (project)ã€ãƒ‘ッケージ (package) ã¾ãŸã¯ã‚¯ãƒ©ã‚¹ (class) + nameプロジェクトã€ãƒ‘ッケージã¾ãŸã¯ã‚¯ãƒ©ã‚¹ã®åå‰ + density 1000 NCSS 毎ã®è­¦å‘Šæ•° + bugs警告数 + NCSSコメント文を除ã„ãŸå‘½ä»¤æ•° (Non Commenting Source Statements) + + +
    +
    + + + convertXmlToText + + ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã™ã‚‹ã“ã¨ã§ã€XML å½¢å¼ã®ãƒã‚°è­¦å‘Šã‚’〠1 è¡Œ 1 ãƒã‚°ã®ãƒ†ã‚­ã‚¹ãƒˆå½¢å¼ã€ã¾ãŸã¯ã€HTMLå½¢å¼ã«å¤‰æ›ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + +ã“ã®æ©Ÿèƒ½ã¯ã€ ant ã‹ã‚‰ã‚‚使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãšæ¬¡ã«ç¤ºã™ã‚ˆã†ã«ã€ãƒ“ルドファイル㫠convertXmlToText ã‚’ taskdef ã§å®šç¾©ã—ã¾ã™ : + + + + + +]]> + + +ã“ã® ant タスクã«æŒ‡å®šã§ãる属性をã€ä¸‹è¡¨ã«ä¸€è¦§ã§ç¤ºã—ã¾ã™ã€‚ + + + convertXmlToText コマンドã®ã‚ªãƒ—ション一覧 + + + + コマンドラインオプション + Ant 属性 + 目的 + + + + input="<filename>" 入力ファイルを指定ã—ã¾ã™ã€‚ + output="<filename>" 出力ファイルを指定ã—ã¾ã™ã€‚ +-longBugCodes longBugCodes="[true|false]" 2 文字ã®ãƒã‚°ç•¥ç§°ã®ä»£ã‚ã‚Šã«ã€çœç•¥ãªã—ã®ãƒã‚°ãƒ‘ターンコードを使用ã—ã¾ã™ã€‚ + format="text" プレーンテキストã®å‡ºåŠ›ãŒä½œæˆã•ã‚Œã¾ã™ã€‚1 è¡Œã«ã¤ã 1 ã¤ã®ãƒã‚°ãŒå‡ºåŠ›ã•ã‚Œã¾ã™ã€‚コマンドライン時ã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã§ã™ã€‚ +-html[:stylesheet] format="html:<stylesheet>" 指定ã•ã‚ŒãŸã‚¹ã‚¿ã‚¤ãƒ«ã‚·ãƒ¼ãƒˆã‚’使用ã—ã¦å‡ºåŠ›ãŒä½œæˆã•ã‚Œã¾ã™ (下記å‚ç…§) 。çœç•¥ã—ãŸå ´åˆã¯ã€ default.xsl ãŒä½¿ç”¨ã•ã‚Œã¾ã™ã€‚ + + +
    + + -html/format オプションã«ã¯ã€plain.xsl 〠default.xsl 〠fancy.xsl 〠fancy-hist.xsl ã¾ãŸã¯ ユーザ自身ãŒä½œæˆã—㟠XSL スタイルシートã®ã„ãšã‚Œã‹ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚オプションåをよãã«ã€ html 以外ã®å½¢å¼ã‚’出力ã™ã‚‹ã‚¹ã‚¿ã‚¤ãƒ«ã‚·ãƒ¼ãƒˆã‚’指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚FindBugs ã«å«ã¾ã‚Œã¦ã„るスタイルシート(上述)以外ã®ã‚¹ã‚¿ã‚¤ãƒ«ã‚·ãƒ¼ãƒˆã‚’使用ã™ã‚‹å ´åˆã¯ã€ã‚ªãƒ—ション -html/format ã§å½“該スタイルシートã¸ã®ãƒ‘スã¾ãŸã¯ URL を指定ã—ã¦ãã ã•ã„。 +
    + + + setBugDatabaseInfo + + ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã™ã‚‹ã“ã¨ã§ã€æŒ‡å®šã—ãŸãƒã‚°è­¦å‘Šã«ãƒ¡ã‚¿æƒ…報を設定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã¯æ¬¡ã«ç¤ºã™ã‚ªãƒ—ションãŒã‚ã‚Šã¾ã™: + +ã“ã®æ©Ÿèƒ½ã¯ã€ ant ã‹ã‚‰ã‚‚使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãšæ¬¡ã«ç¤ºã™ã‚ˆã†ã«ã€ãƒ“ルドファイル㫠setBugDatabaseInfo ã‚’ taskdef ã§å®šç¾©ã—ã¾ã™ : + + + + + +]]> + + +ã“ã® ant タスクã«æŒ‡å®šã§ãる属性をã€ä¸‹è¡¨ã«ä¸€è¦§ã§ç¤ºã—ã¾ã™ã€‚入力ファイルを指定ã™ã‚‹ã«ã¯ã€ input 属性を使用ã™ã‚‹ã‹ã€ <datafile> è¦ç´ ã‚’入れå­ã«ã—ã¦å…¥ã‚Œã¦ãã ã•ã„。次ã«ã€ä¾‹ã‚’示ã—ã¾ã™: + + + + + +]]> + + + + setBugDatabaseInfo オプション一覧 + + + + コマンドラインオプション + Ant 属性 + 目的 + + + + input="<file>" 入力ファイルを指定ã—ã¾ã™ã€‚ + output="<file>" 出力ファイルを指定ã—ã¾ã™ã€‚ + -name <name> name="<name>" 最新リビジョンã®åå‰ã‚’設定ã—ã¾ã™ã€‚ + -timestamp <when> timestamp="<when>" 最新リビジョンã®ã‚¿ã‚¤ãƒ ãƒ»ã‚¹ã‚¿ãƒ³ãƒ—を設定ã—ã¾ã™ã€‚ + -source <directory> source="<directory>" ソースを検索ã™ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼ã‚’追加指定ã—ã¾ã™ã€‚ + -findSource <directory> findSource="<directory>" 指定ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ¼å†…を検索ã—ã¦é–¢é€£ã™ã‚‹ã‚½ãƒ¼ã‚¹ã®å ´æ‰€ã‚’追加ã—ã¾ã™ã€‚ + -suppress <filter file> suppress="<filter file>" 指定ã—ãŸãƒ•ã‚¡ã‚¤ãƒ«ã«ä¸€è‡´ã™ã‚‹è­¦å‘Šã‚’抑止ã—ã¾ã™ (以å‰ã«æŒ‡å®šã—ãŸæŠ‘止設定ã¯ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™)。 + -withMessages withMessages="[true|false]" XMLã«ãƒ†ã‚­ã‚¹ãƒˆãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’追加ã—ã¾ã™ã€‚ + -resetSource resetSource="[true|false]" ソース検索パスをã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚ + + +
    +
    + + + listBugDatabaseInfo + + ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã«ãŠã„ã¦ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã§ 0 個以上㮠xml ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ãƒ•ã‚¡ã‚¤ãƒ«åを指定ã—ã¾ã™ã€‚ファイルåã‚’1ã¤ã‚‚指定ã—ãªã‘ã‚Œã°ã€æ¨™æº–出力ã‹ã‚‰èª­ã¿è¾¼ã¿ã‚’è¡Œã„テーブルã®ãƒ˜ãƒƒãƒ€ãƒ¼ã¯ç”Ÿæˆã•ã‚Œã¾ã›ã‚“。 + +ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã¯ 1 ã¤ã ã‘オプションãŒã‚ã‚Šã¾ã™ : を指定ã™ã‚‹ã¨ãƒ†ã‚­ã‚¹ãƒˆå½¢å¼ã§ãƒ‡ãƒ¼ã‚¿ãŒæç”»ã•ã‚Œã¾ã™ã€‚ + +出力ã•ã‚Œã‚‹è¡¨ã¯ã€å„ãƒã‚°ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã”ã¨ã«è¡Œã‚’æŒã¡ã€æ¬¡ã«ç¤ºã™ã‚«ãƒ©ãƒ ã‹ã‚‰æˆã‚Šã¾ã™ : + + listBugDatabaseInfo カラム一覧 + + + + カラム + 目的 + + + + versionãƒãƒ¼ã‚¸ãƒ§ãƒ³å + timeリリースã•ã‚ŒãŸæ—¥æ™‚ + classes分æžã•ã‚ŒãŸã‚¯ãƒ©ã‚¹æ•° + NCSSコメント文を除ã„ãŸå‘½ä»¤æ•° (Non Commenting Source Statements) + total全警告数 + high優先度(高)ã®è­¦å‘Šã®ç·æ•° + medium優先度(中)ã®è­¦å‘Šã®ç·æ•° + low優先度(低)ã®è­¦å‘Šã®ç·æ•° + filenameデータベースã®ãƒ•ã‚¡ã‚¤ãƒ«å + + + +
    + +
    + +
    + + + 例 + + æä¾›ã•ã‚ŒãŸã‚·ã‚§ãƒ«ãƒ»ã‚¹ã‚¯ãƒªãƒ—トを使用ã—ã¦ã®å±¥æ­´ãƒžã‚¤ãƒ‹ãƒ³ã‚° +以下ã¯ã™ã¹ã¦ã€ jdk1.6.0-b12, jdk1.6.0-b13, ..., jdk1.6.0-b60 ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã„ã¾ã™ã€‚ + +以下ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã¿ã¾ã™ : + +computeBugHistory jdk1.6.0-b* | filterBugs -bugPattern IL_ | mineBugHistory -formatDates + +ã™ã‚‹ã¨ã€æ¬¡ã®ã‚ˆã†ãªå‡ºåŠ›ãŒè¡Œã‚ã‚Œã¾ã™ : + + +seq version time classes NCSS added newCode fixed removed retained dead active +0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 4 0 0 0 0 4 +1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 4 0 4 +2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 0 0 2 0 2 0 2 +3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 0 0 1 0 1 2 1 +4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 0 0 1 3 1 +5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 0 0 1 3 1 +6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1 3 1 +7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 0 0 1 3 1 +8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1 3 1 +9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 0 0 1 3 1 +10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 0 0 0 0 1 3 1 +11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1 3 1 +12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 0 0 0 0 1 3 1 +13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1 3 1 +14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1 3 1 +15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 0 0 0 0 1 3 1 +16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 0 0 0 0 1 3 1 +17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1 3 2 +18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 0 0 0 2 3 2 +19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 2 3 2 +20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 0 0 0 2 3 2 +21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 0 0 0 0 2 3 2 +22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 0 1 0 0 2 3 3 +23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 0 2 0 0 3 3 5 +24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 5 3 5 +25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 0 0 0 0 5 3 5 +26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 0 0 0 0 5 3 5 +27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 5 3 5 +28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 0 0 1 0 4 3 4 +29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 0 0 0 0 4 4 4 +30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 0 0 1 0 3 4 3 +31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 3 5 3 +32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 0 0 0 0 3 5 3 +33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 1 0 0 0 3 5 4 +34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 0 0 0 0 4 5 4 +35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 0 0 4 5 4 +36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 0 0 1 0 3 5 3 +37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 3 6 3 +38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 0 0 0 0 3 6 3 +39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 0 0 0 0 3 6 3 +40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 3 6 3 +41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 0 0 0 3 6 3 +42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 0 0 0 0 3 6 3 +43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 3 6 3 + + +次ã«ç¤ºã™ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã¨ã€db.xml 中間ファイルを生æˆã™ã‚‹ã“ã¨ãªã直接åŒã˜æƒ…報を作æˆã§ãã¾ã™ã€‚ + + +computeBugHistory jdk1.6.0-b*/jre/lib/rt.xml | filterBugs -bugPattern IL_ db.xml | mineBugHistory -formatDates + + +ã“ã®æƒ…報を使ã£ã¦ã€ Sun JDK1.6.0 ã®å„ビルドã«ãŠã„㦠FindBugs ã«ã‚ˆã£ã¦ç™ºè¦‹ã•ã‚ŒãŸç„¡é™å†èµ·ãƒ«ãƒ¼ãƒ—ã®æ•°ã‚’表ã™ã‚°ãƒ©ãƒ•ã‚’表示ã—ã¾ã™ã€‚é’色ã®é ˜åŸŸã¯ã€å½“該ビルドã«ãŠã‘ã‚‹ç„¡é™å†èµ·ãƒ«ãƒ¼ãƒ—ã®æ•°ã‚’表ã—ã¦ã„ã¾ã™ã€‚ãã®ä¸Šã«æã‹ã‚Œã¦ã„る赤色ã®é ˜åŸŸã¯ã€ä»¥å‰ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«ã¯å­˜åœ¨ã—ãŸãŒå½“該ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯é™¤åŽ»ã•ã‚ŒãŸç„¡é™å†èµ·ãƒ«ãƒ¼ãƒ—ã®æ•°ã‚’表ã—ã¦ã„ã¾ã™ã€‚ (ã—ãŸãŒã£ã¦ã€èµ¤è‰²ã®é ˜åŸŸã¨é’色ã®é ˜åŸŸã‚’足ã—åˆã‚ã›ãŸé«˜ã•ã¯æ±ºã—ã¦æ¸›å°‘ã—ãªã„ã“ã¨ãŒä¿è¨¼ã•ã‚Œã¦ã„ã¾ã™ã€‚ãã—ã¦ã€æ–°ãŸã«ç„¡é™å†èµ·ãƒ«ãƒ¼ãƒ—ã®ãƒã‚°ãŒæŒã¡è¾¼ã¾ã‚ŒãŸæ™‚点ã§å¢—加ã—ã¾ã™) 。赤色ã®é ˜åŸŸã®é«˜ã•ã¯ã€å½“該ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«ãŠã„ã¦ä¿®æ­£ã¾ãŸã¯å‰Šé™¤ã•ã‚ŒãŸãƒã‚°æ•°ã®åˆè¨ˆã§ç®—出ã•ã‚Œã¾ã™ã€‚ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 13 ãŠã‚ˆã³ 14 ã«ãŠã„ã¦è¦‹ã‚‰ã‚Œã‚‹æ¸›å°‘ã¯ã€ FindBugs を使用ã—ã¦è¦‹ã¤ã‹ã£ãŸ JDK ã®ãƒã‚°ã®å ±å‘Šã‚’ Sun ãŒå—ã‘å–ã£ãŸã“ã¨ã«ã‚ˆã‚‹ã‚‚ã®ã§ã™ã€‚ + + + + + + +db.xml ファイルã¯ã€ jdk1.6.0 ã®ã™ã¹ã¦ã®ãƒ“ルドã«å¯¾ã™ã‚‹æ¤œç´¢çµæžœã‚’ä¿æŒã—ã¦ã„ã¾ã™ã€‚ã—ãŸãŒã£ã¦ã€æ¬¡ã«ç¤ºã™ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ã§ã€å„ªå…ˆåº¦(高)ã¾ãŸã¯å„ªå…ˆåº¦(低)ã®æ­£ç¢ºæ€§ã«é–¢ã™ã‚‹è­¦å‘Šã®å±¥æ­´ãŒè¡¨ç¤ºã•ã‚Œã¾ã™ : + + +filterBugs -priority M -category C db.xml | mineBugHistory -formatDates + + +作æˆã•ã‚Œã‚‹è¡¨ã®ä¾‹ : + + +seq version time classes NCSS added newCode fixed removed retained dead active +0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 1075 0 0 0 0 1075 +1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 1075 0 1075 +2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 3 0 6 0 1069 0 1072 +3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 2 1 3 0 1069 6 1072 +4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 1 0 1071 9 1071 +5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 1 0 1070 10 1070 +6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1070 11 1070 +7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 1 0 1069 11 1069 +8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1069 12 1069 +9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 2 1 1066 12 1066 +10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 1 0 1 1 1064 15 1065 +11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1065 17 1065 +12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 3 0 8 26 1031 17 1034 +13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1034 51 1034 +14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1034 51 1034 +15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 1 1 0 1 1033 51 1035 +16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 3 0 2 1 1032 52 1035 +17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1035 55 1036 +18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 36 2 0 1034 55 1070 +19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 1070 57 1070 +20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 1 1 0 1069 57 1070 +21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 1 7 2 6 1062 58 1070 +22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 6 39 5 0 1065 66 1110 +23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 7 147 11 0 1099 71 1253 +24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 1253 82 1253 +25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 3 0 1 2 1250 82 1253 +26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 5 11 15 8 1230 85 1246 +27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 1246 108 1246 +28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 19 0 2 0 1244 108 1263 +29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 13 1 1 32 1230 110 1244 +30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 163 8 7 20 1217 143 1388 +31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 1388 170 1388 +32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 1 11 1 0 1387 170 1399 +33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 19 27 16 7 1376 171 1422 +34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 1 15 3 0 1419 194 1435 +35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 1 1 1433 197 1433 +36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 13 12 16 20 1397 199 1422 +37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 1422 235 1422 +38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 1 4 7 0 1415 235 1420 +39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 6 8 37 0 1383 242 1397 +40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 1397 279 1397 +41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 1 1 0 1396 279 1397 +42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 6 0 5 0 1392 280 1398 +43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 1398 285 1398 +44 jdk1.6.0-b61 "Thu Nov 17 01:58:42 EST 2005" 16202 971134 2 0 4 0 1394 285 1396 + + + + + 増分履歴メンテナンス + +ä»®ã«ã€ db.xml ãŒãƒ“ルド b12 - b60 ã«å¯¾ã™ã‚‹ findbugs 実行çµæžœã‚’ä¿æŒã—ã¦ã„ã‚‹å ´åˆã€æ¬¡ã«ç¤ºã™ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ã§ã€ db.xml ã« b61 ã«å¯¾ã™ã‚‹å®Ÿè¡Œçµæžœã‚’追加ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ : + +computeBugHistory -output db.xml db.xml jdk1.6.0-b61/jre/lib/rt.xml + + + + + + + Ant ã®ä¾‹ +findbugs ã®å®Ÿè¡Œã¨ãã®å¾Œã®ãƒ‡ãƒ¼ã‚¿ãƒ»ãƒžã‚¤ãƒ‹ãƒ³ã‚°ãƒ„ールã®æ´»ç”¨ã®ä¸¡æ–¹ã‚’実行ã—ã¦ã„ã‚‹ ant スクリプトã®å®Œå…¨ãªä¾‹ã‚’以下ã«ç¤ºã—ã¾ã™ : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + +
    + + + + + +ライセンス + +å称「FindBugsã€ãŠã‚ˆã³ FindBugs ã®ãƒ­ã‚´ã¯ã€ãƒ¡ãƒªãƒ¼ãƒ©ãƒ³ãƒ‰å¤§å­¦ã®ç™»éŒ²å•†æ¨™ã§ã™ã€‚FindBugs ã¯ãƒ•ãƒªãƒ¼ã‚½ãƒ•ãƒˆã‚¦ã‚§ã‚¢ã§ã‚り〠Lesser GNU Public License ã®æ¡ä»¶ã§é…布ã•ã‚Œã¦ã„ã¾ã™ã€‚使用承諾書を入手ã—ãŸã„å ´åˆã¯ã€ &FindBugs; é…布物ã«å«ã¾ã‚Œã‚‹ LICENSE.txt ファイルをå‚ç…§ã—ã¦ãã ã•ã„。 + +最新ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã® FindBugs ãŠã‚ˆã³ ãã®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã¯ FindBugs web ページ ã§å…¥æ‰‹ã§ãã¾ã™ã€‚ + + + + + + +è¬è¾ž + + +貢献者 + +&FindBugs; was originally written by Bill Pugh (pugh@cs.umd.edu). +David Hovemeyer (daveho@cs.umd.edu) implemented some of the +detectors, added the Swing GUI, and is a co-maintainer. + +Mike Fagan (mfagan@tde.com) contributed the &Ant; build script, +the &Ant; task, and several enhancements and bug fixes to the GUI. + +Germano Leichsenring contributed Japanese translations of the bug +summaries. + +David Li contributed the Emacs bug report format. + +Peter D. Stout contributed recursive detection of Class-Path +attributes in analyzed Jar files, German translations of +text used in the Swing GUI, and other fixes. + +Peter Friese wrote the &FindBugs; Eclipse plugin. + +Rohan Lloyd contributed several Mac OS X enhancements, +bug detector improvements, +and maintains the Fink package for &FindBugs;. + +Hiroshi Okugawa translated the &FindBugs; manual and +more of the bug summaries into Japanese. + +Phil Crosby enhanced the Eclipse plugin to add a view +to display the bug details. + +Dave Brosius fixed a number of bugs, added user preferences +to the Swing GUI, improved several bug detectors, and +contributed the string concatenation detector. + +Thomas Klaeger contributed a number of bug fixes and +bug detector improvements. + +Andrei Loskutov made a number of improvements to the +Eclipse plugin. + +Brian Goetz contributed a major refactoring of the +visitor classes to improve readability and understandability. + + Pete Angstadt fixed several problems in the Swing GUI. + +Francis Lalonde provided a task resource file for the +FindBugs Ant task. + +Garvin LeClaire contributed support for output in +Xdocs format, for use by Maven. + +Holger Stenzhorn contributed improved German translations of items +in the Swing GUI. + +Juha Knuutila contributed Finnish translations of items +in the Swing GUI. + +Tanel Lebedev contributed Estonian translations of items +in the Swing GUI. + +Hanai Shisei (ruimo) contributed full Japanese translations of +bug messages, and text used in the Swing GUI. + +David Cotton contributed Fresh translations for bug +messages and for the Swing GUI. + +Michael Tamm contributed support for the "errorProperty" attribute +in the Ant task. + +Thomas Kuehne improved the German translation of the Swing GUI. + +Len Trigg improved source file support for the Emacs output mode. + +Greg Bentz provided a fix for the hashcode/equals detector. + +K. Hashimoto contributed internationalization fixes and several other + bug fixes. + + + Glenn Boysko contributed support for ignoring specified local + variables in the dead local store detector. + + + + Jay Dunning contributed a detector to find equality comparisons + of floating-point values, and overhauled the analysis summary + report and its representation in the saved XML format. + + + + Olivier Parent contributed updated French translations for bug descriptions and + Swing GUI. + + + + Chris Nappin contributed the plain.xsl + stylesheet. + + + + Etienne Giraudy contributed the fancy.xsl and fancy-hist.xsl + stylesheets, and made improvements to the -xml:withMessages + option. + + + + Takashi Okamoto fixed bugs in the project preferences dialog + in the Eclipse plugin, and contributed to its internationalization and localization. + + +Thomas Einwaller fixed bugs in the project preferences dialog in the Eclipse plugin. + +Jeff Knox contributed support for the warningsProperty attribute +in the Ant task. + +Peter Hendriks extended the Eclipse plugin preferences, +and fixed a bug related to renaming the Eclipse plugin ID. + +Mark McKay contributed an Ant task to launch the findbugs frame. + +Dieter von Holten (dvholten) contributed +some German improvements to findbugs_de.properties. + + +If you have contributed to &FindBugs;, but aren't mentioned above, +please send email to findbugs@cs.umd.edu (and also accept +our humble apologies). + + + + +使用ã—ã¦ã„るソフトウェア + +&FindBugs; ã¯ã€ã„ãã¤ã‹ã®ã‚ªãƒ¼ãƒ—ンソースソフトウェアパッケージを使用ã—ã¦ã„ã¾ã™ã€‚ã“れらãŒãªã‘ã‚Œã°ã€ &FindBugs; ã®é–‹ç™ºã¯ã€ã‚ˆã‚Šä¸€å±¤å›°é›£ãªã‚‚ã®ã«ãªã£ãŸã“ã¨ã§ã—ょã†ã€‚ + + +BCEL +&FindBugs; includes software developed by the Apache Software Foundation +(http://www.apache.org/). +Specifically, it uses the Byte Code +Engineering Library. + + + +ASM +&FindBugs; uses the ASM +bytecode framework, which is distributed under the following license: + +
    + +Copyright (c) 2000-2005 INRIA, France Telecom +All rights reserved. + + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + + + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + +
    +
    + + +DOM4J +&FindBugs; uses DOM4J, which is +distributed under the following license: + +
    + +Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. + + + +Redistribution and use of this software and associated documentation +("Software"), with or without modification, are permitted provided that +the following conditions are met: + + + + + Redistributions of source code must retain copyright statements and + notices. Redistributions must also contain a copy of this document. + + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + The name "DOM4J" must not be used to endorse or promote products + derived from this Software without prior written permission + of MetaStuff, Ltd. For written permission, please contact + dom4j-info@metastuff.com. + + + Products derived from this Software may not be called "DOM4J" nor may + "DOM4J" appear in their names without prior written permission of + MetaStuff, Ltd. DOM4J is a registered trademark of MetaStuff, Ltd. + + + Due credit should be given to the DOM4J Project (http://dom4j.org/). + + + + +THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +
    + +
    + +
    + +
    + + +
    diff --git a/doc/performance.html b/doc/performance.html new file mode 100644 index 0000000..12718f0 --- /dev/null +++ b/doc/performance.html @@ -0,0 +1,114 @@ + + +FindBugs Performance Improvements and Regressions + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    FindBugs Performance Improvements and Regressions

    I did a performance check against 179 + benchmarks applications I regularly test against. Overall (total the total time to analyze all 179 + benchmarks), FindBugs 2.0 gives a 9% performance improvement over 1.3.9. 154 of the 179 benchmarks saw + performance improvements; 24 saw regressions. All of the benchmarks that saw regressions of more than + 10% were small benchmarks (analyzed in less than 60 seconds), which makes consistent benchmarking + particularly difficult. I'm working to repeat the benchmarks, see if the results are consistent. I took + a look, and couldn't find anything that stood out as being a performance glitch in FindBugs. I haven't + yet done benchmarking with constrained memory. It is possible that you may need to increase the heap + size for FindBugs 2.0. + +

    Important Request

    +

    If you are seeing any significant performance regressions in FindBugs 2.0, + I very much need your help. Please either email findbugs@cs.umd.edu + or file a + bug report. with the following information from the xml file for your project (from both the + 1.3.9 and 2.0.0 version if possible). Sending me your code or pointing me to a open source repository + would be great, but I know that isn't feasible for a lot of projects. The information I'm requesting + doesn't include any information about the code being analyzed other than the total size of the code + being analyzed and the total number of issues found at the different confidence levels. The + <FindBugsSummary ... > start tag. For example:

    +   <FindBugsSummary timestamp="Tue, 30 Dec 2008 21:29:52 -0500" 
    +      total_classes="206" referenced_classes="325" total_bugs="72" total_size="7654" num_packages="21" 
    +      vm_version="20.4-b02-402" cpu_seconds="62.52" clock_seconds="22.01" 
    +      peak_mbytes="112.21" alloc_mbytes="1683.38" gc_seconds="1.19" 
    +      priority_3="56" priority_2="14" priority_1="2">
    +
    The <FindBugsProfile>...</FindBugsProfile> element. For example: +
    +   <FindBugsProfile>
    +      <ClassProfile name="edu.umd.cs.findbugs.detect.IncompatMask" totalMilliseconds="11" 
    +        invocations="206" avgMicrosecondsPerInvocation="55" maxMicrosecondsPerInvocation="475" 
    +        standardDeviationMircosecondsPerInvocation="75"/>
    +      <ClassProfile name="edu.umd.cs.findbugs.detect.FindFinalizeInvocations" totalMilliseconds="11" 
    +        invocations="206" avgMicrosecondsPerInvocation="55" maxMicrosecondsPerInvocation="402" 
    +        standardDeviationMircosecondsPerInvocation="69"/>
    +      <ClassProfile name="edu.umd.cs.findbugs.classfile.engine.bcel.LockDataflowFactory" totalMilliseconds="11" 
    +        invocations="23" avgMicrosecondsPerInvocation="515" maxMicrosecondsPerInvocation="2637" 
    +        standardDeviationMircosecondsPerInvocation="639"/>
    +   ...
    + </FindBugsProfile>
    +
    +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/performingARelease.txt b/doc/performingARelease.txt new file mode 100644 index 0000000..3ce350e --- /dev/null +++ b/doc/performingARelease.txt @@ -0,0 +1,27 @@ +Create a directory that contains exactly all the files to upload. For example: + eclipsePlugin-1.3.6.20081104-source.zip findbugs-1.3.6-rc3-source.zip findbugs-1.3.6-rc3.zip + edu.umd.cs.findbugs.plugin.eclipse_1.3.6.20081104.zip findbugs-1.3.6-rc3.tar.gz + +cd to that directory +sftp username,findbugs@frs.sourceforge.net +sftp> cd /home/frs/project/f/fi/findbugs/findbugs/RELEASE +sftp> mput findbugs-* +sftp> cd "../../findbugs eclipse plugin/RELEASE +fstp> mput edu.* eclipsePlugin* +fstp> quit + +Add releases via: + https://sourceforge.net/project/admin/editpackages.php?group_id=96405 + + +release daily/candidate/final eclipse plugins + +From findbugs directory, do: + rsync -avz web/ username,findbugs@web.sourceforge.net:htdocs/ + +For a full release, make a branch in the svn repository: + + +svn copy "https://findbugs.googlecode.com/svn/trunk" "https://findbugs.googlecode.com/svn/branches/1.X.X" + +For a release candidate, send email to findbugs-discuss and findbugs-core. For a full release, send email to findbugs-announce. diff --git a/doc/pluginStructure.txt b/doc/pluginStructure.txt new file mode 100644 index 0000000..f61e983 --- /dev/null +++ b/doc/pluginStructure.txt @@ -0,0 +1,28 @@ + +We have a list of plugins. + +In any particular context, some plugins are enabled. + +DetectorFactoryCollection: + Core plugin + Collection of plugins + Collection of DetectorFactories + Adjustment ranker + +I18N + ResourceBundles + bugPatternMap + bugCodeMap + categoryDescriptionMap + +Plugin + collection of DetectorFactory + bug patterns, codes, etc. + component plugins + bug ranker + enabled + plugin loader + +CloudFactory + registeredClouds + diff --git a/doc/plugins.txt b/doc/plugins.txt new file mode 100644 index 0000000..a307b14 --- /dev/null +++ b/doc/plugins.txt @@ -0,0 +1,9 @@ + +Plugins can be specified in three different ways: +* For a standard FindBugd distro, they can be put into the plugins directory +* For a JAWS distro, the file pluginlist.properties contains + a list of URLs to plugins. These URLs can be relative or absolute. If they + are absolute, they are relative to jar file that contained the pluginlist.properties + file. +* You can define properties findbugs.plugin.*. Each such property defines a URL + for a plugin diff --git a/doc/pressRelease.pdf b/doc/pressRelease.pdf new file mode 100644 index 0000000..47ee37a Binary files /dev/null and b/doc/pressRelease.pdf differ diff --git a/doc/publications.html b/doc/publications.html new file mode 100644 index 0000000..2a06a19 --- /dev/null +++ b/doc/publications.html @@ -0,0 +1,138 @@ + + +FindBugs Documents and Publications + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    FindBugs Documents and Publications

    + +

    This page lists documents, publications, and other sources +of information about FindBugs. + +

    General Information

    + + + +

    Publications

    + +
      +
    • Finding Bugs is Easy, a +paper that appeared in the December 2004 issue of SIGPLAN Notices.  +An extended abstract of the paper appeared in the OOPSLA 2004 Companion, +as part of the Onward! track of the conference.  + + +
    • A Comparison of Bug Finding Tools for Java, by Nick Rutar, Christian Almazan, and Jeff Foster, +compares several bug checkers for Java, including FindBugs. +
    • Chris Grindstaff has written a two-part article about FindBugs +(Part 1, +Part 2) +for IBM developerWorks. +
    + + + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/reportingBugs.html b/doc/reportingBugs.html new file mode 100644 index 0000000..c2bd70b --- /dev/null +++ b/doc/reportingBugs.html @@ -0,0 +1,127 @@ + + +Reporting Bugs in FindBugs + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    Reporting Bugs in FindBugs

    + +

    +First of all, if you find a bug in FindBugs, and have the +skills to fix it, we encourage you to unleash the power of open source and +send us a patch.  We will gladly +credit you on our website and in the manual. +

    + +

    +Please report bugs using the +Sourceforge +bugs tracker.  Note that you need to be logged in to sourceforge to +use the bug tracker. +

    + +

    +If you cannot use the Sourceforge tracker, you can try sending +email to the findbugs-discuss mailing list.  You must be subscribed +to the list to post a message. +

    + +

    +Finally, as a last resort, you can email findbugs@cs.umd.edu.  +However, such emails are much less likely to be handled in a timely manner than +posts to the tracker or mailing list. +

    + +

    False and Inaccurate Warnings

    + +

    + Like most bug-detection tools based on static analysis, FindBugs + issues some warnings that do not correspond to real bugs.  + While in general we would like to make the percentage of such warnings + small, we can never fully eliminate them. +

    + +

    Information to include

    + +

    +When reporting a bug, please include the following information: +

    +
      +
    • Complete list of steps to reproduce the problem
    • +
    • If the error occurs during analysis, a jar file, class file, + or self-contained Java class that demonstrates the problem
    • +
    • FindBugs version
    • +
    • JDK/JRE version
    • +
    • Host operating system
    • +
    • Any exception traces, Eclipse error log entries, etc. that might + be relevant
    • +
    + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/sourceInfo.html b/doc/sourceInfo.html new file mode 100644 index 0000000..3b847d0 --- /dev/null +++ b/doc/sourceInfo.html @@ -0,0 +1,115 @@ + + +FindBugs sourceInfo file + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    FindBugs sourceInfo file

    + +

    The FindBugs analysis engine can be invoked with an optional sourceInfo +file. This file gives line number ranges for classes, files and methods. This +information is an alternative to getting line number information +from the classfiles for methods. Since classfiles only contain line number +information +for methods, without a sourceInfo file we can't provide line numbers for fields, +and for classes we just use the line numbers of the methods in the class. + +

    The first line of the file should be +

    +sourceInfo version 1.0
    +
    + +

    Following that are a series of lines, each describing a class, field, or method. For each, a starting and ending line number is provided. For example, the following sourceInfo file: +

    +sourceInfo version 1.0
    +a.C,3,8
    +a.C,x,4,4
    +a.C,y,4,4
    +a.C,()V,8,8
    +a.C,f(I)I,5,5
    +a.C,g(Ljava/lang/Object;)I,6,7
    +
    +provides the following information about the class a.C: +
      +
    • fields x and y are both declared on line 4. +
    • the method int f(int) is defined on line 5. +
    • the method int g(Object) is defined on lines 6-7. +
    • the void constructor for a.C is defined on line 8. +
    +The classnames should be the same format as used by Class.getName(): +packages are separated by ., inner class names are separated by $. +Thus, if the class a.C had an inner class X and it was onb lines 10-15 of the file, the sourceInfo file might contain: + +
    +a.C$X,10,15
    +
    + + +
    + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + + + + + + + diff --git a/doc/sysprops.html b/doc/sysprops.html new file mode 100644 index 0000000..ad55622 --- /dev/null +++ b/doc/sysprops.html @@ -0,0 +1,202 @@ + + +FindBugs Optional System Properties + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    FindBugs Optional System Properties

    + +

    These system properties can be added to the command line to alter the way +findbugs works. These options should be considered experimental. The description +gives information if the field is set to true. +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    System PropertyDescription
    findbugs.assertionmethodsmethods supplied by user that have assertions
    findbugs.checkreturn.loadtraining +
    findbugs.checkreturn.savetraining
    file name to read/write list of methods whose return values must be checked
    findbugs.de.commentDon't report empty catch blocks if a source comment is found in the block.
    findbugs.dls.exclusionslocal variables that will be excluded from Dead Local Store
    findbugs.fis.unsyncFactorDefault value is 2.0, which means that we report a bug if more than 1/3 of accesses are unsynchronized.
    findbugs.fis.writeBiasDefault value is 2.0. The idea is that this should be above 1.0, because unsynchronized writes are more dangerous than unsynchronized reads.
    fundbugs.gui.bugCount?
    findbugs.maskedfields.localsReport on local variables that mask fields.
    findbugs.nullderef.assumenspsets value for IsNullValueAnalysisFeatures.UNKNOWN_VALUES_ARE_NSP, but is not used by FindBugs
    findbugs.refcomp.reportAll?
    findbugs.report.SummaryHTMLemit SummaryHTML element
    findbugs.sf.commentIgnore switch fall thru bugs if a comment is found with 'fall' or 'nobreak' +
    ba.checkAssertionsthrow excptions on certain illegal class type signatures
    ba.verifyIntegrityenable data structure integrity checks
    BCPMethodReturnCheck.javaAdd methods to the list requiring a check. (format: "class:method:sig|...")
    dataflow.stackonly?
    fis.eval?
    fis.noAdjustSubclassAdjust field so its class name is the same as the type of reference it is accessed through.
    fos.allowWUSIgnore wrapping streams that are wrapping uninteresting streams (like in memory streams).
    ic.createInstance?
    inva.ncpExtraBranch?
    inva.noAssertHack?
    inva.noSplitDowngradeNSP?
    inva.noSwitchDefaultAsExceptionDon't consider switch default cases as exception paths.
    lineNumberBugDisable the workaround for the bug in BCEL 5.0's LineNumberTable class.
    ma.uglyReport method signature with method class and name.
    mrc.checkallCheck for 1.5-specific method return values being ignored even if runtime Java predates 1.5.
    ta.accurateExceptions?
    vna.noRLEPerform redundant load elimination and forward substitution (but not in a correctness-preserving way).
    + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/team.html b/doc/team.html new file mode 100644 index 0000000..a97f46c --- /dev/null +++ b/doc/team.html @@ -0,0 +1,98 @@ + + +FindBugs Development Team + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    FindBugs Development Team

    + +

    These are the current active members of the FindBugs development team: + +

    + +

    Previous and/or inactive members of the FindBugs development team include +

      +
    • David Hovemeyer (project founder), + did Ph.D. thesis on FindBugs +
    • Nay Ayewah +
    • Ben Langmead +
    • Tomas Pollak (Eclipse plugin tests) +
    • Phil Crosby +
    • Peter Friese (Eclipse plugin) +
    • Dave Brosius +
    • Brian Goetz +
    • Rohan Lloyd +
    + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/doc/umdFindbugs.png b/doc/umdFindbugs.png new file mode 100644 index 0000000..c426bc6 Binary files /dev/null and b/doc/umdFindbugs.png differ diff --git a/doc/updateChecking.html b/doc/updateChecking.html new file mode 100644 index 0000000..85384c3 --- /dev/null +++ b/doc/updateChecking.html @@ -0,0 +1,123 @@ + + +Update checking in FindBugs + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + +

    Update checking in FindBugs

    + +

    When FindBugs is run, it now checks for updated versions of FindBugs or plugins. As a side effect + of this, our server sees a request for whether there are any updated version of FindBugs available. + Third party plugins can independently receive this same information. We are recording + information about the operating system, Java version, locale, and Findbugs entry point (ant, command line, + GUI, etc), in order to better understand our users. + +

    For example, here is an example of the information that would be sent to the server: +

    +<?xml version="1.0" encoding="UTF-8"?>
    +
    +<findbugs-invocation version="2.0.0-rc1" app-name="UpdateChecker" app-version="" entry-point="UpdateChecker" os="Mac OS X" 
    +     java-version="1.6" language="en" country="US" uuid="-4bcf8f48ba2842d2">
    +  <plugin id="edu.umd.cs.findbugs.plugins.core" name="Core FindBugs plugin" version="2.0.0-rc1"/>
    +  <plugin id="edu.umd.cs.findbugs.plugins.appengine" name="FindBugs Cloud Plugin" version=""/>
    +  <plugin id="edu.umd.cs.findbugs.plugins.poweruser" name="Power user commnand line tools" version=""/>
    +</findbugs-invocation>
    +
    + +

    You can run the main method of edu.umd.cs.findbugs.updates.UpdateChecker to see what would be reported +for you, and whether update checking is disabled and/or redirected (e.g., run +

     java -classpath ~/findbugs/lib/findbugs.jar  edu.umd.cs.findbugs.updates.UpdateChecker
    + +

    There is one element of the information sent that needs explanation: the uuid. Since we don't report anything like username, +when we receive a bunch of update checks from a particular ip address, we don't know if that is one person running FindBugs many times +on a single machine, or many users running FindBugs on many different machines So we generate a random 64 bit integer, +store it in the Java user preferences, and report that on each use. + +

    Disabling or redirecting update checks

    +

    Some organizations or individuals may have policies or preferences to not let us know any information about +their running of FindBugs. Note that we do not collect any information about the code being analuzed. +Even so, we understand that is very important for a few of our users, + and provide several ways for you to disable or redirect FindBugs update checks. +

      +
    • There is a FindBugs plugin, noUpdateChecks.jar, which is in findbugs/optionalPlugin in the standard distribution. +If this plugin enabled, all update checks are disabled. You can move that plugin from findbugs/optionalPlugin to findbugs/plugin, +to disable it for all users of that distribution. You can also copy it to
      ~/.findbugs/plugin
      , +which will disable it for your account for any distribution of FindBugs you invoke (NOTE: double check location +of personal FindBugs plugin installation for Windows User). +
    • There are noUpdateChecks distributions of FindBugs available from SourceForge. This come with the noUpdateChecks plugin +already moved to findbugs/plugin, and the webCloudClient.jar plug in the optional plugin directory (where it is disabled by default). + +
    • You can also redirect all update checks to a local server. This allows you to collect information about who is using +what versions of FindBugs in your organization, and keep all of that information private. +
    • All of the plugins from the FindBugs project use
      http://update.findbugs.org/update-check
      as the +host we use for update checks. If you wish to ensure that no one from your organization accidently reports any usage +information to the FindBugs project, you can blacklist that URL in your firewall +
        +
      • You can also block
        http://findbugs-cloud.appspot.com
        , the host we use for our publicly hosted +repository of bug evaluations (e.g., evaluations in open source projects such as the JDK, Eclipse and GlassFish). +While people have to explicitly request that their evaluations be stored into the FindBugs cloud, you +can block it to ensure that no one accidently shares evaluations of your own code to the FindBugs cloud. You can also +remove the WebCloudClient + +
      +
    • +
    + + +
    + + + diff --git a/doc/users.html b/doc/users.html new file mode 100644 index 0000000..37efe15 --- /dev/null +++ b/doc/users.html @@ -0,0 +1,199 @@ + + + FindBugs™ Users and Supporters + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FindBugs
     
    Docs and Info
    FindBugs 2.0
    Demo and data
    Users and supporters
    FindBugs blog
    Fact sheet
    Manual
    Manual(ja/日本語)
    FAQ
    Bug descriptions
    Mailing lists
    Documents and Publications
    Links
     
    Downloads
     
    FindBugs Swag
     
    Development
    Open bugs
    Reporting bugs
    Contributing
    Dev team
    API [no frames]
    Change log
    SF project page
    Browse source
    Latest code changes
    +
    + + + +

    + FindBugs Users +

    + +

    + There are a + lot of FindBugs users; as of September 2006, we've had + more than 270,000 downloads. + +

    +

    + FindBugs is used in many companies and organizations. We don't + have a list of all the users of FindBugs, and we don't have + permission to identify many of the companies where we know + FindBugs is being used (getting this permission often involves red + tape and lawyers). But here are some statics from Google Analytics + showing unique visitors to the FindBugs web pages for the months + of June through August, 2006. + +

    +

    + Downloads by country +

    +

    + Cities with the most downloads + +

    +

    + FindBugs Users +

    +

    + The following companies, projects and organizations have given us + permission to identify them as FindBugs users and/or have + publically stated that they use FindBugs. Send email to + findbugs@cs.umd.edu if + you'd like to be listed here. +

    + + + + + + + + + + + + + + +
    + ITA Software + + + Glassfish + +
    + Java Server + Faces + + ObjectLab + +
    + SAT 4j + + + SleepyCat + +
    +

    + FindBugs Supporters +

    +

    + The following companies, organizations and institutions provide + financial support for FindBugs. Tax deductable donations to + support FindBugs can be made to the University of Maryland. + +

    + + + + + + + + + + + + + +
    + Google + +
    + Sun Microsystems + + + National Science Foundation + +
    + Univ. of Maryland + +
    + + + +

    + +

    Send comments to findbugs@cs.umd.edu +

    +SourceForge.net Logo + +

    + + + diff --git a/etc/MANIFEST-findbugs-annotations.MF b/etc/MANIFEST-findbugs-annotations.MF index 6ff7a50..4213b2b 100644 --- a/etc/MANIFEST-findbugs-annotations.MF +++ b/etc/MANIFEST-findbugs-annotations.MF @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: FindbugsAnnotations Bundle-SymbolicName: findbugsAnnotations -Bundle-Version: 2.0.2 +Bundle-Version: 2.0.3 Export-Package: edu.umd.cs.findbugs.annotations, javax.annotation, javax.annotation.concurrent, diff --git a/etc/MANIFEST-findbugs-internal-annotations.MF b/etc/MANIFEST-findbugs-internal-annotations.MF new file mode 100644 index 0000000..5f9b9a3 --- /dev/null +++ b/etc/MANIFEST-findbugs-internal-annotations.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: FindbugsInternalAnnotations +Bundle-SymbolicName: findbugsInternalAnnotations +Bundle-Version: 2.0.3 +Export-Package: edu.umd.cs.findbugs.annotations +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/etc/MANIFEST-findbugs.MF b/etc/MANIFEST-findbugs.MF index 9f7dc04..9ac9bfc 100644 --- a/etc/MANIFEST-findbugs.MF +++ b/etc/MANIFEST-findbugs.MF @@ -1,3 +1,3 @@ Manifest-Version: 1.0 Main-Class: edu.umd.cs.findbugs.LaunchAppropriateUI -Class-Path: bcel.jar dom4j-1.6.1.jar jaxen-1.1.1.jar asm-3.3.jar asm-tree-3.3.jar asm-commons-3.3.jar jsr305.jar jFormatString.jar commons-lang-2.4.jar +Class-Path: bcel.jar dom4j-1.6.1.jar jaxen-1.1.6.jar asm-3.3.jar asm-tree-3.3.jar asm-commons-3.3.jar jsr305.jar jFormatString.jar commons-lang-2.6.jar diff --git a/etc/MANIFEST-findbugsGUI.MF b/etc/MANIFEST-findbugsGUI.MF index 789e454..0837342 100644 --- a/etc/MANIFEST-findbugsGUI.MF +++ b/etc/MANIFEST-findbugsGUI.MF @@ -1,3 +1,3 @@ Manifest-Version: 1.0 Main-Class: edu.umd.cs.findbugs.LaunchAppropriateUI -Class-Path: findbugs.jar bcel.jar dom4j-1.6.1.jar jaxen-1.1.1.jar plastic.jar +Class-Path: bcel.jar dom4j-1.6.1.jar jaxen-1.1.6.jar asm-3.3.jar asm-tree-3.3.jar asm-commons-3.3.jar jsr305.jar jFormatString.jar commons-lang-2.6.jar plastic.jar diff --git a/etc/bugcollection.xsd b/etc/bugcollection.xsd index e4df048..d46c452 100644 --- a/etc/bugcollection.xsd +++ b/etc/bugcollection.xsd @@ -242,6 +242,7 @@ use="optional"/> + diff --git a/etc/bugrank.txt b/etc/bugrank.txt index 2522a31..e3a1ccb 100644 --- a/etc/bugrank.txt +++ b/etc/bugrank.txt @@ -104,10 +104,12 @@ -3 BugPattern NP_IMMEDIATE_DEREFERENCE_OF_READLINE +5 BugPattern TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK +5 BugPattern TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK ++3 BugPattern IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD -6 BugPattern TESTING -2 BugPattern PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS -2 BugPattern DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS +3 BugPattern RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE +-4 BugKind FB -4 BugKind EC +1 BugKind RCN +1 BugKind NP diff --git a/etc/diffBugSummaries b/etc/diffBugSummaries old file mode 100755 new file mode 100644 index 798fe15..798fe15 100644 diff --git a/etc/findbugs.xml b/etc/findbugs.xml index 26a6096..185dcd5 100644 --- a/etc/findbugs.xml +++ b/etc/findbugs.xml @@ -1,10 +1,10 @@ - + - - - - - - - - + @@ -247,10 +238,6 @@ - - - - @@ -304,11 +291,11 @@ diff --git a/etc/messages.xml b/etc/messages.xml index b0cb6c5..9090701 100644 --- a/etc/messages.xml +++ b/etc/messages.xml @@ -54,6 +54,10 @@ Disassemble a class file + + + List analysis errors stored in results file + @@ -219,7 +223,7 @@

    Looks for violations of the rules for classes annotated as net.jcip.annotations.Immutable.

    +

    Looks for violations of the rules for classes annotated as net.jcip.annotations.Immutable or javax.annotation.concurrent.Immutable.

    ]]>
    @@ -1554,6 +1558,14 @@ ]]>
    + +
    + Checks that overriding methods do not relax @Nonnull (made @CheckForNull) on return values + or @CheckForNull (made @Nonnull) on parameters.

    + ]]> +
    +
    Method invoked that should be only be invoked inside a doPrivileged block - invocation of {2}, which should be invoked from within a doPrivileged block, in {1} + Invocation of {2}, which should be invoked from within a doPrivileged block, in {1}
    This code invokes a method that requires a security permission check. @@ -2196,8 +2208,8 @@ {1.givenClass} should be final since {0} is marked as Immutable.
    The class is annotated with net.jcip.annotations.Immutable, and the rules for that annotation require -that all fields are final. +

    The class is annotated with net.jcip.annotations.Immutable or javax.annotation.concurrent.Immutable, + and the rules for those annotations require that all fields are final. .

    ]]>
    @@ -2229,7 +2241,7 @@ The equals and hashCode methods of URL are blocking - invocation of {2}, which blocks to do domain name resolution, in {1} + Invocation of {2}, which blocks to do domain name resolution, in {1}
    The equals and hashCode @@ -2242,7 +2254,7 @@ Can't use reflection to check for presence of annotation without runtime retention - use of reflection to check for the presence the annotation {3} which doesn't have runtime retention, in {1} + Use of reflection to check for the presence the annotation {3} which doesn't have runtime retention, in {1}
    Unless an annotation has itself been annotated with @Retention(RetentionPolicy.RUNTIME), the annotation can't be observed using reflection @@ -2460,6 +2472,16 @@ ]]>
    + + Boxing/unboxing to parse a primitive + Boxing/unboxing to parse a primitive {1} +
    +A boxed primitive is created from a String, just to extract the unboxed primitive value. + It is more efficient to just call the static parseXXX method.

    +]]> +
    +
    Method allocates an object, only to get the class object {1} allocates an object, only to get the class object @@ -2636,7 +2658,7 @@ Explicit invocation of finalizer - explicit invocation of {2} in {1} + Explicit invocation of {2} in {1}
    This method contains an explicit invocation of the finalize() @@ -2676,7 +2698,7 @@ Covariant equals() method defined for enum - enum {0} defines equals({0.givenClass}) + Enum {0} defines equals({0.givenClass})
    This class defines an enumeration, and equality on enumerations are defined @@ -3107,8 +3129,8 @@ {1.givenClass} not guarded against concurrent access; locked {2}% of time
    This field is annotated with net.jcip.annotations.GuardedBy, -but can be accessed in a way that seems to violate the annotation.

    +

    This field is annotated with net.jcip.annotations.GuardedBy or javax.annotation.concurrent.GuardedBy, +but can be accessed in a way that seems to violate those annotations.

    ]]>
    @@ -3137,6 +3159,7 @@

    • The class contains a mix of locked and unlocked accesses,
    • +
    • The class is not annotated as javax.annotation.concurrent.NotThreadSafe,
    • At least one locked access was performed by one of the class's own methods, and
    • The number of unsynchronized field accesses (reads and writes) was no more than one third of all accesses, with writes being weighed twice as high as reads
    • @@ -3178,7 +3201,7 @@ Public static method may expose internal representation by returning array - public static {1} may expose internal representation by returning {2.givenClass} + Public static {1} may expose internal representation by returning {2.givenClass}
      A public static method returns a reference to @@ -3739,16 +3762,26 @@
      - Ambiguous invocation of either an inherited or outer method - Ambiguous invocation of either an outer or inherited method {2} in {1} -
      - An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class. By the Java semantics, + Potentially ambiguous invocation of either an inherited or outer method + Potentially ambiguous invocation of either an outer or inherited method {2} in {1} +
      + +An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class. +For example, you invoke foo(17), which is defined in both a superclass and in an outer method. +By the Java semantics, it will be resolved to invoke the inherited method, but this may not be want -you intend. If you really intend to invoke the inherited method, +you intend. +

      +

      If you really intend to invoke the inherited method, invoke it by invoking the method on super (e.g., invoke super.foo(17)), and thus it will be clear to other readers of your code and to FindBugs that you want to invoke the inherited method, not the method in the outer class. +

      +

      If you call this.foo(17), then the inherited method will be invoked. However, since FindBugs only looks at +classfiles, it +can't tell the difference between an invocation of this.foo(17) and foo(17), it will still +complain about a potential ambiguous invocation.

      ]]>
      @@ -4014,8 +4047,8 @@
      - private readResolve method not inherited by subclasses - private readResolve method in {0} not inherited by subclasses. + Private readResolve method not inherited by subclasses + Private readResolve method in {0} not inherited by subclasses.
      This class defines a private readResolve method. Since it is private, it won't be inherited by subclasses. @@ -4610,7 +4643,7 @@ Method ignores return value, is this OK? - return value of {2.givenClass} ignored, is this OK in {1} + Return value of {2.givenClass} ignored, is this OK in {1}
      This code calls a method and ignores the return value. The return value @@ -4631,7 +4664,7 @@ Method ignores return value - return value of {2.givenClass} ignored in {1} + Return value of {2.givenClass} ignored in {1}
      The return value of this method should be checked. One common @@ -4661,7 +4694,7 @@ Method ignores exceptional return value - exceptional return value of {2} ignored in {1} + Exceptional return value of {2} ignored in {1}
      This method returns a value that is not checked. The return value should be checked @@ -6142,7 +6175,7 @@ equals(...) used to compare incompatible arrays - using equals to compare a {2.simpleClass} and a {3.simpleClass} in {1} + Using equals to compare a {2.simpleClass} and a {3.simpleClass} in {1}
      @@ -6227,6 +6260,7 @@ ]]>
      + Useless assignment in return statement Useless assignment in return from {1} @@ -6239,6 +6273,22 @@ ]]>
      + + Useless increment in return statement + Useless increment in return from {1} +
      + This statement has a return such as return x++;. +A postfix increment/decrement does not impact the value of the expression, +so this increment/decrement has no effect. +Please verify that this statement does the right thing. +

      +]]> +
      +
      + + + Dead store of class literal Dead store of {3}.class in {1} @@ -6613,8 +6663,8 @@
      - integral value cast to double and then passed to Math.ceil - integral value cast to double and then passed to Math.ceil in {1} + Integral value cast to double and then passed to Math.ceil + Integral value cast to double and then passed to Math.ceil in {1}
      @@ -6633,8 +6683,8 @@
      - integral division result cast to double or float - integral division result cast to double or float in {1} + Integral division result cast to double or float + Integral division result cast to double or float in {1}
      @@ -6814,7 +6864,7 @@ Format string references missing argument - format string "{3}" needs argument {5} but only {6} are provided in {1} + Format string "{3}" needs argument {5} but only {6} are provided in {1}
      @@ -7054,17 +7104,18 @@
      - "." used for regular expression - "." used for regular expression in {1} + "." or "|" used for regular expression + "." or "|" used for regular expression in {1}
      -A String function is being invoked and "." is being passed +A String function is being invoked and "." or "|" is being passed to a parameter that takes a regular expression as an argument. Is this what you intended? For example -s.replaceAll(".", "/") will return a String in which every -character has been replaced by a / character, -and s.split(".") always returns a zero length array of String. +
    • s.replaceAll(".", "/") will return a String in which every character has been replaced by a '/' character +
    • s.split(".") always returns a zero length array of String +
    • "ab|cd".replaceAll("|", "/") will return "/a/b/|/c/d/" +
    • "ab|cd".split("|") will return array with six (!) elements: [, a, b, |, c, d]

      ]]>
    • @@ -7244,7 +7295,7 @@
      Bad constant value for month - bad month value of {2} passed to {3} in {1} + Bad month value of {2} passed to {3} in {1}
      @@ -7665,14 +7716,14 @@ A value is being used in a way that requires the value be annotation with a type qualifier. - The type qualifier is strict, so the tool rejects any values that do not have - the appropriate annotation. + The type qualifier is strict, so the tool rejects any values that do not have + the appropriate annotation.

      To coerce a value to have a strict annotation, define an identity function where the return value is annotated - with the strict annotation. - This is the only way to turn a non-annotated value into a value with a strict type qualifier annotation. + with the strict annotation. + This is the only way to turn a non-annotated value into a value with a strict type qualifier annotation.

      ]]> @@ -8009,6 +8060,41 @@ Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.

      ]]> +
      +
      + + Method tightens nullness annotation on parameter + Method {1} overrides the nullness annotation relaxing the ancestor method requirements on parameter. +
      + + A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter + that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull. + Doing so violates the contract that the method should handle a null parameter. +

      ]]> +
      +
      + + Method tightens nullness annotation on parameter + Method {1} overrides the nullness annotation of parameter {2} in an incompatible way +
      + + A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter + that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull. + Doing so violates the contract that the method should handle a null parameter. +

      ]]> +
      +
      + + + Method relaxes nullness annotation on return value + Method {1} overrides the return value nullness annotation in an incompatible way. +
      + + A method should always implement the contract of a method it overrides. Thus, if a method takes is annotated + as returning a @Nonnull value, + you shouldn't override that method in a subclass with a method annotated as returning a @Nullable or @CheckForNull value. + Doing so violates the contract that the method shouldn't return null. +

      ]]>
      @@ -100,7 +103,7 @@ 正確性 C -
      ãƒã‚°ã®å¯èƒ½æ€§ - ãŠãらãã€é–‹ç™ºè€…ãŒæ„図ã—ã¦ã„ãªã‹ã£ãŸã‚³ãƒ¼ãƒ‰ã«ãªã£ã¦ã„る明らã‹ãªã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚°é–“é•ã„。 +
      ãƒã‚°ã®å¯èƒ½æ€§ - ãŠãらãã€é–‹ç™ºè€…ãŒæ„図ã—ã¦ã„ãªã‹ã£ãŸã‚³ãƒ¼ãƒ‰ã«ãªã£ã¦ã„る明らã‹ãªã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚°é–“é•ã„ã§ã™ã€‚ 我々ã¯ã€ä½Žã„誤検出率ã®ãŸã‚ã«åŠªåŠ›ã—ã¾ã™ã€‚
      @@ -122,7 +125,7 @@ ãƒãƒƒãƒ‰ãƒ—ラクティス B -
      推奨ã¾ãŸã¯å¿…é ˆã®ã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚°ãƒ—ラクティスã®é•åã§ã™ã€‚ãŸã¨ãˆã°ã€hashCode 㨠equals ã®å•é¡Œã€cloneable イディオムã€æ¨ã¦ã‚‰ã‚ŒãŸä¾‹å¤–ã€Serializable ã®å•é¡Œã€finalize ã®èª¤ç”¨ãªã©ã€‚ +
      推奨ã¾ãŸã¯å¿…é ˆã®ã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚°ãƒ—ラクティスã®é•åã§ã™ã€‚ãŸã¨ãˆã°ã€hashCode 㨠equals ã®å•é¡Œã€cloneable イディオムã€æ¨ã¦ã‚‰ã‚ŒãŸä¾‹å¤–ã€Serializable ã®å•é¡Œã€finalize ã®èª¤ç”¨ãªã©ã§ã™ã€‚ ã„ãã¤ã‹ã®ã‚°ãƒ«ãƒ¼ãƒ—ã¯ã€ãƒãƒƒãƒ‰ãƒ—ラクティスを気ã«ã—ãªã„ã‹ã‚‚ã—ã‚Œãªã„ãŒã€æˆ‘々ã¯æ­£ç¢ºãªè§£æžã‚’ã—よã†ã¨åŠªåŠ›ã—ã¾ã™ã€‚
      @@ -130,11 +133,11 @@ å±ãªã„コード D -
      紛らã‚ã—ã„コードã€å¤‰å‰‡çš„ãªã‚³ãƒ¼ãƒ‰ã€ãれ自身をエラーã«å°Žã方法ã§æ›¸ã‹ã‚ŒãŸã‚³ãƒ¼ãƒ‰ã€‚ +
      紛らã‚ã—ã„コードã€å¤‰å‰‡çš„ãªã‚³ãƒ¼ãƒ‰ã€ãれ自身をエラーã«å°Žã方法ã§æ›¸ã‹ã‚ŒãŸã‚³ãƒ¼ãƒ‰ã§ã™ã€‚ ãŸã¨ãˆã°ã€ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¸ã®ç„¡åŠ¹ãªä»£å…¥ã€switch æ–‡ã®ãƒ•ã‚©ãƒ¼ãƒ«ã‚¹ãƒ«ãƒ¼ã€æœªç¢ºèªã®ã‚­ãƒ£ã‚¹ãƒˆã€null ã¨ã‚ã‹ã£ã¦ã„る値ã®å†—長㪠null ãƒã‚§ãƒƒã‚¯ãªã©ã§ã™ã€‚ より多ãã®èª¤æ¤œå‡ºã‚’å—ã‘入れã¾ã—ãŸã€‚ FindBugs ã®ä»¥å‰ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯ã€ã“ã®ã‚«ãƒ†ã‚´ãƒªã¯ Style ã¨ã—ã¦çŸ¥ã‚‰ã‚Œã¦ã„ã¾ã—ãŸã€‚ -    
      +
      @@ -249,7 +252,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€net.jcip.annotations.Immutable ã¨ã—ã¦ã‚¢ãƒŽãƒ†ãƒ¼ãƒˆã•ã‚ŒãŸã‚¯ãƒ©ã‚¹ã®ãƒ«ãƒ¼ãƒ«é•åを探ã—ã¾ã™ã€‚ +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€net.jcip.annotations.Immutable ã¾ãŸã¯ javax.annotation.concurrent.Immutable ã¨ã—ã¦ã‚¢ãƒŽãƒ†ãƒ¼ãƒˆã•ã‚ŒãŸã‚¯ãƒ©ã‚¹ã®ãƒ«ãƒ¼ãƒ«é•åを探ã—ã¾ã™ã€‚

      ]]>
      @@ -514,7 +517,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ç„¡å内部クラスã«å®šç¾©ã•ã‚ŒãŸãƒ¡ã‚½ãƒƒãƒ‰ã§ã€ã‚¹ãƒ¼ãƒ‘ークラスã®ãƒ¡ã‚½ãƒƒãƒ‰ã‚’オーãƒãƒ¼ãƒ©ã‚¤ãƒ‰ã™ã‚‹ã“ã¨ã‚’æ„図ã—ã¦ã„ã‚‹ã®ã«ã€å®Ÿéš›ã¯ã‚ªãƒ¼ãƒãƒ¼ãƒ©ã‚¤ãƒ‰ã«ãªã£ã¦ã„ãªã„メソッドを探ã—ã¾ã™ã€‚ +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ç„¡å内部クラスã«å®šç¾©ã•ã‚ŒãŸãƒ¡ã‚½ãƒƒãƒ‰ã§ã€ã‚¹ãƒ¼ãƒ‘ークラスã®ãƒ¡ã‚½ãƒƒãƒ‰ã‚’オーãƒãƒ¼ãƒ©ã‚¤ãƒ‰ã™ã‚‹ã“ã¨ã‚’æ„図ã—ã¦ã„ã¾ã™ãŒã€å®Ÿéš›ã¯ã‚ªãƒ¼ãƒãƒ¼ãƒ©ã‚¤ãƒ‰ã«ãªã£ã¦ã„ãªã„メソッドを探ã—ã¾ã™ã€‚

      ]]>
      @@ -605,7 +608,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€æ–°ã—ã„ディテクタをテストã™ã‚‹ãŸã‚ã®ãƒ•ãƒƒã‚¯ã§ã™ã€‚通常ã€ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ä½•ã‚‚ã—ã¾ã›ã‚“。 +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€æ–°ã—ã„ディテクタをテストã™ã‚‹ãŸã‚ã®ãƒ•ãƒƒã‚¯ã§ã™ã€‚一般ã«ã€ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ä½•ã‚‚ã—ã¾ã›ã‚“。

      ]]>
      @@ -615,7 +618,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€æ–°ã—ã„ディテクタをテストã™ã‚‹ãŸã‚ã®ãƒ•ãƒƒã‚¯ã§ã™ã€‚通常ã€ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ä½•ã‚‚ã—ã¾ã›ã‚“。 +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€æ–°ã—ã„ディテクタをテストã™ã‚‹ãŸã‚ã®ãƒ•ãƒƒã‚¯ã§ã™ã€‚一般ã«ã€ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ä½•ã‚‚ã—ã¾ã›ã‚“。

      ]]>
      @@ -635,7 +638,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€æ–°ã—ã„ディテクタをテストã™ã‚‹ãŸã‚ã®ãƒ•ãƒƒã‚¯ã§ã™ã€‚通常ã€ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ä½•ã‚‚ã—ã¾ã›ã‚“。 +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€æ–°ã—ã„ディテクタをテストã™ã‚‹ãŸã‚ã®ãƒ•ãƒƒã‚¯ã§ã™ã€‚一般ã«ã€ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ä½•ã‚‚ã—ã¾ã›ã‚“。

      ]]>
      @@ -649,7 +652,7 @@ ã“れらã®è­¦å‘Šã¯ã‚½ãƒ•ãƒˆã‚¦ã‚§ã‚¢ã§å®Ÿéš›ã®ãƒã‚°ã‚’発見ã™ã‚‹ã®ã§ã¯ãªãã€ãƒ‡ãƒ¼ã‚¿ãƒžã‚¤ãƒ‹ãƒ³ã‚°å®Ÿé¨“ã®ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«ã¨ã—ã¦å½¹ã«ç«‹ã¤ã“ã¨ã‚’目的ã¨ã—ãŸå½ã®ãƒ©ãƒ³ãƒ€ãƒ ãƒŽã‚¤ã‚ºã§ã™ã€‚

      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€æ–°ã—ã„ディテクタをテストã™ã‚‹ãŸã‚ã®ãƒ•ãƒƒã‚¯ã§ã™ã€‚通常ã€ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ä½•ã‚‚ã—ã¾ã›ã‚“。 +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€æ–°ã—ã„ディテクタをテストã™ã‚‹ãŸã‚ã®ãƒ•ãƒƒã‚¯ã§ã™ã€‚一般ã«ã€ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ä½•ã‚‚ã—ã¾ã›ã‚“。

      ]]>
      @@ -790,7 +793,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ä¾‹å¤–をキャッãƒã—ã¦ã„ã‚‹ã®ã«ä½•ã‚‚ã—ã¦ã„ãªã„コードを探ã—ã¾ã™ã€‚ +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ä¾‹å¤–をキャッãƒã—ã¦ã„ã¾ã™ãŒã€ä½•ã‚‚ã—ã¦ã„ãªã„コードを探ã—ã¾ã™ã€‚

      ]]>
      @@ -1190,7 +1193,7 @@ 中速ディテクタã§ã™ã€‚

      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã‚’使用ã™ã‚‹ãŸã‚ã«ã€è£œåŠ©ã‚¯ãƒ©ã‚¹ãƒ‘ス㫠java.util.concurrent パッケージ (ã¾ãŸã¯ãƒ‘ッケージ自体を解æžã—ã¦ã„ã‚‹) ãŒå¿…è¦ã§ã‚ã‚‹ã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•ã„。 +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã‚’使用ã™ã‚‹ãŸã‚ã«ã€è£œåŠ©ã‚¯ãƒ©ã‚¹ãƒ‘ス㫠java.util.concurrent パッケージ (ã¾ãŸã¯ãƒ‘ッケージ自体を解æžã—ã¦ã„ã‚‹) ãŒå¿…è¦ã§ã‚ã‚‹ã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•ã„。

      ]]>
      @@ -1201,7 +1204,7 @@ ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€2ã¤ã®å‚照値を == ã‚„ != 演算å­ã§æ¯”較ã—ã¦ã„る場所を探ã—ã¾ã™ã€‚ -java.lang.String ã®ã‚ˆã†ãªåž‹ã®ã‚¯ãƒ©ã‚¹ã§å‚照値を比較ã™ã‚‹ã“ã¨ã¯ã€é€šå¸¸èª¤ã‚Šã§ã™ã€‚ +java.lang.String ã®ã‚ˆã†ãªåž‹ã®ã‚¯ãƒ©ã‚¹ã§å‚照値を比較ã™ã‚‹ã“ã¨ã¯ã€ä¸€èˆ¬ã«èª¤ã‚Šã§ã™ã€‚

      低速ディテクタã§ã™ã€‚ @@ -1285,7 +1288,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€JSR-166ã®ãƒ­ãƒƒã‚¯ã§å®Ÿè¡Œã•ã‚Œã‚‹é€šå¸¸ã®åŒæœŸåŒ–を探ã—ã¾ã™ã€‚ +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€JSR-166ã®ãƒ­ãƒƒã‚¯ã§å®Ÿè¡Œã•ã‚Œã‚‹ä¸€èˆ¬ã«ã®åŒæœŸåŒ–を探ã—ã¾ã™ã€‚

      中速ディテクタã§ã™ã€‚ @@ -1333,7 +1336,6 @@ ]]>

      -
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€åˆ—インデックス番å·ãŒ0ã® ResultSetã® getXXX ã¾ãŸã¯ setXXX メソッドã®å‘¼ã³å‡ºã—を探ã—ã¾ã™ã€‚ +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€åˆ—インデックス番å·ãŒ0ã® ResultSet ã® getXXX ã¾ãŸã¯ setXXX メソッドã®å‘¼ã³å‡ºã—を探ã—ã¾ã™ã€‚ ResultSet ã®åˆ—インデックス番å·ã¯1ã§å§‹ã¾ã‚‹ã®ã§ã€ã“ã‚Œã¯å¸¸ã«é–“é•ã„ã§ã™ã€‚

      ]]> @@ -1381,7 +1383,7 @@ ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€éžã‚¹ã‚¿ãƒ†ã‚£ãƒƒã‚¯ãªæ–‡è„ˆã‹ã‚‰ Thread.interrupted() ã®å‘¼ã³å‡ºã—を探ã—ã¾ã™ã€‚ -ãれ㌠Thread.currentThread().interrupted() ã‹ã‚‰å‘¼ã³å‡ºã•ã‚Œã‚‹ãªã‚‰ã€å½¹ã«ç«‹ãŸãªã„行為ãªã®ã§ Thread.interrupted() を使用ã—ã¾ã™ã€‚ +Thread.currentThread().interrupted() ã‹ã‚‰å‘¼ã³å‡ºã•ã‚Œã‚‹ãªã‚‰ã€å½¹ã«ç«‹ãŸãªã„行為ãªã®ã§ Thread.interrupted() を使用ã—ã¾ã™ã€‚ ã—ã‹ã—ãªãŒã‚‰ã€interrupted メソッドã¯å¸¸ã«ã‚«ãƒ¬ãƒ³ãƒˆã‚¹ãƒ¬ãƒƒãƒ‰ã§å‘¼ã³å‡ºã•ã‚Œã‚‹ã®ã§ã€ä»»æ„ã®ã‚¹ãƒ¬ãƒƒãƒ‰ã‚ªãƒ–ジェクトã§å‘¼ã³å‡ºã™ã®ã¯ã»ã¼é–“é•ã„ãªã誤りã§ã™ã€‚

      ]]> @@ -1503,7 +1505,7 @@ ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ã‚¹ãƒ¼ãƒ‘ークラスã¨åŒã˜ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã‚’実装ã™ã‚‹ã¨å®£è¨€ã—ã¦ã„るサブクラスを探ã—ã¾ã™ã€‚ -スーパークラスã§ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã‚’実装ã™ã‚‹ã®ã§ã€ã‚µãƒ–クラスã§åŒã˜ã“ã¨ã‚’ã™ã‚‹ã®ã¯å†—é•·ã§ã™ã€‚ +スーパークラスãŒã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã‚’実装ã—ã¦ã„ã‚‹ã®ã§ã€ã‚µãƒ–クラスã§åŒã˜ã“ã¨ã‚’ã™ã‚‹ã®ã¯å†—é•·ã§ã™ã€‚

      ]]>
      @@ -1576,7 +1578,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ãれらãŒç›´åˆ—化å¯èƒ½ã§ã‚ã‚‹ã“ã¨ã‚’è¦æ±‚ã™ã‚‹ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã§ã€éžSerializableãªã‚ªãƒ–ジェクトã®ä½¿ç”¨æ–¹æ³•ã‚’探ã—ã¾ã™ã€‚ +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ãれらãŒç›´åˆ—化å¯èƒ½ã§ã‚ã‚‹ã“ã¨ã‚’è¦æ±‚ã™ã‚‹ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã§ã€éž Serializable オブジェクトã®ä½¿ç”¨ã‚’探ã—ã¾ã™ã€‚

      ]]>
      @@ -1586,7 +1588,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ObjectOutput ã® writeObject メソッドã«æ¸¡ã•ã‚ŒãŸéžç›´åˆ—化オブジェクトを探ã—ã¾ã™ã€‚ +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ObjectOutput ã® writeObject メソッドã«æ¸¡ã•ã‚Œã‚‹éž Serializable オブジェクトを探ã—ã¾ã™ã€‚

      ]]>
      @@ -1628,8 +1630,8 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€2ã¤ã®åˆ†å²ã«åŒã˜ã‚³ãƒ¼ãƒ‰ãŒã‚ã‚‹ãŸã‚ã«åˆ†å²ãŒç„¡åŠ¹ã«ãªã£ã¦ã„ã‚‹ if/else ã¾ãŸã¯ switch 文を探ã—ã¾ã™ã€‚ -ã“ã‚Œã¯2ã¤ã®åˆ†å²ã«åŒã˜ã‚³ãƒ¼ãƒ‰ã‚’コピー & ペーストã—ã¦ã„ã‚‹ã“ã¨ãŒç‰‡æ–¹ã®åˆ†å²ã®é–“é•ã£ãŸãƒ­ã‚¸ãƒƒã‚¯ã®åŽŸå› ã«ãªã‚Šã¾ã™ã€‚ +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€2ã¤ã®åˆ†å²ã«åŒã˜ã‚³ãƒ¼ãƒ‰ãŒã‚ã‚‹ if/else ã¾ãŸã¯ switch 文を探ã—ã¾ã™ã€‚ +ã“ã‚Œã¯å¤šãã®å ´åˆã€2ã¤ã®åˆ†å²ã«åŒã˜ã‚³ãƒ¼ãƒ‰ã‚’コピー & ペーストã—ã¦ã„ã‚‹ã“ã¨ãŒç‰‡æ–¹ã®åˆ†å²ã®é–“é•ã£ãŸãƒ­ã‚¸ãƒƒã‚¯ã®åŽŸå› ã«ãªã‚Šã¾ã™ã€‚

      ]]>
      @@ -1641,7 +1643,7 @@

      ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€æ‰€æœ‰ã‚¯ãƒ©ã‚¹ã® private フィールドã«æ›¸ã込んã§ã„る内部クラスを探ã—ã¾ã™ã€‚ ã“ã®å ´åˆã€ã‚³ãƒ³ãƒ‘イラã¯å¿…ãšã“ã®ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã¸æ›¸ã込むã“ã¨ã«ä½¿ã‚れるアクセッサーメソッドを生æˆã—ã¾ã™ã€‚ -å¯è¦–性を protected ã«ç·©å’Œã™ã‚‹ã“ã¨ã¯ã€ç›´æŽ¥æ›¸ã込むã“ã¨ã‚’å¯èƒ½ã«ã—ã¾ã™ã€‚ +å¯è¦–性を protected ã«ç·©å’Œã™ã‚‹ã“ã¨ã¯ã€ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã«ç›´æŽ¥æ›¸ã込むã“ã¨ã‚’å¯èƒ½ã«ã—ã¾ã™ã€‚

      ]]>
      @@ -1651,7 +1653,7 @@
      -ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€XML インタフェースを実装ã—ãŸã‚¯ãƒ©ã‚¹ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã‚’作æˆã—ã¦ã„るコードを探ã—ã¾ã™ã€‚ +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€XML インタフェースを実装ã—ãŸã‚¯ãƒ©ã‚¹ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã‚’直接生æˆã—ã¦ã„るコードを探ã—ã¾ã™ã€‚ ã“れらã®ã‚ªãƒ–ジェクトを作æˆã™ã‚‹ãŸã‚ã«æä¾›ã•ã‚ŒãŸãƒ•ã‚¡ã‚¯ãƒˆãƒªãƒ‘ターンを使用ã™ã‚‹ã®ã§ã¯ãªãã€ç‰¹å®šã®å®Ÿè£…ã«ã‚³ãƒ¼ãƒ‰ã‚’çµã³ã¤ã‘ã¾ã™ã€‚

      ]]> @@ -1698,7 +1700,7 @@ ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ã©ã®ãƒ¡ã‚½ãƒƒãƒ‰ãŒ null ã‚’è¿”ã™ã®ã‹ã‚’決定ã—ã¦ãƒ•ã‚¡ã‚¤ãƒ«ã«ä¿å­˜ã—ã¾ã™ã€‚ -çµæžœãƒ•ã‚¡ã‚¤ãƒ«ã¯ã€null å‚照解除ディテクタã®ç²¾åº¦ã‚’å‘上ã•ã›ã‚‹ãŸã‚ã«å¾Œç¶šã®ãƒ‘スã§ä½¿ã‚れるã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。 +çµæžœãƒ•ã‚¡ã‚¤ãƒ«ã¯ã€null 間接å‚照ディテクタã®ç²¾åº¦ã‚’å‘上ã•ã›ã‚‹ãŸã‚ã«å¾Œç¶šã®ãƒ‘スã§ä½¿ã‚れるã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。 ã“ã‚Œã¯ãƒˆãƒ¬ãƒ¼ãƒ‹ãƒ³ã‚°ãƒ‘スãªã®ã§è­¦å‘Šã¯å ±å‘Šã•ã‚Œã¾ã›ã‚“。

      @@ -1713,7 +1715,7 @@ ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ã©ã®ãƒ¡ã‚½ãƒƒãƒ‰ãŒ null 値ã®ãƒ‘ラメータを無æ¡ä»¶ã§åˆ©ç”¨ã™ã‚‹ã®ã‹ã‚’決定ã—ã¦ãƒ•ã‚¡ã‚¤ãƒ«ã«ä¿å­˜ã—ã¾ã™ã€‚ -çµæžœãƒ•ã‚¡ã‚¤ãƒ«ã¯ã€ null å‚照解除ディテクタã®ç²¾åº¦ã‚’å‘上ã•ã›ã‚‹ãŸã‚ã«å¾Œç¶šã®ãƒ‘スã§ä½¿ã‚れるã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。 +çµæžœãƒ•ã‚¡ã‚¤ãƒ«ã¯ã€ null 間接å‚照ディテクタã®ç²¾åº¦ã‚’å‘上ã•ã›ã‚‹ãŸã‚ã«å¾Œç¶šã®ãƒ‘スã§ä½¿ã‚れるã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。 ã“ã‚Œã¯ãƒˆãƒ¬ãƒ¼ãƒ‹ãƒ³ã‚°ãƒ‘スãªã®ã§è­¦å‘Šã¯å ±å‘Šã•ã‚Œã¾ã›ã‚“。

      @@ -1790,9 +1792,9 @@ 無関係ãªã‚¯ãƒ©ã‚¹åž‹ã«ã‚ˆã‚‹å¼•æ•°ã¯æ±ºã—ã¦ã‚³ãƒ¬ã‚¯ã‚·ãƒ§ãƒ³ã®ä¸­ã«æ ¼ç´ã•ã‚Œã‚‹ã“ã¨ã¯ã‚ã‚Šã¾ã›ã‚“。 ãŸã¨ãˆã°ã€foo ㌠List<String> ã§ã€bar ㌠StringBuffer ãªã‚‰ foo.contains(bar) ã®å‘¼ã³å‡ºã—ã¯å¸¸ã« false ã‚’è¿”ã™ã“ã¨ã«ãªã‚Šã¾ã™ã€‚

      +

      高速ディテクタã§ã™ã€‚

      -

      ]]>
      @@ -1811,7 +1813,7 @@
      -ã“ã‚Œã¯ãƒ‡ãƒ¼ã‚¿ãƒ•ãƒ­ãƒ¼è§£æžã‚’テストã™ã‚‹ãŸã‚ã«ã ã‘使ã‚れる内部ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã§ã™ã€‚ +ã“ã‚Œã¯ãƒ‡ãƒ¼ã‚¿ãƒ•ãƒ­ãƒ¼è§£æžã‚’検証ã™ã‚‹ãŸã‚ã«ã ã‘使ã‚れる内部ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã§ã™ã€‚

      デフォルトã§ã¯æœ‰åŠ¹ã«ã•ã‚Œã¾ã›ã‚“。 @@ -1863,7 +1865,7 @@

      - ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ã‚¹ãƒ¼ãƒ‘ークラスã®ãŸã‚ã«ã‚³ãƒ³ã‚¹ãƒˆãƒ©ã‚¯ã‚¿ã‹ã‚‰å‘¼ã³å‡ºã•ã‚Œã‚‹ãƒ¡ã‚½ãƒƒãƒ‰ã‚’ãƒã‚§ãƒƒã‚¯ã—ã¾ã™ã€‚ + ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ã‚¹ãƒ¼ãƒ‘ークラスã®ãŸã‚ã®ã‚³ãƒ³ã‚¹ãƒˆãƒ©ã‚¯ã‚¿ã‹ã‚‰å‘¼ã³å‡ºã•ã‚Œã‚‹ãƒ¡ã‚½ãƒƒãƒ‰ã‚’ãƒã‚§ãƒƒã‚¯ã—ã¾ã™ã€‚

      ]]>
      @@ -1879,7 +1881,17 @@ ]]>
      - + + +
      + +ã“ã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã¯ã€ã‚ªãƒ¼ãƒãƒ©ã‚¤ãƒ‰ãƒ¡ã‚½ãƒƒãƒ‰ãŒ 戻り値ã¾ãŸã¯ãƒ‘ラメータ㮠@CheckForNull (@Nonnullã§ä½œã‚‰ã‚ŒãŸ) 㧠@Nonnull (@CheckForNull ã§ä½œã‚‰ã‚ŒãŸ) ã‚’ç·©å’Œã—ã¦ã„ãªã„ã“ã¨ã‚’ãƒã‚§ãƒƒã‚¯ã—ã¾ã™ã€‚ +

      +]]> +
      +
      + - - - Must set property 'run.class' - - - - - - - - - - - diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index cb896fa..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - org.netbeans.modules.ant.freeform - - - - findbugs - - - - - java - src/java - - - - java - src/junit - - - - java - src/antTask - - - - java - src/gui - - - - java - src/tools - - - - - build - - - clean - - - docs - - - runjunit - - - junittests - - - clean - build - - - - run-selected-file-in-java5 - - run.class - src/gui - \.java$ - java-name - - - - - - - - - - - src/java - - - - src/junit - - - - src/antTask - - - - src/gui - - - - src/tools - - - build.xml - - - - - - - - - - - - - - - - - src/java - src/junit - src/antTask - src/gui - src/tools - build/classes:lib/bcel.jar:lib/junit.jar:lib/ant.jar:lib/AppleJavaExtensions.jar:lib/jsr305.jar:lib/dom4j-1.6.1.jar:lib/jaxen-1.1.1.jar:lib/asm-3.3.jar:lib/asm-analysis-3.3.jar:lib/asm-commons-3.3.jar:lib/asm-tree-3.1.jar:lib/asm-util-3.1.jar:lib/asm-xml-3.1.jar - 1.5 - - - - diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..15b39c7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,355 @@ + + 4.0.0 + + org.sonatype.oss + oss-parent + 7 + + + com.google.code.findbugs + findbugs + 2.0.3-SNAPSHOT + jar + + http://findbugs.sourceforge.net/ + FindBugs-Project + Findbugs: Because it's easy! + 2003 + + + GNU Lesser Public License + http://www.gnu.org/licenses/lgpl.html + repo + + + + + 3.0 + + + + + scm:svn:http://findbugs.googlecode.com/svn/trunk/ + scm:svn:https://findbugs.googlecode.com/svn/trunk/ + http://findbugs.googlecode.com/svn/trunk/ + + + + + bp + Bill Pugh + pugh at cs.umd.edu + http://www.cs.umd.edu/~pugh/ + + Project Lead + Primary Developer + + -5 + + + al + Andrey Loskutov + Loskutov@gmx.de + http://andrei.gmxhome.de/privat.html + + Eclipse plugin + + +1 + + + bp + Keith Lea + + http://keithlea.com/ + + web cloud + + -5 + + + + + Garvin LeClaire + gleclaire@codehaus.org + http://gdleclaire.blogspot.com + + Maven + + -5 + + + David H. Hovemeyer + dhovemey@ycp.edu + http://goose.ycp.edu/~dhovemey/ + + project founder + + -5 + + + Nay Ayewah + + + + + + -5 + + + Ben Langmead + + + + + + -5 + + + Tomas Pollak + + + + Eclipse plugin tests + + -5 + + + Phil Crosby + + + + + + -5 + + + Peter Friese + + + + Eclipse plugin + + -5 + + + Dave Brosius + + + + + + -5 + + + Brian Goetz + + + + + + -5 + + + Rohan Lloyd + + + + + + -5 + + + + + 3.3 + 4.11 + + + + + net.jcip + jcip-annotations + 1.0 + + + com.google.code.findbugs + jsr305 + 2.0.1 + + + com.google.code.findbugs + bcel + 2.0.1 + + + com.google.code.findbugs + jFormatString + 2.0.1 + + + dom4j + dom4j + 1.6.1 + + + org.apache.ant + ant + 1.7.1 + provided + + + asm + asm + ${asmVersion} + + + asm + asm-commons + ${asmVersion} + + + commons-lang + commons-lang + 2.6 + + + com.apple + AppleJavaExtensions + 1.4 + + + junit + junit + ${junitVersion} + test + + + jaxen + jaxen + 1.1.6 + + + icu4j + com.ibm.icu + + + + + + ${basedir}/src + ${basedir}/src/junit + + + ${basedir}/etc + + *.xsd + bugrank.txt + findbugs.xml + messages*.xml + + + + ${basedir}/src/xsl + + *.xsl + + + + ${basedir}/src/antTask + + **/*.xsl + **/*.properties + **/*.db + **/*.png + **/*.html + + + + ${basedir}/src/antTask + + **/*.xsl + **/*.properties + **/*.db + **/*.png + **/*.html + + + + ${basedir}/src/gui + + **/*.xsl + **/*.properties + **/*.db + **/*.png + **/*.html + + + + ${basedir}/src/java + + **/*.xsl + **/*.properties + **/*.db + **/*.png + **/*.html + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + 1.5 + 1.5 + + **/junit/** + **/infonodeJava/** + **/obsolete/** + + + **/architecture/** + **/cloud/** + + **/DetectorsTest.java + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + ${basedir}/etc/MANIFEST-findbugs.MF + + + + + + + + + deploy + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.4 + + + sign-artifacts + install + + sign + + + + + + + + + diff --git a/src/antTask/edu/umd/cs/findbugs/anttask/AbstractFindBugsTask.java b/src/antTask/edu/umd/cs/findbugs/anttask/AbstractFindBugsTask.java index cf134e4..4a0714d 100644 --- a/src/antTask/edu/umd/cs/findbugs/anttask/AbstractFindBugsTask.java +++ b/src/antTask/edu/umd/cs/findbugs/anttask/AbstractFindBugsTask.java @@ -361,7 +361,7 @@ */ private void execFindbugs() throws BuildException { - System.out.println("Executing findbugs from ant task"); + System.out.println("Executing findbugs " + this.getClass().getSimpleName() + " from ant task"); createFindbugsEngine(); configureFindbugsEngine(); @@ -394,7 +394,7 @@ log(be.toString()); } String returnProperty = getFindbugsEngine().getProject().getProperty(execReturnCodeIdentifier); - int rc = returnProperty == null ? 0 : Integer.valueOf(returnProperty).intValue(); + int rc = returnProperty == null ? 0 : Integer.parseInt(returnProperty); afterExecuteJavaProcess(rc); } diff --git a/src/antTask/edu/umd/cs/findbugs/anttask/ConvertXmlToTextTask.java b/src/antTask/edu/umd/cs/findbugs/anttask/ConvertXmlToTextTask.java old file mode 100755 new file mode 100644 index c3c9542..00f98dd 100644 --- a/src/antTask/edu/umd/cs/findbugs/anttask/ConvertXmlToTextTask.java +++ b/src/antTask/edu/umd/cs/findbugs/anttask/ConvertXmlToTextTask.java @@ -111,9 +111,6 @@ if (input == null) { throw new BuildException("input attribute is required", getLocation()); } - if (output == null) { - throw new BuildException("output attribute is required", getLocation()); - } if (!format.equals("text") && !(format.equals("html") || format.startsWith("html:"))) { throw new BuildException("invalid value " + format + " for format attribute", getLocation()); } @@ -139,7 +136,8 @@ addArg("-applySuppression"); } addArg(input); - addArg(output); + if (output != null) + addArg(output); } /* @@ -151,7 +149,10 @@ */ @Override protected void beforeExecuteJavaProcess() { - log("Converting " + input + " to " + output + " using format " + format); + if (output != null) + log("Converting " + input + " to " + output + " using format " + format); + else + log("Converting " + input + " using format " + format); } /* diff --git a/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsTask.java b/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsTask.java index 8d91534..88083cc 100644 --- a/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsTask.java +++ b/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsTask.java @@ -1,55 +1,20 @@ /* - * The Apache Software License, Version 1.1 + * FindBugs - Find Bugs in Java programs + * Copyright (C) 2003-2013 University of Maryland * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights - * reserved. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "Ant" and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package edu.umd.cs.findbugs.anttask; @@ -101,6 +66,7 @@ *
    • pluginList (list of plugin Jar files to load) *
    • projectFile (project filename) *
    • projectName (project name, for display in generated HTML) + *
    • userPrefs (user preferences filename) *
    • quietErrors (boolean - default false) *
    • relaxed (boolean - default false) *
    • reportLevel (enum experimental|low|medium|high) @@ -160,6 +126,8 @@ private File projectFile; + private File userPreferencesFile; + private File baselineBugs; private boolean applySuppression; @@ -414,6 +382,13 @@ */ public void setProjectFile(File projectFile) { this.projectFile = projectFile; + } + + /** + * Set the project file + */ + public void setUserPreferencesFile(File userPreferencesFile) { + this.userPreferencesFile = userPreferencesFile; } /** @@ -698,6 +673,10 @@ if (projectFile != null) { addArg("-project"); addArg(projectFile.getPath()); + } + if (userPreferencesFile != null) { + addArg("-userPrefs"); + addArg(userPreferencesFile.getPath()); } if (applySuppression) { addArg("-applySuppression"); diff --git a/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsViewerTask.java b/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsViewerTask.java index 6a0954d..10ceed0 100644 --- a/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsViewerTask.java +++ b/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsViewerTask.java @@ -95,7 +95,7 @@ /** * Sets the file that contains the XML output of a findbugs report. * - * @param bugReport + * @param loadbugs * XML output from a findbugs session */ public void setLoadbugs(File loadbugs) { diff --git a/src/antTask/edu/umd/cs/findbugs/anttask/UnionBugs2.java b/src/antTask/edu/umd/cs/findbugs/anttask/UnionBugs2.java index a2a2057..3fdb558 100644 --- a/src/antTask/edu/umd/cs/findbugs/anttask/UnionBugs2.java +++ b/src/antTask/edu/umd/cs/findbugs/anttask/UnionBugs2.java @@ -63,7 +63,7 @@ /** * The File everything should get merged into * - * @param file + * @param arg */ public void setTo(String arg) { this.to = arg; diff --git a/src/doc/Changes.html b/src/doc/Changes.html index 13bd2e3..2695fb5 100644 --- a/src/doc/Changes.html +++ b/src/doc/Changes.html @@ -17,6 +17,105 @@

      FindBugs Change Log, Version @VERSION@

      + +

      FindBugs Change Log, Version 2.0.2

      + diff --git a/src/doc/index.html b/src/doc/index.html index 542990e..ce866f4 100644 --- a/src/doc/index.html +++ b/src/doc/index.html @@ -39,23 +39,34 @@

      FindBugs requires JRE (or JDK) 1.5.0 or later to run.  However, it can analyze programs - compiled for any version of Java, from 1.0 to 1.8. The current version of FindBugs is @VERSION@, + compiled for any version of Java, from 1.0 to 1.7. Some classfiles compiled for Java 1.8 give + FindBugs problems, the next major release of FindBugs will handle Java 1.8 classfiles. + +

      The current version of FindBugs is @VERSION@, + released on @RELEASE_DATE@. We are very interested in getting feedback on how to improve FindBugs. File bug reports on our sourceforge bug tracker

      +

      The current version of FindBugs may encounter errors when analyzing + Java 1.8 bytecode, due to changes in the classfile format. After FindBugs 2.0.3 + is released, work will start on the next major release of FindBugs, which will + be able to analyze Java 1.8 (and will require Java 1.7 to compile and run). +

      Changes | Talks | Papers | Sponsors | Support

      -

      FindBugs 2.0 Release

      -

      After many delays, we have released FindBugs 2.0. We are pretty happy and confident about the - functionality, although we know the documentation of the changes in 2.0 is lacking. We decided that - releasing 2.0 took precedence over fixing the documentation. Anyone currently using FindBugs 1.3.9 - should find FindBugs 2.0 to largely be a drop-in replacement that offers better accuracy and - performance.

      + +

      FindBugs 2.0.3 Release

      +

      FindBugs 2.0.3 is intended to be a minor bug fix release over + FindBugs 2.0.2. Although than some improvements to existing bug detectors + and analysis engines, and a few new bug patterns, and some + important bug fixes to the Eclipse plugin, no significant changes + should be observed. Consult the Change log + for more details.

      Also check out http://code.google.com/p/findbugs/w/list @@ -64,7 +75,7 @@

      - Major changes in FindBugs 2.0 + Major changes in FindBugs 2.0 (from FindBugs 1.3.x)

      • FindBugs Communal cloud
      • @@ -104,18 +115,21 @@
        SQE: Software Quality Environment
        +
        Jenkins
        +
        Jenkins FindBugs Plugin +
        Hudson
        - http://wiki.hudson-ci.org/display/HUDSON/FindBugs+Plugin + HUDSON FindBugs Plugin
        IntelliJ
        Several plugins, see http://code.google.com/p/findbugs/wiki/IntellijFindBugsPlugins - for a descrption. + for a description.
        @@ -123,11 +137,17 @@

        New

          -
        • We've released FindBugs 2.0.2. + +
        • jFormatString library republished at + http://code.google.com/p/j-format-string. + This is the library we use for compile time checking of format strings. It is separately published to + +
        • We're releasing FindBugs 2.0.3. + Mostly small changes to address false positives, with one important fix to the Eclipse plugin - to fix a problem that had prevented the plugin from running in some versions of Eclipse. + to fix a problem that had prevented the plugin from running in some versions of Eclipse. Check the change log for more details. - +
        • We've released FindBugs 2.0
        • FindBugs communal cloud and Java web start links:. We have analyzed several large open @@ -154,7 +174,7 @@ the systems at Google. A fixit might work to improve web accessibility, internal testing, removing TODO's from internal software, etc. -

          On May 13-14, Google held a global fixit for UMD's FindBugs tool a static analysis tool for +

          In 2009, Google held a global fixit for UMD's FindBugs tool a static analysis tool for finding coding mistakes in Java software. The focus of the fixit was to get feedback on the 4,000 highest confidence issues found by FindBugs at Google, and let Google engineers decide which issues, if any, needed fixing.

          @@ -185,12 +205,12 @@ Talks about FindBugs
            -

            +

          • Mistakes That Matter, JavaOne, 2009 -

            -
          • Youtube video showing of demo - of our 2.0 Eclipse plugin (16 minutes)
          • + +
          • Youtube video showing of demo + of our 2.0 Eclipse plugin (5 minutes)
          • Quicktime movie showing of demo of our new GUI to view some of the null pointer bugs in Eclipse (Big file warning: 23 Megabytes)
          • JavaOne 2007 talk on @@ -232,8 +252,7 @@ href="http://www.cs.umd.edu/~pugh">Bill Pugh and Andrey Loskutov.

            -

            Current funding for FindBugs comes from a Google Faculty Research Awards. We'd be interested in - any offers of support or sponsorship.

            +

            The most recent funding for FindBugs comes from a Google Faculty Research Awards.

            Additional Support

            @@ -260,7 +279,8 @@

            Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation (NSF). - @HTML_FOOTER@

            +

            + @HTML_FOOTER@ diff --git a/src/doc/manual.xml b/src/doc/manual.xml index 2d411c8..2b2e924 100644 --- a/src/doc/manual.xml +++ b/src/doc/manual.xml @@ -938,6 +938,19 @@ + + -userPrefs edu.umd.cs.findbugs.core.prefs + + + Set the path of the user preferences file to use, which might override some of the options abobe. + Specifying userPrefs as first argument would mean some later + options will override them, as last argument would mean they will override some previous options). + This rationale behind this option is to reuse FindBugs Eclipse project settings for command + line execution. + + + +