---
title: Java Rules
permalink: pmd_rules_java.html
folder: pmd/rules
---
## Best Practices

{% include callout.html content="Rules which enforce generally accepted best practices." %}

*   [AbstractClassWithoutAbstractMethod](pmd_rules_java_bestpractices.html#abstractclasswithoutabstractmethod): The abstract class does not contain any abstract methods. An abstract class suggestsan incomplete...
*   [AccessorClassGeneration](pmd_rules_java_bestpractices.html#accessorclassgeneration): Instantiation by way of private constructors from outside of the constructor's class often causes...
*   [AccessorMethodGeneration](pmd_rules_java_bestpractices.html#accessormethodgeneration): When accessing a private field / method from another class, the Java compiler will generate a acc...
*   [ArrayIsStoredDirectly](pmd_rules_java_bestpractices.html#arrayisstoreddirectly): Constructors and methods receiving arrays should clone objects and store the copy.This prevents f...
*   [AvoidPrintStackTrace](pmd_rules_java_bestpractices.html#avoidprintstacktrace): Avoid printStackTrace(); use a logger call instead.
*   [AvoidReassigningParameters](pmd_rules_java_bestpractices.html#avoidreassigningparameters): Reassigning values to incoming parameters is not recommended.  Use temporary local variables inst...
*   [AvoidStringBufferField](pmd_rules_java_bestpractices.html#avoidstringbufferfield): StringBuffers/StringBuilders can grow considerably, and so may become a source of memory leaksif ...
*   [AvoidUsingHardCodedIP](pmd_rules_java_bestpractices.html#avoidusinghardcodedip): Application with hard-coded IP addresses can become impossible to deploy in some cases.Externaliz...
*   [CheckResultSet](pmd_rules_java_bestpractices.html#checkresultset): Always check the return values of navigation methods (next, previous, first, last) of a ResultSet...
*   [ConstantsInInterface](pmd_rules_java_bestpractices.html#constantsininterface): Avoid constants in interfaces. Interfaces should define types, constants are implementation detai...
*   [DefaultLabelNotLastInSwitchStmt](pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitchstmt): By convention, the default label should be the last label in a switch statement.
*   [ForLoopCanBeForeach](pmd_rules_java_bestpractices.html#forloopcanbeforeach): Reports loops that can be safely replaced with the foreach syntax. The rule considers loops overl...
*   [GuardLogStatement](pmd_rules_java_bestpractices.html#guardlogstatement): Whenever using a log level, one should check if the loglevel is actually enabled, orotherwise ski...
*   [JUnit4SuitesShouldUseSuiteAnnotation](pmd_rules_java_bestpractices.html#junit4suitesshouldusesuiteannotation): In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicatedthro...
*   [JUnit4TestShouldUseAfterAnnotation](pmd_rules_java_bestpractices.html#junit4testshoulduseafterannotation): In JUnit 3, the tearDown method was used to clean up all data entities required in running tests....
*   [JUnit4TestShouldUseBeforeAnnotation](pmd_rules_java_bestpractices.html#junit4testshouldusebeforeannotation): In JUnit 3, the setUp method was used to set up all data entities required in running tests. JUni...
*   [JUnit4TestShouldUseTestAnnotation](pmd_rules_java_bestpractices.html#junit4testshouldusetestannotation): In JUnit 3, the framework executed all methods which started with the word test as a unit test. I...
*   [JUnitAssertionsShouldIncludeMessage](pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage): JUnit assertions should include an informative message - i.e., use the three-argument version of ...
*   [JUnitTestContainsTooManyAsserts](pmd_rules_java_bestpractices.html#junittestcontainstoomanyasserts): JUnit tests should not contain too many asserts.  Many asserts are indicative of a complex test, ...
*   [JUnitTestsShouldIncludeAssert](pmd_rules_java_bestpractices.html#junittestsshouldincludeassert): JUnit tests should include at least one assertion.  This makes the tests more robust, and using a...
*   [JUnitUseExpected](pmd_rules_java_bestpractices.html#junituseexpected): In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions.
*   [LooseCoupling](pmd_rules_java_bestpractices.html#loosecoupling): The use of implementation types (i.e., HashSet) as object references limits your ability to use a...
*   [MethodReturnsInternalArray](pmd_rules_java_bestpractices.html#methodreturnsinternalarray): Exposing internal arrays to the caller violates object encapsulation since elements can be remove...
*   [OneDeclarationPerLine](pmd_rules_java_bestpractices.html#onedeclarationperline): Java allows the use of several variables declaration of the same type on one line. However, itcan...
*   [PositionLiteralsFirstInCaseInsensitiveComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincaseinsensitivecomparisons): Position literals first in comparisons, if the second argument is null then NullPointerExceptions...
*   [PositionLiteralsFirstInComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincomparisons): Position literals first in comparisons, if the second argument is null then NullPointerExceptions...
*   [PreserveStackTrace](pmd_rules_java_bestpractices.html#preservestacktrace): Throwing a new exception from a catch block without passing the original exception into thenew ex...
*   [ReplaceEnumerationWithIterator](pmd_rules_java_bestpractices.html#replaceenumerationwithiterator): Consider replacing Enumeration usages with the newer java.util.Iterator
*   [ReplaceHashtableWithMap](pmd_rules_java_bestpractices.html#replacehashtablewithmap): Consider replacing Hashtable usage with the newer java.util.Map if thread safety is not required.
*   [ReplaceVectorWithList](pmd_rules_java_bestpractices.html#replacevectorwithlist): Consider replacing Vector usages with the newer java.util.ArrayList if expensive thread-safe oper...
*   [SwitchStmtsShouldHaveDefault](pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault): All switch statements should include a default option to catch any unspecified values.
*   [SystemPrintln](pmd_rules_java_bestpractices.html#systemprintln): References to System.(out\|err).print are usually intended for debugging purposes and can remain ...
*   [UnusedFormalParameter](pmd_rules_java_bestpractices.html#unusedformalparameter): Avoid passing parameters to methods or constructors without actually referencing them in the meth...
*   [UnusedImports](pmd_rules_java_bestpractices.html#unusedimports): Avoid unused import statements to prevent unwanted dependencies.This rule will also find unused o...
*   [UnusedLocalVariable](pmd_rules_java_bestpractices.html#unusedlocalvariable): Detects when a local variable is declared and/or assigned, but not used.
*   [UnusedPrivateField](pmd_rules_java_bestpractices.html#unusedprivatefield): Detects when a private field is declared and/or assigned a value, but not used.
*   [UnusedPrivateMethod](pmd_rules_java_bestpractices.html#unusedprivatemethod): Unused Private Method detects when a private method is declared but is unused.
*   [UseAssertEqualsInsteadOfAssertTrue](pmd_rules_java_bestpractices.html#useassertequalsinsteadofasserttrue): This rule detects JUnit assertions in object equality. These assertions should be made by more sp...
*   [UseAssertNullInsteadOfAssertTrue](pmd_rules_java_bestpractices.html#useassertnullinsteadofasserttrue): This rule detects JUnit assertions in object references equality. These assertions should be made...
*   [UseAssertSameInsteadOfAssertTrue](pmd_rules_java_bestpractices.html#useassertsameinsteadofasserttrue): This rule detects JUnit assertions in object references equality. These assertions should be made...
*   [UseAssertTrueInsteadOfAssertEquals](pmd_rules_java_bestpractices.html#useasserttrueinsteadofassertequals): When asserting a value is the same as a literal or Boxed boolean, use assertTrue/assertFalse, ins...
*   [UseCollectionIsEmpty](pmd_rules_java_bestpractices.html#usecollectionisempty): The isEmpty() method on java.util.Collection is provided to determine if a collection has any ele...
*   [UseVarargs](pmd_rules_java_bestpractices.html#usevarargs): Java 5 introduced the varargs parameter declaration for methods and constructors.  This syntactic...

## Code Style

{% include callout.html content="Rules which enforce a specific coding style." %}

*   [AbstractNaming](pmd_rules_java_codestyle.html#abstractnaming): Abstract classes should be named 'AbstractXXX'.
*   [AtLeastOneConstructor](pmd_rules_java_codestyle.html#atleastoneconstructor): Each class should declare at least one constructor.
*   [AvoidDollarSigns](pmd_rules_java_codestyle.html#avoiddollarsigns): Avoid using dollar signs in variable/method/class/interface names.
*   [AvoidFinalLocalVariable](pmd_rules_java_codestyle.html#avoidfinallocalvariable): Avoid using final local variables, turn them into fields.
*   [AvoidPrefixingMethodParameters](pmd_rules_java_codestyle.html#avoidprefixingmethodparameters): Prefixing parameters by 'in' or 'out' pollutes the name of the parameters and reduces code readab...
*   [AvoidProtectedFieldInFinalClass](pmd_rules_java_codestyle.html#avoidprotectedfieldinfinalclass): Do not use protected fields in final classes since they cannot be subclassed.Clarify your intent ...
*   [AvoidProtectedMethodInFinalClassNotExtending](pmd_rules_java_codestyle.html#avoidprotectedmethodinfinalclassnotextending): Do not use protected methods in most final classes since they cannot be subclassed. This shouldon...
*   [AvoidUsingNativeCode](pmd_rules_java_codestyle.html#avoidusingnativecode): Unnecessary reliance on Java Native Interface (JNI) calls directly reduces application portabilit...
*   [BooleanGetMethodName](pmd_rules_java_codestyle.html#booleangetmethodname): Methods that return boolean results should be named as predicate statements to denote this.I.e, '...
*   [CallSuperInConstructor](pmd_rules_java_codestyle.html#callsuperinconstructor): It is a good practice to call super() in a constructor. If super() is not called butanother const...
*   [ClassNamingConventions](pmd_rules_java_codestyle.html#classnamingconventions): Class names should always begin with an upper case character.
*   [CommentDefaultAccessModifier](pmd_rules_java_codestyle.html#commentdefaultaccessmodifier): To avoid mistakes if we want that a Method, Constructor, Field or Nested class have a default acc...
*   [ConfusingTernary](pmd_rules_java_codestyle.html#confusingternary): Avoid negation within an "if" expression with an "else" clause.  For example, rephrase:'if (x != ...
*   [DefaultPackage](pmd_rules_java_codestyle.html#defaultpackage): Use explicit scoping instead of accidental usage of default package private level.The rule allows...
*   [DontImportJavaLang](pmd_rules_java_codestyle.html#dontimportjavalang): Avoid importing anything from the package 'java.lang'.  These classes are automatically imported ...
*   [DuplicateImports](pmd_rules_java_codestyle.html#duplicateimports): Duplicate or overlapping import statements should be avoided.
*   [EmptyMethodInAbstractClassShouldBeAbstract](pmd_rules_java_codestyle.html#emptymethodinabstractclassshouldbeabstract): Empty or auto-generated methods in an abstract class should be tagged as abstract. This helps to ...
*   [ExtendsObject](pmd_rules_java_codestyle.html#extendsobject): No need to explicitly extend Object.
*   [FieldDeclarationsShouldBeAtStartOfClass](pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass): Fields should be declared at the top of the class, before any method declarations, constructors, ...
*   [ForLoopShouldBeWhileLoop](pmd_rules_java_codestyle.html#forloopshouldbewhileloop): Some for loops can be simplified to while loops, this makes them more concise.
*   [ForLoopsMustUseBraces](pmd_rules_java_codestyle.html#forloopsmustusebraces): Avoid using 'for' statements without using curly braces. If the code formatting or indentation is...
*   [GenericsNaming](pmd_rules_java_codestyle.html#genericsnaming): Names for references to generic values should be limited to a single uppercase letter.
*   [IfElseStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using surrounding braces. If the code formatting or inden...
*   [IfStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifstmtsmustusebraces): Avoid using if statements without using braces to surround the code block. If the code formatting...
*   [LocalHomeNamingConvention](pmd_rules_java_codestyle.html#localhomenamingconvention): The Local Home interface of a Session EJB should be suffixed by 'LocalHome'.
*   [LocalInterfaceSessionNamingConvention](pmd_rules_java_codestyle.html#localinterfacesessionnamingconvention): The Local Interface of a Session EJB should be suffixed by 'Local'.
*   [LocalVariableCouldBeFinal](pmd_rules_java_codestyle.html#localvariablecouldbefinal): A local variable assigned only once can be declared final.
*   [LongVariable](pmd_rules_java_codestyle.html#longvariable): Fields, formal arguments, or local variable names that are too long can make the code difficult t...
*   [MDBAndSessionBeanNamingConvention](pmd_rules_java_codestyle.html#mdbandsessionbeannamingconvention): The EJB Specification states that any MessageDrivenBean or SessionBean should be suffixed by 'Bean'.
*   [MethodArgumentCouldBeFinal](pmd_rules_java_codestyle.html#methodargumentcouldbefinal): A method argument that is never re-assigned within the method can be declared final.
*   [MethodNamingConventions](pmd_rules_java_codestyle.html#methodnamingconventions): Method names should always begin with a lower case character, and should not contain underscores.
*   [MIsLeadingVariableName](pmd_rules_java_codestyle.html#misleadingvariablename): Detects when a non-field has a name starting with 'm_'.  This usually denotes a field and could b...
*   [NoPackage](pmd_rules_java_codestyle.html#nopackage): Detects when a class or interface does not have a package definition.
*   [OnlyOneReturn](pmd_rules_java_codestyle.html#onlyonereturn): A method should have only one exit point, and that should be the last statement in the method.
*   [PackageCase](pmd_rules_java_codestyle.html#packagecase): Detects when a package definition contains uppercase characters.
*   [PrematureDeclaration](pmd_rules_java_codestyle.html#prematuredeclaration): Checks for variables that are defined before they might be used. A reference is deemed to be prem...
*   [RemoteInterfaceNamingConvention](pmd_rules_java_codestyle.html#remoteinterfacenamingconvention): Remote Interface of a Session EJB should not have a suffix.
*   [RemoteSessionInterfaceNamingConvention](pmd_rules_java_codestyle.html#remotesessioninterfacenamingconvention): A Remote Home interface type of a Session EJB should be suffixed by 'Home'.
*   [ShortClassName](pmd_rules_java_codestyle.html#shortclassname): Short Classnames with fewer than e.g. five characters are not recommended.
*   [ShortMethodName](pmd_rules_java_codestyle.html#shortmethodname): Method names that are very short are not helpful to the reader.
*   [ShortVariable](pmd_rules_java_codestyle.html#shortvariable): Fields, local variables, or parameter names that are very short are not helpful to the reader.
*   [SuspiciousConstantFieldName](pmd_rules_java_codestyle.html#suspiciousconstantfieldname): Field names using all uppercase characters - Sun's Java naming conventions indicating constants -...
*   [TooManyStaticImports](pmd_rules_java_codestyle.html#toomanystaticimports): If you overuse the static import feature, it can make your program unreadable and unmaintainable,...
*   [UnnecessaryConstructor](pmd_rules_java_codestyle.html#unnecessaryconstructor): This rule detects when a constructor is not necessary; i.e., when there is only one constructor,i...
*   [UnnecessaryFullyQualifiedName](pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname): Import statements allow the use of non-fully qualified names.  The use of a fully qualified namew...
*   [UnnecessaryLocalBeforeReturn](pmd_rules_java_codestyle.html#unnecessarylocalbeforereturn): Avoid the creation of unnecessary local variables
*   [UnnecessaryModifier](pmd_rules_java_codestyle.html#unnecessarymodifier): Fields in interfaces and annotations are automatically 'public static final', and methods are 'pu...
*   [UnnecessaryReturn](pmd_rules_java_codestyle.html#unnecessaryreturn): Avoid the use of unnecessary return statements.
*   [UselessParentheses](pmd_rules_java_codestyle.html#uselessparentheses): Useless parentheses should be removed.
*   [UselessQualifiedThis](pmd_rules_java_codestyle.html#uselessqualifiedthis): Look for qualified this usages in the same class.
*   [VariableNamingConventions](pmd_rules_java_codestyle.html#variablenamingconventions): A variable naming conventions rule - customize this to your liking.  Currently, itchecks for fina...
*   [WhileLoopsMustUseBraces](pmd_rules_java_codestyle.html#whileloopsmustusebraces): Avoid using 'while' statements without using braces to surround the code block. If the code forma...

## Design

{% include callout.html content="Rules that help you discover design issues." %}

*   [AbstractClassWithoutAnyMethod](pmd_rules_java_design.html#abstractclasswithoutanymethod): If an abstract class does not provides any methods, it may be acting as a simple data containerth...
*   [AvoidCatchingGenericException](pmd_rules_java_design.html#avoidcatchinggenericexception): Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in tr...
*   [AvoidDeeplyNestedIfStmts](pmd_rules_java_design.html#avoiddeeplynestedifstmts): Avoid creating deeply nested if-then statements since they are harder to read and error-prone to ...
*   [AvoidRethrowingException](pmd_rules_java_design.html#avoidrethrowingexception): Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity.
*   [AvoidThrowingNewInstanceOfSameException](pmd_rules_java_design.html#avoidthrowingnewinstanceofsameexception): Catch blocks that merely rethrow a caught exception wrapped inside a new instance of the same typ...
*   [AvoidThrowingNullPointerException](pmd_rules_java_design.html#avoidthrowingnullpointerexception): Avoid throwing NullPointerExceptions. These are confusing because most people will assume that th...
*   [AvoidThrowingRawExceptionTypes](pmd_rules_java_design.html#avoidthrowingrawexceptiontypes): Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable,Excep...
*   [ClassWithOnlyPrivateConstructorsShouldBeFinal](pmd_rules_java_design.html#classwithonlyprivateconstructorsshouldbefinal): A class with only private constructors should be final, unless the private constructoris invoked ...
*   [CollapsibleIfStatements](pmd_rules_java_design.html#collapsibleifstatements): Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with...
*   [CouplingBetweenObjects](pmd_rules_java_design.html#couplingbetweenobjects): This rule counts the number of unique attributes, local variables, and return types within an obj...
*   [CyclomaticComplexity](pmd_rules_java_design.html#cyclomaticcomplexity): The complexity of methods directly affects maintenance costs and readability. Concentrating too m...
*   [DataClass](pmd_rules_java_design.html#dataclass): Data Classes are simple data holders, which reveal most of their state, andwithout complex functi...
*   [DoNotExtendJavaLangError](pmd_rules_java_design.html#donotextendjavalangerror): Errors are system exceptions. Do not extend them.
*   [ExceptionAsFlowControl](pmd_rules_java_design.html#exceptionasflowcontrol): Using Exceptions as form of flow control is not recommended as they obscure true exceptions when ...
*   [ExcessiveClassLength](pmd_rules_java_design.html#excessiveclasslength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
*   [ExcessiveImports](pmd_rules_java_design.html#excessiveimports): A high number of imports can indicate a high degree of coupling within an object. This rule count...
*   [ExcessiveMethodLength](pmd_rules_java_design.html#excessivemethodlength): When methods are excessively long this usually indicates that the method is doing more than itsna...
*   [ExcessiveParameterList](pmd_rules_java_design.html#excessiveparameterlist): Methods with numerous parameters are a challenge to maintain, especially if most of them share th...
*   [ExcessivePublicCount](pmd_rules_java_design.html#excessivepubliccount): Classes with large numbers of public methods and attributes require disproportionate testing effo...
*   [FinalFieldCouldBeStatic](pmd_rules_java_design.html#finalfieldcouldbestatic): If a final field is assigned to a compile-time constant, it could be made static, thus saving ove...
*   [GodClass](pmd_rules_java_design.html#godclass): The God Class rule detects the God Class design flaw using metrics. God classes do too many thing...
*   [ImmutableField](pmd_rules_java_design.html#immutablefield): Identifies private fields whose values never change once they are initialized either in the decla...
*   [LawOfDemeter](pmd_rules_java_design.html#lawofdemeter): The Law of Demeter is a simple rule, that says "only talk to friends". It helps to reduce couplin...
*   [LogicInversion](pmd_rules_java_design.html#logicinversion): Use opposite operator instead of negating the whole expression with a logic complement operator.
*   [LoosePackageCoupling](pmd_rules_java_design.html#loosepackagecoupling): Avoid using classes from the configured package hierarchy outside of the package hierarchy, excep...
*   [ModifiedCyclomaticComplexity](pmd_rules_java_design.html#modifiedcyclomaticcomplexity): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Complexity directly affects maintenance costs is determined by the number of decision points in a...
*   [NcssConstructorCount](pmd_rules_java_design.html#ncssconstructorcount): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
*   [NcssCount](pmd_rules_java_design.html#ncsscount): This rule uses the NCSS (Non-Commenting Source Statements) metric to determine the number of line...
*   [NcssMethodCount](pmd_rules_java_design.html#ncssmethodcount): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
*   [NcssTypeCount](pmd_rules_java_design.html#ncsstypecount): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
*   [NPathComplexity](pmd_rules_java_design.html#npathcomplexity): The NPath complexity of a method is the number of acyclic execution paths through that method.Whi...
*   [SignatureDeclareThrowsException](pmd_rules_java_design.html#signaturedeclarethrowsexception): A method/constructor shouldn't explicitly throw the generic java.lang.Exception, since itis uncle...
*   [SimplifiedTernary](pmd_rules_java_design.html#simplifiedternary): Look for ternary operators with the form 'condition ? literalBoolean : foo'or 'condition ? foo : ...
*   [SimplifyBooleanAssertion](pmd_rules_java_design.html#simplifybooleanassertion): Avoid negation in an assertTrue or assertFalse test.For example, rephrase:    assertTrue(!expr);a...
*   [SimplifyBooleanExpressions](pmd_rules_java_design.html#simplifybooleanexpressions): Avoid unnecessary comparisons in boolean expressions, they serve no purpose and impacts readability.
*   [SimplifyBooleanReturns](pmd_rules_java_design.html#simplifybooleanreturns): Avoid unnecessary if-then-else statements when returning a boolean. The result ofthe conditional ...
*   [SimplifyConditional](pmd_rules_java_design.html#simplifyconditional): No need to check for null before an instanceof; the instanceof keyword returns false when given a...
*   [SingularField](pmd_rules_java_design.html#singularfield): Fields whose scopes are limited to just single methods do not rely on the containingobject to pro...
*   [StdCyclomaticComplexity](pmd_rules_java_design.html#stdcyclomaticcomplexity): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Complexity directly affects maintenance costs is determined by the number of decision points in a...
*   [SwitchDensity](pmd_rules_java_design.html#switchdensity): A high ratio of statements to labels in a switch statement implies that the switch statementis ov...
*   [TooManyFields](pmd_rules_java_design.html#toomanyfields): Classes that have too many fields can become unwieldy and could be redesigned to have fewer field...
*   [TooManyMethods](pmd_rules_java_design.html#toomanymethods): A class with too many methods is probably a good suspect for refactoring, in order to reduce itsc...
*   [UselessOverridingMethod](pmd_rules_java_design.html#uselessoverridingmethod): The overriding method merely calls the same method defined in a superclass.
*   [UseObjectForClearerAPI](pmd_rules_java_design.html#useobjectforclearerapi): When you write a public method, you should be thinking in terms of an API. If your method is publ...
*   [UseUtilityClass](pmd_rules_java_design.html#useutilityclass): For classes that only have static methods, consider making them utility classes.Note that this do...

## Documentation

{% include callout.html content="Rules that are related to code documentation." %}

*   [CommentContent](pmd_rules_java_documentation.html#commentcontent): A rule for the politically correct... we don't want to offend anyone.
*   [CommentRequired](pmd_rules_java_documentation.html#commentrequired): Denotes whether comments are required (or unwanted) for specific language elements.
*   [CommentSize](pmd_rules_java_documentation.html#commentsize): Determines whether the dimensions of non-header comments found are within the specified limits.
*   [UncommentedEmptyConstructor](pmd_rules_java_documentation.html#uncommentedemptyconstructor): Uncommented Empty Constructor finds instances where a constructor does notcontain statements, but...
*   [UncommentedEmptyMethodBody](pmd_rules_java_documentation.html#uncommentedemptymethodbody): Uncommented Empty Method Body finds instances where a method body does not containstatements, but...

## Error Prone

{% include callout.html content="Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors." %}

*   [AssignmentInOperand](pmd_rules_java_errorprone.html#assignmentinoperand): Avoid assignments in operands; this can make code more complicated and harder to read.
*   [AssignmentToNonFinalStatic](pmd_rules_java_errorprone.html#assignmenttononfinalstatic): Identifies a possible unsafe usage of a static field.
*   [AvoidAccessibilityAlteration](pmd_rules_java_errorprone.html#avoidaccessibilityalteration): Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),as...
*   [AvoidAssertAsIdentifier](pmd_rules_java_errorprone.html#avoidassertasidentifier): Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
*   [AvoidBranchingStatementAsLastInLoop](pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop): Using a branching statement as the last part of a loop may be a bug, and/or is confusing.Ensure t...
*   [AvoidCallingFinalize](pmd_rules_java_errorprone.html#avoidcallingfinalize): The method Object.finalize() is called by the garbage collector on an object when garbage collect...
*   [AvoidCatchingNPE](pmd_rules_java_errorprone.html#avoidcatchingnpe): Code should never throw NullPointerExceptions under normal circumstances.  A catch block may hide...
*   [AvoidCatchingThrowable](pmd_rules_java_errorprone.html#avoidcatchingthrowable): Catching Throwable errors is not recommended since its scope is very broad. It includes runtime i...
*   [AvoidDecimalLiteralsInBigDecimalConstructor](pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor): One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actu...
*   [AvoidDuplicateLiterals](pmd_rules_java_errorprone.html#avoidduplicateliterals): Code containing duplicate String literals can usually be improved by declaring the String as a co...
*   [AvoidEnumAsIdentifier](pmd_rules_java_errorprone.html#avoidenumasidentifier): Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
*   [AvoidFieldNameMatchingMethodName](pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname): It can be confusing to have a field name with the same name as a method. While this is permitted,...
*   [AvoidFieldNameMatchingTypeName](pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename): It is somewhat confusing to have a field name matching the declaring class name.This probably mea...
*   [AvoidInstanceofChecksInCatchClause](pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause): Each caught exception type should be handled in its own catch clause.
*   [AvoidLiteralsInIfCondition](pmd_rules_java_errorprone.html#avoidliteralsinifcondition): Avoid using hard-coded literals in conditional statements. By declaring them as static variableso...
*   [AvoidLosingExceptionInformation](pmd_rules_java_errorprone.html#avoidlosingexceptioninformation): Statements in a catch block that invoke accessors on the exception without using the informationo...
*   [AvoidMultipleUnaryOperators](pmd_rules_java_errorprone.html#avoidmultipleunaryoperators): The use of multiple unary operators may be problematic, and/or confusing.Ensure that the intended...
*   [AvoidUsingOctalValues](pmd_rules_java_errorprone.html#avoidusingoctalvalues): Integer literals should not start with zero since this denotes that the rest of literal will bein...
*   [BadComparison](pmd_rules_java_errorprone.html#badcomparison): Avoid equality comparisons with Double.NaN. Due to the implicit lack of representationprecision w...
*   [BeanMembersShouldSerialize](pmd_rules_java_errorprone.html#beanmembersshouldserialize): If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializab...
*   [BrokenNullCheck](pmd_rules_java_errorprone.html#brokennullcheck): The null check is broken since it will throw a NullPointerException itself.It is likely that you ...
*   [CallSuperFirst](pmd_rules_java_errorprone.html#callsuperfirst): Super should be called at the start of the method
*   [CallSuperLast](pmd_rules_java_errorprone.html#callsuperlast): Super should be called at the end of the method
*   [CheckSkipResult](pmd_rules_java_errorprone.html#checkskipresult): The skip() method may skip a smaller number of bytes than requested. Check the returned value to ...
*   [ClassCastExceptionWithToArray](pmd_rules_java_errorprone.html#classcastexceptionwithtoarray): When deriving an array of a specific class from your Collection, one should provide an array ofth...
*   [CloneMethodMustBePublic](pmd_rules_java_errorprone.html#clonemethodmustbepublic): The java Manual says "By convention, classes that implement this interface should overrideObject....
*   [CloneMethodMustImplementCloneable](pmd_rules_java_errorprone.html#clonemethodmustimplementcloneable): The method clone() should only be implemented if the class implements the Cloneable interface wit...
*   [CloneMethodReturnTypeMustMatchClassName](pmd_rules_java_errorprone.html#clonemethodreturntypemustmatchclassname): If a class implements cloneable the return type of the method clone() must be the class name. Tha...
*   [CloneThrowsCloneNotSupportedException](pmd_rules_java_errorprone.html#clonethrowsclonenotsupportedexception): The method clone() should throw a CloneNotSupportedException.
*   [CloseResource](pmd_rules_java_errorprone.html#closeresource): Ensure that resources (like Connection, Statement, and ResultSet objects) are always closed after...
*   [CompareObjectsWithEquals](pmd_rules_java_errorprone.html#compareobjectswithequals): Use equals() to compare object references; avoid comparing them with ==.
*   [ConstructorCallsOverridableMethod](pmd_rules_java_errorprone.html#constructorcallsoverridablemethod): Calling overridable methods during construction poses a risk of invoking methods on an incomplete...
*   [DataflowAnomalyAnalysis](pmd_rules_java_errorprone.html#dataflowanomalyanalysis): The dataflow analysis tracks local definitions, undefinitions and references to variables on diff...
*   [DoNotCallGarbageCollectionExplicitly](pmd_rules_java_errorprone.html#donotcallgarbagecollectionexplicitly): Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Co...
*   [DoNotCallSystemExit](pmd_rules_java_errorprone.html#donotcallsystemexit): Web applications should not call System.exit(), since only the web container or theapplication se...
*   [DoNotExtendJavaLangThrowable](pmd_rules_java_errorprone.html#donotextendjavalangthrowable): Extend Exception or RuntimeException instead of Throwable.
*   [DoNotHardCodeSDCard](pmd_rules_java_errorprone.html#donothardcodesdcard): Use Environment.getExternalStorageDirectory() instead of "/sdcard"
*   [DoNotThrowExceptionInFinally](pmd_rules_java_errorprone.html#donotthrowexceptioninfinally): Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions or...
*   [DontImportSun](pmd_rules_java_errorprone.html#dontimportsun): Avoid importing anything from the 'sun.' packages.  These packages are not portable and are likel...
*   [DontUseFloatTypeForLoopIndices](pmd_rules_java_errorprone.html#dontusefloattypeforloopindices): Don't use floating point for loop indices. If you must use floating point, use doubleunless you'r...
*   [EmptyCatchBlock](pmd_rules_java_errorprone.html#emptycatchblock): Empty Catch Block finds instances where an exception is caught, but nothing is done.  In most cir...
*   [EmptyFinalizer](pmd_rules_java_errorprone.html#emptyfinalizer): Empty finalize methods serve no purpose and should be removed.
*   [EmptyFinallyBlock](pmd_rules_java_errorprone.html#emptyfinallyblock): Empty finally blocks serve no purpose and should be removed.
*   [EmptyIfStmt](pmd_rules_java_errorprone.html#emptyifstmt): Empty If Statement finds instances where a condition is checked but nothing is done about it.
*   [EmptyInitializer](pmd_rules_java_errorprone.html#emptyinitializer): Empty initializers serve no purpose and should be removed.
*   [EmptyStatementBlock](pmd_rules_java_errorprone.html#emptystatementblock): Empty block statements serve no purpose and should be removed.
*   [EmptyStatementNotInLoop](pmd_rules_java_errorprone.html#emptystatementnotinloop): An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for' or 'wh...
*   [EmptySwitchStatements](pmd_rules_java_errorprone.html#emptyswitchstatements): Empty switch statements serve no purpose and should be removed.
*   [EmptySynchronizedBlock](pmd_rules_java_errorprone.html#emptysynchronizedblock): Empty synchronized blocks serve no purpose and should be removed.
*   [EmptyTryBlock](pmd_rules_java_errorprone.html#emptytryblock): Avoid empty try blocks - what's the point?
*   [EmptyWhileStmt](pmd_rules_java_errorprone.html#emptywhilestmt): Empty While Statement finds all instances where a while statement does nothing.  If it is a timin...
*   [EqualsNull](pmd_rules_java_errorprone.html#equalsnull): Tests for null should not use the equals() method. The '==' operator should be used instead.
*   [FinalizeDoesNotCallSuperFinalize](pmd_rules_java_errorprone.html#finalizedoesnotcallsuperfinalize): If the finalize() is implemented, its last action should be to call super.finalize.
*   [FinalizeOnlyCallsSuperFinalize](pmd_rules_java_errorprone.html#finalizeonlycallssuperfinalize): If the finalize() is implemented, it should do something besides just calling super.finalize().
*   [FinalizeOverloaded](pmd_rules_java_errorprone.html#finalizeoverloaded): Methods named finalize() should not have parameters.  It is confusing and most likely an attempt ...
*   [FinalizeShouldBeProtected](pmd_rules_java_errorprone.html#finalizeshouldbeprotected): When overriding the finalize(), the new method should be set as protected.  If made public, other...
*   [IdempotentOperations](pmd_rules_java_errorprone.html#idempotentoperations): Avoid idempotent operations - they have no effect.
*   [ImportFromSamePackage](pmd_rules_java_errorprone.html#importfromsamepackage): There is no need to import a type that lives in the same package.
*   [InstantiationToGetClass](pmd_rules_java_errorprone.html#instantiationtogetclass): Avoid instantiating an object just to call getClass() on it; use the .class public member instead.
*   [InvalidSlf4jMessageFormat](pmd_rules_java_errorprone.html#invalidslf4jmessageformat): Check for messages in slf4j loggers with non matching number of arguments and placeholders.
*   [JumbledIncrementer](pmd_rules_java_errorprone.html#jumbledincrementer): Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
*   [JUnitSpelling](pmd_rules_java_errorprone.html#junitspelling): Some JUnit framework methods are easy to misspell.
*   [JUnitStaticSuite](pmd_rules_java_errorprone.html#junitstaticsuite): The suite() method in a JUnit test needs to be both public and static.
*   [LoggerIsNotStaticFinal](pmd_rules_java_errorprone.html#loggerisnotstaticfinal): In most cases, the Logger reference can be declared as static and final.
*   [MethodWithSameNameAsEnclosingClass](pmd_rules_java_errorprone.html#methodwithsamenameasenclosingclass): Non-constructor methods should not have the same name as the enclosing class.
*   [MisplacedNullCheck](pmd_rules_java_errorprone.html#misplacednullcheck): The null check here is misplaced. If the variable is null a NullPointerException will be thrown.E...
*   [MissingBreakInSwitch](pmd_rules_java_errorprone.html#missingbreakinswitch): Switch statements without break or return statements for each case optionmay indicate problematic...
*   [MissingSerialVersionUID](pmd_rules_java_errorprone.html#missingserialversionuid): Serializable classes should provide a serialVersionUID field.
*   [MissingStaticMethodInNonInstantiatableClass](pmd_rules_java_errorprone.html#missingstaticmethodinnoninstantiatableclass): A class that has private constructors and does not have any static methods or fields cannot be used.
*   [MoreThanOneLogger](pmd_rules_java_errorprone.html#morethanonelogger): Normally only one logger is used in each class.
*   [NonCaseLabelInSwitchStatement](pmd_rules_java_errorprone.html#noncaselabelinswitchstatement): A non-case label (e.g. a named break/continue label) was present in a switch statement.This legal...
*   [NonStaticInitializer](pmd_rules_java_errorprone.html#nonstaticinitializer): A non-static initializer block will be called any time a constructor is invoked (just prior toinv...
*   [NullAssignment](pmd_rules_java_errorprone.html#nullassignment): Assigning a "null" to a variable (outside of its declaration) is usually bad form.  Sometimes, th...
*   [OverrideBothEqualsAndHashcode](pmd_rules_java_errorprone.html#overridebothequalsandhashcode): Override both public boolean Object.equals(Object other), and public int Object.hashCode(), or ov...
*   [ProperCloneImplementation](pmd_rules_java_errorprone.html#propercloneimplementation): Object clone() should be implemented with super.clone().
*   [ProperLogger](pmd_rules_java_errorprone.html#properlogger): A logger should normally be defined private static final and be associated with the correct class...
*   [ReturnEmptyArrayRatherThanNull](pmd_rules_java_errorprone.html#returnemptyarrayratherthannull): For any method that returns an array, it is a better to return an empty array rather than anull r...
*   [ReturnFromFinallyBlock](pmd_rules_java_errorprone.html#returnfromfinallyblock): Avoid returning from a finally block, this can discard exceptions.
*   [SimpleDateFormatNeedsLocale](pmd_rules_java_errorprone.html#simpledateformatneedslocale): Be sure to specify a Locale when creating SimpleDateFormat instances to ensure that locale-approp...
*   [SingleMethodSingleton](pmd_rules_java_errorprone.html#singlemethodsingleton): Some classes contain overloaded getInstance. The problem with overloaded getInstance methodsis th...
*   [SingletonClassReturningNewInstance](pmd_rules_java_errorprone.html#singletonclassreturningnewinstance): Some classes contain overloaded getInstance. The problem with overloaded getInstance methodsis th...
*   [StaticEJBFieldShouldBeFinal](pmd_rules_java_errorprone.html#staticejbfieldshouldbefinal): According to the J2EE specification, an EJB should not have any static fieldswith write access. H...
*   [StringBufferInstantiationWithChar](pmd_rules_java_errorprone.html#stringbufferinstantiationwithchar): Individual character values provided as initialization arguments will be converted into integers....
*   [SuspiciousEqualsMethodName](pmd_rules_java_errorprone.html#suspiciousequalsmethodname): The method name and parameter number are suspiciously close to equals(Object), which can denote a...
*   [SuspiciousHashcodeMethodName](pmd_rules_java_errorprone.html#suspicioushashcodemethodname): The method name and return type are suspiciously close to hashCode(), which may denote an intenti...
*   [SuspiciousOctalEscape](pmd_rules_java_errorprone.html#suspiciousoctalescape): A suspicious octal escape sequence was found inside a String literal.The Java language specificat...
*   [TestClassWithoutTestCases](pmd_rules_java_errorprone.html#testclasswithouttestcases): Test classes end with the suffix Test. Having a non-test class with that name is not a good pract...
*   [UnconditionalIfStatement](pmd_rules_java_errorprone.html#unconditionalifstatement): Do not use "if" statements whose conditionals are always true or always false.
*   [UnnecessaryBooleanAssertion](pmd_rules_java_errorprone.html#unnecessarybooleanassertion): A JUnit test assertion with a boolean literal is unnecessary since it always will evaluate to the...
*   [UnnecessaryCaseChange](pmd_rules_java_errorprone.html#unnecessarycasechange): Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals()
*   [UnnecessaryConversionTemporary](pmd_rules_java_errorprone.html#unnecessaryconversiontemporary): Avoid the use temporary objects when converting primitives to Strings. Use the static conversion ...
*   [UnusedNullCheckInEquals](pmd_rules_java_errorprone.html#unusednullcheckinequals): After checking an object reference for null, you should invoke equals() on that object rather tha...
*   [UseCorrectExceptionLogging](pmd_rules_java_errorprone.html#usecorrectexceptionlogging): To make sure the full stacktrace is printed out, use the logging statement with two arguments: a ...
*   [UseEqualsToCompareStrings](pmd_rules_java_errorprone.html#useequalstocomparestrings): Using '==' or '!=' to compare strings only works if intern version is used on both sides.Use the ...
*   [UselessOperationOnImmutable](pmd_rules_java_errorprone.html#uselessoperationonimmutable): An operation on an Immutable object (String, BigDecimal or BigInteger) won't change the object it...
*   [UseLocaleWithCaseConversions](pmd_rules_java_errorprone.html#uselocalewithcaseconversions): When doing String.toLowerCase()/toUpperCase() conversions, use Locales to avoids problems with la...
*   [UseProperClassLoader](pmd_rules_java_errorprone.html#useproperclassloader): In J2EE, the getClassLoader() method might not work as expected. Use Thread.currentThread().getCo...

## Multithreading

{% include callout.html content="Rules that flag issues when dealing with multiple threads of execution." %}

*   [AvoidSynchronizedAtMethodLevel](pmd_rules_java_multithreading.html#avoidsynchronizedatmethodlevel): Method-level synchronization can cause problems when new code is added to the method.Block-level ...
*   [AvoidThreadGroup](pmd_rules_java_multithreading.html#avoidthreadgroup): Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environmentit...
*   [AvoidUsingVolatile](pmd_rules_java_multithreading.html#avoidusingvolatile): Use of the keyword 'volatile' is generally used to fine tune a Java application, and therefore, r...
*   [DoNotUseThreads](pmd_rules_java_multithreading.html#donotusethreads): The J2EE specification explicitly forbids the use of threads.
*   [DontCallThreadRun](pmd_rules_java_multithreading.html#dontcallthreadrun): Explicitly calling Thread.run() method will execute in the caller's thread of control.  Instead, ...
*   [DoubleCheckedLocking](pmd_rules_java_multithreading.html#doublecheckedlocking): Partially created objects can be returned by the Double Checked Locking pattern when used in Java...
*   [NonThreadSafeSingleton](pmd_rules_java_multithreading.html#nonthreadsafesingleton): Non-thread safe singletons can result in bad state changes. Eliminatestatic singletons if possibl...
*   [UnsynchronizedStaticDateFormatter](pmd_rules_java_multithreading.html#unsynchronizedstaticdateformatter): SimpleDateFormat instances are not synchronized. Sun recommends using separate format instancesfo...
*   [UseConcurrentHashMap](pmd_rules_java_multithreading.html#useconcurrenthashmap): Since Java5 brought a new implementation of the Map designed for multi-threaded access, you canpe...
*   [UseNotifyAllInsteadOfNotify](pmd_rules_java_multithreading.html#usenotifyallinsteadofnotify): Thread.notify() awakens a thread monitoring the object. If more than one thread is monitoring, th...

## Performance

{% include callout.html content="Rules that flag suboptimal code." %}

*   [AddEmptyString](pmd_rules_java_performance.html#addemptystring): The conversion of literals to strings by concatenating them with empty strings is inefficient.It ...
*   [AppendCharacterWithChar](pmd_rules_java_performance.html#appendcharacterwithchar): Avoid concatenating characters as strings in StringBuffer/StringBuilder.append methods.
*   [AvoidArrayLoops](pmd_rules_java_performance.html#avoidarrayloops): Instead of manually copying data between two arrays, use the efficient System.arraycopy method in...
*   [AvoidFileStream](pmd_rules_java_performance.html#avoidfilestream): The FileInputStream and FileOutputStream classes contains a finalizer method which will cause gar...
*   [AvoidInstantiatingObjectsInLoops](pmd_rules_java_performance.html#avoidinstantiatingobjectsinloops): New objects created within loops should be checked to see if they can created outside them and re...
*   [AvoidUsingShortType](pmd_rules_java_performance.html#avoidusingshorttype): Java uses the 'short' type to reduce memory usage, not to optimize calculation. In fact, the JVM ...
*   [BigIntegerInstantiation](pmd_rules_java_performance.html#bigintegerinstantiation): Don't create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) andfor Ja...
*   [BooleanInstantiation](pmd_rules_java_performance.html#booleaninstantiation): Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boole...
*   [ByteInstantiation](pmd_rules_java_performance.html#byteinstantiation): Calling new Byte() causes memory allocation that can be avoided by the static Byte.valueOf().It m...
*   [ConsecutiveAppendsShouldReuse](pmd_rules_java_performance.html#consecutiveappendsshouldreuse): Consecutive calls to StringBuffer/StringBuilder .append should be chained, reusing the target obj...
*   [ConsecutiveLiteralAppends](pmd_rules_java_performance.html#consecutiveliteralappends): Consecutively calling StringBuffer/StringBuilder.append with String literals
*   [InefficientEmptyStringCheck](pmd_rules_java_performance.html#inefficientemptystringcheck): String.trim().length() is an inefficient way to check if a String is really empty, as itcreates a...
*   [InefficientStringBuffering](pmd_rules_java_performance.html#inefficientstringbuffering): Avoid concatenating non-literals in a StringBuffer constructor or append() since intermediate buf...
*   [InsufficientStringBufferDeclaration](pmd_rules_java_performance.html#insufficientstringbufferdeclaration): Failing to pre-size a StringBuffer or StringBuilder properly could cause it to re-size many times...
*   [IntegerInstantiation](pmd_rules_java_performance.html#integerinstantiation): Calling new Integer() causes memory allocation that can be avoided by the static Integer.valueOf(...
*   [LongInstantiation](pmd_rules_java_performance.html#longinstantiation): Calling new Long() causes memory allocation that can be avoided by the static Long.valueOf().It m...
*   [OptimizableToArrayCall](pmd_rules_java_performance.html#optimizabletoarraycall): Calls to a collection's 'toArray(E[])' method should specify a target array of zero size. This al...
*   [RedundantFieldInitializer](pmd_rules_java_performance.html#redundantfieldinitializer): Java will initialize fields with known default values so any explicit initialization of those sam...
*   [ShortInstantiation](pmd_rules_java_performance.html#shortinstantiation): Calling new Short() causes memory allocation that can be avoided by the static Short.valueOf().It...
*   [SimplifyStartsWith](pmd_rules_java_performance.html#simplifystartswith): Since it passes in a literal of length 1, calls to (string).startsWith can be rewritten using (st...
*   [StringInstantiation](pmd_rules_java_performance.html#stringinstantiation): Avoid instantiating String objects; this is usually unnecessary since they are immutable and can ...
*   [StringToString](pmd_rules_java_performance.html#stringtostring): Avoid calling toString() on objects already known to be string instances; this is unnecessary.
*   [TooFewBranchesForASwitchStatement](pmd_rules_java_performance.html#toofewbranchesforaswitchstatement): Switch statements are intended to be used to support complex branching behaviour. Using a switch ...
*   [UnnecessaryWrapperObjectCreation](pmd_rules_java_performance.html#unnecessarywrapperobjectcreation): Most wrapper classes provide static conversion methods that avoid the need to create intermediate...
*   [UseArrayListInsteadOfVector](pmd_rules_java_performance.html#usearraylistinsteadofvector): ArrayList is a much better Collection implementation than Vector if thread-safe operation is not ...
*   [UseArraysAsList](pmd_rules_java_performance.html#usearraysaslist): The java.util.Arrays class has a "asList" method that should be used when you want to create a ne...
*   [UseIndexOfChar](pmd_rules_java_performance.html#useindexofchar): Use String.indexOf(char) when checking for the index of a single character; it executes faster.
*   [UselessStringValueOf](pmd_rules_java_performance.html#uselessstringvalueof): No need to call String.valueOf to append to a string; just use the valueOf() argument directly.
*   [UseStringBufferForStringAppends](pmd_rules_java_performance.html#usestringbufferforstringappends): The use of the '+=' operator for appending strings causes the JVM to create and use an internal S...
*   [UseStringBufferLength](pmd_rules_java_performance.html#usestringbufferlength): Use StringBuffer.length() to determine StringBuffer length rather than using StringBuffer.toStrin...

## Additional rulesets

*   Android (`rulesets/java/android.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [CallSuperFirst](pmd_rules_java_errorprone.html#callsuperfirst), [CallSuperLast](pmd_rules_java_errorprone.html#callsuperlast), [DoNotHardCodeSDCard](pmd_rules_java_errorprone.html#donothardcodesdcard)

*   Basic (`rulesets/java/basic.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [AvoidBranchingStatementAsLastInLoop](pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop), [AvoidDecimalLiteralsInBigDecimalConstructor](pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor), [AvoidMultipleUnaryOperators](pmd_rules_java_errorprone.html#avoidmultipleunaryoperators), [AvoidThreadGroup](pmd_rules_java_multithreading.html#avoidthreadgroup), [AvoidUsingHardCodedIP](pmd_rules_java_bestpractices.html#avoidusinghardcodedip), [AvoidUsingOctalValues](pmd_rules_java_errorprone.html#avoidusingoctalvalues), [BigIntegerInstantiation](pmd_rules_java_performance.html#bigintegerinstantiation), [BooleanInstantiation](pmd_rules_java_performance.html#booleaninstantiation), [BrokenNullCheck](pmd_rules_java_errorprone.html#brokennullcheck), [CheckResultSet](pmd_rules_java_bestpractices.html#checkresultset), [CheckSkipResult](pmd_rules_java_errorprone.html#checkskipresult), [ClassCastExceptionWithToArray](pmd_rules_java_errorprone.html#classcastexceptionwithtoarray), [CollapsibleIfStatements](pmd_rules_java_design.html#collapsibleifstatements), [DontCallThreadRun](pmd_rules_java_multithreading.html#dontcallthreadrun), [DontUseFloatTypeForLoopIndices](pmd_rules_java_errorprone.html#dontusefloattypeforloopindices), [DoubleCheckedLocking](pmd_rules_java_multithreading.html#doublecheckedlocking), [ExtendsObject](pmd_rules_java_codestyle.html#extendsobject), [ForLoopShouldBeWhileLoop](pmd_rules_java_codestyle.html#forloopshouldbewhileloop), [JumbledIncrementer](pmd_rules_java_errorprone.html#jumbledincrementer), [MisplacedNullCheck](pmd_rules_java_errorprone.html#misplacednullcheck), [OverrideBothEqualsAndHashcode](pmd_rules_java_errorprone.html#overridebothequalsandhashcode), [ReturnFromFinallyBlock](pmd_rules_java_errorprone.html#returnfromfinallyblock), [SimplifiedTernary](pmd_rules_java_design.html#simplifiedternary), [UnconditionalIfStatement](pmd_rules_java_errorprone.html#unconditionalifstatement)

*   Braces (`rulesets/java/braces.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [ForLoopsMustUseBraces](pmd_rules_java_codestyle.html#forloopsmustusebraces), [IfElseStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifelsestmtsmustusebraces), [IfStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifstmtsmustusebraces), [WhileLoopsMustUseBraces](pmd_rules_java_codestyle.html#whileloopsmustusebraces)

*   Clone Implementation (`rulesets/java/clone.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [CloneMethodMustBePublic](pmd_rules_java_errorprone.html#clonemethodmustbepublic), [CloneMethodMustImplementCloneable](pmd_rules_java_errorprone.html#clonemethodmustimplementcloneable), [CloneMethodReturnTypeMustMatchClassName](pmd_rules_java_errorprone.html#clonemethodreturntypemustmatchclassname), [CloneThrowsCloneNotSupportedException](pmd_rules_java_errorprone.html#clonethrowsclonenotsupportedexception), [ProperCloneImplementation](pmd_rules_java_errorprone.html#propercloneimplementation)

*   Code Size (`rulesets/java/codesize.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [CyclomaticComplexity](pmd_rules_java_design.html#cyclomaticcomplexity), [ExcessiveClassLength](pmd_rules_java_design.html#excessiveclasslength), [ExcessiveMethodLength](pmd_rules_java_design.html#excessivemethodlength), [ExcessiveParameterList](pmd_rules_java_design.html#excessiveparameterlist), [ExcessivePublicCount](pmd_rules_java_design.html#excessivepubliccount), [ModifiedCyclomaticComplexity](pmd_rules_java_design.html#modifiedcyclomaticcomplexity), [NcssConstructorCount](pmd_rules_java_design.html#ncssconstructorcount), [NcssCount](pmd_rules_java_design.html#ncsscount), [NcssMethodCount](pmd_rules_java_design.html#ncssmethodcount), [NcssTypeCount](pmd_rules_java_design.html#ncsstypecount), [NPathComplexity](pmd_rules_java_design.html#npathcomplexity), [StdCyclomaticComplexity](pmd_rules_java_design.html#stdcyclomaticcomplexity), [TooManyFields](pmd_rules_java_design.html#toomanyfields), [TooManyMethods](pmd_rules_java_design.html#toomanymethods)

*   Comments (`rulesets/java/comments.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [CommentContent](pmd_rules_java_documentation.html#commentcontent), [CommentDefaultAccessModifier](pmd_rules_java_codestyle.html#commentdefaultaccessmodifier), [CommentRequired](pmd_rules_java_documentation.html#commentrequired), [CommentSize](pmd_rules_java_documentation.html#commentsize)

*   Controversial (`rulesets/java/controversial.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [AssignmentInOperand](pmd_rules_java_errorprone.html#assignmentinoperand), [AtLeastOneConstructor](pmd_rules_java_codestyle.html#atleastoneconstructor), [AvoidAccessibilityAlteration](pmd_rules_java_errorprone.html#avoidaccessibilityalteration), [AvoidFinalLocalVariable](pmd_rules_java_codestyle.html#avoidfinallocalvariable), [AvoidLiteralsInIfCondition](pmd_rules_java_errorprone.html#avoidliteralsinifcondition), [AvoidPrefixingMethodParameters](pmd_rules_java_codestyle.html#avoidprefixingmethodparameters), [AvoidUsingNativeCode](pmd_rules_java_codestyle.html#avoidusingnativecode), [AvoidUsingShortType](pmd_rules_java_performance.html#avoidusingshorttype), [AvoidUsingVolatile](pmd_rules_java_multithreading.html#avoidusingvolatile), [CallSuperInConstructor](pmd_rules_java_codestyle.html#callsuperinconstructor), [DataflowAnomalyAnalysis](pmd_rules_java_errorprone.html#dataflowanomalyanalysis), [DefaultPackage](pmd_rules_java_codestyle.html#defaultpackage), [DoNotCallGarbageCollectionExplicitly](pmd_rules_java_errorprone.html#donotcallgarbagecollectionexplicitly), [DontImportSun](pmd_rules_java_errorprone.html#dontimportsun), [NullAssignment](pmd_rules_java_errorprone.html#nullassignment), [OneDeclarationPerLine](pmd_rules_java_bestpractices.html#onedeclarationperline), [OnlyOneReturn](pmd_rules_java_codestyle.html#onlyonereturn), [SuspiciousOctalEscape](pmd_rules_java_errorprone.html#suspiciousoctalescape), [UnnecessaryConstructor](pmd_rules_java_codestyle.html#unnecessaryconstructor), [UselessParentheses](pmd_rules_java_codestyle.html#uselessparentheses), [UseConcurrentHashMap](pmd_rules_java_multithreading.html#useconcurrenthashmap), [UseObjectForClearerAPI](pmd_rules_java_design.html#useobjectforclearerapi)

*   Coupling (`rulesets/java/coupling.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [CouplingBetweenObjects](pmd_rules_java_design.html#couplingbetweenobjects), [ExcessiveImports](pmd_rules_java_design.html#excessiveimports), [LawOfDemeter](pmd_rules_java_design.html#lawofdemeter), [LooseCoupling](pmd_rules_java_bestpractices.html#loosecoupling), [LoosePackageCoupling](pmd_rules_java_design.html#loosepackagecoupling)

*   Design (`rulesets/java/design.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [AbstractClassWithoutAbstractMethod](pmd_rules_java_bestpractices.html#abstractclasswithoutabstractmethod), [AbstractClassWithoutAnyMethod](pmd_rules_java_design.html#abstractclasswithoutanymethod), [AccessorClassGeneration](pmd_rules_java_bestpractices.html#accessorclassgeneration), [AccessorMethodGeneration](pmd_rules_java_bestpractices.html#accessormethodgeneration), [AssignmentToNonFinalStatic](pmd_rules_java_errorprone.html#assignmenttononfinalstatic), [AvoidDeeplyNestedIfStmts](pmd_rules_java_design.html#avoiddeeplynestedifstmts), [AvoidInstanceofChecksInCatchClause](pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause), [AvoidProtectedFieldInFinalClass](pmd_rules_java_codestyle.html#avoidprotectedfieldinfinalclass), [AvoidProtectedMethodInFinalClassNotExtending](pmd_rules_java_codestyle.html#avoidprotectedmethodinfinalclassnotextending), [AvoidReassigningParameters](pmd_rules_java_bestpractices.html#avoidreassigningparameters), [AvoidSynchronizedAtMethodLevel](pmd_rules_java_multithreading.html#avoidsynchronizedatmethodlevel), [BadComparison](pmd_rules_java_errorprone.html#badcomparison), [ClassWithOnlyPrivateConstructorsShouldBeFinal](pmd_rules_java_design.html#classwithonlyprivateconstructorsshouldbefinal), [CloseResource](pmd_rules_java_errorprone.html#closeresource), [CompareObjectsWithEquals](pmd_rules_java_errorprone.html#compareobjectswithequals), [ConfusingTernary](pmd_rules_java_codestyle.html#confusingternary), [ConstantsInInterface](pmd_rules_java_bestpractices.html#constantsininterface), [ConstructorCallsOverridableMethod](pmd_rules_java_errorprone.html#constructorcallsoverridablemethod), [DataClass](pmd_rules_java_design.html#dataclass), [DefaultLabelNotLastInSwitchStmt](pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitchstmt), [EmptyMethodInAbstractClassShouldBeAbstract](pmd_rules_java_codestyle.html#emptymethodinabstractclassshouldbeabstract), [EqualsNull](pmd_rules_java_errorprone.html#equalsnull), [FieldDeclarationsShouldBeAtStartOfClass](pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass), [FinalFieldCouldBeStatic](pmd_rules_java_design.html#finalfieldcouldbestatic), [GodClass](pmd_rules_java_design.html#godclass), [IdempotentOperations](pmd_rules_java_errorprone.html#idempotentoperations), [ImmutableField](pmd_rules_java_design.html#immutablefield), [InstantiationToGetClass](pmd_rules_java_errorprone.html#instantiationtogetclass), [LogicInversion](pmd_rules_java_design.html#logicinversion), [MissingBreakInSwitch](pmd_rules_java_errorprone.html#missingbreakinswitch), [MissingStaticMethodInNonInstantiatableClass](pmd_rules_java_errorprone.html#missingstaticmethodinnoninstantiatableclass), [NonCaseLabelInSwitchStatement](pmd_rules_java_errorprone.html#noncaselabelinswitchstatement), [NonStaticInitializer](pmd_rules_java_errorprone.html#nonstaticinitializer), [NonThreadSafeSingleton](pmd_rules_java_multithreading.html#nonthreadsafesingleton), [OptimizableToArrayCall](pmd_rules_java_performance.html#optimizabletoarraycall), [PositionLiteralsFirstInCaseInsensitiveComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincaseinsensitivecomparisons), [PositionLiteralsFirstInComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincomparisons), [PreserveStackTrace](pmd_rules_java_bestpractices.html#preservestacktrace), [ReturnEmptyArrayRatherThanNull](pmd_rules_java_errorprone.html#returnemptyarrayratherthannull), [SimpleDateFormatNeedsLocale](pmd_rules_java_errorprone.html#simpledateformatneedslocale), [SimplifyBooleanExpressions](pmd_rules_java_design.html#simplifybooleanexpressions), [SimplifyBooleanReturns](pmd_rules_java_design.html#simplifybooleanreturns), [SimplifyConditional](pmd_rules_java_design.html#simplifyconditional), [SingleMethodSingleton](pmd_rules_java_errorprone.html#singlemethodsingleton), [SingletonClassReturningNewInstance](pmd_rules_java_errorprone.html#singletonclassreturningnewinstance), [SingularField](pmd_rules_java_design.html#singularfield), [SwitchDensity](pmd_rules_java_design.html#switchdensity), [SwitchStmtsShouldHaveDefault](pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault), [TooFewBranchesForASwitchStatement](pmd_rules_java_performance.html#toofewbranchesforaswitchstatement), [UncommentedEmptyConstructor](pmd_rules_java_documentation.html#uncommentedemptyconstructor), [UncommentedEmptyMethodBody](pmd_rules_java_documentation.html#uncommentedemptymethodbody), [UnnecessaryLocalBeforeReturn](pmd_rules_java_codestyle.html#unnecessarylocalbeforereturn), [UnsynchronizedStaticDateFormatter](pmd_rules_java_multithreading.html#unsynchronizedstaticdateformatter), [UseCollectionIsEmpty](pmd_rules_java_bestpractices.html#usecollectionisempty), [UseLocaleWithCaseConversions](pmd_rules_java_errorprone.html#uselocalewithcaseconversions), [UseNotifyAllInsteadOfNotify](pmd_rules_java_multithreading.html#usenotifyallinsteadofnotify), [UseUtilityClass](pmd_rules_java_design.html#useutilityclass), [UseVarargs](pmd_rules_java_bestpractices.html#usevarargs)

*   Empty Code (`rulesets/java/empty.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [EmptyCatchBlock](pmd_rules_java_errorprone.html#emptycatchblock), [EmptyFinallyBlock](pmd_rules_java_errorprone.html#emptyfinallyblock), [EmptyIfStmt](pmd_rules_java_errorprone.html#emptyifstmt), [EmptyInitializer](pmd_rules_java_errorprone.html#emptyinitializer), [EmptyStatementBlock](pmd_rules_java_errorprone.html#emptystatementblock), [EmptyStatementNotInLoop](pmd_rules_java_errorprone.html#emptystatementnotinloop), [EmptyStaticInitializer](pmd_rules_java_errorprone.html#emptyinitializer), [EmptySwitchStatements](pmd_rules_java_errorprone.html#emptyswitchstatements), [EmptySynchronizedBlock](pmd_rules_java_errorprone.html#emptysynchronizedblock), [EmptyTryBlock](pmd_rules_java_errorprone.html#emptytryblock), [EmptyWhileStmt](pmd_rules_java_errorprone.html#emptywhilestmt)

*   Finalizer (`rulesets/java/finalizers.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [AvoidCallingFinalize](pmd_rules_java_errorprone.html#avoidcallingfinalize), [EmptyFinalizer](pmd_rules_java_errorprone.html#emptyfinalizer), [FinalizeDoesNotCallSuperFinalize](pmd_rules_java_errorprone.html#finalizedoesnotcallsuperfinalize), [FinalizeOnlyCallsSuperFinalize](pmd_rules_java_errorprone.html#finalizeonlycallssuperfinalize), [FinalizeOverloaded](pmd_rules_java_errorprone.html#finalizeoverloaded), [FinalizeShouldBeProtected](pmd_rules_java_errorprone.html#finalizeshouldbeprotected)

*   Import Statements (`rulesets/java/imports.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [DontImportJavaLang](pmd_rules_java_codestyle.html#dontimportjavalang), [DuplicateImports](pmd_rules_java_codestyle.html#duplicateimports), [ImportFromSamePackage](pmd_rules_java_errorprone.html#importfromsamepackage), [TooManyStaticImports](pmd_rules_java_codestyle.html#toomanystaticimports), [UnnecessaryFullyQualifiedName](pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname), [UnusedImports](pmd_rules_java_bestpractices.html#unusedimports)

*   J2EE (`rulesets/java/j2ee.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [DoNotCallSystemExit](pmd_rules_java_errorprone.html#donotcallsystemexit), [DoNotUseThreads](pmd_rules_java_multithreading.html#donotusethreads), [LocalHomeNamingConvention](pmd_rules_java_codestyle.html#localhomenamingconvention), [LocalInterfaceSessionNamingConvention](pmd_rules_java_codestyle.html#localinterfacesessionnamingconvention), [MDBAndSessionBeanNamingConvention](pmd_rules_java_codestyle.html#mdbandsessionbeannamingconvention), [RemoteInterfaceNamingConvention](pmd_rules_java_codestyle.html#remoteinterfacenamingconvention), [RemoteSessionInterfaceNamingConvention](pmd_rules_java_codestyle.html#remotesessioninterfacenamingconvention), [StaticEJBFieldShouldBeFinal](pmd_rules_java_errorprone.html#staticejbfieldshouldbefinal), [UseProperClassLoader](pmd_rules_java_errorprone.html#useproperclassloader)

*   JavaBeans (`rulesets/java/javabeans.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [BeanMembersShouldSerialize](pmd_rules_java_errorprone.html#beanmembersshouldserialize), [MissingSerialVersionUID](pmd_rules_java_errorprone.html#missingserialversionuid)

*   JUnit (`rulesets/java/junit.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [JUnitAssertionsShouldIncludeMessage](pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage), [JUnitSpelling](pmd_rules_java_errorprone.html#junitspelling), [JUnitStaticSuite](pmd_rules_java_errorprone.html#junitstaticsuite), [JUnitTestContainsTooManyAsserts](pmd_rules_java_bestpractices.html#junittestcontainstoomanyasserts), [JUnitTestsShouldIncludeAssert](pmd_rules_java_bestpractices.html#junittestsshouldincludeassert), [SimplifyBooleanAssertion](pmd_rules_java_design.html#simplifybooleanassertion), [TestClassWithoutTestCases](pmd_rules_java_errorprone.html#testclasswithouttestcases), [UnnecessaryBooleanAssertion](pmd_rules_java_errorprone.html#unnecessarybooleanassertion), [UseAssertEqualsInsteadOfAssertTrue](pmd_rules_java_bestpractices.html#useassertequalsinsteadofasserttrue), [UseAssertNullInsteadOfAssertTrue](pmd_rules_java_bestpractices.html#useassertnullinsteadofasserttrue), [UseAssertSameInsteadOfAssertTrue](pmd_rules_java_bestpractices.html#useassertsameinsteadofasserttrue), [UseAssertTrueInsteadOfAssertEquals](pmd_rules_java_bestpractices.html#useasserttrueinsteadofassertequals)

*   Metrics (`rulesets/java/metrics.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [CyclomaticComplexity](pmd_rules_java_design.html#cyclomaticcomplexity)

*   MigratingToJUnit4 (`rulesets/java/migrating_to_junit4.xml`):

    Contains rules for migrating to JUnit 4

    It contains the following rules:

    [JUnit4SuitesShouldUseSuiteAnnotation](pmd_rules_java_bestpractices.html#junit4suitesshouldusesuiteannotation), [JUnit4TestShouldUseAfterAnnotation](pmd_rules_java_bestpractices.html#junit4testshoulduseafterannotation), [JUnit4TestShouldUseBeforeAnnotation](pmd_rules_java_bestpractices.html#junit4testshouldusebeforeannotation), [JUnit4TestShouldUseTestAnnotation](pmd_rules_java_bestpractices.html#junit4testshouldusetestannotation), [JUnitUseExpected](pmd_rules_java_bestpractices.html#junituseexpected)

*   Migration (`rulesets/java/migrating.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [AvoidAssertAsIdentifier](pmd_rules_java_errorprone.html#avoidassertasidentifier), [AvoidEnumAsIdentifier](pmd_rules_java_errorprone.html#avoidenumasidentifier), [ByteInstantiation](pmd_rules_java_performance.html#byteinstantiation), [ForLoopCanBeForeach](pmd_rules_java_bestpractices.html#forloopcanbeforeach), [IntegerInstantiation](pmd_rules_java_performance.html#integerinstantiation), [JUnit4SuitesShouldUseSuiteAnnotation](pmd_rules_java_bestpractices.html#junit4suitesshouldusesuiteannotation), [JUnit4TestShouldUseAfterAnnotation](pmd_rules_java_bestpractices.html#junit4testshoulduseafterannotation), [JUnit4TestShouldUseBeforeAnnotation](pmd_rules_java_bestpractices.html#junit4testshouldusebeforeannotation), [JUnit4TestShouldUseTestAnnotation](pmd_rules_java_bestpractices.html#junit4testshouldusetestannotation), [JUnitUseExpected](pmd_rules_java_bestpractices.html#junituseexpected), [LongInstantiation](pmd_rules_java_performance.html#longinstantiation), [ReplaceEnumerationWithIterator](pmd_rules_java_bestpractices.html#replaceenumerationwithiterator), [ReplaceHashtableWithMap](pmd_rules_java_bestpractices.html#replacehashtablewithmap), [ReplaceVectorWithList](pmd_rules_java_bestpractices.html#replacevectorwithlist), [ShortInstantiation](pmd_rules_java_performance.html#shortinstantiation)

*   Migration13 (`rulesets/java/migrating_to_13.xml`):

    Contains rules for migrating to JDK 1.3

    It contains the following rules:

    [ReplaceEnumerationWithIterator](pmd_rules_java_bestpractices.html#replaceenumerationwithiterator), [ReplaceHashtableWithMap](pmd_rules_java_bestpractices.html#replacehashtablewithmap), [ReplaceVectorWithList](pmd_rules_java_bestpractices.html#replacevectorwithlist)

*   Migration14 (`rulesets/java/migrating_to_14.xml`):

    Contains rules for migrating to JDK 1.4

    It contains the following rules:

    [AvoidAssertAsIdentifier](pmd_rules_java_errorprone.html#avoidassertasidentifier)

*   Migration15 (`rulesets/java/migrating_to_15.xml`):

    Contains rules for migrating to JDK 1.5

    It contains the following rules:

    [AvoidEnumAsIdentifier](pmd_rules_java_errorprone.html#avoidenumasidentifier), [ByteInstantiation](pmd_rules_java_performance.html#byteinstantiation), [IntegerInstantiation](pmd_rules_java_performance.html#integerinstantiation), [LongInstantiation](pmd_rules_java_performance.html#longinstantiation), [ShortInstantiation](pmd_rules_java_performance.html#shortinstantiation)

*   Naming (`rulesets/java/naming.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [AbstractNaming](pmd_rules_java_codestyle.html#abstractnaming), [AvoidDollarSigns](pmd_rules_java_codestyle.html#avoiddollarsigns), [AvoidFieldNameMatchingMethodName](pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname), [AvoidFieldNameMatchingTypeName](pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename), [BooleanGetMethodName](pmd_rules_java_codestyle.html#booleangetmethodname), [ClassNamingConventions](pmd_rules_java_codestyle.html#classnamingconventions), [GenericsNaming](pmd_rules_java_codestyle.html#genericsnaming), [LongVariable](pmd_rules_java_codestyle.html#longvariable), [MethodNamingConventions](pmd_rules_java_codestyle.html#methodnamingconventions), [MethodWithSameNameAsEnclosingClass](pmd_rules_java_errorprone.html#methodwithsamenameasenclosingclass), [MisleadingVariableName](pmd_rules_java_codestyle.html#misleadingvariablename), [MIsLeadingVariableName](pmd_rules_java_codestyle.html#misleadingvariablename), [NoPackage](pmd_rules_java_codestyle.html#nopackage), [PackageCase](pmd_rules_java_codestyle.html#packagecase), [ShortClassName](pmd_rules_java_codestyle.html#shortclassname), [ShortMethodName](pmd_rules_java_codestyle.html#shortmethodname), [ShortVariable](pmd_rules_java_codestyle.html#shortvariable), [SuspiciousConstantFieldName](pmd_rules_java_codestyle.html#suspiciousconstantfieldname), [SuspiciousEqualsMethodName](pmd_rules_java_errorprone.html#suspiciousequalsmethodname), [SuspiciousHashcodeMethodName](pmd_rules_java_errorprone.html#suspicioushashcodemethodname), [VariableNamingConventions](pmd_rules_java_codestyle.html#variablenamingconventions)

*   Optimization (`rulesets/java/optimizations.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [AddEmptyString](pmd_rules_java_performance.html#addemptystring), [AvoidArrayLoops](pmd_rules_java_performance.html#avoidarrayloops), [AvoidInstantiatingObjectsInLoops](pmd_rules_java_performance.html#avoidinstantiatingobjectsinloops), [LocalVariableCouldBeFinal](pmd_rules_java_codestyle.html#localvariablecouldbefinal), [MethodArgumentCouldBeFinal](pmd_rules_java_codestyle.html#methodargumentcouldbefinal), [PrematureDeclaration](pmd_rules_java_codestyle.html#prematuredeclaration), [RedundantFieldInitializer](pmd_rules_java_performance.html#redundantfieldinitializer), [SimplifyStartsWith](pmd_rules_java_performance.html#simplifystartswith), [UnnecessaryWrapperObjectCreation](pmd_rules_java_performance.html#unnecessarywrapperobjectcreation), [UseArrayListInsteadOfVector](pmd_rules_java_performance.html#usearraylistinsteadofvector), [UseArraysAsList](pmd_rules_java_performance.html#usearraysaslist), [UseStringBufferForStringAppends](pmd_rules_java_performance.html#usestringbufferforstringappends)

*   Security Code Guidelines (`rulesets/java/sunsecure.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [ArrayIsStoredDirectly](pmd_rules_java_bestpractices.html#arrayisstoreddirectly), [MethodReturnsInternalArray](pmd_rules_java_bestpractices.html#methodreturnsinternalarray)

*   Strict Exceptions (`rulesets/java/strictexception.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [AvoidCatchingGenericException](pmd_rules_java_design.html#avoidcatchinggenericexception), [AvoidCatchingNPE](pmd_rules_java_errorprone.html#avoidcatchingnpe), [AvoidCatchingThrowable](pmd_rules_java_errorprone.html#avoidcatchingthrowable), [AvoidLosingExceptionInformation](pmd_rules_java_errorprone.html#avoidlosingexceptioninformation), [AvoidRethrowingException](pmd_rules_java_design.html#avoidrethrowingexception), [AvoidThrowingNewInstanceOfSameException](pmd_rules_java_design.html#avoidthrowingnewinstanceofsameexception), [AvoidThrowingNullPointerException](pmd_rules_java_design.html#avoidthrowingnullpointerexception), [AvoidThrowingRawExceptionTypes](pmd_rules_java_design.html#avoidthrowingrawexceptiontypes), [DoNotExtendJavaLangError](pmd_rules_java_design.html#donotextendjavalangerror), [DoNotThrowExceptionInFinally](pmd_rules_java_errorprone.html#donotthrowexceptioninfinally), [ExceptionAsFlowControl](pmd_rules_java_design.html#exceptionasflowcontrol), [SignatureDeclareThrowsException](pmd_rules_java_design.html#signaturedeclarethrowsexception)

*   String and StringBuffer (`rulesets/java/strings.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [AppendCharacterWithChar](pmd_rules_java_performance.html#appendcharacterwithchar), [AvoidDuplicateLiterals](pmd_rules_java_errorprone.html#avoidduplicateliterals), [AvoidStringBufferField](pmd_rules_java_bestpractices.html#avoidstringbufferfield), [ConsecutiveAppendsShouldReuse](pmd_rules_java_performance.html#consecutiveappendsshouldreuse), [ConsecutiveLiteralAppends](pmd_rules_java_performance.html#consecutiveliteralappends), [InefficientEmptyStringCheck](pmd_rules_java_performance.html#inefficientemptystringcheck), [InefficientStringBuffering](pmd_rules_java_performance.html#inefficientstringbuffering), [InsufficientStringBufferDeclaration](pmd_rules_java_performance.html#insufficientstringbufferdeclaration), [StringBufferInstantiationWithChar](pmd_rules_java_errorprone.html#stringbufferinstantiationwithchar), [StringInstantiation](pmd_rules_java_performance.html#stringinstantiation), [StringToString](pmd_rules_java_performance.html#stringtostring), [UnnecessaryCaseChange](pmd_rules_java_errorprone.html#unnecessarycasechange), [UseEqualsToCompareStrings](pmd_rules_java_errorprone.html#useequalstocomparestrings), [UseIndexOfChar](pmd_rules_java_performance.html#useindexofchar), [UselessStringValueOf](pmd_rules_java_performance.html#uselessstringvalueof), [UseStringBufferLength](pmd_rules_java_performance.html#usestringbufferlength)

*   Type Resolution (`rulesets/java/typeresolution.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [CloneMethodMustImplementCloneable](pmd_rules_java_errorprone.html#clonemethodmustimplementcloneable), [LooseCoupling](pmd_rules_java_bestpractices.html#loosecoupling), [SignatureDeclareThrowsException](pmd_rules_java_design.html#signaturedeclarethrowsexception), [UnusedImports](pmd_rules_java_bestpractices.html#unusedimports)

*   Unnecessary (`rulesets/java/unnecessary.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [UnnecessaryConversionTemporary](pmd_rules_java_errorprone.html#unnecessaryconversiontemporary), [UnnecessaryFinalModifier](pmd_rules_java_codestyle.html#unnecessarymodifier), [UnnecessaryModifier](pmd_rules_java_codestyle.html#unnecessarymodifier), [UnnecessaryReturn](pmd_rules_java_codestyle.html#unnecessaryreturn), [UnusedNullCheckInEquals](pmd_rules_java_errorprone.html#unusednullcheckinequals), [UselessOperationOnImmutable](pmd_rules_java_errorprone.html#uselessoperationonimmutable), [UselessOverridingMethod](pmd_rules_java_design.html#uselessoverridingmethod), [UselessParentheses](pmd_rules_java_codestyle.html#uselessparentheses), [UselessQualifiedThis](pmd_rules_java_codestyle.html#uselessqualifiedthis)

*   Unused Code (`rulesets/java/unusedcode.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [UnusedFormalParameter](pmd_rules_java_bestpractices.html#unusedformalparameter), [UnusedLocalVariable](pmd_rules_java_bestpractices.html#unusedlocalvariable), [UnusedPrivateField](pmd_rules_java_bestpractices.html#unusedprivatefield), [UnusedPrivateMethod](pmd_rules_java_bestpractices.html#unusedprivatemethod)


