<rule key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck" priority="MAJOR">
<name><![CDATA[Header]]></name>
<configKey><![CDATA[Checker/Header]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>Checks that a source file begins with a specified header. Property headerFile specifies a file that contains the required header. Alternatively, the header specification can be set directly in the header property without the need for an external file.</p>
<p>Property ignoreLines specifies the line numbers to ignore when matching lines in a header file. This property is very useful for supporting headers that contain copyright dates. For example, consider the following header:</p>
<pre>
<rule key="com.puppycrawl.tools.checkstyle.checks.header.RegexpHeaderCheck" priority="MAJOR">
<name><![CDATA[Regexp Header]]></name>
<configKey><![CDATA[Checker/RegexpHeader]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>Checks the header of a source file against a header that contains a regular expression for each line of the source header.</p>
<p>Rationale: In some projects checking against a fixed header is not sufficient, e.g. the header might require a copyright line where the year information is not static. For example, consider the following header:</p>
<pre>
<rule key="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck" priority="MAJOR">
<name><![CDATA[Annotation Use Style]]></name>
<configKey><![CDATA[Checker/TreeWalker/AnnotationUseStyle]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Controls the style with the usage of annotations.]]></description>
<param key="elementStyle" type="s[expanded,compact,compact_no_array,ignore]">
<description><![CDATA[Defines the annotation element styles. Default value is compact_no_array.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.annotation.MissingDeprecatedCheck" priority="MAJOR">
<name><![CDATA[Missing Deprecated]]></name>
<configKey><![CDATA[Checker/TreeWalker/MissingDeprecated]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Verifies that both the java.lang.Deprecated annotation is present and the @deprecated Javadoc tag is present when either is present.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.annotation.MissingOverrideCheck" priority="MAJOR">
<name><![CDATA[Missing Override]]></name>
<configKey><![CDATA[Checker/TreeWalker/MissingOverride]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Verifies that the java.lang.Override annotation is present when the {@inheritDoc} javadoc tag is present.]]></description>
<param key="javaFiveCompatibility" type="b">
<rule key="com.puppycrawl.tools.checkstyle.checks.annotation.PackageAnnotationCheck" priority="MINOR">
<name><![CDATA[Package Annotation]]></name>
<configKey><![CDATA[Checker/TreeWalker/PackageAnnotation]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>This check makes sure that all package annotations are in the package-info.java file.</p>
<p>According to the Java JLS 3rd ed.</p>
<p>The JLS does not enforce the placement of package annotations. This placement may vary based on implementation. The JLS does highly recommend that all package annotations are placed in the package-info.java file. See <a href="http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html">Java Language specification, sections 7.4.1.1</a>.</p>]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.annotation.SuppressWarningsCheck" priority="MAJOR">
<name><![CDATA[Suppress Warnings]]></name>
<configKey><![CDATA[Checker/TreeWalker/SuppressWarnings]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[<p> This check allows you to specify what warnings that SuppressWarnings is not allowed to suppress. You can also specify a list of TokenTypes that the configured warning(s) cannot be suppressed on.</p>
<p>Limitations: This check does not consider conditionals inside the SuppressWarnings annotation.
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck" priority="MAJOR">
<name><![CDATA[Equals Avoid Null]]></name>
<configKey><![CDATA[Checker/TreeWalker/EqualsAvoidNull]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[<p>Checks that any combination of String literals with optional assignment is on the left side of an equals() comparison.</p>
<p>Rationale: Calling the equals() method on String literals will avoid a potential NullPointerException. Also, it is pretty common to see null check right before equals comparisons which is not necessary in the below example.</p>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.NoCloneCheck" priority="MAJOR">
<name><![CDATA[No Clone Check]]></name>
<configKey><![CDATA[Checker/TreeWalker/NoCloneCheck]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Checks that the clone method is not overridden from the Object class.</p>
<p>Rationale: The clone method relies on strange/hard to follow rules that do not work it all situations. Consequently, it is difficult to override correctly. Below are some of the rules/reasons why the clone method should be avoided.
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.NoFinalizerCheck" priority="MAJOR">
<name><![CDATA[No Finalizer]]></name>
<configKey><![CDATA[Checker/TreeWalker/NoFinalizer]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>Verifies there are no finalize() methods defined in a class.</p>]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStaticImportCheck" priority="MINOR">
<name><![CDATA[Avoid Static Import]]></name>
<configKey><![CDATA[Checker/TreeWalker/AvoidStaticImport]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> Checks that there are no static import statements. Rationale: Importing static members can lead to naming conflicts between class' members. It may lead to poor code readability since it may no longer be clear what class a member resides in (without looking at the import statement).</p>]]></description>
<param key="excludes" type="s{}">
<description>
<rule key="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck" priority="MINOR">
<name><![CDATA[Javadoc Package]]></name>
<configKey><![CDATA[Checker/JavadocPackage]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>Checks that each Java package has a Javadoc file used for commenting. By default it only allows a package-info.java file, but can be configured to allow a package.html file. An error will be reported if both files exist as this is not allowed by the Javadoc tool.</p>]]></description>
<param key="allowLegacy" type="b">
<description>
<rule key="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpMultilineCheck" priority="MAJOR">
<name><![CDATA[Regexp Multiline]]></name>
<configKey><![CDATA[Checker/RegexpMultiline]]></configKey>
- <category name="Maintainability"/>
+
<cardinality>MULTIPLE</cardinality>
<description><![CDATA[<p>A check for detecting that matches across multiple lines. Rationale: This check can be used to when the regular expression can be span multiple lines.</p>]]></description>
<param key="format" type="s">
<rule key="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck" priority="MAJOR">
<name><![CDATA[Regexp Singleline]]></name>
<configKey><![CDATA[Checker/RegexpSingleline]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> A check for detecting single lines that match a supplied regular expression. Works with any file type. Rationale: This check can be used to prototype checks and to find common bad practice such as calling ex.printStacktrace(), System.out.println(), System.exit(), etc.</p>]]></description>
<cardinality>MULTIPLE</cardinality>
<param key="format" type="s">
<rule key="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck" priority="MAJOR">
<name><![CDATA[Regexp Singleline Java]]></name>
<configKey><![CDATA[Checker/TreeWalker/RegexpSinglelineJava]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>This class is variation on RegexpSingleline for detecting single lines that match a supplied regular expression in Java files. It supports suppressing matches in Java comments.</p>]]></description>
<cardinality>MULTIPLE</cardinality>
<param key="format" type="s">
<rule key="com.puppycrawl.tools.checkstyle.checks.sizes.OuterTypeNumberCheck" priority="MINOR">
<name><![CDATA[Outer Type Number]]></name>
<configKey><![CDATA[Checker/TreeWalker/OuterTypeNumber]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> Checks for the number of types declared at the outer (or root) level in a file. Rationale: It is considered good practice to only define one outer type per file.</p>]]></description>
<param key="max" type="i">
<description><![CDATA[maximum allowable number of outer types. Default is 1.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck" priority="MINOR">
<name><![CDATA[File Tab Character]]></name>
<configKey><![CDATA[Checker/FileTabCharacter]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>Checks that there are no tab characters ('\t') in the source code. Rationale:
<ul>
<li>Developers should not need to configure the tab width of their text editors in order to be able to read source code.</li>
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck" priority="MINOR">
<name><![CDATA[Generic Whitespace]]></name>
<configKey><![CDATA[Checker/TreeWalker/GenericWhitespace]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>Checks that the whitespace around the Generic tokens < and > is correct to the typical convention. The convention is not configurable.</p>
<p>
For example the following is legal:
<rule key="com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck" priority="MAJOR">
<name><![CDATA[JavaNCSS]]></name>
<configKey><![CDATA[Checker/TreeWalker/JavaNCSS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[ Determines complexity of methods, classes and files by counting the Non Commenting Source Statements (NCSS). This check adheres to the specification for the JavaNCSS-Tool written by Chr. Clemens Lee.
Rougly said the NCSS metric is calculated by counting the source lines which are not comments, (nearly) equivalent to counting the semicolons and opening curly braces.
The NCSS for a class is summarized from the NCSS of all its methods, the NCSS of its nested classes and the number of member variable declarations.
<rule key="com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck" priority="MINOR">
<name><![CDATA[Redundant import]]></name>
<configKey><![CDATA[Checker/TreeWalker/RedundantImport]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks for redundant import statements. An import statement is considered redundant if:
<ul>
<li>It is a duplicate of another import. This is, when a class is imported more than once.</li>
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.AbstractClassNameCheck" priority="MAJOR">
<name><![CDATA[Abstract Class Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/AbstractClassName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Ensures that the names of abstract classes conforming to some regular expression.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.sizes.AnonInnerLengthCheck" priority="MAJOR">
<name><![CDATA[Anon Inner Length]]></name>
<configKey><![CDATA[Checker/TreeWalker/AnonInnerLength]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Checks for long anonymous inner classes.]]></description>
<param key="max" type="i">
<description><![CDATA[maximum allowable number of lines. Default is 20.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.ArrayTrailingCommaCheck" priority="MAJOR">
<name><![CDATA[Array Trailing Comma]]></name>
<configKey><![CDATA[Checker/TreeWalker/ArrayTrailingComma]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks if array initialization contains optional trailing comma.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck" priority="MINOR">
<name><![CDATA[Array Type Style]]></name>
<configKey><![CDATA[Checker/TreeWalker/ArrayTypeStyle]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks the style of array type definitions. Some like Java-style: public static void main(String[] args) and some like C-style: public static void main(String args[])]]></description>
<param key="javaStyle" type="b">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.AvoidInlineConditionalsCheck" priority="MINOR">
<name><![CDATA[Avoid Inline Conditionals]]></name>
<configKey><![CDATA[Checker/TreeWalker/AvoidInlineConditionals]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Detects inline conditionals.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksCheck" priority="MAJOR">
<name><![CDATA[Avoid Nested Blocks]]></name>
<configKey><![CDATA[Checker/TreeWalker/AvoidNestedBlocks]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Finds nested blocks.]]></description>
<param key="allowInSwitchCase" type="b">
<description><![CDATA[Allow nested blocks in case statements. Default is false.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck" priority="MINOR">
<name><![CDATA[Avoid Star Import]]></name>
<configKey><![CDATA[Checker/TreeWalker/AvoidStarImport]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Check that finds import statements that use the * notation.]]></description>
<param key="excludes" type="s{}">
<description>
<rule key="com.puppycrawl.tools.checkstyle.checks.metrics.BooleanExpressionComplexityCheck" priority="MAJOR">
<name><![CDATA[Boolean Expression Complexity]]></name>
<configKey><![CDATA[Checker/TreeWalker/BooleanExpressionComplexity]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Restricts nested boolean operators (&&, || and ^) to a specified depth (default = 3).]]></description>
<param key="max" type="i">
<rule key="com.puppycrawl.tools.checkstyle.checks.metrics.ClassDataAbstractionCouplingCheck" priority="MAJOR">
<name><![CDATA[Class Data Abstraction Coupling]]></name>
<configKey><![CDATA[Checker/TreeWalker/ClassDataAbstractionCoupling]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[This metric measures the number of instantiations of other classes within the given class.]]></description>
<param key="max" type="i">
<rule key="com.puppycrawl.tools.checkstyle.checks.metrics.ClassFanOutComplexityCheck" priority="MAJOR">
<name><![CDATA[Class Fan Out Complexity]]></name>
<configKey><![CDATA[Checker/TreeWalker/ClassFanOutComplexity]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[The number of other classes a given class relies on.]]></description>
<param key="max" type="i">
<description><![CDATA[the maximum threshold allowed. Default is 20.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck" priority="MINOR">
<name><![CDATA[Constant Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/ConstantName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that constant names conform to a format specified by the format property.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck" priority="CRITICAL">
<name><![CDATA[Covariant Equals]]></name>
<configKey><![CDATA[Checker/TreeWalker/CovariantEquals]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Checks that if a class defines a covariant method equals, then it defines method equals(java.lang.Object).]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.metrics.CyclomaticComplexityCheck" priority="MAJOR">
<name><![CDATA[Cyclomatic Complexity]]></name>
<configKey><![CDATA[Checker/TreeWalker/CyclomaticComplexity]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Checks cyclomatic complexity of methods against a specified limit. The complexity is measured by the number of if, while, do, for, ?:, catch, switch, case statements, and operators && and || (plus one) in the body of a constructor, method, static initializer, or instance initializer. It is a measure of the minimum number of possible paths through the source and therefore the number of required tests. Generally 1-4 is considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now !]]></description>
<param key="max" type="i">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck" priority="INFO">
<name><![CDATA[Declaration Order]]></name>
<configKey><![CDATA[Checker/TreeWalker/DeclarationOrder]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that the parts of a class or interface declaration appear in the order suggested by the Code Convention for the Java Programming Language : <ul><li>Class (static) variables. First the public class variables, then the protected, then package level (no access modifier), and then the private.</li><li>Instance variables. First the public class variables, then the protected, then package level (no access modifier), and then the private.</li><li>Constructors</li><li>Methods</li></ul>]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.DefaultComesLastCheck" priority="MAJOR">
<name><![CDATA[Default Comes Last]]></name>
<configKey><![CDATA[Checker/TreeWalker/DefaultComesLast]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Check that the default is after all the cases in a switch statement.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck" priority="MINOR">
<name><![CDATA[Design For Extension]]></name>
<configKey><![CDATA[Checker/TreeWalker/DesignForExtension]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Checks that classes are designed for inheritance.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.DoubleCheckedLockingCheck" priority="MAJOR">
<name><![CDATA[Double Checked Locking]]></name>
<configKey><![CDATA[Checker/TreeWalker/DoubleCheckedLocking]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Detect the double-checked locking idiom, a technique that tries to avoid synchronization overhead but is incorrect because of subtle artifacts of the java memory model.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck" priority="MAJOR">
<name><![CDATA[Empty Block]]></name>
<configKey><![CDATA[Checker/TreeWalker/EmptyBlock]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Checks for empty blocks.]]></description>
<param key="option" type="s[text,stmt]">
<description><![CDATA[policy on block contents]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck" priority="MINOR">
<name><![CDATA[Empty For Initializer Pad]]></name>
<configKey><![CDATA[Checker/TreeWalker/EmptyForInitializerPad]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks the padding of an empty for initializer; that is whether a space is required at an empty for initializer, or such spaces are forbidden. Example : <code>for ( ; i < j; i++, j--)</code>]]></description>
<param key="option" type="s[nospace,space]">
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck" priority="MINOR">
<name><![CDATA[Empty For Iterator Pad]]></name>
<configKey><![CDATA[Checker/TreeWalker/EmptyForIteratorPad]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks the padding of an empty for iterator; that is whether a space is required at an empty for iterator, or such spaces are forbidden. Example : <code>for (Iterator foo = very.long.line.iterator(); foo.hasNext(); )</code>]]></description>
<param key="option" type="s[nospace,space]">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck" priority="MINOR">
<name><![CDATA[Empty Statement]]></name>
<configKey><![CDATA[Checker/TreeWalker/EmptyStatement]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Detects empty statements (standalone ';').]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck" priority="CRITICAL">
<name><![CDATA[Equals Hash Code]]></name>
<configKey><![CDATA[Checker/TreeWalker/EqualsHashCode]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Checks that classes that override equals() also override hashCode().]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.sizes.ExecutableStatementCountCheck" priority="MAJOR">
<name><![CDATA[Executable Statement Count]]></name>
<configKey><![CDATA[Checker/TreeWalker/ExecutableStatementCount]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Restricts the number of executable statements to a specified limit (default = 30).]]></description>
<param key="max" type="i">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck" priority="MAJOR">
<name><![CDATA[Explicit Initialization]]></name>
<configKey><![CDATA[Checker/TreeWalker/ExplicitInitialization]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Checks if any class or object member explicitly initialized to default for its type value (null for object references, zero for numeric types and char and false for boolean.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck" priority="MAJOR">
<name><![CDATA[Fall Through]]></name>
<configKey><![CDATA[Checker/TreeWalker/FallThrough]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Checks for fall through in switch statements Finds locations where a case contains Java code - but lacks a break, return, throw or continue statement.]]></description>
<param key="checkLastCaseGroup" type="b">
<rule key="com.puppycrawl.tools.checkstyle.checks.sizes.FileLengthCheck" priority="MAJOR">
<name><![CDATA[File Length]]></name>
<configKey><![CDATA[Checker/FileLength]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>Checks for long source files.</p>
<p>Rationale: If a source file becomes very long it is hard to understand. Therefore long classes should usually be refactored into several individual classes that focus on a specific task.</p>]]></description>
<param key="max" type="i">
<rule key="com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck" priority="MAJOR">
<name><![CDATA[Final Class]]></name>
<configKey><![CDATA[Checker/TreeWalker/FinalClass]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks that class which has only private constructors is declared as final.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck" priority="MINOR">
<name><![CDATA[Final Local Variable]]></name>
<configKey><![CDATA[Checker/TreeWalker/FinalLocalVariable]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Ensures that local variables that never get their values changed, must be declared final.]]></description>
<param key="tokens" type="s[PARAMETER_DEF,VARIABLE_DEF]">
<rule key="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck" priority="MINOR">
<name><![CDATA[Final Parameters]]></name>
<configKey><![CDATA[Checker/TreeWalker/FinalParameters]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Check that method/constructor/catch/foreach parameters are final.]]></description>
<param key="tokens" type="s[METHOD_DEF,CTOR_DEF,LITERAL_CATCH]">
<description><![CDATA[blocks to check]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck" priority="MAJOR">
<name><![CDATA[Hidden Field]]></name>
<configKey><![CDATA[Checker/TreeWalker/HiddenField]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that a local variable or a parameter does not shadow a field that is defined in the same class.]]></description>
<param key="tokens" type="s[PARAMETER_DEF,VARIABLE_DEF]">
<rule key="com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck" priority="MAJOR">
<name><![CDATA[Hide Utility Class Constructor]]></name>
<configKey><![CDATA[Checker/TreeWalker/HideUtilityClassConstructor]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Make sure that utility classes (classes that contain only static methods) do not have a public constructor.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.IllegalCatchCheck" priority="MAJOR">
<name><![CDATA[Illegal Catch]]></name>
<configKey><![CDATA[Checker/TreeWalker/IllegalCatch]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Catching java.lang.Exception, java.lang.Error or java.lang.RuntimeException is almost never acceptable.]]></description>
<param key="illegalClassNames" type="s{}">
<rule key="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck" priority="MAJOR">
<name><![CDATA[Illegal Import]]></name>
<configKey><![CDATA[Checker/TreeWalker/IllegalImport]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks for imports from a set of illegal packages, like sun.*]]></description>
<param key="illegalPkgs" type="s{}">
<description><![CDATA[packages to reject]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.IllegalInstantiationCheck" priority="MAJOR">
<name><![CDATA[Illegal Instantiation]]></name>
<configKey><![CDATA[Checker/TreeWalker/IllegalInstantiation]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Checks for illegal instantiations where a factory method is preferred. Depending on the project, for some classes it might be preferable to create instances through factory methods rather than calling the constructor. A simple example is the <code>java.lang.Boolean</code> class. In order to save memory and CPU cycles, it is preferable to use the predefined constants TRUE and FALSE. Constructor invocations should be replaced by calls to <code>Boolean.valueOf()</code>. Some extremely performance sensitive projects may require the use of factory methods for other classes as well, to enforce the usage of number caches or object pools.]]></description>
<param key="classes" type="s{}">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.IllegalThrowsCheck" priority="MAJOR">
<name><![CDATA[Illegal Throws]]></name>
<configKey><![CDATA[Checker/TreeWalker/IllegalThrows]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Throwing java.lang.Error or java.lang.RuntimeException is almost never acceptable.]]></description>
<param key="illegalClassNames" type="s{}">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheck" priority="MAJOR">
<name><![CDATA[Illegal Token]]></name>
<configKey><![CDATA[Checker/TreeWalker/IllegalToken]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks for illegal tokens. Certain language features often lead to hard to maintain code or are non-obvious to novice developers. Other features may be discouraged in certain frameworks, such as not having native methods in EJB components.]]></description>
<param key="tokens" type="s{}">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCheck" priority="MAJOR">
<name><![CDATA[Illegal Token Text]]></name>
<configKey><![CDATA[Checker/TreeWalker/IllegalTokenText]]></configKey>
- <category name="Usability"/>
+
<cardinality>MULTIPLE</cardinality>
<description><![CDATA[Checks for illegal token text.]]></description>
<param key="tokens" type="s{}">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck" priority="MAJOR">
<name><![CDATA[Illegal Type]]></name>
<configKey><![CDATA[Checker/TreeWalker/IllegalType]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Checks that particular class are never used as types in variable declarations, return values or parameters.]]></description>
<param key="tokens" type="s[PARAMETER_DEF,VARIABLE_DEF,METHOD_DEF]">
<rule key="com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck" priority="MINOR">
<name><![CDATA[Import Order]]></name>
<configKey><![CDATA[Checker/TreeWalker/ImportOrder]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[ Checks the ordering/grouping of imports. Features are:<ul>
<li>groups imports: ensures that groups of imports come in a specific order (e.g., java. comes first, javax. comes second, then everything else)</li>
<li>adds a separation between groups : ensures that a blank line sit between each group</li>
<rule key="com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck" priority="MINOR">
<name><![CDATA[Indentation]]></name>
<configKey><![CDATA[Checker/TreeWalker/Indentation]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks correct indentation of Java Code.]]></description>
<param key="basicOffset" type="i">
<description><![CDATA[how many spaces to use for new indentation level. Default is 4.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck" priority="MAJOR">
<name><![CDATA[Inner Assignment]]></name>
<configKey><![CDATA[Checker/TreeWalker/InnerAssignment]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);.]]></description>
<param key="tokens"
<rule key="com.puppycrawl.tools.checkstyle.checks.design.InterfaceIsTypeCheck" priority="MAJOR">
<name><![CDATA[Interface Is Type]]></name>
<configKey><![CDATA[Checker/TreeWalker/InterfaceIsType]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Implements Bloch, Effective Java, Item 17 - Use Interfaces only to define types. According to Bloch, an interface should describe a type. It is therefore inappropriate to define an interface that does not contain any methods but only constants. The Standard class javax.swing.SwingConstants is an example of a class that would be flagged by this check. The check can be configured to also disallow marker interfaces like java.io.Serializable, that do not contain methods or constants at all.]]></description>
<param key="allowMarkerInterfaces" type="b">
<rule key="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck" priority="MAJOR">
<name><![CDATA[Javadoc Method]]></name>
<configKey><![CDATA[Checker/TreeWalker/JavadocMethod]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks the Javadoc of a method or constructor. By default, does not check for unused throws.
To allow documented java.lang.RuntimeExceptions that are not declared, set property allowUndeclaredRTE to true.
The scope to verify is specified using the Scope class and defaults to Scope.PRIVATE.
<rule key="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck" priority="MAJOR">
<name><![CDATA[Javadoc Style]]></name>
<configKey><![CDATA[Checker/TreeWalker/JavadocStyle]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Validates Javadoc comments to help ensure they are well formed. The following checks are performed:
<ul>
<li>Ensures the first sentence ends with proper punctuation (That is a period, question mark, or exclamation mark, by default).
<rule key="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck" priority="MAJOR">
<name><![CDATA[Javadoc Type]]></name>
<configKey><![CDATA[Checker/TreeWalker/JavadocType]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks Javadoc comments for class and interface definitions. By default, does not check for author or version tags.
The scope to verify is specified using the Scope class and defaults to Scope.PRIVATE. To verify another scope, set property scope to one of the Scope constants.
To define the format for an author tag or a version tag, set property authorFormat or versionFormat respectively to a regular expression.
<rule key="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck" priority="MAJOR">
<name><![CDATA[Javadoc Variable]]></name>
<configKey><![CDATA[Checker/TreeWalker/JavadocVariable]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks that a variable has Javadoc comment.]]></description>
<param key="scope" type="s[nothing,public,protected,package,private,anoninner]">
<description><![CDATA[visibility scope where Javadoc comments are checked]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck" priority="MINOR">
<name><![CDATA[Left Curly]]></name>
<configKey><![CDATA[Checker/TreeWalker/LeftCurly]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks for the placement of left curly braces for code blocks. The policy to verify is specified using property option. Policies <code>eol</code> and <code>nlow</code> take into account property maxLineLength.]]></description>
<param key="option" type="s[eol,nl,nlow]">
<rule key="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck" priority="MAJOR">
<name><![CDATA[Line Length]]></name>
<configKey><![CDATA[Checker/TreeWalker/LineLength]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Checks for long lines.]]></description>
<param key="ignorePattern" type="r">
<description><![CDATA[pattern for lines to ignore]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.LocalFinalVariableNameCheck" priority="MAJOR">
<name><![CDATA[Local Final Variable Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/LocalFinalVariableName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that local final variable names conform to a format specified by the format property.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck" priority="MAJOR">
<name><![CDATA[Local Variable Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/LocalVariableName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that local, non-final variable names conform to a format specified by the format property.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck" priority="MINOR">
<name><![CDATA[Magic Number]]></name>
<configKey><![CDATA[Checker/TreeWalker/MagicNumber]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Checks for magic numbers.]]></description>
<param key="tokens" type="s[NUM_DOUBLE,NUM_FLOAT,NUM_INT,NUM_LONG]">
<description><![CDATA[tokens to check]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck" priority="MAJOR">
<name><![CDATA[Member Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/MemberName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that instance variable names conform to a format specified by the format property.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.sizes.MethodLengthCheck" priority="MAJOR">
<name><![CDATA[Method Length]]></name>
<configKey><![CDATA[Checker/TreeWalker/MethodLength]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Checks for long methods.]]></description>
<param key="max" type="i">
<description><![CDATA[maximum allowable number of lines. Default is 150.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck" priority="MAJOR">
<name><![CDATA[Method Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/MethodName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that method names conform to a format specified by the format property.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck" priority="MAJOR">
<name><![CDATA[Method Param Pad]]></name>
<configKey><![CDATA[Checker/TreeWalker/MethodParamPad]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks the padding between the identifier of a method definition, constructor definition, method call, or constructor invocation; and the left parenthesis of the parameter list.]]></description>
<param key="allowLineBreaks" type="b">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.MissingCtorCheck" priority="MAJOR">
<name><![CDATA[Missing Constructor]]></name>
<configKey><![CDATA[Checker/TreeWalker/MissingCtor]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that classes (except abstract one) define a constructor and don't rely on the default one.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.MissingSwitchDefaultCheck" priority="MAJOR">
<name><![CDATA[Missing Switch Default]]></name>
<configKey><![CDATA[Checker/TreeWalker/MissingSwitchDefault]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Checks that switch statement has default clause.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck" priority="MAJOR">
<name><![CDATA[Modified Control Variable]]></name>
<configKey><![CDATA[Checker/TreeWalker/ModifiedControlVariable]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Check for ensuring that for loop control variables are not modified inside the for block.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.modifier.ModifierOrderCheck" priority="MINOR">
<name><![CDATA[Modifier Order]]></name>
<configKey><![CDATA[Checker/TreeWalker/ModifierOrder]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that the order of modifiers conforms to the suggestions in the Java Language specification, sections 8.1.1, 8.3.1 and 8.4.3. The correct order is : public, protected, private, abstract, static, final, transient, volatile, synchronized, native, strictfp.]]></description>
</rule>
<name><![CDATA[Multiple String Literals]]></name>
<configKey><![CDATA[Checker/TreeWalker/MultipleStringLiterals]]></configKey>
<cardinality>MULTIPLE</cardinality>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Checks for multiple occurrences of the same string literal within a single file. Code duplication makes maintenance more difficult, so it can be better to replace the multiple occurrences with a constant.]]></description>
<param key="allowedDuplicates" type="i">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck" priority="MAJOR">
<name><![CDATA[Multiple Variable Declarations]]></name>
<configKey><![CDATA[Checker/TreeWalker/MultipleVariableDeclarations]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that each variable declaration is in its own statement and on its own line.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.design.MutableExceptionCheck" priority="MAJOR">
<name><![CDATA[Mutable Exception]]></name>
<configKey><![CDATA[Checker/TreeWalker/MutableException]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Ensures that exceptions (defined as any class name conforming to some regular expression) are immutable.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.metrics.NPathComplexityCheck" priority="MAJOR">
<name><![CDATA[NPath Complexity]]></name>
<configKey><![CDATA[Checker/TreeWalker/NPathComplexity]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Checks the npath complexity of a method against a specified limit (default = 200). The NPATH metric computes the number of possible execution paths through a function. It takes into account the nesting of conditional statements and multi-part boolean expressions (e.g., A && B, C || D, etc.).]]></description>
<param key="max" type="i">
<rule key="com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck" priority="MINOR">
<name><![CDATA[Need Braces]]></name>
<configKey><![CDATA[Checker/TreeWalker/NeedBraces]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks for braces around code blocks.]]></description>
<param key="tokens" type="s[LITERAL_DO,LITERAL_ELSE,LITERAL_IF,LITERAL_FOR,LITERAL_WHILE]">
<description><![CDATA[blocks to check]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck" priority="MAJOR">
<name><![CDATA[Nested If Depth]]></name>
<configKey><![CDATA[Checker/TreeWalker/NestedIfDepth]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Restricts nested if-else blocks to a specified depth (default = 1).]]></description>
<param key="max" type="i">
<description><![CDATA[allowed nesting depth. Default is 1.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck" priority="MAJOR">
<name><![CDATA[Nested Try Depth]]></name>
<configKey><![CDATA[Checker/TreeWalker/NestedTryDepth]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Restricts nested try-catch-finally blocks to a specified depth (default = 1).]]></description>
<param key="max" type="i">
<description><![CDATA[allowed nesting depth. Default is 1.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck" priority="MINOR">
<name><![CDATA[Newline At End Of File]]></name>
<configKey><![CDATA[Checker/NewlineAtEndOfFile]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that there is a newline at the end of each file. Any source files and text files in general should end with a newline character, especially when using SCM systems such as CVS. CVS will even print a warning when it encounters a file that doesn't end with a newline.]]></description>
<param key="lineSeparator" type="s[system,crlf,cr,lf]">
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfterCheck" priority="MINOR">
<name><![CDATA[No Whitespace After]]></name>
<configKey><![CDATA[Checker/TreeWalker/NoWhitespaceAfter]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks that there is no whitespace after a token.]]></description>
<param key="allowLineBreaks" type="b">
<description>
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck" priority="MINOR">
<name><![CDATA[No Whitespace Before]]></name>
<configKey><![CDATA[Checker/TreeWalker/NoWhitespaceBefore]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks that there is no whitespace before a token.]]></description>
<param key="allowLineBreaks" type="b">
<description>
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck" priority="MINOR">
<name><![CDATA[Operator Wrap]]></name>
<configKey><![CDATA[Checker/TreeWalker/OperatorWrap]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks the policy on how to wrap lines on operators.]]></description>
<param key="option" type="s[nl,eol]">
<description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.PackageDeclarationCheck" priority="MAJOR">
<name><![CDATA[Package Declaration]]></name>
<configKey><![CDATA[Checker/TreeWalker/PackageDeclaration]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Ensures there is a package declaration.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck" priority="MAJOR">
<name><![CDATA[Package Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/PackageName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that package names conform to a format specified by the format property.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.ParameterAssignmentCheck" priority="MAJOR">
<name><![CDATA[Parameter Assignment]]></name>
<configKey><![CDATA[Checker/TreeWalker/ParameterAssignment]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Disallow assignment of parameters.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck" priority="MAJOR">
<name><![CDATA[Parameter Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/ParameterName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that parameter names conform to a format specified by the format property.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck" priority="MAJOR">
<name><![CDATA[Parameter Number]]></name>
<configKey><![CDATA[Checker/TreeWalker/ParameterNumber]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Checks the number of parameters that a method or constructor has.]]></description>
<param key="max" type="i">
<description><![CDATA[maximum allowable number of parameters. Default is 7.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck" priority="MINOR">
<name><![CDATA[Paren Pad]]></name>
<configKey><![CDATA[Checker/TreeWalker/ParenPad]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks the padding of parentheses; that is whether a space is required after a left parenthesis and before a right parenthesis, or such spaces are forbidden, with the exception that it does not check for padding of the right parenthesis at an empty for iterator.]]></description>
<param key="option" type="s[nospace,space]">
<rule key="com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck" priority="MINOR">
<name><![CDATA[Redundant Modifier]]></name>
<configKey><![CDATA[Checker/TreeWalker/RedundantModifier]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Checks for redundant modifiers in interface and annotation definitions.]]></description>
<param key="tokens" type="s[METHOD_DEF,VARIABLE_DEF,ANNOTATION_FIELD_DEF]">
<description><![CDATA[tokens to check]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.RedundantThrowsCheck" priority="MINOR">
<name><![CDATA[Redundant Throws]]></name>
<configKey><![CDATA[Checker/TreeWalker/RedundantThrows]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Checks for redundant exceptions declared in throws clause such as duplicates, unchecked exceptions or subclasses of another declared exception.]]></description>
<param key="allowUnchecked" type="b">
<rule key="com.puppycrawl.tools.checkstyle.checks.RegexpCheck" priority="MAJOR">
<name><![CDATA[Regexp]]></name>
<configKey><![CDATA[Checker/TreeWalker/Regexp]]></configKey>
- <category name="Usability"/>
+
<cardinality>MULTIPLE</cardinality>
<description><![CDATA[A check that makes sure that a specified pattern exists (or not) in the file.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck" priority="MAJOR">
<name><![CDATA[Require This]]></name>
<configKey><![CDATA[Checker/TreeWalker/RequireThis]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks that code doesn't rely on the this default.]]></description>
<param key="checkFields" type="b">
<description><![CDATA[whether we should check fields usage or not. Default is true.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.ReturnCountCheck" priority="MAJOR">
<name><![CDATA[Return Count]]></name>
<configKey><![CDATA[Checker/TreeWalker/ReturnCount]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Restricts return statements to a specified count (default = 2).]]></description>
<param key="max" type="i">
<description><![CDATA[maximum allowed number of return statments]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck" priority="MINOR">
<name><![CDATA[Right Curly]]></name>
<configKey><![CDATA[Checker/TreeWalker/RightCurly]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks the placement of right curly braces.]]></description>
<param key="option" type="s[same,alone]">
<description><![CDATA[policy on placement of a right curly brace ('}')]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpressionCheck" priority="MAJOR">
<name><![CDATA[Simplify Boolean Expression]]></name>
<configKey><![CDATA[Checker/TreeWalker/SimplifyBooleanExpression]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Checks for overly complicated boolean expressions.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck" priority="MAJOR">
<name><![CDATA[Simplify Boolean Return]]></name>
<configKey><![CDATA[Checker/TreeWalker/SimplifyBooleanReturn]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Checks for overly complicated boolean return statements.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.StaticVariableNameCheck" priority="MAJOR">
<name><![CDATA[Static Variable Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/StaticVariableName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that static, non-final variable names conform to a format specified by the format property.]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.duplicates.StrictDuplicateCodeCheck" priority="MAJOR">
<name><![CDATA[Strict Duplicate Code]]></name>
<configKey><![CDATA[Checker/StrictDuplicateCode]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Performs a line-by-line comparison of all code lines and reports duplicate code if a sequence of lines differs only in indentation.]]></description>
<param key="min" type="i">
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.StringLiteralEqualityCheck" priority="MAJOR">
<name><![CDATA[String Literal Equality]]></name>
<configKey><![CDATA[Checker/TreeWalker/StringLiteralEquality]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Checks that string literals are not used with == or !=.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.SuperCloneCheck" priority="MAJOR">
<name><![CDATA[Super Clone]]></name>
<configKey><![CDATA[Checker/TreeWalker/SuperClone]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Checks that an overriding clone() method invokes super.clone().]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.SuperFinalizeCheck" priority="MAJOR">
<name><![CDATA[Super Finalize]]></name>
<configKey><![CDATA[Checker/TreeWalker/SuperFinalize]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Checks that an overriding finalize() method invokes super.finalize().]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.design.ThrowsCountCheck" priority="MAJOR">
<name><![CDATA[Throws Count]]></name>
<configKey><![CDATA[Checker/TreeWalker/ThrowsCount]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Restricts throws statements to a specified count (default = 1).]]></description>
<param key="max" type="i">
<description><![CDATA[maximum allowed number of throws statments]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck" priority="MINOR">
<name><![CDATA[Comment pattern matcher]]></name>
<configKey><![CDATA[Checker/TreeWalker/TodoComment]]></configKey>
- <category name="Maintainability"/>
+
<cardinality>MULTIPLE</cardinality>
<description><![CDATA[This rule allows to find any kind of pattern inside comments like TODO, NOPMD, ..., except NOSONAR]]></description>
<param key="format" type="r">
<rule key="com.puppycrawl.tools.checkstyle.checks.indentation.TrailingCommentCheck" priority="MINOR">
<name><![CDATA[Trailing Comment]]></name>
<configKey><![CDATA[Checker/TreeWalker/TrailingComment]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[The check to ensure that requires that comments be the only thing on a line.]]></description>
<param key="format" type="r">
<description><![CDATA[pattern for string allowed before comment.]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.TranslationCheck" priority="MINOR">
<name><![CDATA[Translation]]></name>
<configKey><![CDATA[Checker/Translation]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Ensures the correct translation of code by checking property files for consistency regarding their keys. Two property files describing one and the same context are consistent if they contain the same keys.]]></description>
<param key="fileExtensions" type="s{}">
<rule key="com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck" priority="MAJOR">
<name><![CDATA[Type Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/TypeName]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks that type names conform to a format specified by the format property.]]></description>
<param key="format" type="r">
<description><![CDATA[Validates identifiers for classes and interfaces]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck" priority="MAJOR">
<name><![CDATA[Typecast Paren Pad]]></name>
<configKey><![CDATA[Checker/TreeWalker/TypecastParenPad]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks the padding of parentheses for typecasts.]]></description>
<param key="option" type="s[nospace,space]">
<description><![CDATA[policy on how to pad parentheses]]></description>
<rule key="com.puppycrawl.tools.checkstyle.checks.UncommentedMainCheck" priority="MAJOR">
<name><![CDATA[Uncommented Main]]></name>
<configKey><![CDATA[Checker/TreeWalker/UncommentedMain]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Detects uncommented main methods.]]></description>
<param key="excludedClasses" type="r">
<description>
<rule key="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck" priority="MINOR">
<name><![CDATA[Unnecessary Parentheses]]></name>
<configKey><![CDATA[Checker/TreeWalker/UnnecessaryParentheses]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks if unnecessary parentheses are used in a statement or expression.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck" priority="INFO">
<name><![CDATA[Unused Imports]]></name>
<configKey><![CDATA[Checker/TreeWalker/UnusedImports]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Checks for unused import statements.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck" priority="MINOR">
<name><![CDATA[Upper Ell]]></name>
<configKey><![CDATA[Checker/TreeWalker/UpperEll]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks that long constants are defined with an upper ell. That is ' L' and not 'l'.
This is in accordance to the Java Language Specification, <a href="http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48282">Section 3.10.1</a>.]]></description>
</rule>
<rule key="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck" priority="MAJOR">
<name><![CDATA[Visibility Modifier]]></name>
<configKey><![CDATA[Checker/TreeWalker/VisibilityModifier]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Checks visibility of class members. Only static final members may be public; other class members must be private unless property protectedAllowed or packageAllowed is set.]]></description>
<param key="packageAllowed" type="b">
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck" priority="MINOR">
<name><![CDATA[Whitespace After]]></name>
<configKey><![CDATA[Checker/TreeWalker/WhitespaceAfter]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Checks that a token is followed by whitespace, with the exception that it does not check for whitespace after the semicolon of an empty for iterator.]]></description>
<param key="tokens" type="s[COMMA,SEMI,TYPECAST]">
<rule key="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck" priority="MINOR">
<name><![CDATA[Whitespace Around]]></name>
<configKey><![CDATA[Checker/TreeWalker/WhitespaceAround]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Checks that a token is surrounded by whitespace.]]></description>
<param key="tokens"
type="s[ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,GENERIC_START,GENERIC_END,TYPE_EXTENSION_AND,WILDCARD_TYPE]">
<rule key="com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck" priority="MINOR">
<name><![CDATA[Write Tag]]></name>
<configKey><![CDATA[Checker/TreeWalker/WriteTag]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Outputs a JavaDoc tag as information. Can be used e.g. with the stylesheets that sort the report by author name. To define the format for a tag, set property tagFormat to a regular expression. This check uses two different severity levels. The normal one is used for reporting when the tag is missing. The additional one (tagSeverity) is used for the level of reporting when the tag exists.]]></description>
<param key="tag" type="s">
<rule key="BC_IMPOSSIBLE_DOWNCAST" priority="BLOCKER">
<name><![CDATA[Correctness - Impossible downcast]]></name>
<configKey><![CDATA[BC_IMPOSSIBLE_DOWNCAST]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[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.]]></description>
</rule>
<rule key="BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY" priority="BLOCKER">
<name><![CDATA[Correctness - Impossible downcast of toArray() result]]></name>
<configKey><![CDATA[BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>This code is casting the result of calling toArray() on a collection to a type more specific than Object[], as in:</p>
<pre>
String[] getAsArray(Collection<String> c) {
<rule key="EC_INCOMPATIBLE_ARRAY_COMPARE" priority="BLOCKER">
<name><![CDATA[Correctness - equals(...) used to compare incompatible arrays]]></name>
<configKey><![CDATA[EC_INCOMPATIBLE_ARRAY_COMPARE]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[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.]]></description>
</rule>
<rule key="EC_INCOMPATIBLE_ARRAY_COMPARE" priority="BLOCKER">
<name><![CDATA[Correctness - equals(...) used to compare incompatible arrays]]></name>
<configKey><![CDATA[EC_INCOMPATIBLE_ARRAY_COMPARE]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[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.]]></description>
</rule>
<rule key="LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE" priority="MAJOR">
<name><![CDATA[Correctness - Potential lost logger changes due to weak reference in OpenJDK ]]></name>
<configKey><![CDATA[LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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:</p>
</pre>
public static void initLogging() throws Exception {
<rule key="NP_CLOSING_NULL" priority="BLOCKER">
<name><![CDATA[Correctness - close() invoked on a value that is always null]]></name>
<configKey><![CDATA[NP_CLOSING_NULL]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[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.]]></description>
</rule>
<rule key="RC_REF_COMPARISON_BAD_PRACTICE" priority="MAJOR">
<name><![CDATA[Correctness - Suspicious reference comparison to constant]]></name>
<configKey><![CDATA[RC_REF_COMPARISON_BAD_PRACTICE]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[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.]]></description>
</rule>
<rule key="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN" priority="MAJOR">
<name><![CDATA[Correctness - Suspicious reference comparison of Boolean values]]></name>
<configKey><![CDATA[RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[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(...)]]></description>
</rule>
<rule key="RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED" priority="MAJOR">
<name><![CDATA[Correctness - Return value of putIfAbsent ignored, value passed to putIfAbsent reused ]]></name>
<configKey><![CDATA[RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[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.]]></description>
</rule>
<rule key="SIC_THREADLOCAL_DEADLY_EMBRACE" priority="MAJOR">
<name><![CDATA[Correctness - Deadly embrace of non-static inner class and thread local]]></name>
<configKey><![CDATA[SIC_THREADLOCAL_DEADLY_EMBRACE]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[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.]]></description>
</rule>
<rule key="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR" priority="MAJOR">
<name><![CDATA[Correctness - Uninitialized read of field method called from constructor of superclass]]></name>
<configKey><![CDATA[UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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:</p>
<pre>
abstract class A {
<rule key="VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED" priority="MAJOR">
<name><![CDATA[Correctness - MessageFormat supplied where printf style format expected ]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[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.]]></description>
</rule>
<rule key="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" priority="MINOR">
<name><![CDATA[Correctness - Field not initialized in constructor]]></name>
<configKey><![CDATA[UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>This field is never initialized within any constructor, and is therefore could be null after the object is constructed. 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.</p>]]></description>
</rule>
<rule key="NP_UNWRITTEN_FIELD" priority="MAJOR">
<name><![CDATA[Correctness - Read of unwritten field]]></name>
<configKey><![CDATA[NP_UNWRITTEN_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>The program is dereferencing a field that does not seem to ever have a non-null value written to it. Dereferencing this value will generate a null pointer exception.</p>]]></description>
</rule>
<rule key="UWF_UNWRITTEN_FIELD" priority="MINOR">
<name><![CDATA[Correctness - Unwritten field]]></name>
<configKey><![CDATA[UWF_UNWRITTEN_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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.</p>]]></description>
</rule>
<rule key="SKIPPED_CLASS_TOO_BIG" priority="MINOR">
<name><![CDATA[Dodgy - Class too big for analysis]]></name>
<configKey><![CDATA[SKIPPED_CLASS_TOO_BIG]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>This class is bigger than can be effectively handled, and was not fully analyzed for errors.
</p>]]></description>
</rule>
<rule key="DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS" priority="MINOR">
<name><![CDATA[Correctness - Creation of ScheduledThreadPoolExecutor with zero core threads]]></name>
<configKey><![CDATA[DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>(<a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html#ScheduledThreadPoolExecutor(int)">Javadoc</a>)
A ScheduledThreadPoolExecutor with zero core threads will never execute anything; changes to the max pool size are ignored.
</p>]]></description>
<rule key="DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR" priority="MINOR">
<name><![CDATA[Correctness - Futile attempt to change max pool size of ScheduledThreadPoolExecutor]]></name>
<configKey><![CDATA[DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>(<a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html">Javadoc</a>)
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.
</p>]]></description>
<rule key="DMI_UNSUPPORTED_METHOD" priority="MAJOR">
<name><![CDATA[Dodgy - Call to unsupported method]]></name>
<configKey><![CDATA[DMI_UNSUPPORTED_METHOD]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>All targets of this method invocation throw an UnsupportedOperationException.
</p>]]></description>
</rule>
<rule key="DMI_EMPTY_DB_PASSWORD" priority="CRITICAL">
<name><![CDATA[Security - Empty database password]]></name>
<configKey><![CDATA[DMI_EMPTY_DB_PASSWORD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>This code creates a database connect using a blank or empty password. This indicates that the database is not protected by a password.
</p>]]></description>
</rule>
<rule key="DMI_CONSTANT_DB_PASSWORD" priority="BLOCKER">
<name><![CDATA[Security - Hardcoded constant database password]]></name>
<configKey><![CDATA[DMI_CONSTANT_DB_PASSWORD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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.
</p>]]></description>
<rule key="HRS_REQUEST_PARAMETER_TO_COOKIE" priority="MAJOR">
<name><![CDATA[Security - HTTP cookie formed from untrusted input]]></name>
<configKey><![CDATA[HRS_REQUEST_PARAMETER_TO_COOKIE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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 <a href="http://en.wikipedia.org/wiki/HTTP_response_splitting">http://en.wikipedia.org/wiki/HTTP_response_splitting</a>
for more information.</p>
<rule key="HRS_REQUEST_PARAMETER_TO_HTTP_HEADER" priority="MAJOR">
<name><![CDATA[Security - HTTP Response splitting vulnerability]]></name>
<configKey><![CDATA[HRS_REQUEST_PARAMETER_TO_HTTP_HEADER]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>This code directly writes an HTTP parameter to an HTTP header, which allows for a HTTP response splitting
vulnerability. See <a href="http://en.wikipedia.org/wiki/HTTP_response_splitting">http://en.wikipedia.org/wiki/HTTP_response_splitting</a>
for more information.</p>
<rule key="XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER" priority="CRITICAL">
<name><![CDATA[Security - Servlet reflected cross site scripting vulnerability]]></name>
<configKey><![CDATA[XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>This code directly writes an HTTP parameter to Servlet output, which allows for a reflected cross site scripting
vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a>
for more information.</p>
<rule key="XSS_REQUEST_PARAMETER_TO_SEND_ERROR" priority="CRITICAL">
<name><![CDATA[Security - Servlet reflected cross site scripting vulnerability]]></name>
<configKey><![CDATA[XSS_REQUEST_PARAMETER_TO_SEND_ERROR]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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 <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a>
<rule key="XSS_REQUEST_PARAMETER_TO_JSP_WRITER" priority="CRITICAL">
<name><![CDATA[Security - JSP reflected cross site scripting vulnerability]]></name>
<configKey><![CDATA[XSS_REQUEST_PARAMETER_TO_JSP_WRITER]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>This code directly writes an HTTP parameter to JSP output, which allows for a cross site scripting
vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a>
for more information.</p>
<rule key="SW_SWING_METHODS_INVOKED_IN_SWING_THREAD" priority="MAJOR">
<name><![CDATA[Bad practice - Certain swing methods needs to be invoked in Swing thread]]></name>
<configKey><![CDATA[SW_SWING_METHODS_INVOKED_IN_SWING_THREAD]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>(<a href="http://java.sun.com/developer/JDCTechTips/2003/tt1208.html#1">From JDC Tech Tip</a>): 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.
<rule key="IL_INFINITE_LOOP" priority="CRITICAL">
<name><![CDATA[Correctness - An apparent infinite loop]]></name>
<configKey><![CDATA[IL_INFINITE_LOOP]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>This loop doesn't seem to have a way to terminate (other than by perhaps
throwing an exception).</p>]]></description>
</rule>
<rule key="IL_INFINITE_RECURSIVE_LOOP" priority="CRITICAL">
<name><![CDATA[Correctness - An apparent infinite recursive loop]]></name>
<configKey><![CDATA[IL_INFINITE_RECURSIVE_LOOP]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>This method unconditionally invokes itself. This would seem to indicate
an infinite recursive loop that will result in a stack overflow.</p>]]></description>
</rule>
<rule key="IL_CONTAINER_ADDED_TO_ITSELF" priority="CRITICAL">
<name><![CDATA[Correctness - A collection is added to itself]]></name>
<configKey><![CDATA[IL_CONTAINER_ADDED_TO_ITSELF]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>A collection is added to itself. As a result, computing the hashCode of this
set will throw a StackOverflowException.
</p>]]></description>
<name>
<![CDATA[Multithreaded correctness - A volatile reference to an array doesn't treat the array elements as volatile]]></name>
<configKey><![CDATA[VO_VOLATILE_REFERENCE_TO_ARRAY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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
<rule key="UI_INHERITANCE_UNSAFE_GETRESOURCE" priority="MAJOR">
<name><![CDATA[Bad practice - Usage of GetResource may be unsafe if class is extended]]></name>
<configKey><![CDATA[UI_INHERITANCE_UNSAFE_GETRESOURCE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>Calling <code>this.getClass().getResource(...)</code> could give
results other than expected if this class is extended by a class in
another package.</p>]]></description>
<rule key="NP_BOOLEAN_RETURN_NULL" priority="MAJOR">
<name><![CDATA[Bad practice - Method with Boolean return type returns explicit null]]></name>
<configKey><![CDATA[NP_BOOLEAN_RETURN_NULL]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>
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
<rule key="NP_SYNC_AND_NULL_CHECK_FIELD" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Synchronize and null check on the same field.]]></name>
<configKey><![CDATA[NP_SYNC_AND_NULL_CHECK_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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
<rule key="RpC_REPEATED_CONDITIONAL_TEST" priority="MAJOR">
<name><![CDATA[Correctness - Repeated conditional tests]]></name>
<configKey><![CDATA[RpC_REPEATED_CONDITIONAL_TEST]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>The code contains a conditional test is performed twice, one right after the other
(e.g., <code>x == 0 || x == 0</code>). Perhaps the second occurrence is intended to be something else
(e.g., <code>x == 0 || y == 0</code>).
<rule key="AM_CREATES_EMPTY_ZIP_FILE_ENTRY" priority="MAJOR">
<name><![CDATA[Bad practice - Creates an empty zip file entry]]></name>
<configKey><![CDATA[AM_CREATES_EMPTY_ZIP_FILE_ENTRY]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>The code calls <code>putNextEntry()</code>, immediately
followed by a call to <code>closeEntry()</code>. This results
in an empty ZipFile entry. The contents of the entry
<rule key="AM_CREATES_EMPTY_JAR_FILE_ENTRY" priority="MAJOR">
<name><![CDATA[Bad practice - Creates an empty jar file entry]]></name>
<configKey><![CDATA[AM_CREATES_EMPTY_JAR_FILE_ENTRY]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>The code calls <code>putNextEntry()</code>, immediately
followed by a call to <code>closeEntry()</code>. This results
in an empty JarFile entry. The contents of the entry
<rule key="IMSE_DONT_CATCH_IMSE" priority="MAJOR">
<name><![CDATA[Bad practice - Dubious catching of IllegalMonitorStateException]]></name>
<configKey><![CDATA[IMSE_DONT_CATCH_IMSE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>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).</p>]]></description>
<rule key="FL_MATH_USING_FLOAT_PRECISION" priority="CRITICAL">
<name><![CDATA[Correctness - Method performs math using floating point precision]]></name>
<configKey><![CDATA[FL_MATH_USING_FLOAT_PRECISION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
The method performs math operations using floating point precision.
Floating point precision is very imprecise. For example,
<rule key="CN_IDIOM" priority="MAJOR">
<name><![CDATA[Bad practice - Class implements Cloneable but does not define or use clone method]]></name>
<configKey><![CDATA[CN_IDIOM]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>
Class implements Cloneable but does not define or
use the clone method.</p>]]></description>
<rule key="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE" priority="MAJOR">
<name><![CDATA[Bad practice - Class defines clone() but doesn't implement Cloneable]]></name>
<configKey><![CDATA[CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.
<rule key="CN_IDIOM_NO_SUPER_CALL" priority="MAJOR">
<name><![CDATA[Bad practice - clone method does not call super.clone()]]></name>
<configKey><![CDATA[CN_IDIOM_NO_SUPER_CALL]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This non-final class defines a clone() method that does not call super.clone().
If this class ("<i>A</i>") is extended by a subclass ("<i>B</i>"),
and the subclass <i>B</i> calls super.clone(), then it is likely that
<rule key="NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER" priority="MAJOR">
<name><![CDATA[Bad practice - Use of identifier that is a keyword in later versions of Java]]></name>
<configKey><![CDATA[NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>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.</p>]]></description>
</rule>
<rule key="NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER" priority="MAJOR">
<name><![CDATA[Bad practice - Use of identifier that is a keyword in later versions of Java]]></name>
<configKey><![CDATA[NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>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.</p>]]></description>
<rule key="DE_MIGHT_DROP" priority="MAJOR">
<name><![CDATA[Bad practice - Method might drop exception]]></name>
<configKey><![CDATA[DE_MIGHT_DROP]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="DE_MIGHT_IGNORE" priority="MAJOR">
<name><![CDATA[Bad practice - Method might ignore exception]]></name>
<configKey><![CDATA[DE_MIGHT_IGNORE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="DP_DO_INSIDE_DO_PRIVILEGED" priority="MAJOR">
<name><![CDATA[Bad practice - Method invoked that should be only be invoked inside a doPrivileged block]]></name>
<configKey><![CDATA[DP_DO_INSIDE_DO_PRIVILEGED]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED" priority="MAJOR">
<name><![CDATA[Bad practice - Classloaders should only be created inside doPrivileged block]]></name>
<configKey><![CDATA[DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This code creates a classloader, which requires a security manager.
If this code will be granted security permissions, but might be invoked by code that does not
have security permissions, then the classloader creation needs to occur inside a doPrivileged block.</p>]]></description>
<rule key="JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS" priority="MINOR">
<name><![CDATA[Bad practice - Fields of immutable classes should be final]]></name>
<configKey><![CDATA[JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> The class is annotated with net.jcip.annotations.Immutable, and the rules for that annotation require
that all fields are final.
.</p>]]></description>
<rule key="DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED" priority="MAJOR">
<name><![CDATA[Dodgy - Thread passed where Runnable expected]]></name>
<configKey><![CDATA[DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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.
<rule key="DMI_COLLECTION_OF_URLS" priority="BLOCKER">
<name><![CDATA[Performance - Maps and sets of URLs can be performance hogs]]></name>
<configKey><![CDATA[DMI_COLLECTION_OF_URLS]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> 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 <a href="http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html</a> for more information.
<rule key="DMI_BLOCKING_METHODS_ON_URL" priority="BLOCKER">
<name><![CDATA[Performance - The equals and hashCode methods of URL are blocking]]></name>
<configKey><![CDATA[DMI_BLOCKING_METHODS_ON_URL]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> The equals and hashCode
method of URL perform domain name resolution, this can result in a big performance hit.
See <a href="http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html</a> for more information.
<name>
<![CDATA[Correctness - Can't use reflection to check for presence of annotation without runtime retention]]></name>
<configKey><![CDATA[DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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).
.</p>]]></description>
<rule key="DM_EXIT" priority="MAJOR">
<name><![CDATA[Bad practice - Method invokes System.exit(...)]]></name>
<configKey><![CDATA[DM_EXIT]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.
<rule key="DM_RUN_FINALIZERS_ON_EXIT" priority="MAJOR">
<name><![CDATA[Bad practice - Method invokes dangerous method runFinalizersOnExit]]></name>
<configKey><![CDATA[DM_RUN_FINALIZERS_ON_EXIT]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> <em>Never call System.runFinalizersOnExit
or Runtime.runFinalizersOnExit for any reason: they are among the most
dangerous methods in the Java libraries.</em> -- Joshua Bloch</p>]]></description>
<rule key="DM_STRING_CTOR" priority="MAJOR">
<name><![CDATA[Performance - Method invokes inefficient new String(String) constructor]]></name>
<configKey><![CDATA[DM_STRING_CTOR]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> Using the <code>java.lang.String(String)</code> constructor wastes memory
because the object so constructed will be functionally indistinguishable
from the <code>String</code> passed as a parameter. Just use the
<rule key="DM_STRING_VOID_CTOR" priority="MAJOR">
<name><![CDATA[Performance - Method invokes inefficient new String() constructor]]></name>
<configKey><![CDATA[DM_STRING_VOID_CTOR]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> Creating a new <code>java.lang.String</code> object using the
no-argument constructor wastes memory because the object so created will
be functionally indistinguishable from the empty string constant
<rule key="DM_STRING_TOSTRING" priority="INFO">
<name><![CDATA[Performance - Method invokes toString() method on a String]]></name>
<configKey><![CDATA[DM_STRING_TOSTRING]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> Calling <code>String.toString()</code> is just a redundant operation.
Just use the String.</p>]]></description>
</rule>
<rule key="DM_GC" priority="MAJOR">
<name><![CDATA[Performance - Explicit garbage collection; extremely dubious except in benchmarking code]]></name>
<configKey><![CDATA[DM_GC]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> Code explicitly invokes garbage collection.
Except for specific use in benchmarking, this is very dubious.</p>
<p>In the past, situations where people have explicitly invoked
<name>
<![CDATA[Performance - Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead]]></name>
<configKey><![CDATA[DM_BOOLEAN_CTOR]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> Creating new instances of <code>java.lang.Boolean</code> wastes
memory, since <code>Boolean</code> objects are immutable and there are
only two useful values of this type. Use the <code>Boolean.valueOf()</code>
<rule key="DM_NUMBER_CTOR" priority="CRITICAL">
<name><![CDATA[Performance - Method invokes inefficient Number constructor; use static valueOf instead]]></name>
<configKey><![CDATA[DM_NUMBER_CTOR]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p>
Using <code>new Integer(int)</code> is guaranteed to always result in a new object whereas
<code>Integer.valueOf(int)</code> allows caching of values to be done by the compiler, class library, or JVM.
<name>
<![CDATA[Performance - Method invokes inefficient floating-point Number constructor; use static valueOf instead]]></name>
<configKey><![CDATA[DM_FP_NUMBER_CTOR]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p>
Using <code>new Double(double)</code> is guaranteed to always result in a new object whereas
<code>Double.valueOf(double)</code> allows caching of values to be done by the compiler, class library, or JVM.
<rule key="DM_CONVERT_CASE" priority="INFO">
<name><![CDATA[Internationalization - Consider using Locale parameterized version of invoked method]]></name>
<configKey><![CDATA[DM_CONVERT_CASE]]></configKey>
- <category name="Portability"/>
+
<description><![CDATA[<p> 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 </p>
<table><tr><td>String.toUpperCase( Locale l )</td></tr><tr><td>String.toLowerCase( Locale l )</td></tr></table>
<rule key="BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR" priority="MAJOR">
<name><![CDATA[Correctness - Primitive value is unboxed and coerced for ternary operator]]></name>
<configKey><![CDATA[BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>A wrapped primitive value is unboxed and converted to another primitive type as part of the
evaluation of a conditional ternary operator (the <code> b ? e1 : e2</code> operator). The
semantics of Java mandate that if <code>e1</code> and <code>e2</code> are wrapped
<rule key="BX_BOXING_IMMEDIATELY_UNBOXED" priority="MAJOR">
<name><![CDATA[Performance - Primitive value is boxed and then immediately unboxed]]></name>
<configKey><![CDATA[BX_BOXING_IMMEDIATELY_UNBOXED]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p>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.
<rule key="BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION" priority="MAJOR">
<name><![CDATA[Performance - Primitive value is boxed then unboxed to perform primitive coercion]]></name>
<configKey><![CDATA[BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p>A primitive boxed value constructed and then immediately converted into a different primitive type
(e.g., <code>new Double(d).intValue()</code>). Just perform direct primitive coercion (e.g., <code>(int) d</code>).</p>]]></description>
</rule>
<rule key="DM_BOXED_PRIMITIVE_TOSTRING" priority="MAJOR">
<name><![CDATA[Performance - Method allocates a boxed primitive just to call toString]]></name>
<configKey><![CDATA[DM_BOXED_PRIMITIVE_TOSTRING]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p>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,</p>
<table>
<rule key="DM_NEW_FOR_GETCLASS" priority="MAJOR">
<name><![CDATA[Performance - Method allocates an object, only to get the class object]]></name>
<configKey><![CDATA[DM_NEW_FOR_GETCLASS]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p>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.</p>]]></description>
</rule>
<rule key="DM_MONITOR_WAIT_ON_CONDITION" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Monitor wait() called on Condition]]></name>
<configKey><![CDATA[DM_MONITOR_WAIT_ON_CONDITION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This method calls <code>wait()</code> on a
<code>java.util.concurrent.locks.Condition</code> object.
<rule key="RV_01_TO_INT" priority="MAJOR">
<name><![CDATA[Correctness - Random value from 0 to 1 is coerced to the integer 0]]></name>
<configKey><![CDATA[RV_01_TO_INT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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 <code>Random.nextInt(n)</code> method.
</p>]]></description>
<name>
<![CDATA[Performance - Use the nextInt method of Random rather than nextDouble to generate a random integer]]></name>
<configKey><![CDATA[DM_NEXTINT_VIA_NEXTDOUBLE]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p>If <code>r</code> is a <code>java.util.Random</code>, you can generate a random number from <code>0</code> to <code>n-1</code>
using <code>r.nextInt(n)</code>, rather than using <code>(int)(r.nextDouble() * n)</code>.
</p>]]></description>
<rule key="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE" priority="CRITICAL">
<name><![CDATA[Security - Nonconstant string passed to execute method on an SQL statement]]></name>
<configKey><![CDATA[SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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
<rule key="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" priority="CRITICAL">
<name><![CDATA[Security - A prepared statement is generated from a nonconstant String]]></name>
<configKey><![CDATA[SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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.
<rule key="DM_USELESS_THREAD" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - A thread was created using the default empty run method]]></name>
<configKey><![CDATA[DM_USELESS_THREAD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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.
</p>]]></description>
<rule key="DC_DOUBLECHECK" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Possible double check of field]]></name>
<configKey><![CDATA[DC_DOUBLECHECK]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="FI_FINALIZER_NULLS_FIELDS" priority="MAJOR">
<name><![CDATA[Bad practice - Finalizer nulls fields]]></name>
<configKey><![CDATA[FI_FINALIZER_NULLS_FIELDS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.]]></description>
</rule>
<rule key="FI_FINALIZER_ONLY_NULLS_FIELDS" priority="MAJOR">
<name><![CDATA[Bad practice - Finalizer only nulls fields]]></name>
<configKey><![CDATA[FI_FINALIZER_ONLY_NULLS_FIELDS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.]]></description>
<rule key="FI_PUBLIC_SHOULD_BE_PROTECTED" priority="MAJOR">
<name><![CDATA[Malicious code vulnerability - Finalizer should be protected, not public]]></name>
<configKey><![CDATA[FI_PUBLIC_SHOULD_BE_PROTECTED]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> A class's <code>finalize()</code> method should have protected access,
not public.</p>]]></description>
</rule>
<rule key="FI_EMPTY" priority="MAJOR">
<name><![CDATA[Bad practice - Empty finalizer should be deleted]]></name>
<configKey><![CDATA[FI_EMPTY]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> Empty <code>finalize()</code> methods are useless, so they should
be deleted.</p>]]></description>
</rule>
<rule key="FI_NULLIFY_SUPER" priority="CRITICAL">
<name><![CDATA[Bad practice - Finalizer nullifies superclass finalizer]]></name>
<configKey><![CDATA[FI_NULLIFY_SUPER]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This empty <code>finalize()</code> method explicitly negates the
effect of any finalizer defined by its superclass. Any finalizer
actions defined for the superclass will not be performed.
<rule key="FI_USELESS" priority="MINOR">
<name><![CDATA[Bad practice - Finalizer does nothing but call superclass finalizer]]></name>
<configKey><![CDATA[FI_USELESS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> The only thing this <code>finalize()</code> method does is call
the superclass's <code>finalize()</code> method, making it
redundant. Delete it.</p>]]></description>
<rule key="FI_MISSING_SUPER_CALL" priority="MAJOR">
<name><![CDATA[Bad practice - Finalizer does not call superclass finalizer]]></name>
<configKey><![CDATA[FI_MISSING_SUPER_CALL]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This <code>finalize()</code> method does not make a call to its
superclass's <code>finalize()</code> method. So, any finalizer
actions defined for the superclass will not be performed.
<rule key="FI_EXPLICIT_INVOCATION" priority="MAJOR">
<name><![CDATA[Bad practice - Explicit invocation of finalizer]]></name>
<configKey><![CDATA[FI_EXPLICIT_INVOCATION]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This method contains an explicit invocation of the <code>finalize()</code>
method on an object. Because finalizer methods are supposed to be
executed once, and only by the VM, this is a bad idea.</p>
<rule key="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS" priority="MAJOR">
<name><![CDATA[Bad practice - Equals checks for noncompatible operand]]></name>
<configKey><![CDATA[EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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
<rule key="EQ_DONT_DEFINE_EQUALS_FOR_ENUM" priority="MAJOR">
<name><![CDATA[Correctness - Covariant equals() method defined for enum]]></name>
<configKey><![CDATA[EQ_DONT_DEFINE_EQUALS_FOR_ENUM]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="EQ_SELF_USE_OBJECT" priority="MAJOR">
<name><![CDATA[Correctness - Covariant equals() method defined, Object.equals(Object) inherited]]></name>
<configKey><![CDATA[EQ_SELF_USE_OBJECT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This class defines a covariant version of the <code>equals()</code>
method, but inherits the normal <code>equals(Object)</code> method
defined in the base <code>java.lang.Object</code> class.
<rule key="EQ_OTHER_USE_OBJECT" priority="MAJOR">
<name><![CDATA[Correctness - equals() method defined that doesn't override Object.equals(Object)]]></name>
<configKey><![CDATA[EQ_OTHER_USE_OBJECT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This class defines an <code>equals()</code>
method, that doesn't override the normal <code>equals(Object)</code> method
defined in the base <code>java.lang.Object</code> class.
<rule key="EQ_OTHER_NO_OBJECT" priority="MAJOR">
<name><![CDATA[Correctness - equals() method defined that doesn't override equals(Object)]]></name>
<configKey><![CDATA[EQ_OTHER_NO_OBJECT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This class defines an <code>equals()</code>
method, that doesn't override the normal <code>equals(Object)</code> method
defined in the base <code>java.lang.Object</code> class. Instead, it
<rule key="EQ_DOESNT_OVERRIDE_EQUALS">
<name><![CDATA[Dodgy - Class doesn't override equals in superclass]]></name>
<configKey><![CDATA[EQ_DOESNT_OVERRIDE_EQUALS]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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,
<rule key="EQ_SELF_NO_OBJECT" priority="MAJOR">
<name><![CDATA[Bad practice - Covariant equals() method defined]]></name>
<configKey><![CDATA[EQ_SELF_NO_OBJECT]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a covariant version of <code>equals()</code>.
To correctly override the <code>equals()</code> method in
<code>java.lang.Object</code>, the parameter of <code>equals()</code>
<rule key="EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC" priority="MAJOR">
<name><![CDATA[Correctness - equals method overrides equals in superclass and may not be symmetric]]></name>
<configKey><![CDATA[EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This class defines an equals method that overrides an equals method in a superclass. Both equals methods
methods use <code>instanceof</code> 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, <code>a.equals(b) == b.equals(a)</code>).
<rule key="EQ_GETCLASS_AND_CLASS_CONSTANT" priority="CRITICAL">
<name><![CDATA[Bad practice - equals method fails for subtypes]]></name>
<configKey><![CDATA[EQ_GETCLASS_AND_CLASS_CONSTANT]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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 <code>Foo</code>
it might check if <code>Foo.class == o.getClass()</code>).
<rule key="EQ_UNUSUAL" priority="MINOR">
<name><![CDATA[Dodgy - Unusual equals method ]]></name>
<configKey><![CDATA[EQ_UNUSUAL]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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 <code>this</code> object. There might not be anything wrong with
this code, but it is worth reviewing.
<rule key="EQ_COMPARING_CLASS_NAMES" priority="MAJOR">
<name><![CDATA[Correctness - equals method compares class names rather than class objects]]></name>
<configKey><![CDATA[EQ_COMPARING_CLASS_NAMES]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
<rule key="EQ_ALWAYS_TRUE" priority="BLOCKER">
<name><![CDATA[Correctness - equals method always returns true]]></name>
<configKey><![CDATA[EQ_ALWAYS_TRUE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
</p>]]></description>
<rule key="EQ_ALWAYS_FALSE" priority="BLOCKER">
<name><![CDATA[Correctness - equals method always returns false]]></name>
<configKey><![CDATA[EQ_ALWAYS_FALSE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.</p>
<p>The likely intended semantics are object identity: that an object is equal to itself. This is the behavior inherited from class <code>Object</code>. If you need to override an equals inherited from a different
<rule key="HSC_HUGE_SHARED_STRING_CONSTANT" priority="CRITICAL">
<name><![CDATA[Performance - Huge string constants is duplicated across multiple class files]]></name>
<configKey><![CDATA[HSC_HUGE_SHARED_STRING_CONSTANT]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p>
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
<rule key="NP_ARGUMENT_MIGHT_BE_NULL" priority="MAJOR">
<name><![CDATA[Correctness - Method does not check for null argument]]></name>
<configKey><![CDATA[NP_ARGUMENT_MIGHT_BE_NULL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT" priority="CRITICAL">
<name><![CDATA[Bad practice - equals() method does not check for null argument]]></name>
<configKey><![CDATA[NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>
This implementation of equals(Object) violates the contract defined
by java.lang.Object.equals() because it does not check for null
<rule key="CO_SELF_NO_OBJECT" priority="MAJOR">
<name><![CDATA[Bad practice - Covariant compareTo() method defined]]></name>
<configKey><![CDATA[CO_SELF_NO_OBJECT]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a covariant version of <code>compareTo()</code>.
To correctly override the <code>compareTo()</code> method in the
<code>Comparable</code> interface, the parameter of <code>compareTo()</code>
<rule key="HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS" priority="CRITICAL">
<name><![CDATA[Correctness - Signature declares use of unhashable class in hashed construct]]></name>
<configKey><![CDATA[HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="HE_USE_OF_UNHASHABLE_CLASS" priority="CRITICAL">
<name><![CDATA[Correctness - Use of class without a hashCode() method in a hashed data structure]]></name>
<configKey><![CDATA[HE_USE_OF_UNHASHABLE_CLASS]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="HE_HASHCODE_USE_OBJECT_EQUALS" priority="CRITICAL">
<name><![CDATA[Bad practice - Class defines hashCode() and uses Object.equals()]]></name>
<configKey><![CDATA[HE_HASHCODE_USE_OBJECT_EQUALS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a <code>hashCode()</code> method but inherits its
<code>equals()</code> method from <code>java.lang.Object</code>
(which defines equality by comparing object references). Although
<rule key="EQ_COMPARETO_USE_OBJECT_EQUALS" priority="CRITICAL">
<name><![CDATA[Bad practice - Class defines compareTo(...) and uses Object.equals()]]></name>
<configKey><![CDATA[EQ_COMPARETO_USE_OBJECT_EQUALS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a <code>compareTo(...)</code> method but inherits its
<code>equals()</code> method from <code>java.lang.Object</code>.
Generally, the value of compareTo should return zero if and only if
<rule key="HE_HASHCODE_NO_EQUALS" priority="CRITICAL">
<name><![CDATA[Bad practice - Class defines hashCode() but not equals()]]></name>
<configKey><![CDATA[HE_HASHCODE_NO_EQUALS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a <code>hashCode()</code> method but not an
<code>equals()</code> method. Therefore, the class may
violate the invariant that equal objects must have equal hashcodes.</p>]]></description>
<rule key="HE_EQUALS_USE_HASHCODE" priority="CRITICAL">
<name><![CDATA[Bad practice - Class defines equals() and uses Object.hashCode()]]></name>
<configKey><![CDATA[HE_EQUALS_USE_HASHCODE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class overrides <code>equals(Object)</code>, but does not
override <code>hashCode()</code>, and inherits the implementation of
<code>hashCode()</code> from <code>java.lang.Object</code> (which returns
<rule key="HE_INHERITS_EQUALS_USE_HASHCODE" priority="CRITICAL">
<name><![CDATA[Bad practice - Class inherits equals() and uses Object.hashCode()]]></name>
<configKey><![CDATA[HE_INHERITS_EQUALS_USE_HASHCODE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class inherits <code>equals(Object)</code> from an abstract
superclass, and <code>hashCode()</code> from
<code>java.lang.Object</code> (which returns
<rule key="HE_EQUALS_NO_HASHCODE" priority="MAJOR">
<name><![CDATA[Bad practice - Class defines equals() but not hashCode()]]></name>
<configKey><![CDATA[HE_EQUALS_NO_HASHCODE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class overrides <code>equals(Object)</code>, but does not
override <code>hashCode()</code>. Therefore, the class may violate the
invariant that equal objects must have equal hashcodes.</p>]]></description>
<rule key="EQ_ABSTRACT_SELF" priority="MAJOR">
<name><![CDATA[Bad practice - Abstract class defines covariant equals() method]]></name>
<configKey><![CDATA[EQ_ABSTRACT_SELF]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a covariant version of <code>equals()</code>.
To correctly override the <code>equals()</code> method in
<code>java.lang.Object</code>, the parameter of <code>equals()</code>
<rule key="ES_COMPARING_STRINGS_WITH_EQ" priority="MAJOR">
<name><![CDATA[Bad practice - Comparison of String objects using == or !=]]></name>
<configKey><![CDATA[ES_COMPARING_STRINGS_WITH_EQ]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>This code compares <code>java.lang.String</code> objects for reference
equality using the == or != operators.
Unless both strings are either constants in a source file, or have been
<rule key="ES_COMPARING_PARAMETER_STRING_WITH_EQ" priority="MAJOR">
<name><![CDATA[Bad practice - Comparison of String parameter using == or !=]]></name>
<configKey><![CDATA[ES_COMPARING_PARAMETER_STRING_WITH_EQ]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>This code compares a <code>java.lang.String</code> parameter for reference
equality using the == or != operators. Requiring callers to
pass only String constants or interned strings to a method is unnecessarily
<rule key="CO_ABSTRACT_SELF" priority="MAJOR">
<name><![CDATA[Bad practice - Abstract class defines covariant compareTo() method]]></name>
<configKey><![CDATA[CO_ABSTRACT_SELF]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a covariant version of <code>compareTo()</code>.
To correctly override the <code>compareTo()</code> method in the
<code>Comparable</code> interface, the parameter of <code>compareTo()</code>
<rule key="IS_FIELD_NOT_GUARDED" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Field not guarded against concurrent access]]></name>
<configKey><![CDATA[IS_FIELD_NOT_GUARDED]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This field is annotated with net.jcip.annotations.GuardedBy,
but can be accessed in a way that seems to violate the annotation.</p>]]></description>
</rule>
<rule key="MSF_MUTABLE_SERVLET_FIELD" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Mutable servlet field]]></name>
<configKey><![CDATA[MSF_MUTABLE_SERVLET_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>A web server generally only creates one instance of servlet or jsp class (i.e., treats
the class as a Singleton),
and will
<rule key="IS2_INCONSISTENT_SYNC" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Inconsistent synchronization]]></name>
<configKey><![CDATA[IS2_INCONSISTENT_SYNC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="NN_NAKED_NOTIFY" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Naked notify]]></name>
<configKey><![CDATA[NN_NAKED_NOTIFY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> A call to <code>notify()</code> or <code>notifyAll()</code>
was made without any (apparent) accompanying
modification to mutable object state. In general, calling a notify
<name>
<![CDATA[Malicious code vulnerability - Public static method may expose internal representation by returning array]]></name>
<configKey><![CDATA[MS_EXPOSE_REP]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<name>
<![CDATA[Malicious code vulnerability - May expose internal representation by returning reference to mutable object]]></name>
<configKey><![CDATA[EI_EXPOSE_REP]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<name>
<![CDATA[Malicious code vulnerability - May expose internal representation by incorporating reference to mutable object]]></name>
<configKey><![CDATA[EI_EXPOSE_REP2]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This code stores a reference to an externally mutable object into the
internal representation of the object.
If instances
<name>
<![CDATA[Malicious code vulnerability - May expose internal static state by storing a mutable object into a static field]]></name>
<configKey><![CDATA[EI_EXPOSE_STATIC_REP2]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This code stores a reference to an externally mutable object into a static
field.
If unchecked changes to
<rule key="RU_INVOKE_RUN" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Invokes run on a thread (did you mean to start it instead?)]]></name>
<configKey><![CDATA[RU_INVOKE_RUN]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method explicitly invokes <code>run()</code> on an object.
In general, classes implement the <code>Runnable</code> interface because
they are going to have their <code>run()</code> method invoked in a new thread,
<rule key="SP_SPIN_ON_FIELD" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Method spins on field]]></name>
<configKey><![CDATA[SP_SPIN_ON_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="NS_DANGEROUS_NON_SHORT_CIRCUIT" priority="CRITICAL">
<name><![CDATA[Dodgy - Potentially dangerous use of non-short-circuit logic]]></name>
<configKey><![CDATA[NS_DANGEROUS_NON_SHORT_CIRCUIT]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This code seems to be using non-short-circuit logic (e.g., &
or |)
rather than short-circuit logic (&& or ||). In addition,
<rule key="NS_NON_SHORT_CIRCUIT" priority="MAJOR">
<name><![CDATA[Dodgy - Questionable use of non-short-circuit logic]]></name>
<configKey><![CDATA[NS_NON_SHORT_CIRCUIT]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This code seems to be using non-short-circuit logic (e.g., &
or |)
rather than short-circuit logic (&& or ||).
<rule key="TLW_TWO_LOCK_WAIT" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Wait with two locks held]]></name>
<configKey><![CDATA[TLW_TWO_LOCK_WAIT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Waiting on a monitor while two locks are held may cause
deadlock.
<rule key="UW_UNCOND_WAIT" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Unconditional wait]]></name>
<configKey><![CDATA[UW_UNCOND_WAIT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method contains a call to <code>java.lang.Object.wait()</code> which
is not guarded by conditional control flow. The code should
verify that condition it intends to wait for is not already satisfied
<rule key="UR_UNINIT_READ" priority="MAJOR">
<name><![CDATA[Correctness - Uninitialized read of field in constructor]]></name>
<configKey><![CDATA[UR_UNINIT_READ]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="UG_SYNC_SET_UNSYNC_GET" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Unsynchronized get method, synchronized set method]]></name>
<configKey><![CDATA[UG_SYNC_SET_UNSYNC_GET]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="IC_INIT_CIRCULARITY" priority="CRITICAL">
<name><![CDATA[Dodgy - Initialization circularity]]></name>
<configKey><![CDATA[IC_INIT_CIRCULARITY]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION" priority="MAJOR">
<name><![CDATA[Bad practice - Superclass uses subclass during initialization]]></name>
<configKey><![CDATA[IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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, <code>foo</code> will be null.</p>
<rule key="IT_NO_SUCH_ELEMENT" priority="MINOR">
<name><![CDATA[Bad practice - Iterator next() method can't throw NoSuchElementException]]></name>
<configKey><![CDATA[IT_NO_SUCH_ELEMENT]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class implements the <code>java.util.Iterator</code> interface.
However, its <code>next()</code> method is not capable of throwing
<code>java.util.NoSuchElementException</code>. The <code>next()</code>
<rule key="DL_SYNCHRONIZATION_ON_SHARED_CONSTANT" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Synchronization on interned String could lead to deadlock]]></name>
<configKey><![CDATA[DL_SYNCHRONIZATION_ON_SHARED_CONSTANT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> The code synchronizes on interned String.
<pre>
private static String LOCK = "LOCK";
<rule key="DL_SYNCHRONIZATION_ON_BOOLEAN" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Synchronization on Boolean could lead to deadlock]]></name>
<configKey><![CDATA[DL_SYNCHRONIZATION_ON_BOOLEAN]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> The code synchronizes on a boxed primitive constant, such as an Boolean.
<pre>
private static Boolean inited = Boolean.FALSE;
<rule key="DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Synchronization on boxed primitive values]]></name>
<configKey><![CDATA[DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> The code synchronizes on an apparently unshared boxed primitive,
such as an Integer.
<pre>
<rule key="DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Synchronization on boxed primitive could lead to deadlock]]></name>
<configKey><![CDATA[DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> The code synchronizes on a boxed primitive constant, such as an Integer.
<pre>
private static Integer count = 0;
<rule key="ESync_EMPTY_SYNC" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Empty synchronized block]]></name>
<configKey><![CDATA[ESync_EMPTY_SYNC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> The code contains an empty synchronized block:</p>
<pre>
synchronized() {}
<rule key="IS_INCONSISTENT_SYNC" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Inconsistent synchronization]]></name>
<configKey><![CDATA[IS_INCONSISTENT_SYNC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Synchronization on field in futile attempt to guard that field]]></name>
<configKey><![CDATA[ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="ML_SYNC_ON_UPDATED_FIELD" priority="MAJOR">
<name><![CDATA[Multithreaded correctness - Method synchronizes on an updated field]]></name>
<configKey><![CDATA[ML_SYNC_ON_UPDATED_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method synchronizes on an object
referenced from a mutable field.
This is unlikely to have useful semantics, since different
<name>
<![CDATA[Malicious code vulnerability - Field should be moved out of an interface and made package protected]]></name>
<configKey><![CDATA[MS_OOI_PKGPROTECT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
A final static field that is
defined in an interface references a mutable
<rule key="MS_FINAL_PKGPROTECT" priority="MAJOR">
<name><![CDATA[Malicious code vulnerability - Field should be both final and package protected]]></name>
<configKey><![CDATA[MS_FINAL_PKGPROTECT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
A mutable static field could be changed by malicious code or
by accident from another package.
<rule key="MS_SHOULD_BE_FINAL" priority="MAJOR">
<name><![CDATA[Malicious code vulnerability - Field isn't final but should be]]></name>
<configKey><![CDATA[MS_SHOULD_BE_FINAL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
A mutable static field could be changed by malicious code or
by accident from another package.
<rule key="MS_PKGPROTECT" priority="MAJOR">
<name><![CDATA[Malicious code vulnerability - Field should be package protected]]></name>
<configKey><![CDATA[MS_PKGPROTECT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> A mutable static field could be changed by malicious code or
by accident.
The field could be made package protected to avoid
<rule key="MS_MUTABLE_HASHTABLE" priority="MAJOR">
<name><![CDATA[Malicious code vulnerability - Field is a mutable Hashtable]]></name>
<configKey><![CDATA[MS_MUTABLE_HASHTABLE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>A final static field references a Hashtable
and can be accessed by malicious code or
by accident from another package.
<rule key="MS_MUTABLE_ARRAY" priority="MAJOR">
<name><![CDATA[Malicious code vulnerability - Field is a mutable array]]></name>
<configKey><![CDATA[MS_MUTABLE_ARRAY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> A final static field references an array
and can be accessed by malicious code or
by accident from another package.
<rule key="MS_CANNOT_BE_FINAL" priority="MAJOR">
<name><![CDATA[Malicious code vulnerability - Field isn't final and can't be protected from malicious code]]></name>
<configKey><![CDATA[MS_CANNOT_BE_FINAL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
A mutable static field could be changed by malicious code or
by accident from another package.
<rule key="IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD" priority="MAJOR">
<name><![CDATA[Dodgy - Ambiguous invocation of either an inherited or outer method]]></name>
<configKey><![CDATA[IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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,
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,
<rule key="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS" priority="MAJOR">
<name><![CDATA[Bad practice - Class names shouldn't shadow simple name of superclass]]></name>
<configKey><![CDATA[NM_SAME_SIMPLE_NAME_AS_SUPERCLASS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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., <code>alpha.Foo</code> extends <code>beta.Foo</code>).
This can be exceptionally confusing, create lots of situations in which you have to look at import statements
<rule key="NM_SAME_SIMPLE_NAME_AS_INTERFACE" priority="MAJOR">
<name><![CDATA[Bad practice - Class names shouldn't shadow simple name of implemented interface]]></name>
<configKey><![CDATA[NM_SAME_SIMPLE_NAME_AS_INTERFACE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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., <code>alpha.Foo</code> extends <code>beta.Foo</code>).
This can be exceptionally confusing, create lots of situations in which you have to look at import statements
<rule key="NM_VERY_CONFUSING" priority="MAJOR">
<name><![CDATA[Correctness - Very confusing method names]]></name>
<configKey><![CDATA[NM_VERY_CONFUSING]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
<rule key="NM_VERY_CONFUSING_INTENTIONAL" priority="MAJOR">
<name><![CDATA[Bad practice - Very confusing method names (but perhaps intentional)]]></name>
<configKey><![CDATA[NM_VERY_CONFUSING_INTENTIONAL]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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
<name>
<![CDATA[Correctness - Method doesn't override method in superclass due to wrong package for parameter]]></name>
<configKey><![CDATA[NM_WRONG_PACKAGE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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:</p>
<name>
<![CDATA[Bad practice - Method doesn't override method in superclass due to wrong package for parameter]]></name>
<configKey><![CDATA[NM_WRONG_PACKAGE_INTENTIONAL]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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:</p>
<rule key="NM_CONFUSING" priority="MAJOR">
<name><![CDATA[Bad practice - Confusing method names]]></name>
<configKey><![CDATA[NM_CONFUSING]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> The referenced methods have names that differ only by capitalization.</p>]]></description>
</rule>
<rule key="NM_METHOD_CONSTRUCTOR_CONFUSION" priority="MAJOR">
<name><![CDATA[Correctness - Apparent method/constructor confusion]]></name>
<configKey><![CDATA[NM_METHOD_CONSTRUCTOR_CONFUSION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="NM_CLASS_NOT_EXCEPTION" priority="MAJOR">
<name><![CDATA[Bad practice - Class is not derived from an Exception, even though it is named as such]]></name>
<configKey><![CDATA[NM_CLASS_NOT_EXCEPTION]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class is not derived from another exception, but ends with 'Exception'. This will
be confusing to users of this class.</p>]]></description>
</rule>
<rule key="RR_NOT_CHECKED" priority="MAJOR">
<name><![CDATA[Bad practice - Method ignores results of InputStream.read()]]></name>
<configKey><![CDATA[RR_NOT_CHECKED]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This method ignores the return value of one of the variants of
<code>java.io.InputStream.read()</code> which can return multiple bytes.
If the return value is not checked, the caller will not be able to correctly
<rule key="SR_NOT_CHECKED" priority="MAJOR">
<name><![CDATA[Bad practice - Method ignores results of InputStream.skip()]]></name>
<configKey><![CDATA[SR_NOT_CHECKED]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This method ignores the return value of
<code>java.io.InputStream.skip()</code> which can skip multiple bytes.
If the return value is not checked, the caller will not be able to correctly
<rule key="SE_READ_RESOLVE_IS_STATIC" priority="MAJOR">
<name><![CDATA[Correctness - The readResolve method must not be declared as a static method. ]]></name>
<configKey><![CDATA[SE_READ_RESOLVE_IS_STATIC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> In order for the readResolve method to be recognized by the serialization
mechanism, it must not be declared as a static method.
</p>]]></description>
<rule key="SE_PRIVATE_READ_RESOLVE_NOT_INHERITED" priority="MAJOR">
<name><![CDATA[Dodgy - private readResolve method not inherited by subclasses]]></name>
<configKey><![CDATA[SE_PRIVATE_READ_RESOLVE_NOT_INHERITED]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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.
</p>]]></description>
<rule key="SE_READ_RESOLVE_MUST_RETURN_OBJECT" priority="MAJOR">
<name><![CDATA[Bad practice - The readResolve method must be declared with a return type of Object. ]]></name>
<configKey><![CDATA[SE_READ_RESOLVE_MUST_RETURN_OBJECT]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> In order for the readResolve method to be recognized by the serialization
mechanism, it must be declared to have a return type of Object.
</p>]]></description>
<rule key="SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS" priority="MAJOR">
<name><![CDATA[Dodgy - Transient field of class that isn't Serializable. ]]></name>
<configKey><![CDATA[SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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
<rule key="SE_TRANSIENT_FIELD_NOT_RESTORED" priority="MAJOR">
<name><![CDATA[Bad practice - Transient field that isn't set by deserialization. ]]></name>
<configKey><![CDATA[SE_TRANSIENT_FIELD_NOT_RESTORED]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.
</p>]]></description>
<rule key="SE_METHOD_MUST_BE_PRIVATE" priority="MAJOR">
<name><![CDATA[Correctness - Method must be private in order for serialization to work]]></name>
<configKey><![CDATA[SE_METHOD_MUST_BE_PRIVATE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This class implements the <code>Serializable</code> 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.</p>]]></description>
<rule key="SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION" priority="MAJOR">
<name><![CDATA[Bad practice - Class is Externalizable but doesn't define a void constructor]]></name>
<configKey><![CDATA[SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class implements the <code>Externalizable</code> interface, but does
not define a void constructor. When Externalizable objects are deserialized,
they first need to be constructed by invoking the void
<rule key="SE_NO_SUITABLE_CONSTRUCTOR" priority="MAJOR">
<name><![CDATA[Bad practice - Class is Serializable but its superclass doesn't define a void constructor]]></name>
<configKey><![CDATA[SE_NO_SUITABLE_CONSTRUCTOR]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class implements the <code>Serializable</code> interface
and its superclass does not. When such an object is deserialized,
the fields of the superclass need to be initialized by
<rule key="SE_NO_SERIALVERSIONID" priority="MAJOR">
<name><![CDATA[Bad practice - Class is Serializable, but doesn't define serialVersionUID]]></name>
<configKey><![CDATA[SE_NO_SERIALVERSIONID]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class implements the <code>Serializable</code> interface, but does
not define a <code>serialVersionUID</code> field.
A change as simple as adding a reference to a .class object
<rule key="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE" priority="MAJOR">
<name><![CDATA[Bad practice - Comparator doesn't implement Serializable]]></name>
<configKey><![CDATA[SE_COMPARATOR_SHOULD_BE_SERIALIZABLE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class implements the <code>Comparator</code> interface. You
should consider whether or not it should also implement the <code>Serializable</code>
interface. If a comparator is used to construct an ordered collection
<name>
<![CDATA[Multithreaded correctness - Class's writeObject() method is synchronized but nothing else is]]></name>
<configKey><![CDATA[WS_WRITEOBJECT_SYNC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This class has a <code>writeObject()</code> method which is synchronized;
however, no other method of the class is synchronized.</p>]]></description>
</rule>
<rule key="RS_READOBJECT_SYNC" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Class's readObject() method is synchronized]]></name>
<configKey><![CDATA[RS_READOBJECT_SYNC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This serializable class defines a <code>readObject()</code> which is
synchronized. By definition, an object created by deserialization
is only reachable by one thread, and thus there is no need for
<rule key="SE_NONSTATIC_SERIALVERSIONID" priority="MAJOR">
<name><![CDATA[Bad practice - serialVersionUID isn't static]]></name>
<configKey><![CDATA[SE_NONSTATIC_SERIALVERSIONID]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a <code>serialVersionUID</code> field that is not static.
The field should be made static
if it is intended to specify
<rule key="SE_NONFINAL_SERIALVERSIONID" priority="CRITICAL">
<name><![CDATA[Bad practice - serialVersionUID isn't final]]></name>
<configKey><![CDATA[SE_NONFINAL_SERIALVERSIONID]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a <code>serialVersionUID</code> field that is not final.
The field should be made final
if it is intended to specify
<rule key="SE_NONLONG_SERIALVERSIONID" priority="MAJOR">
<name><![CDATA[Bad practice - serialVersionUID isn't long]]></name>
<configKey><![CDATA[SE_NONLONG_SERIALVERSIONID]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This class defines a <code>serialVersionUID</code> field that is not long.
The field should be made long
if it is intended to specify
<rule key="SE_BAD_FIELD_INNER_CLASS" priority="MINOR">
<name><![CDATA[Bad practice - Non-serializable class has a serializable inner class]]></name>
<configKey><![CDATA[SE_BAD_FIELD_INNER_CLASS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.
<rule key="SE_INNER_CLASS" priority="MAJOR">
<name><![CDATA[Bad practice - Serializable inner class]]></name>
<configKey><![CDATA[SE_INNER_CLASS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.
<rule key="SE_BAD_FIELD_STORE" priority="CRITICAL">
<name><![CDATA[Bad practice - Non-serializable value stored into instance field of a serializable class]]></name>
<configKey><![CDATA[SE_BAD_FIELD_STORE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> A non-serializable value is stored into a non-transient field
of a serializable class.</p>]]></description>
</rule>
<rule key="SC_START_IN_CTOR" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Constructor invokes Thread.start()]]></name>
<configKey><![CDATA[SC_START_IN_CTOR]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="SS_SHOULD_BE_STATIC" priority="MAJOR">
<name><![CDATA[Performance - Unread field: should this field be static?]]></name>
<configKey><![CDATA[SS_SHOULD_BE_STATIC]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> This class contains an instance final field that
is initialized to a compile-time static value.
Consider making the field static.</p>]]></description>
<rule key="UUF_UNUSED_FIELD" priority="MAJOR">
<name><![CDATA[Performance - Unused field]]></name>
<configKey><![CDATA[UUF_UNUSED_FIELD]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> This field is never used. Consider removing it from the class.</p>]]></description>
</rule>
<rule key="URF_UNREAD_FIELD" priority="MAJOR">
<name><![CDATA[Performance - Unread field]]></name>
<configKey><![CDATA[URF_UNREAD_FIELD]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> This field is never read. Consider removing it from the class.</p>]]></description>
</rule>
<rule key="QF_QUESTIONABLE_FOR_LOOP" priority="CRITICAL">
<name><![CDATA[Dodgy - Complicated, subtle or wrong increment in for-loop ]]></name>
<configKey><![CDATA[QF_QUESTIONABLE_FOR_LOOP]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>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.
<rule key="UWF_NULL_FIELD" priority="CRITICAL">
<name><![CDATA[Correctness - Field only ever set to null]]></name>
<configKey><![CDATA[UWF_NULL_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" priority="CRITICAL">
<name><![CDATA[Dodgy - Write to static field from instance method]]></name>
<configKey><![CDATA[ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This instance method writes to a static field. This is tricky to get
correct if multiple instances are being manipulated,
and generally bad practice.
<rule key="NP_LOAD_OF_KNOWN_NULL_VALUE" priority="CRITICAL">
<name><![CDATA[Dodgy - Load of known null value]]></name>
<configKey><![CDATA[NP_LOAD_OF_KNOWN_NULL_VALUE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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
<rule key="NP_DEREFERENCE_OF_READLINE_VALUE" priority="CRITICAL">
<name><![CDATA[Dodgy - Dereference of the result of readLine() without nullcheck]]></name>
<configKey><![CDATA[NP_DEREFERENCE_OF_READLINE_VALUE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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.
</p>]]></description>
<rule key="NP_IMMEDIATE_DEREFERENCE_OF_READLINE" priority="CRITICAL">
<name><![CDATA[Dodgy - Immediate dereference of the result of readLine()]]></name>
<configKey><![CDATA[NP_IMMEDIATE_DEREFERENCE_OF_READLINE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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.
</p>]]></description>
<rule key="SIC_INNER_SHOULD_BE_STATIC" priority="MAJOR">
<name><![CDATA[Performance - Should be a static inner class]]></name>
<configKey><![CDATA[SIC_INNER_SHOULD_BE_STATIC]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> 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
<rule key="SIC_INNER_SHOULD_BE_STATIC_ANON" priority="MAJOR">
<name><![CDATA[Performance - Could be refactored into a named static inner class]]></name>
<configKey><![CDATA[SIC_INNER_SHOULD_BE_STATIC_ANON]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> 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
<rule key="SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS" priority="MAJOR">
<name><![CDATA[Performance - Could be refactored into a static inner class]]></name>
<configKey><![CDATA[SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> 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
<rule key="WA_NOT_IN_LOOP" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Wait not in loop ]]></name>
<configKey><![CDATA[WA_NOT_IN_LOOP]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method contains a call to <code>java.lang.Object.wait()</code>
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
<rule key="WA_AWAIT_NOT_IN_LOOP" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Condition.await() not in loop ]]></name>
<configKey><![CDATA[WA_AWAIT_NOT_IN_LOOP]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method contains a call to <code>java.util.concurrent.await()</code>
(or variants)
which is not in a loop. If the object is used for multiple conditions,
<rule key="NO_NOTIFY_NOT_NOTIFYALL" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Using notify() rather than notifyAll()]]></name>
<configKey><![CDATA[NO_NOTIFY_NOT_NOTIFYALL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method calls <code>notify()</code> rather than <code>notifyAll()</code>.
Java monitors are often used for multiple conditions. Calling <code>notify()</code>
only wakes up one thread, meaning that the thread woken up might not be the
<rule key="RV_CHECK_FOR_POSITIVE_INDEXOF" priority="MINOR">
<name><![CDATA[Dodgy - Method checks to see if result of String.indexOf is positive]]></name>
<configKey><![CDATA[RV_CHECK_FOR_POSITIVE_INDEXOF]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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
<rule key="RV_DONT_JUST_NULL_CHECK_READLINE" priority="MAJOR">
<name><![CDATA[Dodgy - Method discards result of readLine after checking if it is nonnull]]></name>
<configKey><![CDATA[RV_DONT_JUST_NULL_CHECK_READLINE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="RV_RETURN_VALUE_IGNORED" priority="MINOR">
<name><![CDATA[Correctness - Method ignores return value]]></name>
<configKey><![CDATA[RV_RETURN_VALUE_IGNORED]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" priority="MAJOR">
<name><![CDATA[Bad practice - Method ignores exceptional return value]]></name>
<configKey><![CDATA[RV_RETURN_VALUE_IGNORED_BAD_PRACTICE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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 <code>File.delete()</code> method returns false
<rule key="RV_EXCEPTION_NOT_THROWN" priority="CRITICAL">
<name><![CDATA[Correctness - Exception created and dropped rather than thrown]]></name>
<configKey><![CDATA[RV_EXCEPTION_NOT_THROWN]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This code creates an exception (or error) object, but doesn't do anything with it. For example,
something like </p>
<blockquote>
<rule key="RV_RETURN_VALUE_IGNORED2" priority="MAJOR">
<name><![CDATA[Correctness - Method ignores return value]]></name>
<configKey><![CDATA[RV_RETURN_VALUE_IGNORED2]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="NP_ALWAYS_NULL" priority="CRITICAL">
<name><![CDATA[Correctness - Null pointer dereference]]></name>
<configKey><![CDATA[NP_ALWAYS_NULL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> A null pointer is dereferenced here. This will lead to a
<code>NullPointerException</code> when the code is executed.</p>]]></description>
</rule>
<rule key="NP_STORE_INTO_NONNULL_FIELD" priority="CRITICAL">
<name><![CDATA[Correctness - Store of null value into field annotated NonNull]]></name>
<configKey><![CDATA[NP_STORE_INTO_NONNULL_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[<p> A value that could be null is stored into a field that has been annotated as NonNull. </p>]]></description>
</rule>
<rule key="NP_ALWAYS_NULL_EXCEPTION" priority="CRITICAL">
<name><![CDATA[Correctness - Null pointer dereference in method on exception path]]></name>
<configKey><![CDATA[NP_ALWAYS_NULL_EXCEPTION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> A pointer which is null on an exception path is dereferenced here.
This will lead to a <code>NullPointerException</code> when the code is executed.
Note that because FindBugs currently does not prune infeasible exception paths,
<rule key="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE" priority="CRITICAL">
<name><![CDATA[Dodgy - Parameter must be nonnull but is marked as nullable]]></name>
<configKey><![CDATA[NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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.
<rule key="NP_NULL_ON_SOME_PATH" priority="CRITICAL">
<name><![CDATA[Correctness - Possible null pointer dereference]]></name>
<configKey><![CDATA[NP_NULL_ON_SOME_PATH]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> There is a branch of statement that, <em>if executed,</em> guarantees that
a null value will be dereferenced, which
would generate a <code>NullPointerException</code> when the code is executed.
<rule key="NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE" priority="CRITICAL">
<name><![CDATA[Dodgy - Possible null pointer dereference on path that might be infeasible]]></name>
<configKey><![CDATA[NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> There is a branch of statement that, <em>if executed,</em> guarantees that
a null value will be dereferenced, which
would generate a <code>NullPointerException</code> when the code is executed.
<rule key="NP_NULL_ON_SOME_PATH_EXCEPTION" priority="CRITICAL">
<name><![CDATA[Correctness - Possible null pointer dereference in method on exception path]]></name>
<configKey><![CDATA[NP_NULL_ON_SOME_PATH_EXCEPTION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> A reference value which is null on some exception control path is
dereferenced here. This may lead to a <code>NullPointerException</code>
when the code is executed.
<rule key="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" priority="CRITICAL">
<name><![CDATA[Dodgy - Possible null pointer dereference due to return value of called method]]></name>
<configKey><![CDATA[NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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 <code>NullPointerException</code> when the code is executed.
<rule key="NP_NULL_PARAM_DEREF_NONVIRTUAL" priority="CRITICAL">
<name><![CDATA[Correctness - Non-virtual method call passes null for nonnull parameter]]></name>
<configKey><![CDATA[NP_NULL_PARAM_DEREF_NONVIRTUAL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
A possibly-null value is passed to a nonnull method parameter.
Either the parameter is annotated as a parameter that should
<rule key="NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS" priority="CRITICAL">
<name><![CDATA[Correctness - Method call passes null for nonnull parameter]]></name>
<configKey><![CDATA[NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
A possibly-null value is passed at a call site where all known
target methods require the parameter to be nonnull.
<rule key="NP_NULL_PARAM_DEREF" priority="CRITICAL">
<name><![CDATA[Correctness - Method call passes null for nonnull parameter]]></name>
<configKey><![CDATA[NP_NULL_PARAM_DEREF]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This method call passes a null value for a nonnull method parameter.
Either the parameter is annotated as a parameter that should
<rule key="NP_NONNULL_PARAM_VIOLATION" priority="CRITICAL">
<name><![CDATA[Correctness - Method call passes null to a nonnull parameter ]]></name>
<configKey><![CDATA[NP_NONNULL_PARAM_VIOLATION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This method passes a null value as the parameter of a method which
must be nonnull. Either this parameter has been explicitly marked
<rule key="NP_NONNULL_RETURN_VIOLATION" priority="CRITICAL">
<name><![CDATA[Correctness - Method may return null, but is declared @NonNull]]></name>
<configKey><![CDATA[NP_NONNULL_RETURN_VIOLATION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This method may return a null value, but the method (or a superclass method
which it overrides) is declared to return @NonNull.
<rule key="NP_CLONE_COULD_RETURN_NULL" priority="CRITICAL">
<name><![CDATA[Bad practice - Clone method may return null]]></name>
<configKey><![CDATA[NP_CLONE_COULD_RETURN_NULL]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>
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
<rule key="NP_TOSTRING_COULD_RETURN_NULL" priority="CRITICAL">
<name><![CDATA[Bad practice - toString method may return null]]></name>
<configKey><![CDATA[NP_TOSTRING_COULD_RETURN_NULL]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>
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
<rule key="NP_GUARANTEED_DEREF" priority="BLOCKER">
<name><![CDATA[Correctness - Null value is guaranteed to be dereferenced]]></name>
<configKey><![CDATA[NP_GUARANTEED_DEREF]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
There is a statement or branch that if executed guarantees that
a value is null at this point, and that
<rule key="NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH" priority="CRITICAL">
<name><![CDATA[Correctness - Value is null and guaranteed to be dereferenced on exception path]]></name>
<configKey><![CDATA[NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
There is a statement or branch on an exception path
that if executed guarantees that
<rule key="SI_INSTANCE_BEFORE_FINALS_ASSIGNED" priority="CRITICAL">
<name><![CDATA[Bad practice - Static initializer creates instance before all static final fields assigned]]></name>
<configKey><![CDATA[SI_INSTANCE_BEFORE_FINALS_ASSIGNED]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> The class's static initializer creates an instance of the class
before all of the static final fields are assigned.</p>]]></description>
</rule>
<rule key="OS_OPEN_STREAM" priority="CRITICAL">
<name><![CDATA[Bad practice - Method may fail to close stream]]></name>
<configKey><![CDATA[OS_OPEN_STREAM]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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
<rule key="OS_OPEN_STREAM_EXCEPTION_PATH" priority="CRITICAL">
<name><![CDATA[Bad practice - Method may fail to close stream on exception]]></name>
<configKey><![CDATA[OS_OPEN_STREAM_EXCEPTION_PATH]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.
<rule key="PZLA_PREFER_ZERO_LENGTH_ARRAYS" priority="MAJOR">
<name><![CDATA[Dodgy - Consider returning a zero length array rather than null]]></name>
<configKey><![CDATA[PZLA_PREFER_ZERO_LENGTH_ARRAYS]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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).
<rule key="UCF_USELESS_CONTROL_FLOW" priority="CRITICAL">
<name><![CDATA[Dodgy - Useless control flow]]></name>
<configKey><![CDATA[UCF_USELESS_CONTROL_FLOW]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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,
<rule key="UCF_USELESS_CONTROL_FLOW_NEXT_LINE" priority="CRITICAL">
<name><![CDATA[Correctness - Useless control flow to next line]]></name>
<configKey><![CDATA[UCF_USELESS_CONTROL_FLOW_NEXT_LINE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
<rule key="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" priority="CRITICAL">
<name><![CDATA[Correctness - Nullcheck of value previously dereferenced]]></name>
<configKey><![CDATA[RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
<rule key="RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE" priority="CRITICAL">
<name><![CDATA[Dodgy - Redundant nullcheck of value known to be null]]></name>
<configKey><![CDATA[RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This method contains a redundant check of a known null value against
the constant null.</p>]]></description>
</rule>
<rule key="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" priority="CRITICAL">
<name><![CDATA[Dodgy - Redundant nullcheck of value known to be non-null]]></name>
<configKey><![CDATA[RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This method contains a redundant check of a known non-null value against
the constant null.</p>]]></description>
</rule>
<rule key="RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES" priority="CRITICAL">
<name><![CDATA[Dodgy - Redundant comparison of two null values]]></name>
<configKey><![CDATA[RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This method contains a redundant comparison of two references known to
both be definitely null.</p>]]></description>
</rule>
<rule key="RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE" priority="CRITICAL">
<name><![CDATA[Dodgy - Redundant comparison of non-null value to null]]></name>
<configKey><![CDATA[RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This method contains a reference known to be non-null with another reference
known to be null.</p>]]></description>
</rule>
<rule key="UL_UNRELEASED_LOCK" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Method does not release lock on all paths]]></name>
<configKey><![CDATA[UL_UNRELEASED_LOCK]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method acquires a JSR-166 (<code>java.util.concurrent</code>) 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:
<rule key="UL_UNRELEASED_LOCK_EXCEPTION_PATH" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Method does not release lock on all exception paths]]></name>
<configKey><![CDATA[UL_UNRELEASED_LOCK_EXCEPTION_PATH]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method acquires a JSR-166 (<code>java.util.concurrent</code>) 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:
<rule key="RC_REF_COMPARISON" priority="CRITICAL">
<name><![CDATA[Bad practice - Suspicious reference comparison]]></name>
<configKey><![CDATA[RC_REF_COMPARISON]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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. Examples of classes which should generally
<rule key="EC_UNRELATED_TYPES_USING_POINTER_EQUALITY" priority="CRITICAL">
<name><![CDATA[Correctness - Using pointer equality to compare different types]]></name>
<configKey><![CDATA[EC_UNRELATED_TYPES_USING_POINTER_EQUALITY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
</p>]]></description>
<rule key="EC_UNRELATED_TYPES" priority="CRITICAL">
<name><![CDATA[Correctness - Call to equals() comparing different types]]></name>
<configKey><![CDATA[EC_UNRELATED_TYPES]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method calls equals(Object) on two references of different
class types with no common subclasses.
Therefore, the objects being compared
<rule key="EC_UNRELATED_INTERFACES" priority="CRITICAL">
<name><![CDATA[Correctness - Call to equals() comparing different interface types]]></name>
<configKey><![CDATA[EC_UNRELATED_INTERFACES]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
<rule key="EC_UNRELATED_CLASS_AND_INTERFACE" priority="CRITICAL">
<name><![CDATA[Correctness - Call to equals() comparing unrelated class and interface]]></name>
<configKey><![CDATA[EC_UNRELATED_CLASS_AND_INTERFACE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="EC_NULL_ARG" priority="CRITICAL">
<name><![CDATA[Correctness - Call to equals() with null argument]]></name>
<configKey><![CDATA[EC_NULL_ARG]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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 <code>false</code>.</p>]]></description>
<rule key="MWN_MISMATCHED_WAIT" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Mismatched wait()]]></name>
<configKey><![CDATA[MWN_MISMATCHED_WAIT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method calls Object.wait() without obviously holding a lock
on the object. Calling wait() without a lock held will result in
an <code>IllegalMonitorStateException</code> being thrown.</p>]]></description>
<rule key="MWN_MISMATCHED_NOTIFY" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Mismatched notify()]]></name>
<configKey><![CDATA[MWN_MISMATCHED_NOTIFY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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 <code>IllegalMonitorStateException</code> being thrown.</p>]]></description>
<rule key="SA_LOCAL_SELF_ASSIGNMENT" priority="CRITICAL">
<name><![CDATA[Dodgy - Self assignment of local variable]]></name>
<configKey><![CDATA[SA_LOCAL_SELF_ASSIGNMENT]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This method contains a self assignment of a local variable; e.g.</p>
<pre>
public void foo() {
<rule key="SA_FIELD_SELF_ASSIGNMENT" priority="CRITICAL">
<name><![CDATA[Correctness - Self assignment of field]]></name>
<configKey><![CDATA[SA_FIELD_SELF_ASSIGNMENT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method contains a self assignment of a field; e.g.
</p>
<pre>
<rule key="SA_FIELD_DOUBLE_ASSIGNMENT" priority="CRITICAL">
<name><![CDATA[Correctness - Double assignment of field]]></name>
<configKey><![CDATA[SA_FIELD_DOUBLE_ASSIGNMENT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method contains a double assignment of a field; e.g.
</p>
<pre>
<rule key="SA_LOCAL_DOUBLE_ASSIGNMENT" priority="CRITICAL">
<name><![CDATA[Dodgy - Double assignment of local variable ]]></name>
<configKey><![CDATA[SA_LOCAL_DOUBLE_ASSIGNMENT]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This method contains a double assignment of a local variable; e.g.
</p>
<pre>
<rule key="SA_FIELD_SELF_COMPUTATION" priority="CRITICAL">
<name><![CDATA[Correctness - Nonsensical self computation involving a field (e.g., x & x)]]></name>
<configKey><![CDATA[SA_FIELD_SELF_COMPUTATION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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,
<rule key="SA_LOCAL_SELF_COMPUTATION" priority="CRITICAL">
<name><![CDATA[Correctness - Nonsensical self computation involving a variable (e.g., x & x)]]></name>
<configKey><![CDATA[SA_LOCAL_SELF_COMPUTATION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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,
<rule key="SA_FIELD_SELF_COMPARISON" priority="CRITICAL">
<name><![CDATA[Correctness - Self comparison of field with itself]]></name>
<configKey><![CDATA[SA_FIELD_SELF_COMPARISON]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
</p>]]></description>
<rule key="SA_LOCAL_SELF_COMPARISON" priority="CRITICAL">
<name><![CDATA[Correctness - Self comparison of value with itself]]></name>
<configKey><![CDATA[SA_LOCAL_SELF_COMPARISON]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
</p>]]></description>
<rule key="DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT" priority="CRITICAL">
<name><![CDATA[Correctness - Double.longBitsToDouble invoked on an int]]></name>
<configKey><![CDATA[DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
<rule key="DMI_RANDOM_USED_ONLY_ONCE" priority="CRITICAL">
<name><![CDATA[Bad practice - Random object created and used only once]]></name>
<configKey><![CDATA[DMI_RANDOM_USED_ONLY_ONCE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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
<rule key="RV_ABSOLUTE_VALUE_OF_RANDOM_INT" priority="CRITICAL">
<name><![CDATA[Correctness - Bad attempt to compute absolute value of signed 32-bit random integer]]></name>
<configKey><![CDATA[RV_ABSOLUTE_VALUE_OF_RANDOM_INT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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 <code>Integer.MIN_VALUE</code>, then the result will be negative as well (since
<rule key="RV_ABSOLUTE_VALUE_OF_HASHCODE" priority="CRITICAL">
<name><![CDATA[Correctness - Bad attempt to compute absolute value of signed 32-bit hashcode ]]></name>
<configKey><![CDATA[RV_ABSOLUTE_VALUE_OF_HASHCODE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This code generates a hashcode and then computes
the absolute value of that hashcode. If the hashcode
is <code>Integer.MIN_VALUE</code>, then the result will be negative as well (since
<rule key="RV_REM_OF_RANDOM_INT" priority="CRITICAL">
<name><![CDATA[Dodgy - Remainder of 32-bit signed random integer]]></name>
<configKey><![CDATA[RV_REM_OF_RANDOM_INT]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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
<rule key="RV_REM_OF_HASHCODE" priority="CRITICAL">
<name><![CDATA[Dodgy - Remainder of hashCode could be negative]]></name>
<configKey><![CDATA[RV_REM_OF_HASHCODE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> 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
<rule key="INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE" priority="CRITICAL">
<name><![CDATA[Correctness - Bad comparison of nonnegative value with negative constant]]></name>
<configKey><![CDATA[INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This code compares a value that is guaranteed to be non-negative with a negative constant.
</p>]]></description>
</rule>
<rule key="INT_BAD_COMPARISON_WITH_SIGNED_BYTE" priority="CRITICAL">
<name><![CDATA[Correctness - Bad comparison of signed byte]]></name>
<configKey><![CDATA[INT_BAD_COMPARISON_WITH_SIGNED_BYTE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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 <code>b</code> to an unsigned value in the range 0..255,
<rule key="INT_VACUOUS_BIT_OPERATION" priority="CRITICAL">
<name><![CDATA[Dodgy - Vacuous bit mask operation on integer value]]></name>
<configKey><![CDATA[INT_VACUOUS_BIT_OPERATION]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> This is an integer bit operation (and, or, or exclusive or) that doesn't do any useful work
(e.g., <code>v & 0xffffffff</code>).
<rule key="INT_VACUOUS_COMPARISON" priority="CRITICAL">
<name><![CDATA[Dodgy - Vacuous comparison of integer value]]></name>
<configKey><![CDATA[INT_VACUOUS_COMPARISON]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p> There is an integer comparison that always returns
the same value (e.g., x <= Integer.MAX_VALUE).
</p>]]></description>
<rule key="INT_BAD_REM_BY_1" priority="CRITICAL">
<name><![CDATA[Correctness - Integer remainder modulo 1]]></name>
<configKey><![CDATA[INT_BAD_REM_BY_1]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Any expression (exp % 1) is guaranteed to always return zero.
Did you mean (exp & 1) or (exp % 2) instead?
</p>]]></description>
<rule key="BIT_IOR_OF_SIGNED_BYTE" priority="CRITICAL">
<name><![CDATA[Correctness - Bitwise OR of signed byte value]]></name>
<configKey><![CDATA[BIT_IOR_OF_SIGNED_BYTE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Loads a value from a byte array and performs a bitwise OR with
that value. Values loaded from a byte array are sign extended to 32 bits
before any any bitwise operations are performed on the value.
<rule key="BIT_ADD_OF_SIGNED_BYTE" priority="CRITICAL">
<name><![CDATA[Correctness - Bitwise add of signed byte value]]></name>
<configKey><![CDATA[BIT_ADD_OF_SIGNED_BYTE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Adds a byte value and a value which is known to 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.
<rule key="BIT_AND" priority="CRITICAL">
<name><![CDATA[Correctness - Incompatible bit masks]]></name>
<configKey><![CDATA[BIT_AND]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
<rule key="BIT_SIGNED_CHECK" priority="CRITICAL">
<name><![CDATA[Bad practice - Check for sign of bitwise operation]]></name>
<configKey><![CDATA[BIT_SIGNED_CHECK]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> This method compares an expression such as
<pre>((event.detail & SWT.SELECTED) > 0)</pre>.
Using bit arithmetic and then comparing with the greater than operator can
<rule key="BIT_SIGNED_CHECK_HIGH_BIT" priority="CRITICAL">
<name><![CDATA[Correctness - Check for sign of bitwise operation]]></name>
<configKey><![CDATA[BIT_SIGNED_CHECK_HIGH_BIT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method compares an expression such as
<pre>((event.detail & SWT.SELECTED) > 0)</pre>.
Using bit arithmetic and then comparing with the greater than operator can
<rule key="BIT_AND_ZZ" priority="CRITICAL">
<name><![CDATA[Correctness - Check to see if ((...) & 0) == 0]]></name>
<configKey><![CDATA[BIT_AND_ZZ]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="BIT_IOR" priority="CRITICAL">
<name><![CDATA[Correctness - Incompatible bit masks]]></name>
<configKey><![CDATA[BIT_IOR]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.
<rule key="LI_LAZY_INIT_STATIC" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Incorrect lazy initialization of static field]]></name>
<configKey><![CDATA[LI_LAZY_INIT_STATIC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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,
<rule key="LI_LAZY_INIT_UPDATE_STATIC" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Incorrect lazy initialization and update of static field]]></name>
<configKey><![CDATA[LI_LAZY_INIT_UPDATE_STATIC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="JLM_JSR166_LOCK_MONITORENTER" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Synchronization performed on java.util.concurrent Lock]]></name>
<configKey><![CDATA[JLM_JSR166_LOCK_MONITORENTER]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This method performs synchronization on an implementation of
<code>java.util.concurrent.locks.Lock</code>. You should use
the <code>lock()</code> and <code>unlock()</code> methods instead.
<rule key="UPM_UNCALLED_PRIVATE_METHOD" priority="CRITICAL">
<name><![CDATA[Performance - Private method is never called]]></name>
<configKey><![CDATA[UPM_UNCALLED_PRIVATE_METHOD]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> 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
<rule key="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS" priority="CRITICAL">
<name><![CDATA[Correctness - Uncallable method defined in anonymous class]]></name>
<configKey><![CDATA[UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="ODR_OPEN_DATABASE_RESOURCE" priority="CRITICAL">
<name><![CDATA[Bad practice - Method may fail to close database resource]]></name>
<configKey><![CDATA[ODR_OPEN_DATABASE_RESOURCE]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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
<rule key="ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH" priority="CRITICAL">
<name><![CDATA[Bad practice - Method may fail to close database resource on exception]]></name>
<configKey><![CDATA[ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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
<rule key="SBSC_USE_STRINGBUFFER_CONCATENATION" priority="CRITICAL">
<name><![CDATA[Performance - Method concatenates strings using + in a loop]]></name>
<configKey><![CDATA[SBSC_USE_STRINGBUFFER_CONCATENATION]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> 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.
<rule key="ITA_INEFFICIENT_TO_ARRAY" priority="CRITICAL">
<name><![CDATA[Performance - Method uses toArray() with zero-length array argument]]></name>
<configKey><![CDATA[ITA_INEFFICIENT_TO_ARRAY]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> 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
<code>myCollection.toArray(new Foo[myCollection.size()])</code>
<rule key="IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD" priority="CRITICAL">
<name><![CDATA[Correctness - JUnit assertion in run method will not be noticed by JUnit]]></name>
<configKey><![CDATA[IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="IJU_SETUP_NO_SUPER" priority="CRITICAL">
<name><![CDATA[Correctness - TestCase defines setUp that doesn't call super.setUp()]]></name>
<configKey><![CDATA[IJU_SETUP_NO_SUPER]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Class is a JUnit TestCase and implements the setUp method. The setUp method should call
super.setUp(), but doesn't.</p>]]></description>
</rule>
<rule key="IJU_TEARDOWN_NO_SUPER" priority="CRITICAL">
<name><![CDATA[Correctness - TestCase defines tearDown that doesn't call super.tearDown()]]></name>
<configKey><![CDATA[IJU_TEARDOWN_NO_SUPER]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Class is a JUnit TestCase and implements the tearDown method. The tearDown method should call
super.tearDown(), but doesn't.</p>]]></description>
</rule>
<rule key="IJU_SUITE_NOT_STATIC" priority="CRITICAL">
<name><![CDATA[Correctness - TestCase implements a non-static suite method ]]></name>
<configKey><![CDATA[IJU_SUITE_NOT_STATIC]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Class is a JUnit TestCase and implements the suite() method.
The suite method should be declared as being static, but isn't.</p>]]></description>
</rule>
<rule key="IJU_BAD_SUITE_METHOD" priority="CRITICAL">
<name><![CDATA[Correctness - TestCase declares a bad suite method ]]></name>
<configKey><![CDATA[IJU_BAD_SUITE_METHOD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Class is a JUnit TestCase and defines a suite() method.
However, the suite method needs to be declared as either
<pre>public static junit.framework.Test suite()</pre>
<rule key="IJU_NO_TESTS" priority="CRITICAL">
<name><![CDATA[Correctness - TestCase has no tests]]></name>
<configKey><![CDATA[IJU_NO_TESTS]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Class is a JUnit TestCase but has not implemented any test methods</p>]]></description>
</rule>
<rule key="BOA_BADLY_OVERRIDDEN_ADAPTER" priority="CRITICAL">
<name><![CDATA[Correctness - Class overrides a method implemented in super class Adapter wrongly]]></name>
<configKey><![CDATA[BOA_BADLY_OVERRIDDEN_ADAPTER]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="SQL_BAD_RESULTSET_ACCESS" priority="CRITICAL">
<name><![CDATA[Correctness - Method attempts to access a result set field with index 0]]></name>
<configKey><![CDATA[SQL_BAD_RESULTSET_ACCESS]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
</rule>
<rule key="SQL_BAD_PREPARED_STATEMENT_ACCESS" priority="CRITICAL">
<name><![CDATA[Correctness - Method attempts to access a prepared statement parameter with index 0]]></name>
<configKey><![CDATA[SQL_BAD_PREPARED_STATEMENT_ACCESS]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
</rule>
<rule key="SIO_SUPERFLUOUS_INSTANCEOF" priority="CRITICAL">
<name><![CDATA[Correctness - Unnecessary type check done using instanceof operator]]></name>
<configKey><![CDATA[SIO_SUPERFLUOUS_INSTANCEOF]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> Type check performed using the instanceof operator where it can be statically determined whether the object
is of the type requested. </p>]]></description>
</rule>
<rule key="EC_ARRAY_AND_NONARRAY" priority="CRITICAL">
<name><![CDATA[Correctness - equals() used to compare array and nonarray]]></name>
<configKey><![CDATA[EC_ARRAY_AND_NONARRAY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="EC_BAD_ARRAY_COMPARE" priority="CRITICAL">
<name><![CDATA[Correctness - Invocation of equals() on an array, which is equivalent to ==]]></name>
<configKey><![CDATA[EC_BAD_ARRAY_COMPARE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="STI_INTERRUPTED_ON_CURRENTTHREAD" priority="CRITICAL">
<name><![CDATA[Correctness - Unneeded use of currentThread() call, to call interrupted() ]]></name>
<configKey><![CDATA[STI_INTERRUPTED_ON_CURRENTTHREAD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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().
<rule key="STI_INTERRUPTED_ON_UNKNOWNTHREAD" priority="CRITICAL">
<name><![CDATA[Correctness - Static Thread.interrupted() method invoked on thread instance]]></name>
<configKey><![CDATA[STI_INTERRUPTED_ON_UNKNOWNTHREAD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN" priority="CRITICAL">
<name><![CDATA[Correctness - A parameter is dead upon entry to a method but overwritten]]></name>
<configKey><![CDATA[IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
The initial value of this parameter is ignored, and the parameter
is overwritten here. This often indicates a mistaken belief that
<rule key="DLS_DEAD_LOCAL_STORE" priority="CRITICAL">
<name><![CDATA[Dodgy - Dead store to local variable]]></name>
<configKey><![CDATA[DLS_DEAD_LOCAL_STORE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This instruction assigns a value to a local variable,
but the value is not read or used in any subsequent instruction.
<rule key="DLS_DEAD_LOCAL_STORE_IN_RETURN" priority="CRITICAL">
<name><![CDATA[Correctness - Useless assignment in return statement]]></name>
<configKey><![CDATA[DLS_DEAD_LOCAL_STORE_IN_RETURN]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This statement assigns to a local variable in a return statement. This assignment
has effect. Please verify that this statement does the right thing.
<rule key="DLS_DEAD_STORE_OF_CLASS_LITERAL" priority="CRITICAL">
<name><![CDATA[Correctness - Dead store of class literal]]></name>
<configKey><![CDATA[DLS_DEAD_STORE_OF_CLASS_LITERAL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This instruction assigns a class literal to a variable and then never uses it.
<a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">The behavior of this differs in Java 1.4 and in Java 5.</a>
<rule key="DLS_DEAD_LOCAL_STORE_OF_NULL" priority="CRITICAL">
<name><![CDATA[Dodgy - Dead store of null to local variable]]></name>
<configKey><![CDATA[DLS_DEAD_LOCAL_STORE_OF_NULL]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>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.
<rule key="MF_METHOD_MASKS_FIELD" priority="MAJOR">
<name><![CDATA[Correctness - Method defines a variable that obscures a field]]></name>
<configKey><![CDATA[MF_METHOD_MASKS_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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,
<rule key="MF_CLASS_MASKS_FIELD" priority="MAJOR">
<name><![CDATA[Correctness - Class defines field that masks a superclass field]]></name>
<configKey><![CDATA[MF_CLASS_MASKS_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="WMI_WRONG_MAP_ITERATOR" priority="CRITICAL">
<name><![CDATA[Performance - Inefficient use of keySet iterator instead of entrySet iterator]]></name>
<configKey><![CDATA[WMI_WRONG_MAP_ITERATOR]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
<rule key="ISC_INSTANTIATE_STATIC_CLASS" priority="MAJOR">
<name><![CDATA[Bad practice - Needless instantiation of class that only supplies static methods]]></name>
<configKey><![CDATA[ISC_INSTANTIATE_STATIC_CLASS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.</p>]]></description>
</rule>
<rule key="REC_CATCH_EXCEPTION" priority="MAJOR">
<name><![CDATA[Dodgy - Exception is caught when Exception is not thrown]]></name>
<configKey><![CDATA[REC_CATCH_EXCEPTION]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<rule key="FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER" priority="CRITICAL">
<name><![CDATA[Correctness - Doomed test for equality to NaN]]></name>
<configKey><![CDATA[FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This code checks to see if a floating point value is equal to the special
Not A Number value (e.g., <code>if (x == Double.NaN)</code>). However,
<rule key="FE_FLOATING_POINT_EQUALITY" priority="CRITICAL">
<name><![CDATA[Dodgy - Test for floating point equality]]></name>
<configKey><![CDATA[FE_FLOATING_POINT_EQUALITY]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This operation compares two floating point values for equality.
Because floating point calculations may involve rounding,
<rule key="UM_UNNECESSARY_MATH" priority="CRITICAL">
<name><![CDATA[Performance - Method calls static Math class method on a constant value]]></name>
<configKey><![CDATA[UM_UNNECESSARY_MATH]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[<p> 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:
<rule key="RI_REDUNDANT_INTERFACES" priority="MAJOR">
<name><![CDATA[Dodgy - Class implements same interface as superclass]]></name>
<configKey><![CDATA[RI_REDUNDANT_INTERFACES]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<rule key="MTIA_SUSPECT_STRUTS_INSTANCE_FIELD" priority="CRITICAL">
<name><![CDATA[Dodgy - Class extends Struts Action class and uses instance variables]]></name>
<configKey><![CDATA[MTIA_SUSPECT_STRUTS_INSTANCE_FIELD]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<rule key="MTIA_SUSPECT_SERVLET_INSTANCE_FIELD" priority="CRITICAL">
<name><![CDATA[Dodgy - Class extends Servlet class and uses instance variables]]></name>
<configKey><![CDATA[MTIA_SUSPECT_SERVLET_INSTANCE_FIELD]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<rule key="PS_PUBLIC_SEMAPHORES" priority="CRITICAL">
<name><![CDATA[Dodgy - Class exposes synchronization and semaphores in its public interface]]></name>
<configKey><![CDATA[PS_PUBLIC_SEMAPHORES]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<rule key="ICAST_INTEGER_MULTIPLY_CAST_TO_LONG" priority="CRITICAL">
<name><![CDATA[Dodgy - Result of integer multiplication cast to long]]></name>
<configKey><![CDATA[ICAST_INTEGER_MULTIPLY_CAST_TO_LONG]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This code performs integer multiply and then converts the result to a long,
as in:
<rule key="ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND" priority="CRITICAL">
<name><![CDATA[Correctness - int value cast to float and then passed to Math.round]]></name>
<configKey><![CDATA[ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This code converts an int value to a float precision
floating point number and then
<rule key="ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL" priority="CRITICAL">
<name><![CDATA[Correctness - int value cast to double and then passed to Math.ceil]]></name>
<configKey><![CDATA[ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This code converts an int value to a double precision
floating point number and then
<rule key="ICAST_IDIV_CAST_TO_DOUBLE" priority="CRITICAL">
<name><![CDATA[Dodgy - int division result cast to double or float]]></name>
<configKey><![CDATA[ICAST_IDIV_CAST_TO_DOUBLE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This code casts the result of an integer division operation to double or
float.
<rule key="J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION" priority="CRITICAL">
<name><![CDATA[Bad practice - Store of non serializable object into HttpSession]]></name>
<configKey><![CDATA[J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>
This code seems to be storing a non-serializable object into an HttpSession.
If this session is passivated or migrated, an error will result.
<rule key="DMI_NONSERIALIZABLE_OBJECT_WRITTEN" priority="CRITICAL">
<name><![CDATA[Dodgy - Non serializable object written to ObjectOutput]]></name>
<configKey><![CDATA[DMI_NONSERIALIZABLE_OBJECT_WRITTEN]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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.
<rule key="VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT" priority="CRITICAL">
<name><![CDATA[Correctness - No previous argument for format string]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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.
<rule key="VA_FORMAT_STRING_BAD_CONVERSION" priority="CRITICAL">
<name><![CDATA[Correctness - The type of a supplied argument doesn't match format specifier]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_BAD_CONVERSION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
One of the arguments is uncompatible with the corresponding format string specifier.
As a result, this will generate a runtime exception when executed.
<rule key="VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN" priority="MAJOR">
<name><![CDATA[Dodgy - Non-Boolean argument formatted using %b format specifier]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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.
<rule key="VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY" priority="MAJOR">
<name><![CDATA[Correctness - Array formatted in useless way using format string]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<name>
<![CDATA[Correctness - Number of format-string arguments does not correspond to number of placeholders]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_ARG_MISMATCH]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED" priority="MAJOR">
<name><![CDATA[Correctness - More arguments are passed that are actually used in the format string]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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.
<rule key="VA_FORMAT_STRING_ILLEGAL" priority="CRITICAL">
<name><![CDATA[Correctness - Illegal format string]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_ILLEGAL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
The format string is syntactically invalid,
and a runtime exception will occur when
<rule key="VA_FORMAT_STRING_MISSING_ARGUMENT" priority="CRITICAL">
<name><![CDATA[Correctness - Format string references missing argument]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_MISSING_ARGUMENT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
Not enough arguments are passed to satisfy a placeholder in the format string.
A runtime exception will occur when
<rule key="VA_FORMAT_STRING_BAD_ARGUMENT" priority="CRITICAL">
<name><![CDATA[Correctness - Format string placeholder incompatible with passed argument]]></name>
<configKey><![CDATA[VA_FORMAT_STRING_BAD_ARGUMENT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
The format string placeholder is incompatible with the corresponding
argument. For example,
<name>
<![CDATA[Correctness - Primitive array passed to function expecting a variable number of object arguments]]></name>
<configKey><![CDATA[VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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.
<rule key="BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS" priority="CRITICAL">
<name><![CDATA[Bad practice - Equals method should not assume anything about the type of its argument]]></name>
<configKey><![CDATA[BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p>
The <code>equals(Object o)</code> method shouldn't make any assumptions
about the type of <code>o</code>. It should simply return
<rule key="BC_BAD_CAST_TO_ABSTRACT_COLLECTION" priority="MAJOR">
<name><![CDATA[Dodgy - Questionable cast to abstract collection ]]></name>
<configKey><![CDATA[BC_BAD_CAST_TO_ABSTRACT_COLLECTION]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This code casts a Collection to an abstract collection
(such as <code>List</code>, <code>Set</code>, or <code>Map</code>).
<rule key="BC_IMPOSSIBLE_CAST" priority="BLOCKER">
<name><![CDATA[Correctness - Impossible cast]]></name>
<configKey><![CDATA[BC_IMPOSSIBLE_CAST]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This cast will always throw a ClassCastException.
</p>]]></description>
<rule key="NP_NULL_INSTANCEOF" priority="BLOCKER">
<name><![CDATA[Correctness - A known null value is checked to see if it is an instance of a type]]></name>
<configKey><![CDATA[NP_NULL_INSTANCEOF]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="BC_IMPOSSIBLE_INSTANCEOF" priority="CRITICAL">
<name><![CDATA[Correctness - instanceof will always return false]]></name>
<configKey><![CDATA[BC_IMPOSSIBLE_INSTANCEOF]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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.
<rule key="BC_VACUOUS_INSTANCEOF" priority="CRITICAL">
<name><![CDATA[Dodgy - instanceof will always return true]]></name>
<configKey><![CDATA[BC_VACUOUS_INSTANCEOF]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This instanceof test will always return true (unless the value being tested is null).
Although this is safe, make sure it isn't
<rule key="BC_UNCONFIRMED_CAST" priority="CRITICAL">
<name><![CDATA[Dodgy - Unchecked/unconfirmed cast]]></name>
<configKey><![CDATA[BC_UNCONFIRMED_CAST]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This cast is unchecked, and not all instances of the type casted from can be cast to
the type it is being cast to. Ensure that your program logic ensures that this
<rule key="BC_BAD_CAST_TO_CONCRETE_COLLECTION" priority="CRITICAL">
<name><![CDATA[Dodgy - Questionable cast to concrete collection]]></name>
<configKey><![CDATA[BC_BAD_CAST_TO_CONCRETE_COLLECTION]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This code casts an abstract collection (such as a Collection, List, or Set)
to a specific concrete implementation (such as an ArrayList or HashSet).
<rule key="RE_POSSIBLE_UNINTENDED_PATTERN" priority="CRITICAL">
<name><![CDATA[Correctness - "." used for regular expression]]></name>
<configKey><![CDATA[RE_POSSIBLE_UNINTENDED_PATTERN]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
A String function is being invoked and "." is being passed
to a parameter that takes a regular expression as an argument. Is this what you intended?
<rule key="RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION" priority="CRITICAL">
<name><![CDATA[Correctness - Invalid syntax for regular expression]]></name>
<configKey><![CDATA[RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
The code here uses a regular expression that is invalid according to the syntax
for regular expressions. This statement will throw a PatternSyntaxException when
<rule key="RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION" priority="CRITICAL">
<name><![CDATA[Correctness - File.separator used for regular expression]]></name>
<configKey><![CDATA[RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
The code here uses <code>File.separator</code>
where a regular expression is required. This will fail on Windows
<rule key="DLS_OVERWRITTEN_INCREMENT" priority="CRITICAL">
<name><![CDATA[Correctness - Overwritten increment]]></name>
<configKey><![CDATA[DLS_OVERWRITTEN_INCREMENT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
The code performs an increment operation (e.g., <code>i++</code>) and then
immediately overwrites it. For example, <code>i = i++</code> immediately
<rule key="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT" priority="CRITICAL">
<name><![CDATA[Dodgy - Unsigned right shift cast to short/byte]]></name>
<configKey><![CDATA[ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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.
<rule key="ICAST_BAD_SHIFT_AMOUNT" priority="CRITICAL">
<name><![CDATA[Correctness - Integer shift by an amount not in the range 0..31]]></name>
<configKey><![CDATA[ICAST_BAD_SHIFT_AMOUNT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
The code performs an integer shift by a constant amount outside
the range 0..31.
<rule key="IM_MULTIPLYING_RESULT_OF_IREM" priority="CRITICAL">
<name><![CDATA[Correctness - Integer multiply of result of integer remainder]]></name>
<configKey><![CDATA[IM_MULTIPLYING_RESULT_OF_IREM]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="DMI_INVOKING_HASHCODE_ON_ARRAY" priority="CRITICAL">
<name><![CDATA[Correctness - Invocation of hashCode on an array]]></name>
<configKey><![CDATA[DMI_INVOKING_HASHCODE_ON_ARRAY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
The code invokes hashCode on an array. Calling hashCode on
an array returns the same value as System.identityHashCode, and ingores
<rule key="DMI_INVOKING_TOSTRING_ON_ARRAY" priority="CRITICAL">
<name><![CDATA[Correctness - Invocation of toString on an array]]></name>
<configKey><![CDATA[DMI_INVOKING_TOSTRING_ON_ARRAY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY" priority="CRITICAL">
<name><![CDATA[Correctness - Invocation of toString on an array]]></name>
<configKey><![CDATA[DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="IM_AVERAGE_COMPUTATION_COULD_OVERFLOW" priority="CRITICAL">
<name><![CDATA[Dodgy - Computation of average could overflow]]></name>
<configKey><![CDATA[IM_AVERAGE_COMPUTATION_COULD_OVERFLOW]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>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
<rule key="IM_BAD_CHECK_FOR_ODD" priority="CRITICAL">
<name><![CDATA[Dodgy - Check for oddness that won't work for negative numbers ]]></name>
<configKey><![CDATA[IM_BAD_CHECK_FOR_ODD]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<rule key="DMI_HARDCODED_ABSOLUTE_FILENAME" priority="CRITICAL">
<name><![CDATA[Dodgy - Code contains a hard coded reference to an absolute pathname]]></name>
<configKey><![CDATA[DMI_HARDCODED_ABSOLUTE_FILENAME]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>This code constructs a File object using a hard coded to an absolute pathname
(e.g., <code>new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment");</code>
</p>]]></description>
<rule key="DMI_BAD_MONTH" priority="CRITICAL">
<name><![CDATA[Correctness - Bad constant value for month]]></name>
<configKey><![CDATA[DMI_BAD_MONTH]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This code passes a constant month
value outside the expected range of 0..11 to a method.
<rule key="DMI_USELESS_SUBSTRING" priority="CRITICAL">
<name><![CDATA[Dodgy - Invocation of substring(0), which returns the original value]]></name>
<configKey><![CDATA[DMI_USELESS_SUBSTRING]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This code invokes substring(0) on a String, which returns the original value.
</p>]]></description>
<rule key="DMI_CALLING_NEXT_FROM_HASNEXT" priority="CRITICAL">
<name><![CDATA[Correctness - hasNext method invokes next]]></name>
<configKey><![CDATA[DMI_CALLING_NEXT_FROM_HASNEXT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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,
<rule key="SWL_SLEEP_WITH_LOCK_HELD" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Method calls Thread.sleep() with a lock held]]></name>
<configKey><![CDATA[SWL_SLEEP_WITH_LOCK_HELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="DB_DUPLICATE_BRANCHES" priority="CRITICAL">
<name><![CDATA[Dodgy - Method uses the same code for two branches]]></name>
<configKey><![CDATA[DB_DUPLICATE_BRANCHES]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
This method uses the same code to implement two branches of a conditional branch.
Check to ensure that this isn't a coding mistake.
<rule key="DB_DUPLICATE_SWITCH_CLAUSES" priority="CRITICAL">
<name><![CDATA[Dodgy - Method uses the same code for two switch clauses]]></name>
<configKey><![CDATA[DB_DUPLICATE_SWITCH_CLAUSES]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<rule key="XFB_XML_FACTORY_BYPASS" priority="CRITICAL">
<name><![CDATA[Dodgy - Method directly allocates a specific implementation of xml interfaces]]></name>
<configKey><![CDATA[XFB_XML_FACTORY_BYPASS]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<rule key="CI_CONFUSED_INHERITANCE" priority="MINOR">
<name><![CDATA[Dodgy - Class is final but declares protected field]]></name>
<configKey><![CDATA[CI_CONFUSED_INHERITANCE]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<rule key="QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT" priority="CRITICAL">
<name><![CDATA[Correctness - Method assigns boolean literal in boolean expression]]></name>
<configKey><![CDATA[QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="GC_UNCHECKED_TYPE_IN_GENERIC_CALL" priority="CRITICAL">
<name><![CDATA[Bad practice - Unchecked type in generic call]]></name>
<configKey><![CDATA[GC_UNCHECKED_TYPE_IN_GENERIC_CALL]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[<p> 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.
<rule key="GC_UNRELATED_TYPES" priority="CRITICAL">
<name><![CDATA[Correctness - No relationship between generic parameter and method argument]]></name>
<configKey><![CDATA[GC_UNRELATED_TYPES]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> 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
<rule key="DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES" priority="CRITICAL">
<name><![CDATA[Correctness - Collections should not contain themselves]]></name>
<configKey><![CDATA[DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This call to a generic collection's method would only make sense if a collection contained
itself (e.g., if <code>s.contains(s)</code> 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).
<rule key="DMI_VACUOUS_SELF_COLLECTION_CALL" priority="CRITICAL">
<name><![CDATA[Correctness - Vacuous call to collections]]></name>
<configKey><![CDATA[DMI_VACUOUS_SELF_COLLECTION_CALL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> This call doesn't make sense. For any collection <code>c</code>, calling <code>c.containsAll(c)</code> should
always be true, and <code>c.retainAll(c)</code> should have no effect.
</p>]]></description>
<rule key="DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION" priority="CRITICAL">
<name><![CDATA[Correctness - Don't use removeAll to clear a collection]]></name>
<configKey><![CDATA[DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p> If you want to remove all elements from a collection <code>c</code>, use <code>c.clear</code>,
not <code>c.removeAll(c)</code>.
</p>]]></description>
<rule key="STCAL_STATIC_CALENDAR_INSTANCE" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Static Calendar]]></name>
<configKey><![CDATA[STCAL_STATIC_CALENDAR_INSTANCE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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
<rule key="STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Call to static Calendar]]></name>
<configKey><![CDATA[STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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.</p>
<rule key="STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Static DateFormat]]></name>
<configKey><![CDATA[STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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.</p>
<rule key="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Call to static DateFormat]]></name>
<configKey><![CDATA[STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>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.</p>
<name>
<![CDATA[Correctness - Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is required]]></name>
<configKey><![CDATA[TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
A value specified as carrying a type qualifier annotation is
consumed in a location or locations requiring that the value not
<name>
<![CDATA[Correctness - Value annotated as never carrying a type qualifier used where value carrying that qualifier is required]]></name>
<configKey><![CDATA[TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<name>
<![CDATA[Correctness - Value that might not carry a type qualifier is always used in a way requires that type qualifier]]></name>
<configKey><![CDATA[TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<name>
<![CDATA[Correctness - Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifier]]></name>
<configKey><![CDATA[TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK" priority="CRITICAL">
<name><![CDATA[Correctness - Explicit annotation inconsistent with use]]></name>
<configKey><![CDATA[TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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.
<rule key="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK" priority="CRITICAL">
<name><![CDATA[Correctness - Explicit annotation inconsistent with use]]></name>
<configKey><![CDATA[TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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.
<rule key="IO_APPENDING_TO_OBJECT_OUTPUT_STREAM" priority="CRITICAL">
<name><![CDATA[Correctness - Doomed attempt to append to an object output stream]]></name>
<configKey><![CDATA[IO_APPENDING_TO_OBJECT_OUTPUT_STREAM]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<rule key="WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL" priority="CRITICAL">
<name><![CDATA[Multithreaded correctness - Sychronization on getClass rather than class literal]]></name>
<configKey><![CDATA[WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This instance method synchronizes on <code>this.getClass()</code>. If this class is subclassed,
subclasses will synchronize on the class object for the subclass, which isn't likely what was intended.
<name>
<![CDATA[Switch statement found where one case falls through to the next case]]></name>
<configKey><![CDATA[SF_SWITCH_FALLTHROUGH]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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.
<name>
<![CDATA[Switch statement found where default case is missing]]></name>
<configKey><![CDATA[SF_SWITCH_NO_DEFAULT]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This method contains a switch statement where default case is missing.
Usually you need to provide a default case.
<name>
<![CDATA[Dead store due to switch statement fall through]]></name>
<configKey><![CDATA[SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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
<name>
<![CDATA[Dead store due to switch statement fall through to throw]]></name>
<configKey><![CDATA[SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
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.
<name>
<![CDATA[Class names should start with an upper case letter]]></name>
<configKey><![CDATA[NM_CLASS_NAMING_CONVENTION]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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
<name>
<![CDATA[Field names should start with a lower case letter]]></name>
<configKey><![CDATA[NM_FIELD_NAMING_CONVENTION]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
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.
<name>
<![CDATA[Method names should start with a lower case letter]]></name>
<configKey><![CDATA[NM_METHOD_NAMING_CONVENTION]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[<p>
Methods should be verbs, in mixed case with the first letter lowercase,
with the first letter of each internal word capitalized.
<name>
<![CDATA[Non-transient non-serializable instance field in serializable class]]></name>
<configKey><![CDATA[SE_BAD_FIELD]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This Serializable class defines a non-primitive instance field which is neither transient,
Serializable, or <code>java.lang.Object</code>, and does not appear to implement the <code>Externalizable</code>
<name>
<![CDATA[Class defines equal(Object); should it be equals(Object)?]]></name>
<configKey><![CDATA[NM_BAD_EQUAL]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This class defines a method <code>equal(Object)</code>.
This method does not override the <code>equals(Object)</code> method
<name>
<![CDATA[Class defines hashcode(); should it be hashCode()?]]></name>
<configKey><![CDATA[NM_LCASE_HASHCODE]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This class defines a method called <code>hashcode()</code>.
This method does not override the <code>hashCode()</code>
<name>
<![CDATA[Class defines tostring(); should it be toString()?]]></name>
<configKey><![CDATA[NM_LCASE_TOSTRING]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This class defines a method called <code>tostring()</code>.
This method does not override the <code>toString()</code>
<name>
<![CDATA[Class defines tostring(); should it be toString()?]]></name>
<configKey><![CDATA[NM_LCASE_TOSTRING]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[<p>
This class defines a method called <code>tostring()</code>.
This method does not override the <code>toString()</code>
<rule key="AvoidThrowingNewInstanceOfSameException" priority="MAJOR">
<name><![CDATA[Strict Exception - Avoid throwing new instance of same exception]]></name>
<configKey>rulesets/strictexception.xml/AvoidThrowingNewInstanceOfSameException</configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Catch blocks that merely rethrow a caught exception wrapped inside a new instance of the same type only add to code size and runtime complexity. Example :
<pre>
<rule key="CallSuperFirst" priority="MAJOR">
<name><![CDATA[Android - call super first]]></name>
<configKey>rulesets/android.xml/CallSuperFirst</configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Super should be called at the start of the method. Example :
<pre>
<rule key="CallSuperLast" priority="MAJOR">
<name><![CDATA[Android - call super last]]></name>
<configKey>rulesets/android.xml/CallSuperLast</configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Super should be called at the end of the method. Example :
<pre>
<rule key="ProtectLogD" priority="MAJOR">
<name><![CDATA[Android - Protect LOGD]]></name>
<configKey>rulesets/android.xml/ProtectLogD</configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Log.d calls should be protected by checking Config.LOGD first. Example :
<pre>
<rule key="ProtectLogV" priority="MAJOR">
<name><![CDATA[Android - Protect LOGV]]></name>
<configKey>rulesets/android.xml/ProtectLogV</configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Log.v calls should be protected by checking Config.LOGV first. Example :
<pre>
<rule key="EmptyInitializer" priority="MAJOR">
<name><![CDATA[Basic - Empty Initializer]]></name>
<configKey>rulesets/basic.xml/EmptyInitializer</configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[An empty initializer was found. Example :
<pre>
<rule key="CyclomaticComplexity" priority="MAJOR">
<name><![CDATA[Code size - cyclomatic complexity]]></name>
<configKey>rulesets/codesize.xml/CyclomaticComplexity</configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.]]></description>
<param key="reportLevel" type="i">
<rule key="AvoidStringBufferField" priority="MAJOR">
<name><![CDATA[Avoid StringBuffer field]]></name>
<configKey>rulesets/strings.xml/AvoidStringBufferField</configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[StringBuffers can grow quite a lot, and so may become a source of memory leak (if the owning class has a long life time). Example :
<pre>
<rule key="DoNotThrowExceptionInFinally" priority="MAJOR">
<name><![CDATA[Strict Exception - Do not throw exception in finally]]></name>
<configKey><![CDATA[rulesets/strictexception.xml/DoNotThrowExceptionInFinally]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Throwing exception in a finally block is confusing. It may mask exception or a defect of the code, it also render code cleanup uninstable. Example :
<pre>
public class Foo
<rule key="TooManyMethods" priority="MAJOR">
<name><![CDATA[Too many methods]]></name>
<configKey><![CDATA[rulesets/codesize.xml/TooManyMethods]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.]]></description>
<param key="maxmethods" type="i">
<rule key="ReturnEmptyArrayRatherThanNull" priority="MINOR">
<name><![CDATA[Return empty array rather than null]]></name>
<configKey><![CDATA[rulesets/design.xml/ReturnEmptyArrayRatherThanNull]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[For any method that returns an array, it's a better behavior to return an empty array rather than a null reference. Example :
<pre>
public class Example
<rule key="TooFewBranchesForASwitchStatement" priority="MINOR">
<name><![CDATA[Too few branches for a switch statement]]></name>
<configKey><![CDATA[rulesets/design.xml/TooFewBranchesForASwitchStatement]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Swith are designed complex branches, and allow branches to share treatement. Using a switch for only a few branches is ill advised, as switches are not as easy to understand as if. In this case, it's most likely is a good idea to use a if statement instead, at least to increase code readability. Example :
<pre>
// With a minimumNumberCaseForASwitch of 3
<rule key="AbstractClassWithoutAnyMethod" priority="MAJOR">
<name><![CDATA[Abstract class without any methods]]></name>
<configKey><![CDATA[rulesets/design.xml/AbstractClassWithoutAnyMethod]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[If the abstract class does not provides any methods, it may be just a data container that is not to be instantiated. In this case, it's probably better to use a private or a protected constructor in order to prevent instantiation than make the class misleadingly abstract. Example :
<pre>
public class abstract Example {
<rule key="DoNotCallGarbageCollectionExplicitly" priority="CRITICAL">
<name><![CDATA[Do not call garbage collection explicitly]]></name>
<configKey><![CDATA[rulesets/controversial.xml/DoNotCallGarbageCollectionExplicitly]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Code should have the same behavior whether the garbage collection is disabled using the option -Xdisableexplicitgc or not. Moreover, "modern" jvms do a very good job handling garbage collections. If memory usage issues unrelated to memory leaks develop within an application, it should be dealt with JVM options rather than within the code itself. Example :
<pre>
<rule key="AvoidMultipleUnaryOperators" priority="MAJOR">
<name><![CDATA[Avoid Multiple Unary Operators]]></name>
<configKey><![CDATA[rulesets/basic.xml/AvoidMultipleUnaryOperators]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Using multiple unary operators may be a bug, and/or is confusing. Check the usage is not a bug, or consider simplifying the expression. Example :
<pre>
<rule key="DoubleCheckedLocking" priority="MAJOR">
<name><![CDATA[Double checked locking]]></name>
<configKey><![CDATA[rulesets/basic.xml/DoubleCheckedLocking]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Partially created objects can be returned by the Double Checked Locking pattern when used in Java. An optimizing JRE may assign a reference to the baz variable before it creates the object the reference is intended to point to. <a href="http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html">More details</a>. Example :
<pre>
<rule key="NPathComplexity" priority="MAJOR">
<name><![CDATA[NPath complexity]]></name>
<configKey><![CDATA[rulesets/codesize.xml/NPathComplexity]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity. Example :
<pre>
<rule key="SimplifyBooleanReturns" priority="MINOR">
<name><![CDATA[Simplify boolean returns]]></name>
<configKey><![CDATA[rulesets/design.xml/SimplifyBooleanReturns]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Avoid unnecessary if..then..else statements when returning a boolean. Example :
<pre>
<rule key="SimplifyBooleanExpressions" priority="MAJOR">
<name><![CDATA[Avoid unnecessary comparisons in boolean expressions]]></name>
<configKey><![CDATA[rulesets/design.xml/SimplifyBooleanExpressions]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Avoid unnecessary comparisons in boolean expressions - this complicates simple code. Example :
<pre>
<rule key="SwitchStmtsShouldHaveDefault" priority="MAJOR">
<name><![CDATA[Switch statements should have default]]></name>
<configKey><![CDATA[rulesets/design.xml/SwitchStmtsShouldHaveDefault]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Switch statements should have a default label. Example :
<pre>
<rule key="DefaultLabelNotLastInSwitchStmt" priority="MAJOR">
<name><![CDATA[Default label not last in switch statement]]></name>
<configKey><![CDATA[rulesets/design.xml/DefaultLabelNotLastInSwitchStmt]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Switch statements should have a default label. Example :
<pre>
<rule key="ClassWithOnlyPrivateConstructorsShouldBeFinal" priority="MAJOR">
<name><![CDATA[Class with only private constructors should be final]]></name>
<configKey><![CDATA[rulesets/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[A class with only private constructors should be final, unless the private constructor is called by a inner class. Example :
<pre>
<rule key="AvoidFinalLocalVariable" priority="MAJOR">
<name><![CDATA[Avoid Final Local Variable]]></name>
<configKey><![CDATA[rulesets/controversial.xml/AvoidFinalLocalVariable]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Avoid using final local variables, turn them into fields. Example :
<pre>
<rule key="UnnecessaryParentheses" priority="MINOR">
<name><![CDATA[Unnecessary parentheses]]></name>
<configKey><![CDATA[rulesets/controversial.xml/UnnecessaryParentheses]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Sometimes expressions are wrapped in unnecessary parentheses, making them look like a function call. Example :
<pre>
<rule key="OverrideBothEqualsAndHashcode" priority="CRITICAL">
<name><![CDATA[Override both equals and hashcode]]></name>
<configKey><![CDATA[rulesets/basic.xml/OverrideBothEqualsAndHashcode]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Override both public boolean Object.equals(Object other), and public int Object.hashCode(), or override neither. Even if you are inheriting a hashCode() from a parent class, consider implementing hashCode and explicitly delegating to your superclass. Example :
<pre>
<rule key="UnusedImports" priority="INFO">
<name><![CDATA[Unused imports]]></name>
<configKey><![CDATA[rulesets/imports.xml/UnusedImports]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Avoid unused import statements. Example :
<pre>
<rule key="LocalVariableCouldBeFinal" priority="MINOR">
<name><![CDATA[Local variable could be final]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/LocalVariableCouldBeFinal]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[A local variable assigned only once can be declared final. Example :
<pre>
<rule key="AbstractNaming" priority="MAJOR">
<name><![CDATA[Abstract naming]]></name>
<configKey><![CDATA[rulesets/naming.xml/AbstractNaming]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Abstract classes should be named 'AbstractXXX'. Example :
<pre>
<rule key="NoPackage" priority="MAJOR">
<name><![CDATA[No package]]></name>
<configKey><![CDATA[rulesets/naming.xml/NoPackage]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Detects when a class or interface does not have a package definition. Example :
<pre>
<rule key="PackageCase" priority="MAJOR">
<name><![CDATA[Package case]]></name>
<configKey><![CDATA[rulesets/naming.xml/PackageCase]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[ Detects when a package definition contains upper case characters. Example :
<pre>
<rule key="ByteInstantiation" priority="MAJOR">
<name><![CDATA[Java5 migration - Byte instantiation]]></name>
<configKey><![CDATA[rulesets/migrating.xml/ByteInstantiation]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[In JDK 1.5, calling new Byte() causes memory allocation. Byte.valueOf() is more memory friendly. Example :
<pre>
<rule key="ShortInstantiation" priority="MAJOR">
<name><![CDATA[Java5 migration - Short instantiation]]></name>
<configKey><![CDATA[rulesets/migrating.xml/ShortInstantiation]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[In JDK 1.5, calling new Short() causes memory allocation. Short.valueOf() is more memory friendly. Example :
<pre>
<rule key="LongInstantiation" priority="MAJOR">
<name><![CDATA[Java5 migration - Long instantiation]]></name>
<configKey><![CDATA[rulesets/migrating.xml/LongInstantiation]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[In JDK 1.5, calling new Long() causes memory allocation. Long.valueOf() is more memory friendly. Example :
<pre>
<rule key="ProperCloneImplementation" priority="CRITICAL">
<name><![CDATA[Proper clone implementation]]></name>
<configKey><![CDATA[rulesets/clone.xml/ProperCloneImplementation]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Object clone() should be implemented with super.clone(). Example :
<pre>
<rule key="EmptyFinalizer" priority="MAJOR">
<name><![CDATA[Empty Finalizer]]></name>
<configKey><![CDATA[rulesets/finalizers.xml/EmptyFinalizer]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[If the finalize() method is empty, then it does not need to exist.]]></description>
</rule>
<rule key="FinalizeOnlyCallsSuperFinalize" priority="MAJOR">
<name><![CDATA[Finalize Only Calls Super Finalize]]></name>
<configKey><![CDATA[rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[If the finalize() is implemented, it should do something besides just calling super.finalize().]]></description>
</rule>
<rule key="FinalizeOverloaded" priority="MAJOR">
<name><![CDATA[Finalize Overloaded]]></name>
<configKey><![CDATA[rulesets/finalizers.xml/FinalizeOverloaded]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Methods named finalize() should not have parameters. It is confusing and probably a bug to overload finalize(). It will not be called by the VM.]]></description>
</rule>
<rule key="FinalizeDoesNotCallSuperFinalize" priority="MAJOR">
<name><![CDATA[Finalize Does Not Call Super Finalize]]></name>
<configKey><![CDATA[rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[If the finalize() is implemented, its last action should be to call super.finalize.]]></description>
</rule>
<rule key="FinalizeShouldBeProtected" priority="MAJOR">
<name><![CDATA[Finalize Should Be Protected]]></name>
<configKey><![CDATA[rulesets/finalizers.xml/FinalizeShouldBeProtected]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[If you override finalize(), make it protected. If you make it public, other classes may call it.]]></description>
</rule>
<rule key="AvoidCallingFinalize" priority="MAJOR">
<name><![CDATA[Avoid Calling Finalize]]></name>
<configKey><![CDATA[rulesets/finalizers.xml/AvoidCallingFinalize]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Object.finalize() is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. ]]></description>
</rule>
<rule key="DontNestJsfInJstlIteration" priority="MAJOR">
<name><![CDATA[Dont Nest Jsf In Jstl Iteration]]></name>
<configKey><![CDATA[rulesets/basic-jsf.xml/DontNestJsfInJstlIteration]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Do not nest JSF component custom actions inside a custom action that iterates over its body.]]></description>
</rule>
<rule key="UnusedPrivateField" priority="MAJOR">
<name><![CDATA[Unused Private Field]]></name>
<configKey><![CDATA[rulesets/unusedcode.xml/UnusedPrivateField]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Detects when a private field is declared and/or assigned a value, but not used.]]></description>
</rule>
<rule key="UnusedLocalVariable" priority="MAJOR">
<name><![CDATA[Unused local variable]]></name>
<configKey><![CDATA[rulesets/unusedcode.xml/UnusedLocalVariable]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Detects when a local variable is declared and/or assigned, but not used.]]></description>
</rule>
<rule key="UnusedPrivateMethod" priority="MAJOR">
<name><![CDATA[Unused private method]]></name>
<configKey><![CDATA[rulesets/unusedcode.xml/UnusedPrivateMethod]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Unused Private Method detects when a private method is declared but is unused. This PMD rule should be switched off and replaced by its equivalent from Squid that is more effective : it generates less false-positives and detects more dead code.]]></description>
</rule>
<rule key="UnusedFormalParameter" priority="MAJOR">
<name><![CDATA[Unused formal parameter]]></name>
<configKey><![CDATA[rulesets/unusedcode.xml/UnusedFormalParameter]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid passing parameters to methods or constructors and then not using those parameters. ]]></description>
</rule>
<rule key="UnnecessaryConstructor" priority="MAJOR">
<name><![CDATA[Unnecessary constructor]]></name>
<configKey><![CDATA[rulesets/controversial.xml/UnnecessaryConstructor]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[This rule detects when a constructor is not necessary; i.e., when there's only one constructor, it's public, has an empty body, and takes no arguments.]]></description>
</rule>
<rule key="NullAssignment" priority="MAJOR">
<name><![CDATA[Null Assignment]]></name>
<configKey><![CDATA[rulesets/controversial.xml/NullAssignment]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Assigning a null to a variable (outside of its declaration) is usually bad form. Some times, the assignment is an indication that the programmer doesn't completely understand what is going on in the code. NOTE: This sort of assignment may in rare cases be useful to encourage garbage collection. If that's what you're using it for, by all means, disregard this rule :-)]]></description>
</rule>
<rule key="OnlyOneReturn" priority="MINOR">
<name><![CDATA[Only One Return]]></name>
<configKey><![CDATA[rulesets/controversial.xml/OnlyOneReturn]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[A method should have only one exit point, and that should be the last statement in the method.]]></description>
</rule>
<rule key="UnusedModifier" priority="INFO">
<name><![CDATA[Unused Modifier]]></name>
<configKey><![CDATA[rulesets/controversial.xml/UnusedModifier]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Fields in interfaces are automatically public static final, and methods are public abstract. Classes or interfaces nested in an interface are automatically public and static (all nested interfaces are automatically static). For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous.]]></description>
</rule>
<rule key="AssignmentInOperand" priority="MAJOR">
<name><![CDATA[Assignment In Operand]]></name>
<configKey><![CDATA[rulesets/controversial.xml/AssignmentInOperand]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Avoid assignments in operands; this can make code more complicated and harder to read.]]></description>
</rule>
<rule key="AtLeastOneConstructor" priority="MAJOR">
<name><![CDATA[At Least One Constructor]]></name>
<configKey><![CDATA[rulesets/controversial.xml/AtLeastOneConstructor]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Each class should declare at least one constructor.]]></description>
</rule>
<rule key="DontImportSun" priority="MINOR">
<name><![CDATA[Dont Import Sun]]></name>
<configKey><![CDATA[rulesets/controversial.xml/DontImportSun]]></configKey>
- <category name="Portability"/>
+
<description><![CDATA[Avoid importing anything from the 'sun.*' packages. These packages are not portable and are likely to change.]]></description>
</rule>
<rule key="SuspiciousOctalEscape" priority="MAJOR">
<name><![CDATA[Suspicious Octal Escape]]></name>
<configKey><![CDATA[rulesets/controversial.xml/SuspiciousOctalEscape]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[A suspicious octal escape sequence was found inside a String literal. The Java language specification (section 3.10.6) says an octal escape sequence inside a literal String shall consist of a backslash followed by: OctalDigit | OctalDigit OctalDigit | ZeroToThree OctalDigit OctalDigit Any octal escape sequence followed by non-octal digits can be confusing, e.g. "\038" is interpreted as the octal escape sequence "\03" followed by the literal character 8.]]></description>
</rule>
<rule key="CallSuperInConstructor" priority="MINOR">
<name><![CDATA[Call Super In Constructor]]></name>
<configKey><![CDATA[rulesets/controversial.xml/CallSuperInConstructor]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[It is a good practice to call super() in a constructor. If super() is not called but another constructor (such as an overloaded constructor) is called, this rule will not report it.]]></description>
</rule>
<rule key="SingularField" priority="MINOR">
<name><![CDATA[Singular Field]]></name>
<configKey><![CDATA[rulesets/design.xml/SingularField]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[A field that's only used by one method could perhaps be replaced by a local variable.]]></description>
</rule>
<rule key="DefaultPackage" priority="MINOR">
<name><![CDATA[Default Package]]></name>
<configKey><![CDATA[rulesets/controversial.xml/DefaultPackage]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Use explicit scoping instead of the default package private level.]]></description>
</rule>
<rule key="BooleanInversion" priority="MAJOR">
<name><![CDATA[Boolean Inversion]]></name>
<configKey><![CDATA[rulesets/controversial.xml/BooleanInversion]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Use bitwise inversion to invert boolean values - it's the fastest way to do this. See http://www.javaspecialists.co.za/archive/newsletter.do?issue=042&locale=en_US for specific details]]></description>
</rule>
<rule key="DataflowAnomalyAnalysis" priority="MAJOR">
<name><![CDATA[Dataflow Anomaly Analysis]]></name>
<configKey><![CDATA[rulesets/controversial.xml/DataflowAnomalyAnalysis]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[The dataflow analysis tracks local definitions, undefinitions and references to variables on different paths on the data flow. From those informations there can be found various problems. 1. UR - Anomaly: There is a reference to a variable that was not defined before. This is a bug and leads to an error. 2. DU - Anomaly: A recently defined variable is undefined. These anomalies may appear in normal source text. 3. DD - Anomaly: A recently defined variable is redefined. This is ominous but don't have to be a bug. ]]></description>
<param key="maxviolations" type="i">
<rule key="CouplingBetweenObjects" priority="MAJOR">
<name><![CDATA[Coupling between objects]]></name>
<configKey><![CDATA[rulesets/coupling.xml/CouplingBetweenObjects]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[This rule counts unique attributes, local variables and return types within an object. A number higher than specified threshold can indicate a high degree of coupling.]]></description>
<param key="threshold" type="i">
<rule key="ExcessiveImports" priority="MAJOR">
<name><![CDATA[Coupling - excessive imports]]></name>
<configKey><![CDATA[rulesets/coupling.xml/ExcessiveImports]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[A high number of imports can indicate a high degree of coupling within an object. Rule counts the number of unique imports and reports a violation if the count is above the user defined threshold.]]></description>
<param key="minimum" type="i">
<rule key="LooseCoupling" priority="MAJOR">
<name><![CDATA[Loose coupling]]></name>
<configKey><![CDATA[rulesets/coupling.xml/LooseCoupling]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid using implementation types (i.e., HashSet); use the interface (i.e, Set) instead]]></description>
</rule>
<rule key="MethodArgumentCouldBeFinal" priority="MINOR">
<name><![CDATA[Method Argument Could Be Final]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/MethodArgumentCouldBeFinal]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[A method argument that is never assigned can be declared final.]]></description>
</rule>
<rule key="AvoidInstantiatingObjectsInLoops" priority="MINOR">
<name><![CDATA[Avoid instantiating objects in loops]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Detects when a new object is created inside a loop]]></description>
</rule>
<rule key="UseArrayListInsteadOfVector" priority="MAJOR">
<name><![CDATA[Use Array List Instead Of Vector]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/UseArrayListInsteadOfVector]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[ArrayList is a much better Collection implementation than Vector.]]></description>
</rule>
<rule key="SimplifyStartsWith" priority="MINOR">
<name><![CDATA[Simplify Starts With]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/SimplifyStartsWith]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Since it passes in a literal of length 1, this call to String.startsWith can be rewritten using String.charAt(0) to save some time.]]></description>
</rule>
<rule key="UseStringBufferForStringAppends" priority="MAJOR">
<name><![CDATA[Use String Buffer For String Appends]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/UseStringBufferForStringAppends]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Finds usages of += for appending strings.]]></description>
</rule>
<rule key="UseArraysAsList" priority="MAJOR">
<name><![CDATA[Use Arrays As List]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/UseArraysAsList]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[The class java.util.Arrays has a asList method that should be use when you want to create a new List from an array of objects. It is faster than executing a loop to cpy all the elements of the array one by one]]></description>
</rule>
<rule key="AvoidArrayLoops" priority="MAJOR">
<name><![CDATA[Avoid Array Loops]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/AvoidArrayLoops]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Instead of copying data between two arrays, use System.arrayCopy method]]></description>
</rule>
<rule key="UnnecessaryWrapperObjectCreation" priority="MAJOR">
<name><![CDATA[Unnecessary Wrapper Object Creation]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/UnnecessaryWrapperObjectCreation]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Parsing method should be called directy instead. ]]></description>
</rule>
<rule key="UseProperClassLoader" priority="CRITICAL">
<name><![CDATA[Use Proper Class Loader]]></name>
<configKey><![CDATA[rulesets/j2ee.xml/UseProperClassLoader]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[In J2EE getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead.]]></description>
</rule>
<rule key="EmptyCatchBlock" priority="CRITICAL">
<name><![CDATA[Empty Catch Block]]></name>
<configKey><![CDATA[rulesets/basic.xml/EmptyCatchBlock]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Empty Catch Block finds instances where an exception is caught, but nothing is done. In most circumstances, this swallows an exception which should either be acted on or reported.]]></description>
<param key="allowCommentedBlocks" type="b">
<rule key="EmptyIfStmt" priority="CRITICAL">
<name><![CDATA[Empty If Stmt]]></name>
<configKey><![CDATA[rulesets/basic.xml/EmptyIfStmt]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Empty If Statement finds instances where a condition is checked but nothing is done about it.]]></description>
</rule>
<rule key="EmptyWhileStmt" priority="CRITICAL">
<name><![CDATA[Empty While Stmt]]></name>
<configKey><![CDATA[rulesets/basic.xml/EmptyWhileStmt]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Empty While Statement finds all instances where a while statement does nothing. If it is a timing loop, then you should use Thread.sleep() for it; if it's a while loop that does a lot in the exit expression, rewrite it to make it clearer.]]></description>
</rule>
<rule key="EmptyTryBlock" priority="MAJOR">
<name><![CDATA[Empty Try Block]]></name>
<configKey><![CDATA[rulesets/basic.xml/EmptyTryBlock]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid empty try blocks - what's the point?]]></description>
</rule>
<rule key="EmptyFinallyBlock" priority="CRITICAL">
<name><![CDATA[Empty Finally Block]]></name>
<configKey><![CDATA[rulesets/basic.xml/EmptyFinallyBlock]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid empty finally blocks - these can be deleted.]]></description>
</rule>
<rule key="EmptySwitchStatements" priority="MAJOR">
<name><![CDATA[Empty Switch Statements]]></name>
<configKey><![CDATA[rulesets/basic.xml/EmptySwitchStatements]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid empty switch statements.]]></description>
</rule>
<rule key="JumbledIncrementer" priority="MAJOR">
<name><![CDATA[Jumbled Incrementer]]></name>
<configKey><![CDATA[rulesets/basic.xml/JumbledIncrementer]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Avoid jumbled loop incrementers - it's usually a mistake, and it's confusing even if it's what's intended.
<br>Example :
<pre>
<rule key="ForLoopShouldBeWhileLoop" priority="MINOR">
<name><![CDATA[For Loop Should Be While Loop]]></name>
<configKey><![CDATA[rulesets/basic.xml/ForLoopShouldBeWhileLoop]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Some for loops can be simplified to while loops - this makes them more concise.]]></description>
</rule>
<rule key="UnnecessaryConversionTemporary" priority="MAJOR">
<name><![CDATA[Unnecessary Conversion Temporary]]></name>
<configKey><![CDATA[rulesets/basic.xml/UnnecessaryConversionTemporary]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Avoid unnecessary temporaries when converting primitives to Strings]]></description>
</rule>
<rule key="ReturnFromFinallyBlock" priority="MAJOR">
<name><![CDATA[Return From Finally Block]]></name>
<configKey><![CDATA[rulesets/basic.xml/ReturnFromFinallyBlock]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Avoid returning from a finally block - this can discard exceptions.]]></description>
</rule>
<rule key="EmptySynchronizedBlock" priority="CRITICAL">
<name><![CDATA[Empty Synchronized Block]]></name>
<configKey><![CDATA[rulesets/basic.xml/EmptySynchronizedBlock]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid empty synchronized blocks - they're useless.]]></description>
</rule>
<rule key="UnnecessaryReturn" priority="MINOR">
<name><![CDATA[Unnecessary Return]]></name>
<configKey><![CDATA[rulesets/basic.xml/UnnecessaryReturn]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid unnecessary return statements]]></description>
</rule>
<rule key="EmptyStaticInitializer" priority="MAJOR">
<name><![CDATA[Empty Static Initializer]]></name>
<configKey><![CDATA[rulesets/basic.xml/EmptyStaticInitializer]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[An empty static initializer was found.]]></description>
</rule>
<rule key="UnconditionalIfStatement" priority="CRITICAL">
<name><![CDATA[Unconditional If Statement]]></name>
<configKey><![CDATA[rulesets/basic.xml/UnconditionalIfStatement]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Do not use if statements that are always true or always false.]]></description>
</rule>
<rule key="EmptyStatementNotInLoop" priority="MAJOR">
<name><![CDATA[Empty Statement Not In Loop]]></name>
<configKey><![CDATA[rulesets/basic.xml/EmptyStatementNotInLoop]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[An empty statement (aka a semicolon by itself) that is not used as the sole body of a for loop or while loop is probably a bug. It could also be a double semicolon, which is useless and should be removed.]]></description>
</rule>
<rule key="BooleanInstantiation" priority="MAJOR">
<name><![CDATA[Boolean Instantiation]]></name>
<configKey><![CDATA[rulesets/basic.xml/BooleanInstantiation]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boolean.valueOf() instead.]]></description>
</rule>
<rule key="UnnecessaryFinalModifier" priority="INFO">
<name><![CDATA[Unnecessary Final Modifier]]></name>
<configKey><![CDATA[rulesets/basic.xml/UnnecessaryFinalModifier]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[When a class has the final modifier, all the methods are automatically final.]]></description>
</rule>
<rule key="CollapsibleIfStatements" priority="MINOR">
<name><![CDATA[Collapsible If Statements]]></name>
<configKey><![CDATA[rulesets/basic.xml/CollapsibleIfStatements]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Sometimes two 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.]]></description>
</rule>
<rule key="UselessOverridingMethod" priority="MAJOR">
<name><![CDATA[Useless Overriding Method]]></name>
<configKey><![CDATA[rulesets/basic.xml/UselessOverridingMethod]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[The overriding method merely calls the same method defined in a superclass]]></description>
</rule>
<rule key="ClassCastExceptionWithToArray" priority="MAJOR">
<name><![CDATA[Class Cast Exception With To Array]]></name>
<configKey><![CDATA[rulesets/basic.xml/ClassCastExceptionWithToArray]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[if you need to get an array of a class from your Collection, you should pass an array of the desidered class as the parameter of the toArray method. Otherwise you will get a ClassCastException.]]></description>
</rule>
<rule key="AvoidDecimalLiteralsInBigDecimalConstructor" priority="MAJOR">
<name><![CDATA[Avoid Decimal Literals In Big Decimal Constructor]]></name>
<configKey><![CDATA[rulesets/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[One might assume that new BigDecimal(.1) is exactly equal to .1, but it is actually equal to .1000000000000000055511151231257827021181583404541015625. This is so because .1 cannot be represented exactly as a double (or, for that matter, as a binary fraction of any finite length). Thus, the long value that is being passed in to the constructor is not exactly equal to .1, appearances notwithstanding. The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal(.1)' is exactly equal to .1, as one would expect. Therefore, it is generally recommended that the (String) constructor be used in preference to this one.]]></description>
</rule>
<rule key="UselessOperationOnImmutable" priority="CRITICAL">
<name><![CDATA[Useless Operation On Immutable]]></name>
<configKey><![CDATA[rulesets/basic.xml/UselessOperationOnImmutable]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[An operation on an Immutable object (BigDecimal or BigInteger) won't change the object itself. The result of the operation is a new object. Therefore, ignoring the operation result is an error.]]></description>
</rule>
<rule key="MisplacedNullCheck" priority="CRITICAL">
<name><![CDATA[Misplaced Null Check]]></name>
<configKey><![CDATA[rulesets/basic.xml/MisplacedNullCheck]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[The null check here is misplaced. if the variable is null you'll get a NullPointerException.
Either the check is useless (the variable will never be null) or it's incorrect.
<rule key="UnusedNullCheckInEquals" priority="MAJOR">
<name><![CDATA[Unused Null Check In Equals]]></name>
<configKey><![CDATA[rulesets/basic.xml/UnusedNullCheckInEquals]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[After checking an object reference for null, you should invoke equals() on that object rather than passing it to another object's equals() method.]]></description>
</rule>
<rule key="AvoidThreadGroup" priority="CRITICAL">
<name><![CDATA[Avoid Thread Group]]></name>
<configKey><![CDATA[rulesets/basic.xml/AvoidThreadGroup]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Avoid using ThreadGroup; although it is intended to be used in a threaded environment it contains methods that are not thread safe.]]></description>
</rule>
<rule key="BrokenNullCheck" priority="CRITICAL">
<name><![CDATA[Broken Null Check]]></name>
<configKey><![CDATA[rulesets/basic.xml/BrokenNullCheck]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[The null check is broken since it will throw a Nullpointer itself. The reason is that a method is called on the object when it is null. It is likely that you used || instead of && or vice versa.]]></description>
</rule>
<rule key="BigIntegerInstantiation" priority="MAJOR">
<name><![CDATA[Big Integer Instantiation]]></name>
<configKey><![CDATA[rulesets/basic.xml/BigIntegerInstantiation]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Don't create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) and for 1.5 on, BigInteger.TEN and BigDecimal (BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN)]]></description>
</rule>
<rule key="AvoidUsingOctalValues" priority="MAJOR">
<name><![CDATA[Avoid Using Octal Values]]></name>
<configKey><![CDATA[rulesets/basic.xml/AvoidUsingOctalValues]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Integer literals should not start with zero. Zero means that the rest of literal will be interpreted as an octal value. ]]></description>
</rule>
<rule key="UseSingleton" priority="MAJOR">
<name><![CDATA[Use Singleton]]></name>
<configKey><![CDATA[rulesets/design.xml/UseSingleton]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[If you have a class that has nothing but static methods, consider making it a Singleton. Note that this doesn't apply to abstract classes, since their subclasses may well include non-static methods. Also, if you want this class to be a Singleton, remember to add a private constructor to prevent instantiation.]]></description>
</rule>
<rule key="AvoidDeeplyNestedIfStmts" priority="MAJOR">
<name><![CDATA[Avoid Deeply Nested If Stmts]]></name>
<configKey><![CDATA[rulesets/design.xml/AvoidDeeplyNestedIfStmts]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Deeply nested if..then statements are hard to read.]]></description>
<param key="problemDepth" type="i">
<description><![CDATA[The if statement depth reporting threshold. Default is 3.]]></description>
<rule key="AvoidReassigningParameters" priority="MAJOR">
<name><![CDATA[Avoid Reassigning Parameters]]></name>
<configKey><![CDATA[rulesets/design.xml/AvoidReassigningParameters]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Reassigning values to parameters is a questionable practice. Use a temporary local variable instead.]]></description>
</rule>
<rule key="SwitchDensity" priority="MAJOR">
<name><![CDATA[Switch Density]]></name>
<configKey><![CDATA[rulesets/design.xml/SwitchDensity]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[A high ratio of statements to labels in a switch statement implies that the switch statement is doing too much work. Consider moving the statements into new methods, or creating subclasses based on the switch variable.]]></description>
<param key="minimum" type="i">
<rule key="ConstructorCallsOverridableMethod" priority="MAJOR">
<name><![CDATA[Constructor Calls Overridable Method]]></name>
<configKey><![CDATA[rulesets/design.xml/ConstructorCallsOverridableMethod]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Calling overridable methods during construction poses a risk of invoking methods on an incompletely constructed object
and can be difficult to discern. It may leave the sub-class unable to construct its superclass or forced to replicate
<rule key="AccessorClassGeneration" priority="MAJOR">
<name><![CDATA[Accessor Class Generation]]></name>
<configKey><![CDATA[rulesets/design.xml/AccessorClassGeneration]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Instantiation by way of private constructors from outside of the constructor's class often causes the generation of an accessor. A factory method, or non-privitization of the constructor can eliminate this situation. The generated class file is actually an interface. It gives the accessing class the ability to invoke a new hidden package scope constructor that takes the interface as a supplementary parameter. This turns a private constructor effectively into one with package scope, and is challenging to discern.]]></description>
</rule>
<rule key="FinalFieldCouldBeStatic" priority="MINOR">
<name><![CDATA[Final Field Could Be Static]]></name>
<configKey><![CDATA[rulesets/design.xml/FinalFieldCouldBeStatic]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[If a final field is assigned to a compile-time constant, it could be made static, thus saving overhead in each object at runtime.]]></description>
</rule>
<rule key="CloseResource" priority="MAJOR">
<name><![CDATA[Close Resource]]></name>
<configKey><![CDATA[rulesets/design.xml/CloseResource]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Ensure that resources (like Connection, Statement, and ResultSet objects) are always closed after use. It does this by looking for code patterned like :
<pre>
Connection c = openConnection();
<rule key="NonStaticInitializer" priority="MAJOR">
<name><![CDATA[Non Static Initializer]]></name>
<configKey><![CDATA[rulesets/design.xml/NonStaticInitializer]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[A nonstatic initializer block will be called any time a constructor is invoked (just prior to invoking the constructor). While this is a valid language construct, it is rarely used and is confusing. Example :<br/><code>public class MyClass {<br/>// this block gets run before any call to a constructor {<br/>System.out.println("I am about to construct myself");<br/>}<br/>}</code>]]></description>
</rule>
<rule key="NonCaseLabelInSwitchStatement" priority="MAJOR">
<name><![CDATA[Non Case Label In Switch Statement]]></name>
<configKey><![CDATA[rulesets/design.xml/NonCaseLabelInSwitchStatement]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[A non-case label (e.g. a named break/continue label) was present in a switch statement. This legal, but confusing. It is easy to mix up the case labels and the non-case labels.]]></description>
</rule>
<rule key="OptimizableToArrayCall" priority="MAJOR">
<name><![CDATA[Optimizable To Array Call]]></name>
<configKey><![CDATA[rulesets/design.xml/OptimizableToArrayCall]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[A call to Collection.toArray can use the Collection's size vs an empty Array of the desired type.]]></description>
</rule>
<rule key="BadComparison" priority="MAJOR">
<name><![CDATA[Bad Comparison]]></name>
<configKey><![CDATA[rulesets/design.xml/BadComparison]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Avoid equality comparisons with Double.NaN - these are likely to be logic errors.]]></description>
</rule>
<rule key="EqualsNull" priority="CRITICAL">
<name><![CDATA[Equals Null]]></name>
<configKey><![CDATA[rulesets/design.xml/EqualsNull]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Inexperienced programmers sometimes confuse comparison concepts and use equals() to compare to null.]]></description>
</rule>
<rule key="ConfusingTernary" priority="MAJOR">
<name><![CDATA[Confusing Ternary]]></name>
<configKey><![CDATA[rulesets/design.xml/ConfusingTernary]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[In an if expression with an else clause, avoid negation in the test. For example, rephrase: if (x != y) diff(); else same(); as: if (x == y) same(); else diff(); Most if (x != y) cases without an else are often return cases, so consistent use of this rule makes the code easier to read. Also, this resolves trivial ordering problems, such as does the error case go first? or does the common case go first?.]]></description>
</rule>
<rule key="InstantiationToGetClass" priority="MAJOR">
<name><![CDATA[Instantiation To Get Class]]></name>
<configKey><![CDATA[rulesets/design.xml/InstantiationToGetClass]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Avoid instantiating an object just to call getClass() on it; use the .class public member instead. Example : replace <code>Class c = new String().getClass();</code> with <code>Class c = String.class;</code>]]></description>
</rule>
<rule key="IdempotentOperations" priority="MAJOR">
<name><![CDATA[Idempotent Operations]]></name>
<configKey><![CDATA[rulesets/design.xml/IdempotentOperations]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Avoid idempotent operations - they are have no effect. Example : <br/><code>int x = 2;<br/> x = x;</code>]]></description>
</rule>
<rule key="SimpleDateFormatNeedsLocale" priority="MAJOR">
<name><![CDATA[Simple Date Format Needs Locale]]></name>
<configKey><![CDATA[rulesets/design.xml/SimpleDateFormatNeedsLocale]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Be sure to specify a Locale when creating a new instance of SimpleDateFormat.]]></description>
</rule>
<rule key="ImmutableField" priority="MAJOR">
<name><![CDATA[Immutable Field]]></name>
<configKey><![CDATA[rulesets/design.xml/ImmutableField]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Identifies private fields whose values never change once they are initialized either in the declaration of the field or by a constructor. This aids in converting existing classes to immutable classes.]]></description>
</rule>
<rule key="UseLocaleWithCaseConversions" priority="MAJOR">
<name><![CDATA[Use Locale With Case Conversions]]></name>
<configKey><![CDATA[rulesets/design.xml/UseLocaleWithCaseConversions]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[When doing a String.toLowerCase()/toUpperCase() call, use a Locale. This avoids problems with certain locales, i.e. Turkish.]]></description>
</rule>
<rule key="AvoidProtectedFieldInFinalClass" priority="MAJOR">
<name><![CDATA[Avoid Protected Field In Final Class]]></name>
<configKey><![CDATA[rulesets/design.xml/AvoidProtectedFieldInFinalClass]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Do not use protected fields in final classes since they cannot be subclassed. Clarify your intent by using private or package access modifiers instead.]]></description>
</rule>
<rule key="AssignmentToNonFinalStatic" priority="MAJOR">
<name><![CDATA[Assignment To Non Final Static]]></name>
<configKey><![CDATA[rulesets/design.xml/AssignmentToNonFinalStatic]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Identifies a possible unsafe usage of a static field.]]></description>
</rule>
<rule key="MissingStaticMethodInNonInstantiatableClass" priority="MAJOR">
<name><![CDATA[Missing Static Method In Non Instantiatable Class]]></name>
<configKey><![CDATA[rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[A class that has private constructors and does not have any static methods or fields cannot be used.]]></description>
</rule>
<rule key="AvoidSynchronizedAtMethodLevel" priority="MAJOR">
<name><![CDATA[Avoid Synchronized At Method Level]]></name>
<configKey><![CDATA[rulesets/design.xml/AvoidSynchronizedAtMethodLevel]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Method level synchronization can backfire when new code is added to the method. Block-level synchronization helps to ensure that only the code that needs synchronization gets it.]]></description>
</rule>
<rule key="MissingBreakInSwitch" priority="CRITICAL">
<name><![CDATA[Missing Break In Switch]]></name>
<configKey><![CDATA[rulesets/design.xml/MissingBreakInSwitch]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[A switch statement without an enclosed break statement may be a bug.]]></description>
</rule>
<rule key="UseNotifyAllInsteadOfNotify" priority="MAJOR">
<name><![CDATA[Use Notify All Instead Of Notify]]></name>
<configKey><![CDATA[rulesets/design.xml/UseNotifyAllInsteadOfNotify]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Thread.notify() awakens a thread monitoring the object. If more than one thread is monitoring, then only one is chosen. The thread chosen is arbitrary; thus it's usually safer to call notifyAll() instead.]]></description>
</rule>
<rule key="AvoidInstanceofChecksInCatchClause" priority="MINOR">
<name><![CDATA[Avoid Instanceof Checks In Catch Clause]]></name>
<configKey><![CDATA[rulesets/design.xml/AvoidInstanceofChecksInCatchClause]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Each caught exception type should be handled in its own catch clause.]]></description>
</rule>
<rule key="AbstractClassWithoutAbstractMethod" priority="MAJOR">
<name><![CDATA[Abstract Class Without Abstract Method]]></name>
<configKey><![CDATA[rulesets/design.xml/AbstractClassWithoutAbstractMethod]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[The abstract class does not contain any abstract methods. An abstract class suggests an incomplete implementation, which is to be completed by subclasses implementing the abstract methods. If the class is intended to be used as a base class only (not to be instantiated direcly) a protected constructor can be provided prevent direct instantiation.]]></description>
</rule>
<rule key="SimplifyConditional" priority="MAJOR">
<name><![CDATA[Simplify Conditional]]></name>
<configKey><![CDATA[rulesets/design.xml/SimplifyConditional]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[No need to check for null before an instanceof; the instanceof keyword returns false when given a null argument.]]></description>
</rule>
<rule key="CompareObjectsWithEquals" priority="MAJOR">
<name><![CDATA[Compare Objects With Equals]]></name>
<configKey><![CDATA[rulesets/design.xml/CompareObjectsWithEquals]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Use equals() to compare object references; avoid comparing them with ==.]]></description>
</rule>
<rule key="PositionLiteralsFirstInComparisons" priority="MAJOR">
<name><![CDATA[Position Literals First In Comparisons]]></name>
<configKey><![CDATA[rulesets/design.xml/PositionLiteralsFirstInComparisons]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Position literals first in String comparisons - that way if the String is null you won't get a NullPointerException, it'll just return false.]]></description>
</rule>
<rule key="UnnecessaryLocalBeforeReturn" priority="MAJOR">
<name><![CDATA[Unnecessary Local Before Return]]></name>
<configKey><![CDATA[rulesets/design.xml/UnnecessaryLocalBeforeReturn]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Avoid unnecessarily creating local variables]]></description>
</rule>
<rule key="NonThreadSafeSingleton" priority="MAJOR">
<name><![CDATA[Non Thread Safe Singleton]]></name>
<configKey><![CDATA[rulesets/design.xml/NonThreadSafeSingleton]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Non-thread safe singletons can result in bad state changes. Eliminate static singletons if possible by instantiating the object directly. Static singletons are usually not needed as only a single instance exists anyway. Other possible fixes are to synchronize the entire method or to use an initialize-on-demand holder class (do not use the double-check idiom). See Effective Java, item 48.]]></description>
<param key="checkNonStaticMethods" type="b" priority="MAJOR">
<rule key="UncommentedEmptyMethod" priority="MAJOR">
<name><![CDATA[Uncommented Empty Method]]></name>
<configKey><![CDATA[rulesets/design.xml/UncommentedEmptyMethod]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Uncommented Empty Method finds instances where a method does not contain statements, but there is no comment. By explicitly commenting empty methods it is easier to distinguish between intentional (commented) and unintentional empty methods.]]></description>
</rule>
<rule key="UncommentedEmptyConstructor" priority="MAJOR">
<name><![CDATA[Uncommented Empty Constructor]]></name>
<configKey><![CDATA[rulesets/design.xml/UncommentedEmptyConstructor]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Uncommented Empty Constructor finds instances where a constructor does not contain statements, but there is no comment. By explicitly commenting empty constructors it is easier to distinguish between intentional (commented) and unintentional empty constructors.]]></description>
<param key="ignoreExplicitConstructorInvocation" type="b">
<rule key="AvoidConstantsInterface" priority="MAJOR">
<name><![CDATA[Avoid Constants Interface]]></name>
<configKey><![CDATA[rulesets/design.xml/AvoidConstantsInterface]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[An interface should be used only to model a behaviour of a class: using an interface as a container of constants is a poor usage pattern.]]></description>
</rule>
<rule key="UnsynchronizedStaticDateFormatter" priority="MAJOR">
<name><![CDATA[Unsynchronized Static Date Formatter]]></name>
<configKey><![CDATA[rulesets/design.xml/UnsynchronizedStaticDateFormatter]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[SimpleDateFormat is not synchronized. Sun recomends separate format instances for each thread. If multiple threads must access a static formatter, the formatter must be synchronized either on method or block level.]]></description>
</rule>
<rule key="PreserveStackTrace" priority="MAJOR">
<name><![CDATA[Preserve Stack Trace]]></name>
<configKey><![CDATA[rulesets/design.xml/PreserveStackTrace]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Throwing a new exception from a catch block without passing the original exception into the new Exception will cause the true stack trace to be lost, and can make it difficult to debug effectively.]]></description>
</rule>
<rule key="UseCollectionIsEmpty" priority="MINOR">
<name><![CDATA[Use Collection Is Empty]]></name>
<configKey><![CDATA[rulesets/design.xml/UseCollectionIsEmpty]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[The isEmpty() method on java.util.Collection is provided to see if a collection has any elements. Comparing the value of size() to 0 merely duplicates existing behavior. ]]></description>
</rule>
<rule key="MethodReturnsInternalArray" priority="CRITICAL">
<name><![CDATA[Security - Method returns internal array]]></name>
<configKey><![CDATA[rulesets/sunsecure.xml/MethodReturnsInternalArray]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Exposing internal arrays directly allows the user to modify some code that could be critical. It is safer to return a copy of the array.]]></description>
</rule>
<rule key="ArrayIsStoredDirectly" priority="CRITICAL">
<name><![CDATA[Security - Array is stored directly]]></name>
<configKey><![CDATA[rulesets/sunsecure.xml/ArrayIsStoredDirectly]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Constructors and methods receiving arrays should clone objects and store the copy. This prevents that future changes from the user affect the internal functionality. ]]></description>
</rule>
<rule key="AvoidCatchingThrowable" priority="CRITICAL">
<name><![CDATA[Avoid Catching Throwable]]></name>
<configKey><![CDATA[rulesets/strictexception.xml/AvoidCatchingThrowable]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[This is dangerous because it casts too wide a net; it can catch things like OutOfMemoryError.]]></description>
</rule>
<rule key="SignatureDeclareThrowsException" priority="MAJOR">
<name><![CDATA[Signature Declare Throws Exception]]></name>
<configKey><![CDATA[rulesets/strictexception.xml/SignatureDeclareThrowsException]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[It is unclear which exceptions that can be thrown from the methods. It might be difficult to document and understand the vague interfaces. Use either a class derived from RuntimeException or a checked exception.]]></description>
</rule>
<rule key="ExceptionAsFlowControl" priority="MAJOR">
<name><![CDATA[Exception As Flow Control]]></name>
<configKey><![CDATA[rulesets/strictexception.xml/ExceptionAsFlowControl]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Using Exceptions as flow control leads to GOTOish code and obscures true exceptions when debugging.]]></description>
</rule>
<rule key="AvoidCatchingNPE" priority="MAJOR">
<name><![CDATA[Avoid Catching NPE]]></name>
<configKey><![CDATA[rulesets/strictexception.xml/AvoidCatchingNPE]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Code should never throw NPE under normal circumstances. A catch block may hide the original error, causing other more subtle errors in its wake.]]></description>
</rule>
<rule key="AvoidThrowingRawExceptionTypes" priority="MAJOR">
<name><![CDATA[Avoid Throwing Raw Exception Types]]></name>
<configKey><![CDATA[rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable, Exception, or Error, use a subclassed exception or error instead.]]></description>
</rule>
<rule key="AvoidThrowingNullPointerException" priority="MAJOR">
<name><![CDATA[Avoid Throwing Null Pointer Exception]]></name>
<configKey><![CDATA[rulesets/strictexception.xml/AvoidThrowingNullPointerException]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Avoid throwing a NullPointerException - it's confusing because most people will assume that the virtual machine threw it. Consider using an IllegalArgumentException instead; this will be clearly seen as a programmer-initiated exception.]]></description>
</rule>
<rule key="AvoidRethrowingException" priority="MAJOR">
<name><![CDATA[Avoid Rethrowing Exception]]></name>
<configKey><![CDATA[rulesets/strictexception.xml/AvoidRethrowingException]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity.]]></description>
</rule>
<rule key="BeanMembersShouldSerialize" priority="MAJOR">
<name><![CDATA[Bean Members Should Serialize]]></name>
<configKey><![CDATA[rulesets/javabeans.xml/BeanMembersShouldSerialize]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable. Member variables need to be marked as transient, static, or have accessor methods in the class. Marking variables as transient is the safest and easiest modification. Accessor methods should follow the Java naming conventions, i.e.if you have a variable foo, you should provide getFoo and setFoo methods.]]></description>
<param key="prefix" type="s">
<rule key="MissingSerialVersionUID" priority="MAJOR">
<name><![CDATA[Missing Serial Version UID]]></name>
<configKey><![CDATA[rulesets/javabeans.xml/MissingSerialVersionUID]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Classes that are serializable should provide a serialVersionUID field. ]]></description>
</rule>
<rule key="CloneMethodMustImplementCloneable" priority="MAJOR">
<name><![CDATA[Clone method must implement Cloneable]]></name>
<configKey><![CDATA[rulesets/clone.xml/CloneMethodMustImplementCloneable]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[The method clone() should only be implemented if the class implements the Cloneable interface with the exception of a final method that only throws CloneNotSupportedException. This version uses PMD's type resolution facilities, and can detect if the class implements or extends a Cloneable class ]]></description>
</rule>
<rule key="AvoidDuplicateLiterals" priority="MAJOR">
<name><![CDATA[Avoid Duplicate Literals]]></name>
<configKey><![CDATA[rulesets/strings.xml/AvoidDuplicateLiterals]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Code containing duplicate String literals can usually be improved by declaring the String as a constant field. Example :
<pre>
public class Foo {
<rule key="StringInstantiation" priority="MAJOR">
<name><![CDATA[String Instantiation]]></name>
<configKey><![CDATA[rulesets/strings.xml/StringInstantiation]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Avoid instantiating String objects; this is usually unnecessary.]]></description>
</rule>
<rule key="StringToString" priority="MAJOR">
<name><![CDATA[String To String]]></name>
<configKey><![CDATA[rulesets/strings.xml/StringToString]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid calling toString() on String objects; this is unnecessary.]]></description>
</rule>
<rule key="InefficientStringBuffering" priority="MAJOR">
<name><![CDATA[Inefficient String Buffering]]></name>
<configKey><![CDATA[rulesets/strings.xml/InefficientStringBuffering]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Avoid concatenating non literals in a StringBuffer constructor or append().]]></description>
</rule>
<rule key="UnnecessaryCaseChange" priority="MINOR">
<name><![CDATA[Unnecessary Case Change]]></name>
<configKey><![CDATA[rulesets/strings.xml/UnnecessaryCaseChange]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals()]]></description>
</rule>
<rule key="UseStringBufferLength" priority="MINOR">
<name><![CDATA[Use String Buffer Length]]></name>
<configKey><![CDATA[rulesets/strings.xml/UseStringBufferLength]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Use StringBuffer.length() to determine StringBuffer length rather than using StringBuffer.toString().equals() or StringBuffer.toString().length() ==.]]></description>
</rule>
<rule key="AppendCharacterWithChar" priority="MINOR">
<name><![CDATA[Append Character With Char]]></name>
<configKey><![CDATA[rulesets/strings.xml/AppendCharacterWithChar]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Avoid concatenating characters as strings in StringBuffer.append.]]></description>
</rule>
<rule key="ConsecutiveLiteralAppends" priority="MINOR">
<name><![CDATA[Consecutive Literal Appends]]></name>
<configKey><![CDATA[rulesets/strings.xml/ConsecutiveLiteralAppends]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Consecutively calling StringBuffer.append with String literals]]></description>
<param key="threshold" type="i">
<description><![CDATA[The report threshold. Default is 1.]]></description>
<rule key="UseIndexOfChar" priority="MAJOR">
<name><![CDATA[Use Index Of Char]]></name>
<configKey><![CDATA[rulesets/strings.xml/UseIndexOfChar]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Use String.indexOf(char) when checking for the index of a single character; it executes faster.]]></description>
</rule>
<rule key="InefficientEmptyStringCheck" priority="MAJOR">
<name><![CDATA[Inefficient Empty String Check]]></name>
<configKey><![CDATA[rulesets/strings.xml/InefficientEmptyStringCheck]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[String.trim().length() is an inefficient way to check if a String is really empty, as it creates a new String object just to check its size. Consider creating a static function that loops through a string, checking Character.isWhitespace() on each character and returning false if a non-whitespace character is found.]]></description>
</rule>
<rule key="InsufficientStringBufferDeclaration" priority="MAJOR">
<name><![CDATA[Insufficient String Buffer Declaration]]></name>
<configKey><![CDATA[rulesets/strings.xml/InsufficientStringBufferDeclaration]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Failing to pre-size a StringBuffer properly could cause it to re-size many times during runtime. This rule checks the characters that are actually passed into StringBuffer.append(), but represents a best guess worst case scenario. An empty StringBuffer constructor initializes the object to 16 characters. This default is assumed if the length of the constructor can not be determined.]]></description>
</rule>
<rule key="UselessStringValueOf" priority="MINOR">
<name><![CDATA[Useless String Value Of]]></name>
<configKey><![CDATA[rulesets/strings.xml/UselessStringValueOf]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[No need to call String.valueOf to append to a string; just use the valueOf() argument directly.]]></description>
</rule>
<rule key="StringBufferInstantiationWithChar" priority="MAJOR">
<name><![CDATA[String Buffer Instantiation With Char]]></name>
<configKey><![CDATA[rulesets/strings.xml/StringBufferInstantiationWithChar]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[StringBuffer sb = new StringBuffer('c'); The char will be converted into int to intialize StringBuffer size. ]]></description>
</rule>
<rule key="ExcessiveMethodLength" priority="MAJOR">
<name><![CDATA[Excessive Method Length]]></name>
<configKey><![CDATA[rulesets/codesize.xml/ExcessiveMethodLength]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Violations of this rule usually indicate that the method is doing too much. Try to reduce the method size by creating helper methods and removing any copy/pasted code.]]></description>
<param key="minimum" type="i">
<rule key="ExcessiveParameterList" priority="MAJOR">
<name><![CDATA[Excessive Parameter List]]></name>
<configKey><![CDATA[rulesets/codesize.xml/ExcessiveParameterList]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Long parameter lists can indicate that a new object should be created to wrap the numerous parameters. Basically, try to group the parameters together.]]></description>
<param key="minimum" type="i">
<rule key="ExcessiveClassLength" priority="MAJOR">
<name><![CDATA[Excessive Class Length]]></name>
<configKey><![CDATA[rulesets/codesize.xml/ExcessiveClassLength]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Long Class files are indications that the class may be trying to do too much. Try to break it down, and reduce the size to something manageable.]]></description>
<param key="minimum" type="i">
<rule key="ExcessivePublicCount" priority="MAJOR">
<name><![CDATA[Excessive Public Count]]></name>
<configKey><![CDATA[rulesets/codesize.xml/ExcessivePublicCount]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.]]></description>
<param key="minimum" type="i">
<rule key="TooManyFields" priority="MAJOR">
<name><![CDATA[Too Many Fields]]></name>
<configKey><![CDATA[rulesets/codesize.xml/TooManyFields]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.]]></description>
<param key="maxfields" type="i">
<rule key="NcssMethodCount" priority="MAJOR">
<name><![CDATA[Ncss Method Count]]></name>
<configKey><![CDATA[rulesets/codesize.xml/NcssMethodCount]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given method. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one.]]></description>
<param key="minimum" type="i">
<rule key="NcssTypeCount" priority="MAJOR">
<name><![CDATA[Ncss Type Count]]></name>
<configKey><![CDATA[rulesets/codesize.xml/NcssTypeCount]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given type. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one.]]></description>
<param key="minimum" type="i">
<rule key="NcssConstructorCount" priority="MAJOR">
<name><![CDATA[Ncss Constructor Count]]></name>
<configKey><![CDATA[rulesets/codesize.xml/NcssConstructorCount]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given constructor. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one.]]></description>
<param key="minimum" type="i">
<rule key="DuplicateImports" priority="MINOR">
<name><![CDATA[Duplicate Imports]]></name>
<configKey><![CDATA[rulesets/imports.xml/DuplicateImports]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid duplicate import statements.]]></description>
</rule>
<rule key="DontImportJavaLang" priority="MINOR">
<name><![CDATA[Dont Import Java Lang]]></name>
<configKey><![CDATA[rulesets/imports.xml/DontImportJavaLang]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[Avoid importing anything from the package 'java.lang'. These classes are automatically imported (JLS 7.5.3).]]></description>
</rule>
<rule key="ImportFromSamePackage" priority="MINOR">
<name><![CDATA[Import From Same Package]]></name>
<configKey><![CDATA[rulesets/imports.xml/ImportFromSamePackage]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[No need to import a type that lives in the same package.]]></description>
</rule>
<rule key="CloneThrowsCloneNotSupportedException" priority="MAJOR">
<name><![CDATA[Clone Throws Clone Not Supported Exception]]></name>
<configKey><![CDATA[rulesets/clone.xml/CloneThrowsCloneNotSupportedException]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[The method clone() should throw a CloneNotSupportedException.]]></description>
</rule>
<rule key="UseCorrectExceptionLogging" priority="MAJOR">
<name><![CDATA[Use Correct Exception Logging]]></name>
<configKey><![CDATA[rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging]]></configKey>
- <category name="Maintainability"/>
+
<description><![CDATA[To make sure the full stacktrace is printed out, use the logging statement with 2 arguments: a String and a Throwable.]]></description>
</rule>
<rule key="ProperLogger" priority="MAJOR">
<name><![CDATA[Proper Logger]]></name>
<configKey><![CDATA[rulesets/logging-jakarta-commons.xml/ProperLogger]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Logger should normally be defined private static final and have the correct class. Private final Log log; is also allowed for rare cases when loggers need to be passed around, but the logger needs to be passed into the constructor. ]]></description>
<param key="staticLoggerName" type="s">
<rule key="ShortVariable" priority="MAJOR">
<name><![CDATA[Short Variable]]></name>
<configKey><![CDATA[rulesets/naming.xml/ShortVariable]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Detects when a field, local, or parameter has a very short name.]]></description>
</rule>
<rule key="LongVariable" priority="MAJOR">
<name><![CDATA[Long Variable]]></name>
<configKey><![CDATA[rulesets/naming.xml/LongVariable]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Detects when a field, formal or local variable is declared with a long name.]]></description>
<param key="minimum" type="i">
<description><![CDATA[The variable length reporting threshold. Default is 17.]]></description>
<rule key="ShortMethodName" priority="MAJOR">
<name><![CDATA[Naming - Short method name]]></name>
<configKey><![CDATA[rulesets/naming.xml/ShortMethodName]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Detects when very short method names are used. Example :
<pre>
public class ShortMethod {
<rule key="VariableNamingConventions" priority="MAJOR">
<name><![CDATA[Naming - Variable naming conventions]]></name>
<configKey><![CDATA[rulesets/naming.xml/VariableNamingConventions]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[A variable naming conventions rule - customize this to your liking. Currently, it checks for final variables that should be fully capitalized and non-final variables that should not include underscores.]]></description>
<param key="staticPrefix" type="s">
<rule key="MethodNamingConventions" priority="MAJOR">
<name><![CDATA[Naming - Method naming conventions]]></name>
<configKey>rulesets/naming.xml/MethodNamingConventions</configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[Method names should always begin with a lower case character, and should not contain underscores. Example :
<pre>
<rule key="ClassNamingConventions" priority="MAJOR">
<name><![CDATA[Naming - Class naming conventions]]></name>
<configKey><![CDATA[rulesets/naming.xml/ClassNamingConventions]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Class names should always begin with an upper case character.]]></description>
</rule>
<rule key="AvoidDollarSigns" priority="MINOR">
<name><![CDATA[Naming - Avoid dollar signs]]></name>
<configKey><![CDATA[rulesets/naming.xml/AvoidDollarSigns]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Avoid using dollar signs in variable/method/class/interface names.]]></description>
</rule>
<rule key="MethodWithSameNameAsEnclosingClass" priority="MAJOR">
<name><![CDATA[Naming - Method with same name as enclosing class]]></name>
<configKey><![CDATA[rulesets/naming.xml/MethodWithSameNameAsEnclosingClass]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Non-constructor methods should not have the same name as the enclosing class. Example :
<pre>
public class MyClass {
<rule key="SuspiciousHashcodeMethodName" priority="MAJOR">
<name><![CDATA[Naming - Suspicious Hashcode method name]]></name>
<configKey><![CDATA[rulesets/naming.xml/SuspiciousHashcodeMethodName]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[The method name and return type are suspiciously close to hashCode(), which may mean you are intending to override the hashCode() method. Example :
<pre>
public class Foo {
<rule key="SuspiciousConstantFieldName" priority="MAJOR">
<name><![CDATA[Naming - Suspicious constant field name]]></name>
<configKey><![CDATA[rulesets/naming.xml/SuspiciousConstantFieldName]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[A field name is all in uppercase characters, which in Sun's Java naming conventions indicate a constant. However, the field is not final. Example :
<pre>
public class Foo {
<rule key="SuspiciousEqualsMethodName" priority="CRITICAL">
<name><![CDATA[Naming - Suspicious equals method name]]></name>
<configKey><![CDATA[rulesets/naming.xml/SuspiciousEqualsMethodName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[The method name and parameter number are suspiciously close to equals(Object), which may mean you are intending to override the equals(Object) method. Example :
<pre>
<rule key="AvoidFieldNameMatchingTypeName" priority="MAJOR">
<name><![CDATA[Naming - Avoid field name matching type name]]></name>
<configKey><![CDATA[rulesets/naming.xml/AvoidFieldNameMatchingTypeName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[It is somewhat confusing to have a field name matching the declaring class name. This probably means that type and or field names could be more precise. Example :
<pre>
<rule key="AvoidFieldNameMatchingMethodName" priority="MAJOR">
<name><![CDATA[Naming - Avoid field name matching method name]]></name>
<configKey><![CDATA[rulesets/naming.xml/AvoidFieldNameMatchingMethodName]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[It is somewhat confusing to have a field name with the same name as a method. While this is totally legal, having information (field) and actions (method) is not clear naming. Example :
<pre>
<rule key="MisleadingVariableName" priority="MAJOR">
<name><![CDATA[Naming - Misleading variable name]]></name>
<configKey><![CDATA[rulesets/naming.xml/MisleadingVariableName]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Detects when a non-field has a name starting with 'm_'. This usually indicates a field and thus is confusing. Example :
<pre>
public class Foo {
<rule key="ReplaceVectorWithList" priority="MAJOR">
<name><![CDATA[Replace Vector With List]]></name>
<configKey><![CDATA[rulesets/migrating.xml/ReplaceVectorWithList]]></configKey>
- <category name="Portability"/>
+
<description><![CDATA[Consider replacing Vector usages with the newer java.util.ArrayList if expensive threadsafe operation is not required.]]></description>
</rule>
<rule key="ReplaceHashtableWithMap" priority="MAJOR">
<name><![CDATA[Replace Hashtable With Map]]></name>
<configKey><![CDATA[rulesets/migrating.xml/ReplaceHashtableWithMap]]></configKey>
- <category name="Portability"/>
+
<description><![CDATA[Consider replacing this Hashtable with the newer java.util.Map]]></description>
</rule>
<rule key="ReplaceEnumerationWithIterator" priority="MAJOR">
<name><![CDATA[Replace Enumeration With Iterator]]></name>
<configKey><![CDATA[rulesets/migrating.xml/ReplaceEnumerationWithIterator]]></configKey>
- <category name="Portability"/>
+
<description><![CDATA[Consider replacing this Enumeration with the newer java.util.Iterator]]></description>
</rule>
<rule key="AvoidEnumAsIdentifier" priority="MAJOR">
<name><![CDATA[Avoid Enum As Identifier]]></name>
<configKey><![CDATA[rulesets/migrating.xml/AvoidEnumAsIdentifier]]></configKey>
- <category name="Portability"/>
+
<description><![CDATA[Finds all places 'enum' is used as an identifier is used.]]></description>
</rule>
<rule key="AvoidAssertAsIdentifier" priority="MAJOR">
<name><![CDATA[Avoid Assert As Identifier]]></name>
<configKey><![CDATA[rulesets/migrating.xml/AvoidAssertAsIdentifier]]></configKey>
- <category name="Portability"/>
+
<description><![CDATA[Finds all places 'assert' is used as an identifier is used.]]></description>
</rule>
<rule key="IntegerInstantiation" priority="MAJOR">
<name><![CDATA[Integer Instantiation]]></name>
<configKey><![CDATA[rulesets/migrating.xml/IntegerInstantiation]]></configKey>
- <category name="Portability"/>
+
<description><![CDATA[In JDK 1.5, calling new Integer() causes memory allocation. Integer.valueOf() is more memory friendly.]]></description>
</rule>
<rule key="MoreThanOneLogger" priority="MAJOR">
<name><![CDATA[More Than One Logger]]></name>
<configKey><![CDATA[rulesets/logging-java.xml/MoreThanOneLogger]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Normally only one logger is used in each class.]]></description>
</rule>
<rule key="LoggerIsNotStaticFinal" priority="MAJOR">
<name><![CDATA[Logger Is Not Static Final]]></name>
<configKey><![CDATA[rulesets/logging-java.xml/LoggerIsNotStaticFinal]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[In most cases, the Logger can be declared static and final.]]></description>
</rule>
<rule key="SystemPrintln" priority="MAJOR">
<name><![CDATA[System Println]]></name>
<configKey><![CDATA[rulesets/logging-java.xml/SystemPrintln]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[System.(out|err).print is used, consider using a logger.]]></description>
</rule>
<rule key="AvoidPrintStackTrace" priority="MAJOR">
<name><![CDATA[Avoid Print Stack Trace]]></name>
<configKey><![CDATA[rulesets/logging-java.xml/AvoidPrintStackTrace]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Avoid printStackTrace(); use a logger call instead.]]></description>
</rule>
<rule key="IfStmtsMustUseBraces" priority="MAJOR">
<name><![CDATA[If Stmts Must Use Braces]]></name>
<configKey><![CDATA[rulesets/braces.xml/IfStmtsMustUseBraces]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Avoid using if statements without using curly braces.]]></description>
</rule>
<rule key="WhileLoopsMustUseBraces" priority="MAJOR">
<name><![CDATA[While Loops Must Use Braces]]></name>
<configKey><![CDATA[rulesets/braces.xml/WhileLoopsMustUseBraces]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Avoid using 'while' statements without using curly braces.]]></description>
</rule>
<rule key="IfElseStmtsMustUseBraces" priority="MAJOR">
<name><![CDATA[If Else Stmts Must Use Braces]]></name>
<configKey><![CDATA[rulesets/braces.xml/IfElseStmtsMustUseBraces]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Avoid using if..else statements without using curly braces.]]></description>
</rule>
<rule key="ForLoopsMustUseBraces" priority="MAJOR">
<name><![CDATA[For Loops Must Use Braces]]></name>
<configKey><![CDATA[rulesets/braces.xml/ForLoopsMustUseBraces]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Avoid using 'for' statements without using curly braces, like <code>for (int i=0; i<42;i++) foo();</code>]]></description>
</rule>
<rule key="AvoidUsingHardCodedIP" priority="MAJOR">
<name><![CDATA[Avoid Using Hard Coded IP]]></name>
<configKey><![CDATA[rulesets/basic.xml/AvoidUsingHardCodedIP]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[An application with hard coded IP may become impossible to deploy in some case. It never hurts to externalize IP adresses.]]></description>
<param key="pattern" type="r">
<description><![CDATA[Regular Expression. Default is ^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$]]></description>
<rule key="CheckResultSet" priority="MAJOR">
<name><![CDATA[Check ResultSet]]></name>
<configKey><![CDATA[rulesets/basic.xml/CheckResultSet]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[Always check the return of one of the navigation method (next,previous,first,last) of a ResultSet. Indeed, if the value return is "false", the developer should deal with it !]]></description>
</rule>
<rule key="AvoidUsingShortType" priority="MAJOR">
<name><![CDATA[Avoid Using Short Type]]></name>
<configKey><![CDATA[rulesets/controversial.xml/AvoidUsingShortType]]></configKey>
- <category name="Efficiency"/>
+
<description>
<![CDATA[Java uses the short type to reduce memory usage, not to optimize calculation. On the contrary, the jvm does not has an arithmetic capabilities with the type short. So, the P-code must convert the short into int, then do the proper caculation and then again, convert int to short. So, use of the "short" type may have a great effect on memory usage.]]></description>
</rule>
<rule key="AvoidUsingVolatile" priority="MAJOR">
<name><![CDATA[Avoid Using Volatile]]></name>
<configKey><![CDATA[rulesets/controversial.xml/AvoidUsingVolatile]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Use of the keyword "volatile" is general used to fine tune a Java application, and therefore, requires a good expertise of the Java Memory Model. Morover, its range of action is somewhat misknown. Therefore, the volatile keyword should not be used for maintenance purpose and portability.]]></description>
</rule>
<rule key="AvoidUsingNativeCode" priority="MAJOR">
<name><![CDATA[Avoid Using Native Code]]></name>
<configKey><![CDATA[rulesets/controversial.xml/AvoidUsingNativeCode]]></configKey>
- <category name="Portability"/>
+
<description>
<![CDATA[As JVM and Java language offer already many help in creating application, it should be very rare to have to rely on non-java code. Even though, it is rare to actually have to use Java Native Interface (JNI). As the use of JNI make application less portable, and harder to maintain, it is not recommended.]]></description>
</rule>
<rule key="AvoidAccessibilityAlteration" priority="MAJOR">
<name><![CDATA[Avoid Accessibility Alteration]]></name>
<configKey><![CDATA[rulesets/controversial.xml/AvoidAccessibilityAlteration]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(), as the interface PrivilegedAction, allow to alter, at runtime, the visilibilty of variable, classes, or methods, even if they are private. Obviously, no one should do so, as such behavior is against everything encapsulation principal stands for.]]></description>
</rule>
<rule key="EmptyMethodInAbstractClassShouldBeAbstract" priority="MAJOR">
<name><![CDATA[Empty Method In Abstract Class Should Be Abstract]]></name>
<configKey><![CDATA[rulesets/design.xml/EmptyMethodInAbstractClassShouldBeAbstract]]></configKey>
- <category name="Usability"/>
+
<description>
<![CDATA[An empty method in an abstract class should be abstract instead, as developer may rely on this empty implementation rather than code the appropriate one.
<pre>
<rule key="TooManyStaticImports" priority="MAJOR">
<name><![CDATA[Too Many Static Imports]]></name>
<configKey><![CDATA[rulesets/imports.xml/TooManyStaticImports]]></configKey>
- <category name="Maintainability"/>
+
<description>
<![CDATA[If you overuse the static import feature, it can make your program unreadable and unmaintainable, polluting its namespace with all the static members you import. Readers of your code (including you, a few months after you wrote it) will not know which class a static member comes from (Sun 1.5 Language Guide).]]></description>
<param key="maximumStaticImports" type="i">
<rule key="DoNotCallSystemExit" priority="MAJOR">
<name><![CDATA[Do Not Call System Exit]]></name>
<configKey><![CDATA[rulesets/j2ee.xml/DoNotCallSystemExit]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Web applications should not call System.exit(), since only the web container or the application server should stop the JVM.]]></description>
</rule>
<rule key="StaticEJBFieldShouldBeFinal" priority="MAJOR">
<name><![CDATA[Static EJB Field Should Be Final]]></name>
<configKey><![CDATA[rulesets/j2ee.xml/StaticEJBFieldShouldBeFinal]]></configKey>
- <category name="Reliability"/>
+
<description>
<![CDATA[According to the J2EE specification (p.494), an EJB should not have any static fields with write access. However, static read only fields are allowed. This ensures proper behavior especially when instances are distributed by the container on several JREs.]]></description>
</rule>
<rule key="DoNotUseThreads" priority="MAJOR">
<name><![CDATA[Do Not Use Threads]]></name>
<configKey><![CDATA[rulesets/j2ee.xml/DoNotUseThreads]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[The J2EE specification explicitly forbid use of threads.]]></description>
</rule>
<rule key="MDBAndSessionBeanNamingConvention" priority="MAJOR">
<name><![CDATA[Message Driven Bean And Session Bean Naming Convention]]></name>
<configKey><![CDATA[rulesets/j2ee.xml/MDBAndSessionBeanNamingConvention]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[The EJB Specification state that any MessageDrivenBean or SessionBean should be suffixed by Bean.]]></description>
</rule>
<rule key="RemoteSessionInterfaceNamingConvention" priority="MAJOR">
<name><![CDATA[Remote Session Interface Naming Convention]]></name>
<configKey><![CDATA[rulesets/j2ee.xml/RemoteSessionInterfaceNamingConvention]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Remote Home interface of a Session EJB should be suffixed by "Home".]]></description>
</rule>
<rule key="LocalInterfaceSessionNamingConvention" priority="MAJOR">
<name><![CDATA[Local Interface Session Naming Convention]]></name>
<configKey><![CDATA[rulesets/j2ee.xml/LocalInterfaceSessionNamingConvention]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[The Local Interface of a Session EJB should be suffixed by "Local".]]></description>
</rule>
<rule key="LocalHomeNamingConvention" priority="MAJOR">
<name><![CDATA[Local Home Naming Convention]]></name>
<configKey><![CDATA[rulesets/j2ee.xml/LocalHomeNamingConvention]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[The Local Home interface of a Session EJB should be suffixed by "LocalHome".]]></description>
</rule>
<rule key="RemoteInterfaceNamingConvention" priority="MAJOR">
<name><![CDATA[Remote Interface Naming Convention]]></name>
<configKey><![CDATA[rulesets/j2ee.xml/RemoteInterfaceNamingConvention]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Remote Interface of a Session EJB should NOT be suffixed.]]></description>
</rule>
<rule key="UseEqualsToCompareStrings" priority="MAJOR">
<name><![CDATA[Use Equals To Compare Strings]]></name>
<configKey><![CDATA[rulesets/strings.xml/UseEqualsToCompareStrings]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Using "==" or "!=" to compare strings only works if intern version is used on both sides.]]></description>
</rule>
<rule key="DoNotExtendJavaLangError" priority="MAJOR">
<name><![CDATA[Do Not Extend Java Lang Error]]></name>
<configKey><![CDATA[rulesets/strictexception.xml/DoNotExtendJavaLangError]]></configKey>
- <category name="Reliability"/>
+
<description><![CDATA[Errors are system exceptions. Do not extend them.]]></description>
</rule>
<rule key="AddEmptyString" priority="MAJOR">
<name><![CDATA[Add Empty String]]></name>
<configKey><![CDATA[rulesets/optimizations.xml/AddEmptyString]]></configKey>
- <category name="Efficiency"/>
+
<description><![CDATA[Finds empty string literals which are being added. This is an inefficient way to convert any type to a String.]]></description>
</rule>
<rule key="BooleanGetMethodName" priority="MAJOR">
<name><![CDATA[Boolean Get Method Name]]></name>
<configKey><![CDATA[rulesets/naming.xml/BooleanGetMethodName]]></configKey>
- <category name="Usability"/>
+
<description><![CDATA[Looks for methods named "getX()" with "boolean" as the return type. The convention is to name these methods "isX()".]]></description>
<param key="checkParameterizedMethods" type="b">
<description><![CDATA[Check parameterized methods. Default is false.]]></description>
<rule key="XPathRule" priority="MAJOR">
<name><![CDATA[XPath rule template]]></name>
<configKey><![CDATA[net.sourceforge.pmd.rules.XPathRule]]></configKey>
- <category name="Maintainability"/>
+
<cardinality>MULTIPLE</cardinality>
<description>
<![CDATA[PMD provides a very handy method for creating new rules by writing an XPath query. When the XPath query finds a match, a violation is created.