diff --git a/docs/pages/pmd/userdocs/faq.md b/docs/pages/pmd/projectdocs/faq.md
similarity index 97%
rename from docs/pages/pmd/userdocs/faq.md
rename to docs/pages/pmd/projectdocs/faq.md
index 3290de321d9..030e0b92f22 100644
--- a/docs/pages/pmd/userdocs/faq.md
+++ b/docs/pages/pmd/projectdocs/faq.md
@@ -1,7 +1,7 @@
---
title: FAQ
sidebar: pmd_sidebar
-permalink: pmd_userdocs_faq.html
+permalink: pmd_projectdocs_faq.html
folder: pmd/userdocs
---
diff --git a/docs/pages/pmd/userdocs/meaning.md b/docs/pages/pmd/projectdocs/trivia/meaning.md
similarity index 93%
rename from docs/pages/pmd/userdocs/meaning.md
rename to docs/pages/pmd/projectdocs/trivia/meaning.md
index b2bd1bc71f3..1c033dab4f1 100644
--- a/docs/pages/pmd/userdocs/meaning.md
+++ b/docs/pages/pmd/projectdocs/trivia/meaning.md
@@ -1,6 +1,6 @@
---
title: What does 'PMD' mean?
-permalink: pmd_userdocs_meaning.html
+permalink: pmd_projectdocs_trivia_meaning.html
author: David Dixon-Peugh
---
diff --git a/docs/pages/pmd/userdocs/news.md b/docs/pages/pmd/projectdocs/trivia/news.md
similarity index 99%
rename from docs/pages/pmd/userdocs/news.md
rename to docs/pages/pmd/projectdocs/trivia/news.md
index 937c1bbcf4b..42eab2a3461 100644
--- a/docs/pages/pmd/userdocs/news.md
+++ b/docs/pages/pmd/projectdocs/trivia/news.md
@@ -1,6 +1,6 @@
---
title: PMD in the press
-permalink: pmd_userdocs_news.html
+permalink: pmd_projectdocs_trivia_news.html
author: Tom Copeland
---
diff --git a/docs/pages/pmd/userdocs/products.md b/docs/pages/pmd/projectdocs/trivia/products.md
similarity index 98%
rename from docs/pages/pmd/userdocs/products.md
rename to docs/pages/pmd/projectdocs/trivia/products.md
index ffba09cb9f6..54175793a47 100644
--- a/docs/pages/pmd/userdocs/products.md
+++ b/docs/pages/pmd/projectdocs/trivia/products.md
@@ -1,6 +1,6 @@
---
title: Products/books related to PMD
-permalink: pmd_userdocs_products.html
+permalink: pmd_projectdocs_trivia_products.html
author: Tom Copeland
---
diff --git a/docs/pages/pmd/userdocs/similarprojects.md b/docs/pages/pmd/projectdocs/trivia/similarprojects.md
similarity index 95%
rename from docs/pages/pmd/userdocs/similarprojects.md
rename to docs/pages/pmd/projectdocs/trivia/similarprojects.md
index 60f574aaf35..e076052416f 100644
--- a/docs/pages/pmd/userdocs/similarprojects.md
+++ b/docs/pages/pmd/projectdocs/trivia/similarprojects.md
@@ -1,6 +1,6 @@
---
title: Similar projects
-permalink: pmd_userdocs_similarprojects.html
+permalink: pmd_projectdocs_trivia_similarprojects.html
author: Tom Copeland , David Dixon-Peugh
---
@@ -16,6 +16,7 @@ author: Tom Copeland , David Dixon-Peugh
Uses Java Modeling Language annotations.
* FindBugs - works on bytecode, uses BCEL. Source code uses
templates, nifty stuff!
+* SpotBugs - SpotBugs is the spiritual successor of FindBugs, carrying on from the point where it left off with support of its community.
* Hammurapi -
Uses ANTLR, excellent documentation, lots of rules
* Jamit - bytecode analyzer, nice graphs
diff --git a/docs/pages/pmd/rules/apex.md b/docs/pages/pmd/rules/apex.md
index 6c4a2ae36e1..682964277be 100644
--- a/docs/pages/pmd/rules/apex.md
+++ b/docs/pages/pmd/rules/apex.md
@@ -1,43 +1,74 @@
---
title: Apex Rules
+tags: [rule_references, apex]
+summary: Index of all built-in rules available for Apex
+language_name: Apex
permalink: pmd_rules_apex.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
-
-* [ApexUnit](pmd_rules_apex_apexunit.html): These rules deal with different problems that can occur with Apex unit tests.
-* [Braces](pmd_rules_apex_braces.html): The Braces ruleset contains rules regarding the use and placement of braces.
-* [Complexity](pmd_rules_apex_complexity.html): The Complexity ruleset contains rules that find problems related to code size or complexity.
-* [Performance](pmd_rules_apex_performance.html): The Performance ruleset contains a collection of good practices which should be followed.
-* [Security](pmd_rules_apex_security.html): These rules deal with different security problems that can occur within Apex.
-* [Style](pmd_rules_apex_style.html): The Style Ruleset contains rules regarding preferred usage of names and identifiers.
-
-## ApexUnit
-* [ApexUnitTestClassShouldHaveAsserts](pmd_rules_apex_apexunit.html#apexunittestclassshouldhaveasserts): Apex unit tests should include at least one assertion. This makes the tests more robust, and usi...
-* [ApexUnitTestShouldNotUseSeeAllDataTrue](pmd_rules_apex_apexunit.html#apexunittestshouldnotuseseealldatatrue): Apex unit tests should not use @isTest(seeAllData=true) because it opens up the existing database...
-
-## Braces
-* [ForLoopsMustUseBraces](pmd_rules_apex_braces.html#forloopsmustusebraces): Avoid using 'for' statements without using surrounding braces. If the code formatting orindentati...
-* [IfElseStmtsMustUseBraces](pmd_rules_apex_braces.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using surrounding braces. If the code formattingor indent...
-* [IfStmtsMustUseBraces](pmd_rules_apex_braces.html#ifstmtsmustusebraces): Avoid using if statements without using braces to surround the code block. If the codeformatting ...
-* [WhileLoopsMustUseBraces](pmd_rules_apex_braces.html#whileloopsmustusebraces): Avoid using 'while' statements without using braces to surround the code block. If the codeformat...
-
-## Complexity
-* [AvoidDeeplyNestedIfStmts](pmd_rules_apex_complexity.html#avoiddeeplynestedifstmts): Avoid creating deeply nested if-then statements since they are harder to read and error-prone to ...
-* [ExcessiveClassLength](pmd_rules_apex_complexity.html#excessiveclasslength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
-* [ExcessiveParameterList](pmd_rules_apex_complexity.html#excessiveparameterlist): Methods with numerous parameters are a challenge to maintain, especially if most of them share th...
-* [ExcessivePublicCount](pmd_rules_apex_complexity.html#excessivepubliccount): Classes with large numbers of public methods and attributes require disproportionate testing effo...
-* [NcssConstructorCount](pmd_rules_apex_complexity.html#ncssconstructorcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
-* [NcssMethodCount](pmd_rules_apex_complexity.html#ncssmethodcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
-* [NcssTypeCount](pmd_rules_apex_complexity.html#ncsstypecount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
-* [StdCyclomaticComplexity](pmd_rules_apex_complexity.html#stdcyclomaticcomplexity): Complexity directly affects maintenance costs is determined by the number of decision points in a...
-* [TooManyFields](pmd_rules_apex_complexity.html#toomanyfields): Classes that have too many fields can become unwieldy and could be redesigned to have fewer field...
+## Best Practices
+
+{% include callout.html content="Rules which enforce generally accepted best practices." %}
+
+* [ApexUnitTestClassShouldHaveAsserts](pmd_rules_apex_bestpractices.html#apexunittestclassshouldhaveasserts): Apex unit tests should include at least one assertion. This makes the tests more robust, and usi...
+* [ApexUnitTestShouldNotUseSeeAllDataTrue](pmd_rules_apex_bestpractices.html#apexunittestshouldnotuseseealldatatrue): Apex unit tests should not use @isTest(seeAllData=true) because it opens up the existing database...
+* [AvoidGlobalModifier](pmd_rules_apex_bestpractices.html#avoidglobalmodifier): Global classes should be avoided (especially in managed packages) as they can never be deleted or...
+* [AvoidLogicInTrigger](pmd_rules_apex_bestpractices.html#avoidlogicintrigger): As triggers do not allow methods like regular classes they are less flexible and suited to apply ...
+
+## Code Style
+
+{% include callout.html content="Rules which enforce a specific coding style." %}
+
+* [ClassNamingConventions](pmd_rules_apex_codestyle.html#classnamingconventions): Class names should always begin with an upper case character.
+* [ForLoopsMustUseBraces](pmd_rules_apex_codestyle.html#forloopsmustusebraces): Avoid using 'for' statements without using surrounding braces. If the code formatting orindentati...
+* [IfElseStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using surrounding braces. If the code formattingor indent...
+* [IfStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifstmtsmustusebraces): Avoid using if statements without using braces to surround the code block. If the codeformatting ...
+* [MethodNamingConventions](pmd_rules_apex_codestyle.html#methodnamingconventions): Method names should always begin with a lower case character, and should not contain underscores.
+* [OneDeclarationPerLine](pmd_rules_apex_codestyle.html#onedeclarationperline): Apex allows the use of several variables declaration of the same type on one line. However, itcan...
+* [VariableNamingConventions](pmd_rules_apex_codestyle.html#variablenamingconventions): A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina...
+* [WhileLoopsMustUseBraces](pmd_rules_apex_codestyle.html#whileloopsmustusebraces): Avoid using 'while' statements without using braces to surround the code block. If the codeformat...
+
+## Design
+
+{% include callout.html content="Rules that help you discover design issues." %}
+
+* [AvoidDeeplyNestedIfStmts](pmd_rules_apex_design.html#avoiddeeplynestedifstmts): Avoid creating deeply nested if-then statements since they are harder to read and error-prone to ...
+* [CyclomaticComplexity](pmd_rules_apex_design.html#cyclomaticcomplexity): The complexity of methods directly affects maintenance costs and readability. Concentrating too m...
+* [ExcessiveClassLength](pmd_rules_apex_design.html#excessiveclasslength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
+* [ExcessiveParameterList](pmd_rules_apex_design.html#excessiveparameterlist): Methods with numerous parameters are a challenge to maintain, especially if most of them share th...
+* [ExcessivePublicCount](pmd_rules_apex_design.html#excessivepubliccount): Classes with large numbers of public methods and attributes require disproportionate testing effo...
+* [NcssConstructorCount](pmd_rules_apex_design.html#ncssconstructorcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
+* [NcssMethodCount](pmd_rules_apex_design.html#ncssmethodcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
+* [NcssTypeCount](pmd_rules_apex_design.html#ncsstypecount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
+* [StdCyclomaticComplexity](pmd_rules_apex_design.html#stdcyclomaticcomplexity): Complexity directly affects maintenance costs is determined by the number of decision points in a...
+* [TooManyFields](pmd_rules_apex_design.html#toomanyfields): Classes that have too many fields can become unwieldy and could be redesigned to have fewer field...
+
+## Error Prone
+
+{% include callout.html content="Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors." %}
+
+* [AvoidDirectAccessTriggerMap](pmd_rules_apex_errorprone.html#avoiddirectaccesstriggermap): Avoid directly accessing Trigger.old and Trigger.new as it can lead to a bug. Triggers should be ...
+* [AvoidHardcodingId](pmd_rules_apex_errorprone.html#avoidhardcodingid): When deploying Apex code between sandbox and production environments, or installing Force.com App...
+* [AvoidNonExistentAnnotations](pmd_rules_apex_errorprone.html#avoidnonexistentannotations): Apex supported non existent annotations for legacy reasons. In the future, use of such...
+* [EmptyCatchBlock](pmd_rules_apex_errorprone.html#emptycatchblock): Empty Catch Block finds instances where an exception is caught, but nothing is done. In most cir...
+* [EmptyIfStmt](pmd_rules_apex_errorprone.html#emptyifstmt): Empty If Statement finds instances where a condition is checked but nothing is done about it.
+* [EmptyStatementBlock](pmd_rules_apex_errorprone.html#emptystatementblock): Empty block statements serve no purpose and should be removed.
+* [EmptyTryOrFinallyBlock](pmd_rules_apex_errorprone.html#emptytryorfinallyblock): Avoid empty try or finally blocks - what's the point?
+* [EmptyWhileStmt](pmd_rules_apex_errorprone.html#emptywhilestmt): Empty While Statement finds all instances where a while statement does nothing. If it is a timin...
+* [MethodWithSameNameAsEnclosingClass](pmd_rules_apex_errorprone.html#methodwithsamenameasenclosingclass): Non-constructor methods should not have the same name as the enclosing class.
## Performance
+
+{% include callout.html content="Rules that flag suboptimal code." %}
+
* [AvoidDmlStatementsInLoops](pmd_rules_apex_performance.html#avoiddmlstatementsinloops): Avoid DML statements inside loops to avoid hitting the DML governor limit. Instead, try to batch ...
* [AvoidSoqlInLoops](pmd_rules_apex_performance.html#avoidsoqlinloops): New objects created within loops should be checked to see if they can created outside them and re...
+* [AvoidSoslInLoops](pmd_rules_apex_performance.html#avoidsoslinloops): Sosl calls within loops can cause governor limit exceptions.
## Security
+
+{% include callout.html content="Rules that flag potential security flaws." %}
+
* [ApexBadCrypto](pmd_rules_apex_security.html#apexbadcrypto): The rule makes sure you are using randomly generated IVs and keys for 'Crypto' calls.Hard-wiring ...
* [ApexCRUDViolation](pmd_rules_apex_security.html#apexcrudviolation): The rule validates you are checking for access permissions before a SOQL/SOSL/DML operation.Since...
* [ApexCSRF](pmd_rules_apex_security.html#apexcsrf): Check to avoid making DML operations in Apex class constructor/init method. This preventsmodifica...
@@ -50,11 +81,78 @@ List of rulesets and rules contained in each ruleset.
* [ApexXSSFromEscapeFalse](pmd_rules_apex_security.html#apexxssfromescapefalse): Reports on calls to 'addError' with disabled escaping. The message passed to 'addError'will be di...
* [ApexXSSFromURLParam](pmd_rules_apex_security.html#apexxssfromurlparam): Makes sure that all values obtained from URL parameters are properly escaped / sanitizedto avoid ...
-## Style
-* [AvoidGlobalModifier](pmd_rules_apex_style.html#avoidglobalmodifier): Global classes should be avoided (especially in managed packages) as they can never be deleted or...
-* [AvoidLogicInTrigger](pmd_rules_apex_style.html#avoidlogicintrigger): As triggers do not allow methods like regular classes they are less flexible and suited to apply ...
-* [ClassNamingConventions](pmd_rules_apex_style.html#classnamingconventions): Class names should always begin with an upper case character.
-* [MethodNamingConventions](pmd_rules_apex_style.html#methodnamingconventions): Method names should always begin with a lower case character, and should not contain underscores.
-* [MethodWithSameNameAsEnclosingClass](pmd_rules_apex_style.html#methodwithsamenameasenclosingclass): Non-constructor methods should not have the same name as the enclosing class.
-* [VariableNamingConventions](pmd_rules_apex_style.html#variablenamingconventions): A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina...
+## Additional rulesets
+
+* ApexUnit (`rulesets/apex/apexunit.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [ApexUnitTestClassShouldHaveAsserts](pmd_rules_apex_bestpractices.html#apexunittestclassshouldhaveasserts), [ApexUnitTestShouldNotUseSeeAllDataTrue](pmd_rules_apex_bestpractices.html#apexunittestshouldnotuseseealldatatrue)
+
+* Braces (`rulesets/apex/braces.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [ForLoopsMustUseBraces](pmd_rules_apex_codestyle.html#forloopsmustusebraces), [IfElseStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces), [IfStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifstmtsmustusebraces), [WhileLoopsMustUseBraces](pmd_rules_apex_codestyle.html#whileloopsmustusebraces)
+
+* Complexity (`rulesets/apex/complexity.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [AvoidDeeplyNestedIfStmts](pmd_rules_apex_design.html#avoiddeeplynestedifstmts), [ExcessiveClassLength](pmd_rules_apex_design.html#excessiveclasslength), [ExcessiveParameterList](pmd_rules_apex_design.html#excessiveparameterlist), [ExcessivePublicCount](pmd_rules_apex_design.html#excessivepubliccount), [NcssConstructorCount](pmd_rules_apex_design.html#ncssconstructorcount), [NcssMethodCount](pmd_rules_apex_design.html#ncssmethodcount), [NcssTypeCount](pmd_rules_apex_design.html#ncsstypecount), [StdCyclomaticComplexity](pmd_rules_apex_design.html#stdcyclomaticcomplexity), [TooManyFields](pmd_rules_apex_design.html#toomanyfields)
+
+* Default ruleset used by the CodeClimate Engine for Salesforce.com Apex (`rulesets/apex/ruleset.xml`):
+
+ Default ruleset used by the Code Climate Engine for Salesforce.com Apex
+
+ It contains the following rules:
+
+ [ApexBadCrypto](pmd_rules_apex_security.html#apexbadcrypto), [ApexCRUDViolation](pmd_rules_apex_security.html#apexcrudviolation), [ApexCSRF](pmd_rules_apex_security.html#apexcsrf), [ApexDangerousMethods](pmd_rules_apex_security.html#apexdangerousmethods), [ApexDoc](pmd_rules_apex_documentation.html#apexdoc), [ApexInsecureEndpoint](pmd_rules_apex_security.html#apexinsecureendpoint), [ApexOpenRedirect](pmd_rules_apex_security.html#apexopenredirect), [ApexSharingViolations](pmd_rules_apex_security.html#apexsharingviolations), [ApexSOQLInjection](pmd_rules_apex_security.html#apexsoqlinjection), [ApexSuggestUsingNamedCred](pmd_rules_apex_security.html#apexsuggestusingnamedcred), [ApexUnitTestClassShouldHaveAsserts](pmd_rules_apex_bestpractices.html#apexunittestclassshouldhaveasserts), [ApexUnitTestShouldNotUseSeeAllDataTrue](pmd_rules_apex_bestpractices.html#apexunittestshouldnotuseseealldatatrue), [ApexXSSFromEscapeFalse](pmd_rules_apex_security.html#apexxssfromescapefalse), [ApexXSSFromURLParam](pmd_rules_apex_security.html#apexxssfromurlparam), [AvoidDeeplyNestedIfStmts](pmd_rules_apex_design.html#avoiddeeplynestedifstmts), [AvoidDirectAccessTriggerMap](pmd_rules_apex_errorprone.html#avoiddirectaccesstriggermap), [AvoidDmlStatementsInLoops](pmd_rules_apex_performance.html#avoiddmlstatementsinloops), [AvoidGlobalModifier](pmd_rules_apex_bestpractices.html#avoidglobalmodifier), [AvoidHardcodingId](pmd_rules_apex_errorprone.html#avoidhardcodingid), [AvoidLogicInTrigger](pmd_rules_apex_bestpractices.html#avoidlogicintrigger), [AvoidNonExistentAnnotations](pmd_rules_apex_errorprone.html#avoidnonexistentannotations), [AvoidSoqlInLoops](pmd_rules_apex_performance.html#avoidsoqlinloops), [AvoidSoslInLoops](pmd_rules_apex_performance.html#avoidsoslinloops), [ClassNamingConventions](pmd_rules_apex_codestyle.html#classnamingconventions), [CyclomaticComplexity](pmd_rules_apex_design.html#cyclomaticcomplexity), [EmptyCatchBlock](pmd_rules_apex_errorprone.html#emptycatchblock), [EmptyIfStmt](pmd_rules_apex_errorprone.html#emptyifstmt), [EmptyStatementBlock](pmd_rules_apex_errorprone.html#emptystatementblock), [EmptyTryOrFinallyBlock](pmd_rules_apex_errorprone.html#emptytryorfinallyblock), [EmptyWhileStmt](pmd_rules_apex_errorprone.html#emptywhilestmt), [ExcessiveClassLength](pmd_rules_apex_design.html#excessiveclasslength), [ExcessiveParameterList](pmd_rules_apex_design.html#excessiveparameterlist), [ExcessivePublicCount](pmd_rules_apex_design.html#excessivepubliccount), [ForLoopsMustUseBraces](pmd_rules_apex_codestyle.html#forloopsmustusebraces), [IfElseStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces), [IfStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifstmtsmustusebraces), [MethodNamingConventions](pmd_rules_apex_codestyle.html#methodnamingconventions), [MethodWithSameNameAsEnclosingClass](pmd_rules_apex_errorprone.html#methodwithsamenameasenclosingclass), [NcssConstructorCount](pmd_rules_apex_design.html#ncssconstructorcount), [NcssMethodCount](pmd_rules_apex_design.html#ncssmethodcount), [NcssTypeCount](pmd_rules_apex_design.html#ncsstypecount), [OneDeclarationPerLine](pmd_rules_apex_codestyle.html#onedeclarationperline), [StdCyclomaticComplexity](pmd_rules_apex_design.html#stdcyclomaticcomplexity), [TooManyFields](pmd_rules_apex_design.html#toomanyfields), [VariableNamingConventions](pmd_rules_apex_codestyle.html#variablenamingconventions), [WhileLoopsMustUseBraces](pmd_rules_apex_codestyle.html#whileloopsmustusebraces)
+
+* Empty Code (`rulesets/apex/empty.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [EmptyCatchBlock](pmd_rules_apex_errorprone.html#emptycatchblock), [EmptyIfStmt](pmd_rules_apex_errorprone.html#emptyifstmt), [EmptyStatementBlock](pmd_rules_apex_errorprone.html#emptystatementblock), [EmptyTryOrFinallyBlock](pmd_rules_apex_errorprone.html#emptytryorfinallyblock), [EmptyWhileStmt](pmd_rules_apex_errorprone.html#emptywhilestmt)
+
+* Metrics temporary ruleset (`rulesets/apex/metrics.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [CyclomaticComplexity](pmd_rules_apex_design.html#cyclomaticcomplexity)
+
+* Performance (`rulesets/apex/performance.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [AvoidDmlStatementsInLoops](pmd_rules_apex_performance.html#avoiddmlstatementsinloops), [AvoidSoqlInLoops](pmd_rules_apex_performance.html#avoidsoqlinloops), [AvoidSoslInLoops](pmd_rules_apex_performance.html#avoidsoslinloops)
+
+* Security (`rulesets/apex/security.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [ApexBadCrypto](pmd_rules_apex_security.html#apexbadcrypto), [ApexCRUDViolation](pmd_rules_apex_security.html#apexcrudviolation), [ApexCSRF](pmd_rules_apex_security.html#apexcsrf), [ApexDangerousMethods](pmd_rules_apex_security.html#apexdangerousmethods), [ApexInsecureEndpoint](pmd_rules_apex_security.html#apexinsecureendpoint), [ApexOpenRedirect](pmd_rules_apex_security.html#apexopenredirect), [ApexSharingViolations](pmd_rules_apex_security.html#apexsharingviolations), [ApexSOQLInjection](pmd_rules_apex_security.html#apexsoqlinjection), [ApexSuggestUsingNamedCred](pmd_rules_apex_security.html#apexsuggestusingnamedcred), [ApexXSSFromEscapeFalse](pmd_rules_apex_security.html#apexxssfromescapefalse), [ApexXSSFromURLParam](pmd_rules_apex_security.html#apexxssfromurlparam)
+
+* Style (`rulesets/apex/style.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [AvoidDirectAccessTriggerMap](pmd_rules_apex_errorprone.html#avoiddirectaccesstriggermap), [AvoidGlobalModifier](pmd_rules_apex_bestpractices.html#avoidglobalmodifier), [AvoidHardcodingId](pmd_rules_apex_errorprone.html#avoidhardcodingid), [AvoidLogicInTrigger](pmd_rules_apex_bestpractices.html#avoidlogicintrigger), [ClassNamingConventions](pmd_rules_apex_codestyle.html#classnamingconventions), [MethodNamingConventions](pmd_rules_apex_codestyle.html#methodnamingconventions), [MethodWithSameNameAsEnclosingClass](pmd_rules_apex_errorprone.html#methodwithsamenameasenclosingclass), [VariableNamingConventions](pmd_rules_apex_codestyle.html#variablenamingconventions)
+
diff --git a/docs/pages/pmd/rules/apex/apexunit.md b/docs/pages/pmd/rules/apex/apexunit.md
deleted file mode 100644
index b6b26fda984..00000000000
--- a/docs/pages/pmd/rules/apex/apexunit.md
+++ /dev/null
@@ -1,84 +0,0 @@
----
-title: ApexUnit
-summary: These rules deal with different problems that can occur with Apex unit tests.
-permalink: pmd_rules_apex_apexunit.html
-folder: pmd/rules/apex
-sidebaractiveurl: /pmd_rules_apex.html
-editmepath: ../pmd-apex/src/main/resources/rulesets/apex/apexunit.xml
-keywords: ApexUnit, ApexUnitTestClassShouldHaveAsserts, ApexUnitTestShouldNotUseSeeAllDataTrue
----
-## ApexUnitTestClassShouldHaveAsserts
-
-**Since:** PMD 5.5.1
-
-**Priority:** Medium (3)
-
-Apex unit tests should include at least one assertion. This makes the tests more robust, and using assert
- with messages provide the developer a clearer idea of what the test does.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestClassShouldHaveAssertsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/apexunit/ApexUnitTestClassShouldHaveAssertsRule.java)
-
-**Example(s):**
-
-``` java
-@isTest
-public class Foo {
- public static testMethod void testSomething() {
- Account a = null;
- // This is better than having a NullPointerException
- // System.assertNotEquals(a, null, 'account not found');
- a.toString();
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ApexUnitTestShouldNotUseSeeAllDataTrue
-
-**Since:** PMD 5.5.1
-
-**Priority:** Medium (3)
-
-Apex unit tests should not use @isTest(seeAllData=true) because it opens up the existing database data for unexpected modification by tests.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestShouldNotUseSeeAllDataTrueRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/apexunit/ApexUnitTestShouldNotUseSeeAllDataTrueRule.java)
-
-**Example(s):**
-
-``` java
-@isTest(seeAllData = true)
-public class Foo {
- public static testMethod void testSomething() {
- Account a = null;
- // This is better than having a NullPointerException
- // System.assertNotEquals(a, null, 'account not found');
- a.toString();
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/apex/bestpractices.md b/docs/pages/pmd/rules/apex/bestpractices.md
new file mode 100644
index 00000000000..d59c846baf3
--- /dev/null
+++ b/docs/pages/pmd/rules/apex/bestpractices.md
@@ -0,0 +1,163 @@
+---
+title: Best Practices
+summary: Rules which enforce generally accepted best practices.
+permalink: pmd_rules_apex_bestpractices.html
+folder: pmd/rules/apex
+sidebaractiveurl: /pmd_rules_apex.html
+editmepath: ../pmd-apex/src/main/resources/category/apex/bestpractices.xml
+keywords: Best Practices, ApexUnitTestClassShouldHaveAsserts, ApexUnitTestShouldNotUseSeeAllDataTrue, AvoidGlobalModifier, AvoidLogicInTrigger
+language: Apex
+---
+## ApexUnitTestClassShouldHaveAsserts
+
+**Since:** PMD 5.5.1
+
+**Priority:** Medium (3)
+
+Apex unit tests should include at least one assertion. This makes the tests more robust, and using assert
+with messages provide the developer a clearer idea of what the test does.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.bestpractices.ApexUnitTestClassShouldHaveAssertsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java)
+
+**Example(s):**
+
+``` java
+@isTest
+public class Foo {
+ public static testMethod void testSomething() {
+ Account a = null;
+ // This is better than having a NullPointerException
+ // System.assertNotEquals(a, null, 'account not found');
+ a.toString();
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ApexUnitTestShouldNotUseSeeAllDataTrue
+
+**Since:** PMD 5.5.1
+
+**Priority:** Medium (3)
+
+Apex unit tests should not use @isTest(seeAllData=true) because it opens up the existing database data for unexpected modification by tests.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.bestpractices.ApexUnitTestShouldNotUseSeeAllDataTrueRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestShouldNotUseSeeAllDataTrueRule.java)
+
+**Example(s):**
+
+``` java
+@isTest(seeAllData = true)
+public class Foo {
+ public static testMethod void testSomething() {
+ Account a = null;
+ // This is better than having a NullPointerException
+ // System.assertNotEquals(a, null, 'account not found');
+ a.toString();
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidGlobalModifier
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+Global classes should be avoided (especially in managed packages) as they can never be deleted or changed in signature. Always check twice if something needs to be global.
+Many interfaces (e.g. Batch) required global modifiers in the past but don't require this anymore. Don't lock yourself in.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.bestpractices.AvoidGlobalModifierRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidGlobalModifierRule.java)
+
+**Example(s):**
+
+``` java
+global class Unchangeable {
+ global UndeletableType unchangable(UndeletableType param) {
+ // ...
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidLogicInTrigger
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+As triggers do not allow methods like regular classes they are less flexible and suited to apply good encapsulation style.
+Therefore delegate the triggers work to a regular class (often called Trigger handler class).
+
+See more here: https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigger_Best_Practices
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.bestpractices.AvoidLogicInTriggerRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidLogicInTriggerRule.java)
+
+**Example(s):**
+
+``` java
+trigger Accounts on Account (before insert, before update, before delete, after insert, after update, after delete, after undelete) {
+ for(Account acc : Trigger.new) {
+ if(Trigger.isInsert) {
+ // ...
+ }
+
+ // ...
+
+ if(Trigger.isDelete) {
+ // ...
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/apex/braces.md b/docs/pages/pmd/rules/apex/braces.md
deleted file mode 100644
index 5f4b7e565aa..00000000000
--- a/docs/pages/pmd/rules/apex/braces.md
+++ /dev/null
@@ -1,167 +0,0 @@
----
-title: Braces
-summary: The Braces ruleset contains rules regarding the use and placement of braces.
-permalink: pmd_rules_apex_braces.html
-folder: pmd/rules/apex
-sidebaractiveurl: /pmd_rules_apex.html
-editmepath: ../pmd-apex/src/main/resources/rulesets/apex/braces.xml
-keywords: Braces, IfStmtsMustUseBraces, WhileLoopsMustUseBraces, IfElseStmtsMustUseBraces, ForLoopsMustUseBraces
----
-## ForLoopsMustUseBraces
-
-**Since:** PMD 5.6.0
-
-**Priority:** Medium (3)
-
-Avoid using 'for' statements without using surrounding braces. If the code formatting or
-indentation is lost then it becomes difficult to separate the code being controlled
-from the rest.
-
-```
-//ForLoopStatement/BlockStatement[@CurlyBrace='false']
-|
-//ForEachStatement/BlockStatement[@CurlyBrace='false']
-```
-
-**Example(s):**
-
-``` java
-for (int i = 0; i < 42; i++) // not recommended
- foo();
-
-for (int i = 0; i < 42; i++) { // preferred approach
- foo();
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## IfElseStmtsMustUseBraces
-
-**Since:** PMD 5.6.0
-
-**Priority:** Medium (3)
-
-Avoid using if..else statements without using surrounding braces. If the code formatting
-or indentation is lost then it becomes difficult to separate the code being controlled
-from the rest.
-
-```
-//IfBlockStatement/BlockStatement[@CurlyBrace='false'][count(child::*) > 0]
-|
-//IfElseBlockStatement/BlockStatement[@CurlyBrace='false'][count(child::*) > 0]
-```
-
-**Example(s):**
-
-``` java
-// this is OK
-if (foo) x++;
-
-// but this is not
-if (foo)
- x = x+1;
-else
- x = x-1;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## IfStmtsMustUseBraces
-
-**Since:** PMD 5.6.0
-
-**Priority:** Medium (3)
-
-Avoid using if statements without using braces to surround the code block. If the code
-formatting or indentation is lost then it becomes difficult to separate the code being
-controlled from the rest.
-
-```
-//IfBlockStatement/BlockStatement[@CurlyBrace='false']
-```
-
-**Example(s):**
-
-``` java
-if (foo) // not recommended
- x++;
-
-if (foo) { // preferred approach
- x++;
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## WhileLoopsMustUseBraces
-
-**Since:** PMD 5.6.0
-
-**Priority:** Medium (3)
-
-Avoid using 'while' statements without using braces to surround the code block. If the code
-formatting or indentation is lost then it becomes difficult to separate the code being
-controlled from the rest.
-
-```
-//WhileLoopStatement/BlockStatement[@CurlyBrace='false']
-```
-
-**Example(s):**
-
-``` java
-while (true) // not recommended
- x++;
-
-while (true) { // preferred approach
- x++;
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/apex/codestyle.md b/docs/pages/pmd/rules/apex/codestyle.md
new file mode 100644
index 00000000000..0e59a82e233
--- /dev/null
+++ b/docs/pages/pmd/rules/apex/codestyle.md
@@ -0,0 +1,325 @@
+---
+title: Code Style
+summary: Rules which enforce a specific coding style.
+permalink: pmd_rules_apex_codestyle.html
+folder: pmd/rules/apex
+sidebaractiveurl: /pmd_rules_apex.html
+editmepath: ../pmd-apex/src/main/resources/category/apex/codestyle.xml
+keywords: Code Style, ClassNamingConventions, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, ForLoopsMustUseBraces, MethodNamingConventions, OneDeclarationPerLine, VariableNamingConventions, WhileLoopsMustUseBraces
+language: Apex
+---
+## ClassNamingConventions
+
+**Since:** PMD 5.5.0
+
+**Priority:** High (1)
+
+Class names should always begin with an upper case character.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.ClassNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ForLoopsMustUseBraces
+
+**Since:** PMD 5.6.0
+
+**Priority:** Medium (3)
+
+Avoid using 'for' statements without using surrounding braces. If the code formatting or
+indentation is lost then it becomes difficult to separate the code being controlled
+from the rest.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ForLoopStatement/BlockStatement[@CurlyBrace='false']
+|
+//ForEachStatement/BlockStatement[@CurlyBrace='false']
+```
+
+**Example(s):**
+
+``` java
+for (int i = 0; i < 42; i++) // not recommended
+ foo();
+
+for (int i = 0; i < 42; i++) { // preferred approach
+ foo();
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## IfElseStmtsMustUseBraces
+
+**Since:** PMD 5.6.0
+
+**Priority:** Medium (3)
+
+Avoid using if..else statements without using surrounding braces. If the code formatting
+or indentation is lost then it becomes difficult to separate the code being controlled
+from the rest.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfBlockStatement/BlockStatement[@CurlyBrace='false'][count(child::*) > 0]
+|
+//IfElseBlockStatement/BlockStatement[@CurlyBrace='false'][count(child::*) > 0]
+```
+
+**Example(s):**
+
+``` java
+// this is OK
+if (foo) x++;
+
+// but this is not
+if (foo)
+ x = x+1;
+else
+ x = x-1;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## IfStmtsMustUseBraces
+
+**Since:** PMD 5.6.0
+
+**Priority:** Medium (3)
+
+Avoid using if statements without using braces to surround the code block. If the code
+formatting or indentation is lost then it becomes difficult to separate the code being
+controlled from the rest.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfBlockStatement/BlockStatement[@CurlyBrace='false']
+```
+
+**Example(s):**
+
+``` java
+if (foo) // not recommended
+ x++;
+
+if (foo) { // preferred approach
+ x++;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MethodNamingConventions
+
+**Since:** PMD 5.5.0
+
+**Priority:** High (1)
+
+Method names should always begin with a lower case character, and should not contain underscores.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.MethodNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void fooStuff() {
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## OneDeclarationPerLine
+
+**Since:** PMD 6.7.0
+
+**Priority:** High (1)
+
+Apex allows the use of several variables declaration of the same type on one line. However, it
+can lead to quite messy code. This rule looks for several declarations on the same line.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//VariableDeclarationStatements
+ [count(VariableDeclaration) > 1]
+ [$strictMode or count(distinct-values(VariableDeclaration/@BeginLine)) != count(VariableDeclaration)]
+|
+//FieldDeclarationStatements
+ [count(FieldDeclaration) > 1]
+ [$strictMode or count(distinct-values(FieldDeclaration/VariableExpression/@BeginLine)) != count(FieldDeclaration/VariableExpression)]
+```
+
+**Example(s):**
+
+``` java
+Integer a, b; // not recommended
+
+Integer a,
+ b; // ok by default, can be flagged setting the strictMode property
+
+Integer a; // preferred approach
+Integer b;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|strictMode|false|If true, mark combined declaration even if the declarations are on separate lines.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## VariableNamingConventions
+
+**Since:** PMD 5.5.0
+
+**Priority:** High (1)
+
+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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.VariableNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/VariableNamingConventionsRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public static final Integer MY_NUM = 0;
+ public String myTest = '';
+ DataModule dmTest = new DataModule();
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|parameterSuffix||Method parameter variable suffixes|yes. Delimiter is ','.|
+|parameterPrefix||Method parameter variable prefixes|yes. Delimiter is ','.|
+|localSuffix||Local variable suffixes|yes. Delimiter is ','.|
+|localPrefix||Local variable prefixes|yes. Delimiter is ','.|
+|memberSuffix||Member variable suffixes|yes. Delimiter is ','.|
+|memberPrefix||Member variable prefixes|yes. Delimiter is ','.|
+|staticSuffix||Static variable suffixes|yes. Delimiter is ','.|
+|staticPrefix||Static variable prefixes|yes. Delimiter is ','.|
+|checkParameters|true|Check constructor and method parameter variables|no|
+|checkLocals|true|Check local variables|no|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|checkMembers|true|Check member variables|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## WhileLoopsMustUseBraces
+
+**Since:** PMD 5.6.0
+
+**Priority:** Medium (3)
+
+Avoid using 'while' statements without using braces to surround the code block. If the code
+formatting or indentation is lost then it becomes difficult to separate the code being
+controlled from the rest.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//WhileLoopStatement/BlockStatement[@CurlyBrace='false']
+```
+
+**Example(s):**
+
+``` java
+while (true) // not recommended
+ x++;
+
+while (true) { // preferred approach
+ x++;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/apex/complexity.md b/docs/pages/pmd/rules/apex/complexity.md
deleted file mode 100644
index b3832f5631b..00000000000
--- a/docs/pages/pmd/rules/apex/complexity.md
+++ /dev/null
@@ -1,428 +0,0 @@
----
-title: Complexity
-summary: The Complexity ruleset contains rules that find problems related to code size or complexity.
-permalink: pmd_rules_apex_complexity.html
-folder: pmd/rules/apex
-sidebaractiveurl: /pmd_rules_apex.html
-editmepath: ../pmd-apex/src/main/resources/rulesets/apex/complexity.xml
-keywords: Complexity, AvoidDeeplyNestedIfStmts, ExcessiveParameterList, ExcessiveClassLength, NcssMethodCount, NcssTypeCount, NcssConstructorCount, StdCyclomaticComplexity, TooManyFields, ExcessivePublicCount
----
-## AvoidDeeplyNestedIfStmts
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-Avoid creating deeply nested if-then statements since they are harder to read and error-prone to maintain.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.complexity.AvoidDeeplyNestedIfStmtsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AvoidDeeplyNestedIfStmtsRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar(Integer x, Integer y, Integer z) {
- if (x>y) {
- if (y>z) {
- if (z==x) {
- // !! too deep
- }
- }
- }
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|problemDepth|3|The if statement depth reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveClassLength
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-Excessive class file lengths are usually indications that the class may be burdened with excessive
-responsibilities that could be provided by external classes or functions. In breaking these methods
-apart the code becomes more managable and ripe for reuse.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.complexity.ExcessiveClassLengthRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveClassLengthRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar1() {
- // 1000 lines of code
- }
- public void bar2() {
- // 1000 lines of code
- }
- public void bar3() {
- // 1000 lines of code
- }
- public void barN() {
- // 1000 lines of code
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveParameterList
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-Methods with numerous parameters are a challenge to maintain, especially if most of them share the
-same datatype. These situations usually denote the need for new objects to wrap the numerous parameters.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.complexity.ExcessiveParameterListRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessiveParameterListRule.java)
-
-**Example(s):**
-
-``` java
-// too many arguments liable to be mixed up
-public void addPerson(int birthYear, int birthMonth, int birthDate, int height, int weight, int ssn) {
- // ...
-}
-// preferred approach
-public void addPerson(Date birthdate, BodyMeasurements measurements, int ssn) {
- // ...
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessivePublicCount
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-Classes with large numbers of public methods and attributes require disproportionate testing efforts
-since combinational side effects grow rapidly and increase risk. Refactoring these classes into
-smaller ones not only increases testability and reliability but also allows new variations to be
-developed easily.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.complexity.ExcessivePublicCountRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/ExcessivePublicCountRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public String value;
- public Bar something;
- public Variable var;
- // [... more more public attributes ...]
-
- public void doWork() {}
- public void doMoreWork() {}
- public void doWorkAgain() {}
- // [... more more public methods ...]
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NcssConstructorCount
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.complexity.NcssConstructorCountRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssConstructorCountRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo extends Bar {
- //this constructor only has 1 NCSS lines
- public Foo() {
- super();
-
-
-
-
- super.foo();
-}
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NcssMethodCount
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.complexity.NcssMethodCountRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssMethodCountRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo extends Bar {
- //this method only has 1 NCSS lines
- public Integer methd() {
- super.methd();
-
-
-
- return 1;
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NcssTypeCount
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.complexity.NcssTypeCountRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/NcssTypeCountRule.java)
-
-**Example(s):**
-
-``` java
-//this class only has 6 NCSS lines
-public class Foo extends Bar {
- public Foo() {
- super();
-
-
-
-
-
- super.foo();
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## StdCyclomaticComplexity
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-Complexity directly affects maintenance costs is determined by the number of decision points in a method
-plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
-Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
-high complexity, and 11+ is very high complexity.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.complexity.StdCyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/StdCyclomaticComplexityRule.java)
-
-**Example(s):**
-
-``` java
-// This has a Cyclomatic Complexity = 12
-public class Foo {
-1 public void example() {
-2 if (a == b || (c == d && e == f)) {
-3 if (a1 == b1) {
- fiddle();
-4 } else if a2 == b2) {
- fiddle();
- } else {
- fiddle();
- }
-5 } else if (c == d) {
-6 while (c == d) {
- fiddle();
- }
-7 } else if (e == f) {
-8 for (int n = 0; n < h; n++) {
- fiddle();
- }
- } else {
- switch (z) {
-9 case 1:
- fiddle();
- break;
-10 case 2:
- fiddle();
- break;
-11 case 3:
- fiddle();
- break;
-12 default:
- fiddle();
- break;
- }
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|showMethodsComplexity|true|Add method average violations to the report|
-|showClassesComplexity|true|Add class average violations to the report|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|reportLevel|10|Cyclomatic Complexity reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TooManyFields
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields,
-possibly through grouping related fields in new objects. For example, a class with individual
-city/state/zip fields could park them within a single Address field.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.complexity.TooManyFieldsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/TooManyFieldsRule.java)
-
-**Example(s):**
-
-``` java
-public class Person {
- // too many separate fields
- int birthYear;
- int birthMonth;
- int birthDate;
- float height;
- float weight;
-}
-
-public class Person {
- // this is more manageable
- Date birthDate;
- BodyMeasurements measurements;
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|maxfields|15|Max allowable fields|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/apex/design.md b/docs/pages/pmd/rules/apex/design.md
new file mode 100644
index 00000000000..8ac0a075469
--- /dev/null
+++ b/docs/pages/pmd/rules/apex/design.md
@@ -0,0 +1,495 @@
+---
+title: Design
+summary: Rules that help you discover design issues.
+permalink: pmd_rules_apex_design.html
+folder: pmd/rules/apex
+sidebaractiveurl: /pmd_rules_apex.html
+editmepath: ../pmd-apex/src/main/resources/category/apex/design.xml
+keywords: Design, AvoidDeeplyNestedIfStmts, CyclomaticComplexity, ExcessiveClassLength, ExcessiveParameterList, ExcessivePublicCount, NcssConstructorCount, NcssMethodCount, NcssTypeCount, StdCyclomaticComplexity, TooManyFields
+language: Apex
+---
+## AvoidDeeplyNestedIfStmts
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+Avoid creating deeply nested if-then statements since they are harder to read and error-prone to maintain.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.AvoidDeeplyNestedIfStmtsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar(Integer x, Integer y, Integer z) {
+ if (x>y) {
+ if (y>z) {
+ if (z==x) {
+ // !! too deep
+ }
+ }
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|problemDepth|3|The if statement depth reporting threshold|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CyclomaticComplexity
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+The complexity of methods directly affects maintenance costs and readability. Concentrating too much decisional logic
+in a single method makes its behaviour hard to read and change.
+
+Cyclomatic complexity assesses the complexity of a method by counting the number of decision points in a method,
+plus one for the method entry. Decision points are places where the control flow jumps to another place in the
+program. As such, they include all control flow statements, such as 'if', 'while', 'for', and 'case'.
+
+Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
+high complexity, and 11+ is very high complexity. By default, this rule reports methods with a complexity >= 10.
+Additionnally, classes with many methods of moderate complexity get reported as well once the total of their
+methods' complexities reaches 40, even if none of the methods was directly reported.
+
+Reported methods should be broken down into several smaller methods. Reported classes should probably be broken down
+into subcomponents.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.CyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java)
+
+**Example(s):**
+
+``` java
+public class Complicated {
+ public void example() { // This method has a cyclomatic complexity of 12
+ int x = 0, y = 1, z = 2, t = 2;
+ boolean a = false, b = true, c = false, d = true;
+ if (a && b || b && d) {
+ if (y == z) {
+ x = 2;
+ } else if (y == t && !d) {
+ x = 2;
+ } else {
+ x = 2;
+ }
+ } else if (c && d) {
+ while (z < y) {
+ x = 2;
+ }
+ } else {
+ for (int n = 0; n < t; n++) {
+ x = 2;
+ }
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|methodReportLevel|10|Cyclomatic complexity reporting threshold|no|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|classReportLevel|40|Total class complexity reporting threshold|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessiveClassLength
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+Excessive class file lengths are usually indications that the class may be burdened with excessive
+responsibilities that could be provided by external classes or functions. In breaking these methods
+apart the code becomes more managable and ripe for reuse.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.ExcessiveClassLengthRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar1() {
+ // 1000 lines of code
+ }
+ public void bar2() {
+ // 1000 lines of code
+ }
+ public void bar3() {
+ // 1000 lines of code
+ }
+ public void barN() {
+ // 1000 lines of code
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessiveParameterList
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+Methods with numerous parameters are a challenge to maintain, especially if most of them share the
+same datatype. These situations usually denote the need for new objects to wrap the numerous parameters.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.ExcessiveParameterListRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListRule.java)
+
+**Example(s):**
+
+``` java
+// too many arguments liable to be mixed up
+public void addPerson(int birthYear, int birthMonth, int birthDate, int height, int weight, int ssn) {
+ // ...
+}
+// preferred approach
+public void addPerson(Date birthdate, BodyMeasurements measurements, int ssn) {
+ // ...
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessivePublicCount
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+Classes with large numbers of public methods and attributes require disproportionate testing efforts
+since combinational side effects grow rapidly and increase risk. Refactoring these classes into
+smaller ones not only increases testability and reliability but also allows new variations to be
+developed easily.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.ExcessivePublicCountRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public String value;
+ public Bar something;
+ public Variable var;
+ // [... more more public attributes ...]
+
+ public void doWork() {}
+ public void doMoreWork() {}
+ public void doWorkAgain() {}
+ // [... more more public methods ...]
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NcssConstructorCount
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.NcssConstructorCountRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo extends Bar {
+ //this constructor only has 1 NCSS lines
+ public Foo() {
+ super();
+
+
+
+
+ super.foo();
+}
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NcssMethodCount
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.NcssMethodCountRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo extends Bar {
+ //this method only has 1 NCSS lines
+ public Integer methd() {
+ super.methd();
+
+
+
+ return 1;
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NcssTypeCount
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.NcssTypeCountRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountRule.java)
+
+**Example(s):**
+
+``` java
+//this class only has 6 NCSS lines
+public class Foo extends Bar {
+ public Foo() {
+ super();
+
+
+
+
+
+ super.foo();
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## StdCyclomaticComplexity
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+Complexity directly affects maintenance costs is determined by the number of decision points in a method
+plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
+Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
+high complexity, and 11+ is very high complexity.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.StdCyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java)
+
+**Example(s):**
+
+``` java
+// This has a Cyclomatic Complexity = 12
+public class Foo {
+1 public void example() {
+2 if (a == b || (c == d && e == f)) {
+3 if (a1 == b1) {
+ fiddle();
+4 } else if a2 == b2) {
+ fiddle();
+ } else {
+ fiddle();
+ }
+5 } else if (c == d) {
+6 while (c == d) {
+ fiddle();
+ }
+7 } else if (e == f) {
+8 for (int n = 0; n < h; n++) {
+ fiddle();
+ }
+ } else {
+ switch (z) {
+9 case 1:
+ fiddle();
+ break;
+10 case 2:
+ fiddle();
+ break;
+11 case 3:
+ fiddle();
+ break;
+12 default:
+ fiddle();
+ break;
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|showMethodsComplexity|true|Add method average violations to the report|no|
+|showClassesComplexity|true|Add class average violations to the report|no|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|reportLevel|10|Cyclomatic Complexity reporting threshold|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## TooManyFields
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields,
+possibly through grouping related fields in new objects. For example, a class with individual
+city/state/zip fields could park them within a single Address field.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.design.TooManyFieldsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsRule.java)
+
+**Example(s):**
+
+``` java
+public class Person {
+ // too many separate fields
+ int birthYear;
+ int birthMonth;
+ int birthDate;
+ float height;
+ float weight;
+}
+
+public class Person {
+ // this is more manageable
+ Date birthDate;
+ BodyMeasurements measurements;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+|maxfields|15|Max allowable fields|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/apex/errorprone.md b/docs/pages/pmd/rules/apex/errorprone.md
new file mode 100644
index 00000000000..8e1aa7d2c6f
--- /dev/null
+++ b/docs/pages/pmd/rules/apex/errorprone.md
@@ -0,0 +1,367 @@
+---
+title: Error Prone
+summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+permalink: pmd_rules_apex_errorprone.html
+folder: pmd/rules/apex
+sidebaractiveurl: /pmd_rules_apex.html
+editmepath: ../pmd-apex/src/main/resources/category/apex/errorprone.xml
+keywords: Error Prone, AvoidDirectAccessTriggerMap, AvoidHardcodingId, EmptyCatchBlock, EmptyIfStmt, EmptyStatementBlock, EmptyTryOrFinallyBlock, EmptyWhileStmt, MethodWithSameNameAsEnclosingClass, AvoidNonExistentAnnotations
+language: Apex
+---
+## AvoidDirectAccessTriggerMap
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+Avoid directly accessing Trigger.old and Trigger.new as it can lead to a bug. Triggers should be bulkified and iterate through the map to handle the actions for each item separately.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ArrayLoadExpression[TriggerVariableExpression and LiteralExpression]
+```
+
+**Example(s):**
+
+``` java
+trigger AccountTrigger on Account (before insert, before update) {
+ Account a = Trigger.new[0]; //Bad: Accessing the trigger array directly is not recommended.
+
+ foreach ( Account a : Trigger.new ){
+ //Good: Iterate through the trigger.new array instead.
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidHardcodingId
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+When deploying Apex code between sandbox and production environments, or installing Force.com AppExchange packages,
+it is essential to avoid hardcoding IDs in the Apex code. By doing so, if the record IDs change between environments,
+the logic can dynamically identify the proper data to operate against and not fail.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidHardcodingIdRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdRule.java)
+
+**Example(s):**
+
+``` java
+public without sharing class Foo {
+ void foo() {
+ //Error - hardcoded the record type id
+ if(a.RecordTypeId == '012500000009WAr'){
+ //do some logic here.....
+ } else if(a.RecordTypeId == '0123000000095Km'){
+ //do some logic here for a different record type...
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidNonExistentAnnotations
+
+**Since:** PMD 6.5.0
+
+**Priority:** Medium (3)
+
+Apex supported non existent annotations for legacy reasons.
+In the future, use of such non-existent annotations could result in broken apex code that will not compile.
+This will prevent users of garbage annotations from being able to use legitimate annotations added to Apex in the future.
+A full list of supported annotations can be found at https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation.htm
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidNonExistentAnnotationsRule.java)
+
+**Example(s):**
+
+``` java
+@NonExistentAnnotation public class ClassWithNonexistentAnnotation {
+ @NonExistentAnnotation public void methodWithNonExistentAnnotation() {
+ // ...
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyCatchBlock
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CatchBlockStatement[./BlockStatement[count(*) = 0]]
+```
+
+**Example(s):**
+
+``` java
+public void doSomething() {
+ ...
+ try {
+ insert accounts;
+ } catch (DmlException dmle) {
+ // not good
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyIfStmt
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+Empty If Statement finds instances where a condition is checked but nothing is done about it.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfBlockStatement
+ [BlockStatement[count(*) = 0]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar(Integer x) {
+ if (x == 0) {
+ // empty!
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyStatementBlock
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+Empty block statements serve no purpose and should be removed.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Method/ModifierNode[@Abstract!='true' and ../BlockStatement[count(*) = 0]]
+| //Method/BlockStatement//BlockStatement[count(*) = 0 and @Location != parent::*/@Location]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+
+ private int _bar;
+
+ public void setBar(int bar) {
+ // empty
+ }
+
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyTryOrFinallyBlock
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+Avoid empty try or finally blocks - what's the point?
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//TryCatchFinallyBlockStatement[./BlockStatement[count(*) = 0]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar() {
+ try {
+ // empty !
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
+
+public class Foo {
+ public void bar() {
+ try {
+ int x=2;
+ } finally {
+ // empty!
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyWhileStmt
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+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 is
+a while loop that does a lot in the exit expression, rewrite it to make it clearer.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//WhileLoopStatement[./BlockStatement[count(*) = 0]]
+```
+
+**Example(s):**
+
+``` java
+public void bar(Integer a, Integer b) {
+ while (a == b) {
+ // empty!
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MethodWithSameNameAsEnclosingClass
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+Non-constructor methods should not have the same name as the enclosing class.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.errorprone.MethodWithSameNameAsEnclosingClassRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/MethodWithSameNameAsEnclosingClassRule.java)
+
+**Example(s):**
+
+``` java
+public class MyClass {
+ // this is OK because it is a constructor
+ public MyClass() {}
+ // this is bad because it is a method
+ public void MyClass() {}
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/apex/performance.md b/docs/pages/pmd/rules/apex/performance.md
index 6cf63881068..1d293a87ed3 100644
--- a/docs/pages/pmd/rules/apex/performance.md
+++ b/docs/pages/pmd/rules/apex/performance.md
@@ -1,11 +1,12 @@
---
title: Performance
-summary: The Performance ruleset contains a collection of good practices which should be followed.
+summary: Rules that flag suboptimal code.
permalink: pmd_rules_apex_performance.html
folder: pmd/rules/apex
sidebaractiveurl: /pmd_rules_apex.html
-editmepath: ../pmd-apex/src/main/resources/rulesets/apex/performance.xml
-keywords: Performance, AvoidSoqlInLoops, AvoidDmlStatementsInLoops
+editmepath: ../pmd-apex/src/main/resources/category/apex/performance.xml
+keywords: Performance, AvoidDmlStatementsInLoops, AvoidSoqlInLoops, AvoidSoslInLoops
+language: Apex
---
## AvoidDmlStatementsInLoops
@@ -33,15 +34,15 @@ public class Something {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## AvoidSoqlInLoops
@@ -68,14 +69,49 @@ public class Something {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
+```
+
+## AvoidSoslInLoops
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+Sosl calls within loops can cause governor limit exceptions.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.performance.AvoidSoslInLoopsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoslInLoopsRule.java)
+
+**Example(s):**
+
+``` java
+public class Something {
+ public static void main( String as[] ) {
+ for (Integer i = 0; i < 10; i++) {
+ List> searchList = [FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead];
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
+
+**Use this rule by referencing it:**
+``` xml
+
```
diff --git a/docs/pages/pmd/rules/apex/security.md b/docs/pages/pmd/rules/apex/security.md
index 09ca5f39051..9648289959b 100644
--- a/docs/pages/pmd/rules/apex/security.md
+++ b/docs/pages/pmd/rules/apex/security.md
@@ -1,11 +1,12 @@
---
title: Security
-summary: These rules deal with different security problems that can occur within Apex.
+summary: Rules that flag potential security flaws.
permalink: pmd_rules_apex_security.html
folder: pmd/rules/apex
sidebaractiveurl: /pmd_rules_apex.html
-editmepath: ../pmd-apex/src/main/resources/rulesets/apex/security.xml
-keywords: Security, ApexSharingViolations, ApexOpenRedirect, ApexInsecureEndpoint, ApexXSSFromURLParam, ApexXSSFromEscapeFalse, ApexBadCrypto, ApexCSRF, ApexSOQLInjection, ApexCRUDViolation, ApexDangerousMethods, ApexSuggestUsingNamedCred
+editmepath: ../pmd-apex/src/main/resources/category/apex/security.xml
+keywords: Security, ApexBadCrypto, ApexCRUDViolation, ApexCSRF, ApexDangerousMethods, ApexInsecureEndpoint, ApexOpenRedirect, ApexSharingViolations, ApexSOQLInjection, ApexSuggestUsingNamedCred, ApexXSSFromEscapeFalse, ApexXSSFromURLParam
+language: Apex
---
## ApexBadCrypto
@@ -31,15 +32,15 @@ public without sharing class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexCRUDViolation
@@ -75,15 +76,15 @@ public class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexCSRF
@@ -113,15 +114,15 @@ public class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexDangerousMethods
@@ -153,15 +154,15 @@ public class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexInsecureEndpoint
@@ -188,15 +189,15 @@ public without sharing class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexOpenRedirect
@@ -223,15 +224,15 @@ public without sharing class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexSharingViolations
@@ -255,15 +256,15 @@ public without sharing class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexSOQLInjection
@@ -288,15 +289,15 @@ public class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexSuggestUsingNamedCred
@@ -335,15 +336,15 @@ public class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexXSSFromEscapeFalse
@@ -368,15 +369,15 @@ public without sharing class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## ApexXSSFromURLParam
@@ -401,14 +402,14 @@ public without sharing class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.|
+|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no|
+|cc_block_highlighting|false|Code Climate Block Highlighting|no|
**Use this rule by referencing it:**
``` xml
-
+
```
diff --git a/docs/pages/pmd/rules/apex/style.md b/docs/pages/pmd/rules/apex/style.md
deleted file mode 100644
index 660db734fd4..00000000000
--- a/docs/pages/pmd/rules/apex/style.md
+++ /dev/null
@@ -1,228 +0,0 @@
----
-title: Style
-summary: The Style Ruleset contains rules regarding preferred usage of names and identifiers.
-permalink: pmd_rules_apex_style.html
-folder: pmd/rules/apex
-sidebaractiveurl: /pmd_rules_apex.html
-editmepath: ../pmd-apex/src/main/resources/rulesets/apex/style.xml
-keywords: Style, VariableNamingConventions, MethodNamingConventions, ClassNamingConventions, MethodWithSameNameAsEnclosingClass, AvoidLogicInTrigger, AvoidGlobalModifier
----
-## AvoidGlobalModifier
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-Global classes should be avoided (especially in managed packages) as they can never be deleted or changed in signature. Always check twice if something needs to be global.
-Many interfaces (e.g. Batch) required global modifiers in the past but don't require this anymore. Don't lock yourself in.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.style.AvoidGlobalModifierRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidGlobalModifierRule.java)
-
-**Example(s):**
-
-``` java
-global class Unchangeable {
- global UndeletableType unchangable(UndeletableType param) {
- // ...
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidLogicInTrigger
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-As triggers do not allow methods like regular classes they are less flexible and suited to apply good encapsulation style.
-Therefore delegate the triggers work to a regular class (often called Trigger handler class).
-
-See more here: https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigger_Best_Practices
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.style.AvoidLogicInTriggerRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/AvoidLogicInTriggerRule.java)
-
-**Example(s):**
-
-``` java
-trigger Accounts on Account (before insert, before update, before delete, after insert, after update, after delete, after undelete) {
- for(Account acc : Trigger.new) {
- if(Trigger.isInsert) {
- // ...
- }
-
- // ...
-
- if(Trigger.isDelete) {
- // ...
- }
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ClassNamingConventions
-
-**Since:** PMD 5.5.0
-
-**Priority:** High (1)
-
-Class names should always begin with an upper case character.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.style.ClassNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/ClassNamingConventionsRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MethodNamingConventions
-
-**Since:** PMD 5.5.0
-
-**Priority:** High (1)
-
-Method names should always begin with a lower case character, and should not contain underscores.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.style.MethodNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodNamingConventionsRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void fooStuff() {
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MethodWithSameNameAsEnclosingClass
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-Non-constructor methods should not have the same name as the enclosing class.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.style.MethodWithSameNameAsEnclosingClassRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/MethodWithSameNameAsEnclosingClassRule.java)
-
-**Example(s):**
-
-``` java
-public class MyClass {
- // this is OK because it is a constructor
- public MyClass() {}
- // this is bad because it is a method
- public void MyClass() {}
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## VariableNamingConventions
-
-**Since:** PMD 5.5.0
-
-**Priority:** High (1)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.style.VariableNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/style/VariableNamingConventionsRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public static final Integer MY_NUM = 0;
- public String myTest = '';
- DataModule dmTest = new DataModule();
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|parameterSuffix|[]|Method parameter variable suffixes|
-|parameterPrefix|[]|Method parameter variable prefixes|
-|localSuffix|[]|Local variable suffixes|
-|localPrefix|[]|Local variable prefixes|
-|memberSuffix|[]|Member variable suffixes|
-|memberPrefix|[]|Member variable prefixes|
-|staticSuffix|[]|Static variable suffixes|
-|staticPrefix|[]|Static variable prefixes|
-|checkParameters|true|Check constructor and method parameter variables|
-|checkLocals|true|Check local variables|
-|cc_categories|[Style]|Code Climate Categories|
-|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|
-|cc_block_highlighting|false|Code Climate Block Highlighting|
-|checkMembers|true|Check member variables|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/ecmascript.md b/docs/pages/pmd/rules/ecmascript.md
index 84bbba4703c..6e500d0d9a6 100644
--- a/docs/pages/pmd/rules/ecmascript.md
+++ b/docs/pages/pmd/rules/ecmascript.md
@@ -1,37 +1,75 @@
---
title: Ecmascript Rules
+tags: [rule_references, ecmascript]
+summary: Index of all built-in rules available for Ecmascript
+language_name: Ecmascript
permalink: pmd_rules_ecmascript.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
-
-* [Basic Ecmascript](pmd_rules_ecmascript_basic.html): Rules concerning basic ECMAScript guidelines.
-* [Braces](pmd_rules_ecmascript_braces.html): The Braces Ruleset contains a collection of braces rules.
-* [Controversial Ecmascript](pmd_rules_ecmascript_controversial.html): The Controversial ruleset contains rules that, for whatever reason, are considered controversial. They are held here to allow people to include them as they see fit within their custom rulesets.
-* [Unnecessary](pmd_rules_ecmascript_unnecessary.html): The Unnecessary Ruleset contains a collection of rules for unnecessary code.
-
-## Basic Ecmascript
-* [AssignmentInOperand](pmd_rules_ecmascript_basic.html#assignmentinoperand): Avoid assignments in operands; this can make code more complicated and harder to read. This is s...
-* [AvoidTrailingComma](pmd_rules_ecmascript_basic.html#avoidtrailingcomma): This rule helps improve code portability due to differences in browser treatment of trailing comm...
-* [ConsistentReturn](pmd_rules_ecmascript_basic.html#consistentreturn): ECMAScript does provide for return types on functions, and therefore there is no solid rule as to...
-* [EqualComparison](pmd_rules_ecmascript_basic.html#equalcomparison): Using == in condition may lead to unexpected results, as the variables are automatically casted t...
-* [GlobalVariable](pmd_rules_ecmascript_basic.html#globalvariable): This rule helps to avoid using accidently global variables by simply missing the "var" declaratio...
-* [InnaccurateNumericLiteral](pmd_rules_ecmascript_basic.html#innaccuratenumericliteral): The numeric literal will have at different value at runtime, which can happen if you provide too ...
-* [ScopeForInVariable](pmd_rules_ecmascript_basic.html#scopeforinvariable): A for-in loop in which the variable name is not explicitly scoped to the enclosing scope with the...
-* [UnreachableCode](pmd_rules_ecmascript_basic.html#unreachablecode): A 'return', 'break', 'continue', or 'throw' statement should be the last in a block. Statements a...
-* [UseBaseWithParseInt](pmd_rules_ecmascript_basic.html#usebasewithparseint): This rule checks for usages of parseInt. While the second parameter is optional and usually defau...
-
-## Braces
-* [ForLoopsMustUseBraces](pmd_rules_ecmascript_braces.html#forloopsmustusebraces): Avoid using 'for' statements without using curly braces.
-* [IfElseStmtsMustUseBraces](pmd_rules_ecmascript_braces.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using curly braces.
-* [IfStmtsMustUseBraces](pmd_rules_ecmascript_braces.html#ifstmtsmustusebraces): Avoid using if statements without using curly braces.
-* [WhileLoopsMustUseBraces](pmd_rules_ecmascript_braces.html#whileloopsmustusebraces): Avoid using 'while' statements without using curly braces.
-
-## Controversial Ecmascript
-* [AvoidWithStatement](pmd_rules_ecmascript_controversial.html#avoidwithstatement): Avoid using with - it's bad news
-
-## Unnecessary
-* [NoElseReturn](pmd_rules_ecmascript_unnecessary.html#noelsereturn): The else block in a if-else-construct is unnecessary if the 'if' block contains a return.Then the...
-* [UnnecessaryBlock](pmd_rules_ecmascript_unnecessary.html#unnecessaryblock): An unnecessary Block is present. Such Blocks are often used in other languages tointroduce a new...
-* [UnnecessaryParentheses](pmd_rules_ecmascript_unnecessary.html#unnecessaryparentheses): Unnecessary parentheses should be removed.
+## Best Practices
+
+{% include callout.html content="Rules which enforce generally accepted best practices." %}
+
+* [AvoidWithStatement](pmd_rules_ecmascript_bestpractices.html#avoidwithstatement): Avoid using with - it's bad news
+* [ConsistentReturn](pmd_rules_ecmascript_bestpractices.html#consistentreturn): ECMAScript does provide for return types on functions, and therefore there is no solid rule as to...
+* [GlobalVariable](pmd_rules_ecmascript_bestpractices.html#globalvariable): This rule helps to avoid using accidently global variables by simply missing the "var" declaratio...
+* [ScopeForInVariable](pmd_rules_ecmascript_bestpractices.html#scopeforinvariable): A for-in loop in which the variable name is not explicitly scoped to the enclosing scope with the...
+* [UseBaseWithParseInt](pmd_rules_ecmascript_bestpractices.html#usebasewithparseint): This rule checks for usages of parseInt. While the second parameter is optional and usually defau...
+
+## Code Style
+
+{% include callout.html content="Rules which enforce a specific coding style." %}
+
+* [AssignmentInOperand](pmd_rules_ecmascript_codestyle.html#assignmentinoperand): Avoid assignments in operands; this can make code more complicated and harder to read. This is s...
+* [ForLoopsMustUseBraces](pmd_rules_ecmascript_codestyle.html#forloopsmustusebraces): Avoid using 'for' statements without using curly braces.
+* [IfElseStmtsMustUseBraces](pmd_rules_ecmascript_codestyle.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using curly braces.
+* [IfStmtsMustUseBraces](pmd_rules_ecmascript_codestyle.html#ifstmtsmustusebraces): Avoid using if statements without using curly braces.
+* [NoElseReturn](pmd_rules_ecmascript_codestyle.html#noelsereturn): The else block in a if-else-construct is unnecessary if the 'if' block contains a return.Then the...
+* [UnnecessaryBlock](pmd_rules_ecmascript_codestyle.html#unnecessaryblock): An unnecessary Block is present. Such Blocks are often used in other languages tointroduce a new...
+* [UnnecessaryParentheses](pmd_rules_ecmascript_codestyle.html#unnecessaryparentheses): Unnecessary parentheses should be removed.
+* [UnreachableCode](pmd_rules_ecmascript_codestyle.html#unreachablecode): A 'return', 'break', 'continue', or 'throw' statement should be the last in a block. Statements a...
+* [WhileLoopsMustUseBraces](pmd_rules_ecmascript_codestyle.html#whileloopsmustusebraces): Avoid using 'while' statements without using curly braces.
+
+## Error Prone
+
+{% include callout.html content="Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors." %}
+
+* [AvoidTrailingComma](pmd_rules_ecmascript_errorprone.html#avoidtrailingcomma): This rule helps improve code portability due to differences in browser treatment of trailing comm...
+* [EqualComparison](pmd_rules_ecmascript_errorprone.html#equalcomparison): Using == in condition may lead to unexpected results, as the variables are automatically casted t...
+* [InnaccurateNumericLiteral](pmd_rules_ecmascript_errorprone.html#innaccuratenumericliteral): The numeric literal will have a different value at runtime, which can happen if you provide too m...
+
+## Additional rulesets
+
+* Basic Ecmascript (`rulesets/ecmascript/basic.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [AssignmentInOperand](pmd_rules_ecmascript_codestyle.html#assignmentinoperand), [AvoidTrailingComma](pmd_rules_ecmascript_errorprone.html#avoidtrailingcomma), [ConsistentReturn](pmd_rules_ecmascript_bestpractices.html#consistentreturn), [EqualComparison](pmd_rules_ecmascript_errorprone.html#equalcomparison), [GlobalVariable](pmd_rules_ecmascript_bestpractices.html#globalvariable), [InnaccurateNumericLiteral](pmd_rules_ecmascript_errorprone.html#innaccuratenumericliteral), [ScopeForInVariable](pmd_rules_ecmascript_bestpractices.html#scopeforinvariable), [UnreachableCode](pmd_rules_ecmascript_codestyle.html#unreachablecode), [UseBaseWithParseInt](pmd_rules_ecmascript_bestpractices.html#usebasewithparseint)
+
+* Braces (`rulesets/ecmascript/braces.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [ForLoopsMustUseBraces](pmd_rules_ecmascript_codestyle.html#forloopsmustusebraces), [IfElseStmtsMustUseBraces](pmd_rules_ecmascript_codestyle.html#ifelsestmtsmustusebraces), [IfStmtsMustUseBraces](pmd_rules_ecmascript_codestyle.html#ifstmtsmustusebraces), [WhileLoopsMustUseBraces](pmd_rules_ecmascript_codestyle.html#whileloopsmustusebraces)
+
+* Controversial Ecmascript (`rulesets/ecmascript/controversial.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [AvoidWithStatement](pmd_rules_ecmascript_bestpractices.html#avoidwithstatement)
+
+* Unnecessary (`rulesets/ecmascript/unnecessary.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [NoElseReturn](pmd_rules_ecmascript_codestyle.html#noelsereturn), [UnnecessaryBlock](pmd_rules_ecmascript_codestyle.html#unnecessaryblock), [UnnecessaryParentheses](pmd_rules_ecmascript_codestyle.html#unnecessaryparentheses)
+
diff --git a/docs/pages/pmd/rules/ecmascript/basic.md b/docs/pages/pmd/rules/ecmascript/basic.md
deleted file mode 100644
index 9663b6c9d0a..00000000000
--- a/docs/pages/pmd/rules/ecmascript/basic.md
+++ /dev/null
@@ -1,378 +0,0 @@
----
-title: Basic Ecmascript
-summary: Rules concerning basic ECMAScript guidelines.
-permalink: pmd_rules_ecmascript_basic.html
-folder: pmd/rules/ecmascript
-sidebaractiveurl: /pmd_rules_ecmascript.html
-editmepath: ../pmd-javascript/src/main/resources/rulesets/ecmascript/basic.xml
-keywords: Basic Ecmascript, AssignmentInOperand, UnreachableCode, InnaccurateNumericLiteral, ConsistentReturn, ScopeForInVariable, EqualComparison, GlobalVariable, AvoidTrailingComma, UseBaseWithParseInt
----
-## AssignmentInOperand
-
-**Since:** PMD 5.0
-
-**Priority:** Medium High (2)
-
-Avoid assignments in operands; this can make code more complicated and harder to read. This is sometime
-indicative of the bug where the assignment operator '=' was used instead of the equality operator '=='.
-
-```
-//IfStatement[$allowIf = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
-|
- //WhileLoop[$allowWhile = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
-|
- //DoLoop[$allowWhile = "false"]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
-|
- //ForLoop[$allowFor = "false"]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
-|
- //ConditionalExpression[$allowTernary = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
-|
- //ConditionalExpression[$allowTernaryResults = "false"]/child::node()[position() = 2 or position() = 3]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
-```
-
-**Example(s):**
-
-``` javascript
-var x = 2;
-// Bad
-if ((x = getX()) == 3) {
- alert('3!');
-}
-
-function getX() {
- return 3;
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|allowIf|false|Allow assignment within the conditional expression of an if statement|
-|allowFor|false|Allow assignment within the conditional expression of a for statement|
-|allowWhile|false|Allow assignment within the conditional expression of a while statement|
-|allowTernary|false|Allow assignment within the conditional expression of a ternary operator|
-|allowTernaryResults|false|Allow assignment within the result expressions of a ternary operator|
-|allowIncrementDecrement|false|Allow increment or decrement operators within the conditional expression of an if, for, or while statement|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidTrailingComma
-
-**Since:** PMD 5.1
-
-**Priority:** High (1)
-
-This rule helps improve code portability due to differences in browser treatment of trailing commas in object or array literals.
-
-```
-//ObjectLiteral[$allowObjectLiteral = "false" and @TrailingComma = 'true']
-|
-//ArrayLiteral[$allowArrayLiteral = "false" and @TrailingComma = 'true']
-```
-
-**Example(s):**
-
-``` javascript
-function(arg) {
- var obj1 = { a : 1 }; // Ok
- var arr1 = [ 1, 2 ]; // Ok
-
- var obj2 = { a : 1, }; // Syntax error in some browsers!
- var arr2 = [ 1, 2, ]; // Length 2 or 3 depending on the browser!
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|allowObjectLiteral|false|Allow a trailing comma within an object literal|
-|allowArrayLiteral|false|Allow a trailing comma within an array literal|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ConsistentReturn
-
-**Since:** PMD 5.0
-
-**Priority:** Medium High (2)
-
-ECMAScript does provide for return types on functions, and therefore there is no solid rule as to their usage.
-However, when a function does use returns they should all have a value, or all with no value. Mixed return
-usage is likely a bug, or at best poor style.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.ecmascript.rule.basic.ConsistentReturnRule](https://github.com/pmd/pmd/blob/master/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/basic/ConsistentReturnRule.java)
-
-**Example(s):**
-
-``` javascript
-// Ok
-function foo() {
- if (condition1) {
- return true;
- }
- return false;
-}
-
-// Bad
-function bar() {
- if (condition1) {
- return;
- }
- return false;
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|rhinoLanguageVersion|VERSION_DEFAULT|Specifies the Rhino Language Version to use for parsing. Defaults to Rhino default.|
-|recordingLocalJsDocComments|true|Specifies that JsDoc comments are produced in the AST.|
-|recordingComments|true|Specifies that comments are produced in the AST.|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EqualComparison
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Using == in condition may lead to unexpected results, as the variables are automatically casted to be of the
-same type. The === operator avoids the casting.
-
-```
-//InfixExpression[(@Image = "==" or @Image = "!=")
- and
- (child::KeywordLiteral[@Image = "true" or @Image = "false"]
- or
- child::NumberLiteral)
-]
-```
-
-**Example(s):**
-
-``` javascript
-// Ok
-if (someVar === true) {
- ...
-}
-// Ok
-if (someVar !== 3) {
- ...
-}
-// Bad
-if (someVar == true) {
- ...
-}
-// Bad
-if (someVar != 3) {
- ...
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## GlobalVariable
-
-**Since:** PMD 5.0
-
-**Priority:** High (1)
-
-This rule helps to avoid using accidently global variables by simply missing the "var" declaration.
-Global variables can lead to side-effects that are hard to debug.
-
-```
-//Assignment[Name/@GlobalName = 'true']
-```
-
-**Example(s):**
-
-``` javascript
-function(arg) {
- notDeclaredVariable = 1; // this will create a global variable and trigger the rule
-
- var someVar = 1; // this is a local variable, that's ok
-
- window.otherGlobal = 2; // this will not trigger the rule, although it is a global variable.
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## InnaccurateNumericLiteral
-
-**Since:** PMD 5.0
-
-**Priority:** Medium High (2)
-
-The numeric literal will have at different value at runtime, which can happen if you provide too much
-precision in a floating point number. This may result in numeric calculations being in error.
-
-```
-//NumberLiteral[
- @Image != @Number
- and translate(@Image, "e", "E") != @Number
- and concat(@Image, ".0") != @Number
- and @Image != substring-before(translate(@Number, ".", ""), "E")]
-```
-
-**Example(s):**
-
-``` javascript
-var a = 9; // Ok
-var b = 999999999999999; // Ok
-var c = 999999999999999999999; // Not good
-var w = 1.12e-4; // Ok
-var x = 1.12; // Ok
-var y = 1.1234567890123; // Ok
-var z = 1.12345678901234567; // Not good
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ScopeForInVariable
-
-**Since:** PMD 5.0
-
-**Priority:** High (1)
-
-A for-in loop in which the variable name is not explicitly scoped to the enclosing scope with the 'var' keyword can
-refer to a variable in an enclosing scope outside the nearest enclosing scope. This will overwrite the
-existing value of the variable in the outer scope when the body of the for-in is evaluated. When the for-in loop
-has finished, the variable will contain the last value used in the for-in, and the original value from before
-the for-in loop will be gone. Since the for-in variable name is most likely intended to be a temporary name, it
-is better to explicitly scope the variable name to the nearest enclosing scope with 'var'.
-
-```
-//ForInLoop[not(child::VariableDeclaration)]/Name[1]
-```
-
-**Example(s):**
-
-``` javascript
-// Ok
-function foo() {
- var p = 'clean';
- function() {
- var obj = { dirty: 'dirty' };
- for (var p in obj) { // Use 'var' here.
- obj[p] = obj[p];
- }
- return x;
- }();
-
- // 'p' still has value of 'clean'.
-}
-// Bad
-function bar() {
- var p = 'clean';
- function() {
- var obj = { dirty: 'dirty' };
- for (p in obj) { // Oh no, missing 'var' here!
- obj[p] = obj[p];
- }
- return x;
- }();
-
- // 'p' is trashed and has value of 'dirty'!
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnreachableCode
-
-**Since:** PMD 5.0
-
-**Priority:** High (1)
-
-A 'return', 'break', 'continue', or 'throw' statement should be the last in a block. Statements after these
-will never execute. This is a bug, or extremely poor style.
-
-```
-//ReturnStatement[following-sibling::node()]
-|
- //ContinueStatement[following-sibling::node()]
-|
- //BreakStatement[following-sibling::node()]
-|
- //ThrowStatement[following-sibling::node()]
-```
-
-**Example(s):**
-
-``` javascript
-// Ok
-function foo() {
- return 1;
-}
-// Bad
-function bar() {
- var x = 1;
- return x;
- x = 2;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseBaseWithParseInt
-
-**Since:** PMD 5.0.1
-
-**Priority:** High (1)
-
-This rule checks for usages of parseInt. While the second parameter is optional and usually defaults
-to 10 (base/radix is 10 for a decimal number), different implementations may behave differently.
-It also improves readability, if the base is given.
-
-See also: [parseInt()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
-
-```
-//FunctionCall/Name[
- @Image = 'parseInt'
- and
- count(../*) < 3
-]
-```
-
-**Example(s):**
-
-``` javascript
-parseInt("010"); // unclear, could be interpreted as 10 or 7 (with a base of 7)
-
-parseInt("10", 10); // good
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/ecmascript/bestpractices.md b/docs/pages/pmd/rules/ecmascript/bestpractices.md
new file mode 100644
index 00000000000..ef55bc95344
--- /dev/null
+++ b/docs/pages/pmd/rules/ecmascript/bestpractices.md
@@ -0,0 +1,200 @@
+---
+title: Best Practices
+summary: Rules which enforce generally accepted best practices.
+permalink: pmd_rules_ecmascript_bestpractices.html
+folder: pmd/rules/ecmascript
+sidebaractiveurl: /pmd_rules_ecmascript.html
+editmepath: ../pmd-javascript/src/main/resources/category/ecmascript/bestpractices.xml
+keywords: Best Practices, AvoidWithStatement, ConsistentReturn, GlobalVariable, ScopeForInVariable, UseBaseWithParseInt
+language: Ecmascript
+---
+## AvoidWithStatement
+
+**Since:** PMD 5.0.1
+
+**Priority:** High (1)
+
+Avoid using with - it's bad news
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//WithStatement
+```
+
+**Example(s):**
+
+``` javascript
+with (object) {
+ property = 3; // Might be on object, might be on window: who knows.
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ConsistentReturn
+
+**Since:** PMD 5.0
+
+**Priority:** Medium High (2)
+
+ECMAScript does provide for return types on functions, and therefore there is no solid rule as to their usage.
+However, when a function does use returns they should all have a value, or all with no value. Mixed return
+usage is likely a bug, or at best poor style.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.ecmascript.rule.bestpractices.ConsistentReturnRule](https://github.com/pmd/pmd/blob/master/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/bestpractices/ConsistentReturnRule.java)
+
+**Example(s):**
+
+``` javascript
+// Ok
+function foo() {
+ if (condition1) {
+ return true;
+ }
+ return false;
+}
+
+// Bad
+function bar() {
+ if (condition1) {
+ return;
+ }
+ return false;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|rhinoLanguageVersion|VERSION\_DEFAULT|Specifies the Rhino Language Version to use for parsing. Defaults to Rhino default.|no|
+|recordingLocalJsDocComments|true|Specifies that JsDoc comments are produced in the AST.|no|
+|recordingComments|true|Specifies that comments are produced in the AST.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## GlobalVariable
+
+**Since:** PMD 5.0
+
+**Priority:** High (1)
+
+This rule helps to avoid using accidently global variables by simply missing the "var" declaration.
+Global variables can lead to side-effects that are hard to debug.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Assignment[Name/@GlobalName = 'true']
+```
+
+**Example(s):**
+
+``` javascript
+function(arg) {
+ notDeclaredVariable = 1; // this will create a global variable and trigger the rule
+
+ var someVar = 1; // this is a local variable, that's ok
+
+ window.otherGlobal = 2; // this will not trigger the rule, although it is a global variable.
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ScopeForInVariable
+
+**Since:** PMD 5.0
+
+**Priority:** High (1)
+
+A for-in loop in which the variable name is not explicitly scoped to the enclosing scope with the 'var' keyword can
+refer to a variable in an enclosing scope outside the nearest enclosing scope. This will overwrite the
+existing value of the variable in the outer scope when the body of the for-in is evaluated. When the for-in loop
+has finished, the variable will contain the last value used in the for-in, and the original value from before
+the for-in loop will be gone. Since the for-in variable name is most likely intended to be a temporary name, it
+is better to explicitly scope the variable name to the nearest enclosing scope with 'var'.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ForInLoop[not(child::VariableDeclaration)]/Name[1]
+```
+
+**Example(s):**
+
+``` javascript
+// Ok
+function foo() {
+ var p = 'clean';
+ function() {
+ var obj = { dirty: 'dirty' };
+ for (var p in obj) { // Use 'var' here.
+ obj[p] = obj[p];
+ }
+ return x;
+ }();
+
+ // 'p' still has value of 'clean'.
+}
+// Bad
+function bar() {
+ var p = 'clean';
+ function() {
+ var obj = { dirty: 'dirty' };
+ for (p in obj) { // Oh no, missing 'var' here!
+ obj[p] = obj[p];
+ }
+ return x;
+ }();
+
+ // 'p' is trashed and has value of 'dirty'!
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseBaseWithParseInt
+
+**Since:** PMD 5.0.1
+
+**Priority:** High (1)
+
+This rule checks for usages of parseInt. While the second parameter is optional and usually defaults
+to 10 (base/radix is 10 for a decimal number), different implementations may behave differently.
+It also improves readability, if the base is given.
+
+See also: [parseInt()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//FunctionCall/Name[
+ @Image = 'parseInt'
+ and
+ count(../*) < 3
+]
+```
+
+**Example(s):**
+
+``` javascript
+parseInt("010"); // unclear, could be interpreted as 10 or 7 (with a base of 7)
+
+parseInt("10", 10); // good
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/ecmascript/braces.md b/docs/pages/pmd/rules/ecmascript/braces.md
deleted file mode 100644
index 5f67d6dcf73..00000000000
--- a/docs/pages/pmd/rules/ecmascript/braces.md
+++ /dev/null
@@ -1,137 +0,0 @@
----
-title: Braces
-summary: The Braces Ruleset contains a collection of braces rules.
-permalink: pmd_rules_ecmascript_braces.html
-folder: pmd/rules/ecmascript
-sidebaractiveurl: /pmd_rules_ecmascript.html
-editmepath: ../pmd-javascript/src/main/resources/rulesets/ecmascript/braces.xml
-keywords: Braces, IfStmtsMustUseBraces, IfElseStmtsMustUseBraces, WhileLoopsMustUseBraces, ForLoopsMustUseBraces
----
-## ForLoopsMustUseBraces
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Avoid using 'for' statements without using curly braces.
-
-```
-//ForLoop[not(child::Scope)]
-|
-//ForInLoop[not(child::Scope)]
-```
-
-**Example(s):**
-
-``` javascript
-// Ok
-for (var i = 0; i < 42; i++) {
- foo();
-}
-
-// Bad
-for (var i = 0; i < 42; i++)
- foo();
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## IfElseStmtsMustUseBraces
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Avoid using if..else statements without using curly braces.
-
-```
-//ExpressionStatement[parent::IfStatement[@Else = "true"]]
- [not(child::Scope)]
- [not(child::IfStatement)]
-```
-
-**Example(s):**
-
-``` javascript
-// Ok
-if (foo) {
- x++;
-} else {
- y++;
-}
-
-// Bad
-if (foo)
- x++;
-else
- y++;
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## IfStmtsMustUseBraces
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Avoid using if statements without using curly braces.
-
-```
-//IfStatement[@Else = "false" and not(child::Scope)]
-```
-
-**Example(s):**
-
-``` javascript
-// Ok
-if (foo) {
- x++;
-}
-
-// Bad
-if (foo)
- x++;
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## WhileLoopsMustUseBraces
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Avoid using 'while' statements without using curly braces.
-
-```
-//WhileLoop[not(child::Scope)]
-```
-
-**Example(s):**
-
-``` javascript
-// Ok
-while (true) {
- x++;
-}
-
-// Bad
-while (true)
- x++;
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/ecmascript/codestyle.md b/docs/pages/pmd/rules/ecmascript/codestyle.md
new file mode 100644
index 00000000000..a1892c4b9ff
--- /dev/null
+++ b/docs/pages/pmd/rules/ecmascript/codestyle.md
@@ -0,0 +1,337 @@
+---
+title: Code Style
+summary: Rules which enforce a specific coding style.
+permalink: pmd_rules_ecmascript_codestyle.html
+folder: pmd/rules/ecmascript
+sidebaractiveurl: /pmd_rules_ecmascript.html
+editmepath: ../pmd-javascript/src/main/resources/category/ecmascript/codestyle.xml
+keywords: Code Style, AssignmentInOperand, ForLoopsMustUseBraces, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, NoElseReturn, UnnecessaryBlock, UnnecessaryParentheses, UnreachableCode, WhileLoopsMustUseBraces
+language: Ecmascript
+---
+## AssignmentInOperand
+
+**Since:** PMD 5.0
+
+**Priority:** Medium High (2)
+
+Avoid assignments in operands; this can make code more complicated and harder to read. This is sometime
+indicative of the bug where the assignment operator '=' was used instead of the equality operator '=='.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfStatement[$allowIf = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
+|
+ //WhileLoop[$allowWhile = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
+|
+ //DoLoop[$allowWhile = "false"]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
+|
+ //ForLoop[$allowFor = "false"]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
+|
+ //ConditionalExpression[$allowTernary = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
+|
+ //ConditionalExpression[$allowTernaryResults = "false"]/child::node()[position() = 2 or position() = 3]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
+```
+
+**Example(s):**
+
+``` javascript
+var x = 2;
+// Bad
+if ((x = getX()) == 3) {
+ alert('3!');
+}
+
+function getX() {
+ return 3;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|allowIf|false|Allow assignment within the conditional expression of an if statement|no|
+|allowFor|false|Allow assignment within the conditional expression of a for statement|no|
+|allowWhile|false|Allow assignment within the conditional expression of a while statement|no|
+|allowTernary|false|Allow assignment within the conditional expression of a ternary operator|no|
+|allowTernaryResults|false|Allow assignment within the result expressions of a ternary operator|no|
+|allowIncrementDecrement|false|Allow increment or decrement operators within the conditional expression of an if, for, or while statement|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ForLoopsMustUseBraces
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Avoid using 'for' statements without using curly braces.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ForLoop[not(child::Scope)]
+|
+//ForInLoop[not(child::Scope)]
+```
+
+**Example(s):**
+
+``` javascript
+// Ok
+for (var i = 0; i < 42; i++) {
+ foo();
+}
+
+// Bad
+for (var i = 0; i < 42; i++)
+ foo();
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## IfElseStmtsMustUseBraces
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Avoid using if..else statements without using curly braces.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ExpressionStatement[parent::IfStatement[@Else = "true"]]
+ [not(child::Scope)]
+ [not(child::IfStatement)]
+```
+
+**Example(s):**
+
+``` javascript
+// Ok
+if (foo) {
+ x++;
+} else {
+ y++;
+}
+
+// Bad
+if (foo)
+ x++;
+else
+ y++;
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## IfStmtsMustUseBraces
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Avoid using if statements without using curly braces.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfStatement[@Else = "false" and not(child::Scope)]
+```
+
+**Example(s):**
+
+``` javascript
+// Ok
+if (foo) {
+ x++;
+}
+
+// Bad
+if (foo)
+ x++;
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoElseReturn
+
+**Since:** PMD 5.5.0
+
+**Priority:** Medium (3)
+
+The else block in a if-else-construct is unnecessary if the `if` block contains a return.
+Then the content of the else block can be put outside.
+
+See also:
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfStatement[@Else="true"][Scope[1]/ReturnStatement]
+```
+
+**Example(s):**
+
+``` javascript
+// Bad:
+if (x) {
+ return y;
+} else {
+ return z;
+}
+
+// Good:
+if (x) {
+ return y;
+}
+return z;
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryBlock
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+An unnecessary Block is present. Such Blocks are often used in other languages to
+introduce a new variable scope. Blocks do not behave like this in ECMAScipt, and using them can
+be misleading. Considering removing this unnecessary Block.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Block[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
+ or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)]
+|
+//Scope[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
+ or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)]
+```
+
+**Example(s):**
+
+``` javascript
+if (foo) {
+ // Ok
+}
+if (bar) {
+ {
+ // Bad
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryParentheses
+
+**Since:** PMD 5.0
+
+**Priority:** Medium Low (4)
+
+Unnecessary parentheses should be removed.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ParenthesizedExpression/ParenthesizedExpression
+```
+
+**Example(s):**
+
+``` javascript
+var x = 1; // Ok
+var y = (1 + 1); // Ok
+var z = ((1 + 1)); // Bad
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnreachableCode
+
+**Since:** PMD 5.0
+
+**Priority:** High (1)
+
+A 'return', 'break', 'continue', or 'throw' statement should be the last in a block. Statements after these
+will never execute. This is a bug, or extremely poor style.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ReturnStatement[following-sibling::node()]
+|
+ //ContinueStatement[following-sibling::node()]
+|
+ //BreakStatement[following-sibling::node()]
+|
+ //ThrowStatement[following-sibling::node()]
+```
+
+**Example(s):**
+
+``` javascript
+// Ok
+function foo() {
+ return 1;
+}
+// Bad
+function bar() {
+ var x = 1;
+ return x;
+ x = 2;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## WhileLoopsMustUseBraces
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Avoid using 'while' statements without using curly braces.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//WhileLoop[not(child::Scope)]
+```
+
+**Example(s):**
+
+``` javascript
+// Ok
+while (true) {
+ x++;
+}
+
+// Bad
+while (true)
+ x++;
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/ecmascript/controversial.md b/docs/pages/pmd/rules/ecmascript/controversial.md
deleted file mode 100644
index b73ea9d35b5..00000000000
--- a/docs/pages/pmd/rules/ecmascript/controversial.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-title: Controversial Ecmascript
-summary: The Controversial ruleset contains rules that, for whatever reason, are considered controversial. They are held here to allow people to include them as they see fit within their custom rulesets.
-permalink: pmd_rules_ecmascript_controversial.html
-folder: pmd/rules/ecmascript
-sidebaractiveurl: /pmd_rules_ecmascript.html
-editmepath: ../pmd-javascript/src/main/resources/rulesets/ecmascript/controversial.xml
-keywords: Controversial Ecmascript, AvoidWithStatement
----
-## AvoidWithStatement
-
-**Since:** PMD 5.0.1
-
-**Priority:** High (1)
-
-Avoid using with - it's bad news
-
-```
-//WithStatement
-```
-
-**Example(s):**
-
-``` javascript
-with (object) {
- property = 3; // Might be on object, might be on window: who knows.
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/ecmascript/errorprone.md b/docs/pages/pmd/rules/ecmascript/errorprone.md
new file mode 100644
index 00000000000..2fdf7e27025
--- /dev/null
+++ b/docs/pages/pmd/rules/ecmascript/errorprone.md
@@ -0,0 +1,125 @@
+---
+title: Error Prone
+summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+permalink: pmd_rules_ecmascript_errorprone.html
+folder: pmd/rules/ecmascript
+sidebaractiveurl: /pmd_rules_ecmascript.html
+editmepath: ../pmd-javascript/src/main/resources/category/ecmascript/errorprone.xml
+keywords: Error Prone, AvoidTrailingComma, EqualComparison, InnaccurateNumericLiteral
+language: Ecmascript
+---
+## AvoidTrailingComma
+
+**Since:** PMD 5.1
+
+**Priority:** High (1)
+
+This rule helps improve code portability due to differences in browser treatment of trailing commas in object or array literals.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ObjectLiteral[$allowObjectLiteral = "false" and @TrailingComma = 'true']
+|
+//ArrayLiteral[$allowArrayLiteral = "false" and @TrailingComma = 'true']
+```
+
+**Example(s):**
+
+``` javascript
+function(arg) {
+ var obj1 = { a : 1 }; // Ok
+ var arr1 = [ 1, 2 ]; // Ok
+
+ var obj2 = { a : 1, }; // Syntax error in some browsers!
+ var arr2 = [ 1, 2, ]; // Length 2 or 3 depending on the browser!
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|allowObjectLiteral|false|Allow a trailing comma within an object literal|no|
+|allowArrayLiteral|false|Allow a trailing comma within an array literal|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EqualComparison
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Using == in condition may lead to unexpected results, as the variables are automatically casted to be of the
+same type. The === operator avoids the casting.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//InfixExpression[(@Image = "==" or @Image = "!=")
+ and
+ (child::KeywordLiteral[@Image = "true" or @Image = "false"]
+ or
+ child::NumberLiteral)
+]
+```
+
+**Example(s):**
+
+``` javascript
+// Ok
+if (someVar === true) {
+ ...
+}
+// Ok
+if (someVar !== 3) {
+ ...
+}
+// Bad
+if (someVar == true) {
+ ...
+}
+// Bad
+if (someVar != 3) {
+ ...
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## InnaccurateNumericLiteral
+
+**Since:** PMD 5.0
+
+**Priority:** Medium High (2)
+
+The numeric literal will have a different value at runtime, which can happen if you provide too much
+precision in a floating point number. This may result in numeric calculations being in error.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//NumberLiteral[@NormalizedImage != @Number]
+```
+
+**Example(s):**
+
+``` javascript
+var a = 9; // Ok
+var b = 999999999999999; // Ok
+var c = 999999999999999999999; // Not good
+var w = 1.12e-4; // Ok
+var x = 1.12; // Ok
+var y = 1.1234567890123; // Ok
+var z = 1.12345678901234567; // Not good
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/ecmascript/unnecessary.md b/docs/pages/pmd/rules/ecmascript/unnecessary.md
deleted file mode 100644
index 6c5c0f5ec08..00000000000
--- a/docs/pages/pmd/rules/ecmascript/unnecessary.md
+++ /dev/null
@@ -1,107 +0,0 @@
----
-title: Unnecessary
-summary: The Unnecessary Ruleset contains a collection of rules for unnecessary code.
-permalink: pmd_rules_ecmascript_unnecessary.html
-folder: pmd/rules/ecmascript
-sidebaractiveurl: /pmd_rules_ecmascript.html
-editmepath: ../pmd-javascript/src/main/resources/rulesets/ecmascript/unnecessary.xml
-keywords: Unnecessary, UnnecessaryParentheses, UnnecessaryBlock, NoElseReturn
----
-## NoElseReturn
-
-**Since:** PMD 5.5.0
-
-**Priority:** Medium (3)
-
-The else block in a if-else-construct is unnecessary if the `if` block contains a return.
-Then the content of the else block can be put outside.
-
-See also:
-
-```
-//IfStatement[@Else="true"][Scope[1]/ReturnStatement]
-```
-
-**Example(s):**
-
-``` javascript
-// Bad:
-if (x) {
- return y;
-} else {
- return z;
-}
-
-// Good:
-if (x) {
- return y;
-}
-return z;
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryBlock
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-An unnecessary Block is present. Such Blocks are often used in other languages to
-introduce a new variable scope. Blocks do not behave like this in ECMAScipt, and using them can
-be misleading. Considering removing this unnecessary Block.
-
-```
-//Block[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
- or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)]
-|
-//Scope[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
- or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)]
-```
-
-**Example(s):**
-
-``` javascript
-if (foo) {
- // Ok
-}
-if (bar) {
- {
- // Bad
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryParentheses
-
-**Since:** PMD 5.0
-
-**Priority:** Medium Low (4)
-
-Unnecessary parentheses should be removed.
-
-```
-//ParenthesizedExpression/ParenthesizedExpression
-```
-
-**Example(s):**
-
-``` javascript
-var x = 1; // Ok
-var y = (1 + 1); // Ok
-var z = ((1 + 1)); // Bad
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java.md b/docs/pages/pmd/rules/java.md
index 92c8d37e804..12b3ab615d6 100644
--- a/docs/pages/pmd/rules/java.md
+++ b/docs/pages/pmd/rules/java.md
@@ -1,367 +1,584 @@
---
title: Java Rules
+tags: [rule_references, java]
+summary: Index of all built-in rules available for Java
+language_name: Java
permalink: pmd_rules_java.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
-
-* [Android](pmd_rules_java_android.html): These rules deal with the Android SDK, mostly related to best practices. To get better results, make sure that the auxclasspath is defined for type resolution to work.
-* [Basic](pmd_rules_java_basic.html): The Basic ruleset contains a collection of good practices which should be followed.
-* [Braces](pmd_rules_java_braces.html): The Braces ruleset contains rules regarding the use and placement of braces.
-* [Clone Implementation](pmd_rules_java_clone.html): The Clone Implementation ruleset contains a collection of rules that find questionable usages of the clone() method.
-* [Code Size](pmd_rules_java_codesize.html): The Code Size ruleset contains rules that find problems related to code size or complexity.
-* [Comments](pmd_rules_java_comments.html): Rules intended to catch errors related to code comments
-* [Controversial](pmd_rules_java_controversial.html): The Controversial ruleset contains rules that, for whatever reason, are considered controversial. They are held here to allow people to include them as they see fit within their custom rulesets.
-* [Coupling](pmd_rules_java_coupling.html): Rules which find instances of high or inappropriate coupling between objects and packages.
-* [Design](pmd_rules_java_design.html): The Design ruleset contains rules that flag suboptimal code implementations. Alternate approaches are suggested.
-* [Empty Code](pmd_rules_java_empty.html): The Empty Code ruleset contains rules that find empty statements of any kind (empty method, empty block statement, empty try or catch block,...).
-* [Finalizer](pmd_rules_java_finalizers.html): These rules deal with different problems that can occur with finalizers.
-* [Import Statements](pmd_rules_java_imports.html): These rules deal with different problems that can occur with import statements.
-* [J2EE](pmd_rules_java_j2ee.html): Rules specific to the use of J2EE implementations.
-* [Jakarta Commons Logging](pmd_rules_java_logging-jakarta-commons.html): The Jakarta Commons Logging ruleset contains a collection of rules that find questionable usages of that framework.
-* [Java Logging](pmd_rules_java_logging-java.html): The Java Logging ruleset contains a collection of rules that find questionable usages of the logger.
-* [JavaBeans](pmd_rules_java_javabeans.html): The JavaBeans Ruleset catches instances of bean rules not being followed.
-* [JUnit](pmd_rules_java_junit.html): These rules deal with different problems that can occur with JUnit tests.
-* [Migration](pmd_rules_java_migrating.html): Contains rules about migrating from one JDK version to another. Don't use these rules directly, rather, use a wrapper ruleset such as migrating_to_13.xml.
-* [Naming](pmd_rules_java_naming.html): The Naming Ruleset contains rules regarding preferred usage of names and identifiers.
-* [Optimization](pmd_rules_java_optimizations.html): These rules deal with different optimizations that generally apply to best practices.
-* [Security Code Guidelines](pmd_rules_java_sunsecure.html): These rules check the security guidelines from Sun, published at http://java.sun.com/security/seccodeguide.html#gcg
-* [Strict Exceptions](pmd_rules_java_strictexception.html): These rules provide some strict guidelines about throwing and catching exceptions.
-* [String and StringBuffer](pmd_rules_java_strings.html): These rules deal with different issues that can arise with manipulation of the String, StringBuffer, or StringBuilder instances.
-* [Unnecessary](pmd_rules_java_unnecessary.html): The Unnecessary Ruleset contains a collection of rules for unnecessary code.
-* [Unused Code](pmd_rules_java_unusedcode.html): The Unused Code ruleset contains rules that find unused or ineffective code.
-
-## Android
-* [CallSuperFirst](pmd_rules_java_android.html#callsuperfirst): Super should be called at the start of the method
-* [CallSuperLast](pmd_rules_java_android.html#callsuperlast): Super should be called at the end of the method
-* [DoNotHardCodeSDCard](pmd_rules_java_android.html#donothardcodesdcard): Use Environment.getExternalStorageDirectory() instead of "/sdcard"
-
-## Basic
-* [AvoidBranchingStatementAsLastInLoop](pmd_rules_java_basic.html#avoidbranchingstatementaslastinloop): Using a branching statement as the last part of a loop may be a bug, and/or is confusing.Ensure t...
-* [AvoidDecimalLiteralsInBigDecimalConstructor](pmd_rules_java_basic.html#avoiddecimalliteralsinbigdecimalconstructor): One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actu...
-* [AvoidMultipleUnaryOperators](pmd_rules_java_basic.html#avoidmultipleunaryoperators): The use of multiple unary operators may be problematic, and/or confusing.Ensure that the intended...
-* [AvoidThreadGroup](pmd_rules_java_basic.html#avoidthreadgroup): Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environmentit...
-* [AvoidUsingHardCodedIP](pmd_rules_java_basic.html#avoidusinghardcodedip): Application with hard-coded IP addresses can become impossible to deploy in some cases.Externaliz...
-* [AvoidUsingOctalValues](pmd_rules_java_basic.html#avoidusingoctalvalues): Integer literals should not start with zero since this denotes that the rest of literal will bein...
-* [BigIntegerInstantiation](pmd_rules_java_basic.html#bigintegerinstantiation): Don't create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) andfor Ja...
-* [BooleanInstantiation](pmd_rules_java_basic.html#booleaninstantiation): Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boole...
-* [BrokenNullCheck](pmd_rules_java_basic.html#brokennullcheck): The null check is broken since it will throw a NullPointerException itself.It is likely that you ...
-* [CheckResultSet](pmd_rules_java_basic.html#checkresultset): Always check the return values of navigation methods (next, previous, first, last) of a ResultSet...
-* [CheckSkipResult](pmd_rules_java_basic.html#checkskipresult): The skip() method may skip a smaller number of bytes than requested. Check the returned value to ...
-* [ClassCastExceptionWithToArray](pmd_rules_java_basic.html#classcastexceptionwithtoarray): When deriving an array of a specific class from your Collection, one should provide an array ofth...
-* [CollapsibleIfStatements](pmd_rules_java_basic.html#collapsibleifstatements): Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with...
-* [DontCallThreadRun](pmd_rules_java_basic.html#dontcallthreadrun): Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, ...
-* [DontUseFloatTypeForLoopIndices](pmd_rules_java_basic.html#dontusefloattypeforloopindices): Don't use floating point for loop indices. If you must use floating point, use doubleunless you'r...
-* [DoubleCheckedLocking](pmd_rules_java_basic.html#doublecheckedlocking): Partially created objects can be returned by the Double Checked Locking pattern when used in Java...
-* [ExtendsObject](pmd_rules_java_basic.html#extendsobject): No need to explicitly extend Object.
-* [ForLoopShouldBeWhileLoop](pmd_rules_java_basic.html#forloopshouldbewhileloop): Some for loops can be simplified to while loops, this makes them more concise.
-* [JumbledIncrementer](pmd_rules_java_basic.html#jumbledincrementer): Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
-* [MisplacedNullCheck](pmd_rules_java_basic.html#misplacednullcheck): The null check here is misplaced. If the variable is null a NullPointerException will be thrown.E...
-* [OverrideBothEqualsAndHashcode](pmd_rules_java_basic.html#overridebothequalsandhashcode): Override both public boolean Object.equals(Object other), and public int Object.hashCode(), or ov...
-* [ReturnFromFinallyBlock](pmd_rules_java_basic.html#returnfromfinallyblock): Avoid returning from a finally block, this can discard exceptions.
-* [SimplifiedTernary](pmd_rules_java_basic.html#simplifiedternary): Look for ternary operators with the form 'condition ? literalBoolean : foo'or 'condition ? foo : ...
-* [UnconditionalIfStatement](pmd_rules_java_basic.html#unconditionalifstatement): Do not use "if" statements whose conditionals are always true or always false.
-
-## Braces
-* [ForLoopsMustUseBraces](pmd_rules_java_braces.html#forloopsmustusebraces): Avoid using 'for' statements without using curly braces. If the code formatting or indentation is...
-* [IfElseStmtsMustUseBraces](pmd_rules_java_braces.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using surrounding braces. If the code formatting or inden...
-* [IfStmtsMustUseBraces](pmd_rules_java_braces.html#ifstmtsmustusebraces): Avoid using if statements without using braces to surround the code block. If the code formatting...
-* [WhileLoopsMustUseBraces](pmd_rules_java_braces.html#whileloopsmustusebraces): Avoid using 'while' statements without using braces to surround the code block. If the code forma...
-
-## Clone Implementation
-* [CloneMethodMustBePublic](pmd_rules_java_clone.html#clonemethodmustbepublic): The java Manual says "By convention, classes that implement this interface should overrideObject....
-* [CloneMethodMustImplementCloneable](pmd_rules_java_clone.html#clonemethodmustimplementcloneable): The method clone() should only be implemented if the class implements the Cloneable interface wit...
-* [CloneMethodReturnTypeMustMatchClassName](pmd_rules_java_clone.html#clonemethodreturntypemustmatchclassname): If a class implements cloneable the return type of the method clone() must be the class name. Tha...
-* [CloneThrowsCloneNotSupportedException](pmd_rules_java_clone.html#clonethrowsclonenotsupportedexception): The method clone() should throw a CloneNotSupportedException.
-* [ProperCloneImplementation](pmd_rules_java_clone.html#propercloneimplementation): Object clone() should be implemented with super.clone().
-
-## Code Size
-* [CyclomaticComplexity](pmd_rules_java_codesize.html#cyclomaticcomplexity): Deprecated Complexity directly affects maintenance costs is determined by the number of decision points in a...
-* [ExcessiveClassLength](pmd_rules_java_codesize.html#excessiveclasslength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
-* [ExcessiveMethodLength](pmd_rules_java_codesize.html#excessivemethodlength): When methods are excessively long this usually indicates that the method is doing more than itsna...
-* [ExcessiveParameterList](pmd_rules_java_codesize.html#excessiveparameterlist): Methods with numerous parameters are a challenge to maintain, especially if most of them share th...
-* [ExcessivePublicCount](pmd_rules_java_codesize.html#excessivepubliccount): Classes with large numbers of public methods and attributes require disproportionate testing effo...
-* [ModifiedCyclomaticComplexity](pmd_rules_java_codesize.html#modifiedcyclomaticcomplexity): Deprecated Complexity directly affects maintenance costs is determined by the number of decision points in a...
-* [NcssConstructorCount](pmd_rules_java_codesize.html#ncssconstructorcount): Deprecated This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
-* [NcssCount](pmd_rules_java_codesize.html#ncsscount): This rule uses the NCSS (Non-Commenting Source Statements) metric to determine the number of line...
-* [NcssMethodCount](pmd_rules_java_codesize.html#ncssmethodcount): Deprecated This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
-* [NcssTypeCount](pmd_rules_java_codesize.html#ncsstypecount): Deprecated This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
-* [NPathComplexity](pmd_rules_java_codesize.html#npathcomplexity): The NPath complexity of a method is the number of acyclic execution paths through that method.A t...
-* [StdCyclomaticComplexity](pmd_rules_java_codesize.html#stdcyclomaticcomplexity): Deprecated Complexity directly affects maintenance costs is determined by the number of decision points in a...
-* [TooManyFields](pmd_rules_java_codesize.html#toomanyfields): Classes that have too many fields can become unwieldy and could be redesigned to have fewer field...
-* [TooManyMethods](pmd_rules_java_codesize.html#toomanymethods): A class with too many methods is probably a good suspect for refactoring, in order to reduce itsc...
-
-## Comments
-* [CommentContent](pmd_rules_java_comments.html#commentcontent): A rule for the politically correct... we don't want to offend anyone.
-* [CommentDefaultAccessModifier](pmd_rules_java_comments.html#commentdefaultaccessmodifier): To avoid mistakes if we want that a Method, Constructor, Field or Nested class have a default acc...
-* [CommentRequired](pmd_rules_java_comments.html#commentrequired): Denotes whether comments are required (or unwanted) for specific language elements.
-* [CommentSize](pmd_rules_java_comments.html#commentsize): Determines whether the dimensions of non-header comments found are within the specified limits.
-
-## Controversial
-* [AssignmentInOperand](pmd_rules_java_controversial.html#assignmentinoperand): Avoid assignments in operands; this can make code more complicated and harder to read.
-* [AtLeastOneConstructor](pmd_rules_java_controversial.html#atleastoneconstructor): Each class should declare at least one constructor.
-* [AvoidAccessibilityAlteration](pmd_rules_java_controversial.html#avoidaccessibilityalteration): Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),as...
-* [AvoidFinalLocalVariable](pmd_rules_java_controversial.html#avoidfinallocalvariable): Avoid using final local variables, turn them into fields.
-* [AvoidLiteralsInIfCondition](pmd_rules_java_controversial.html#avoidliteralsinifcondition): Avoid using hard-coded literals in conditional statements. By declaring them as static variableso...
-* [AvoidPrefixingMethodParameters](pmd_rules_java_controversial.html#avoidprefixingmethodparameters): Prefixing parameters by 'in' or 'out' pollutes the name of the parameters and reduces code readab...
-* [AvoidUsingNativeCode](pmd_rules_java_controversial.html#avoidusingnativecode): Unnecessary reliance on Java Native Interface (JNI) calls directly reduces application portabilit...
-* [AvoidUsingShortType](pmd_rules_java_controversial.html#avoidusingshorttype): Java uses the 'short' type to reduce memory usage, not to optimize calculation. In fact, the JVM ...
-* [AvoidUsingVolatile](pmd_rules_java_controversial.html#avoidusingvolatile): Use of the keyword 'volatile' is generally used to fine tune a Java application, and therefore, r...
-* [CallSuperInConstructor](pmd_rules_java_controversial.html#callsuperinconstructor): It is a good practice to call super() in a constructor. If super() is not called butanother const...
-* [DataflowAnomalyAnalysis](pmd_rules_java_controversial.html#dataflowanomalyanalysis): The dataflow analysis tracks local definitions, undefinitions and references to variables on diff...
-* [DefaultPackage](pmd_rules_java_controversial.html#defaultpackage): Use explicit scoping instead of accidental usage of default package private level.The rule allows...
-* [DoNotCallGarbageCollectionExplicitly](pmd_rules_java_controversial.html#donotcallgarbagecollectionexplicitly): Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Co...
-* [DontImportSun](pmd_rules_java_controversial.html#dontimportsun): Avoid importing anything from the 'sun.' packages. These packages are not portable and are likel...
-* [NullAssignment](pmd_rules_java_controversial.html#nullassignment): Assigning a "null" to a variable (outside of its declaration) is usually bad form. Sometimes, th...
-* [OneDeclarationPerLine](pmd_rules_java_controversial.html#onedeclarationperline): Java allows the use of several variables declaration of the same type on one line. However, itcan...
-* [OnlyOneReturn](pmd_rules_java_controversial.html#onlyonereturn): A method should have only one exit point, and that should be the last statement in the method.
-* [SuspiciousOctalEscape](pmd_rules_java_controversial.html#suspiciousoctalescape): A suspicious octal escape sequence was found inside a String literal.The Java language specificat...
-* [UnnecessaryConstructor](pmd_rules_java_controversial.html#unnecessaryconstructor): This rule detects when a constructor is not necessary; i.e., when there is only one constructor,i...
-* [UnnecessaryParentheses](pmd_rules_java_controversial.html#unnecessaryparentheses): Deprecated The rule has been moved to another ruleset. Use instead [UselessParentheses](pmd_rules_java_unnecessary.html#uselessparentheses).
-* [UseConcurrentHashMap](pmd_rules_java_controversial.html#useconcurrenthashmap): Since Java5 brought a new implementation of the Map designed for multi-threaded access, you canpe...
-* [UseObjectForClearerAPI](pmd_rules_java_controversial.html#useobjectforclearerapi): When you write a public method, you should be thinking in terms of an API. If your method is publ...
-
-## Coupling
-* [CouplingBetweenObjects](pmd_rules_java_coupling.html#couplingbetweenobjects): This rule counts the number of unique attributes, local variables, and return types within an obj...
-* [ExcessiveImports](pmd_rules_java_coupling.html#excessiveimports): A high number of imports can indicate a high degree of coupling within an object. This rule count...
-* [LawOfDemeter](pmd_rules_java_coupling.html#lawofdemeter): The Law of Demeter is a simple rule, that says "only talk to friends". It helps to reduce couplin...
-* [LooseCoupling](pmd_rules_java_coupling.html#loosecoupling): The use of implementation types as object references limits your ability to use alternateimplemen...
-* [LoosePackageCoupling](pmd_rules_java_coupling.html#loosepackagecoupling): Avoid using classes from the configured package hierarchy outside of the package hierarchy, excep...
+## 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): Unit tests should not contain too many asserts. Many asserts are indicative of a complex test, fo...
+* [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...
+* [MissingOverride](pmd_rules_java_bestpractices.html#missingoverride): Annotating overridden methods with @Override ensures at compile time that the method r...
+* [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): Deprecated Abstract classes should be named 'AbstractXXX'.
+* [AtLeastOneConstructor](pmd_rules_java_codestyle.html#atleastoneconstructor): Each non-static class should declare at least one constructor.Classes with solely static members ...
+* [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): Deprecated 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): Configurable naming conventions for type declarations. This rule reports type declarat...
+* [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 != ...
+* [ControlStatementBraces](pmd_rules_java_codestyle.html#controlstatementbraces): Enforce a policy for braces on control statements. It is recommended to use braces on 'if ... els...
+* [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, ...
+* [FieldNamingConventions](pmd_rules_java_codestyle.html#fieldnamingconventions): Configurable naming conventions for field declarations. This rule reports variable declarations ...
+* [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): Deprecated Avoid using 'for' statements without using curly braces. If the code formatting or indentation is...
+* [FormalParameterNamingConventions](pmd_rules_java_codestyle.html#formalparameternamingconventions): Configurable naming conventions for formal parameters of methods and lambdas. This rul...
+* [GenericsNaming](pmd_rules_java_codestyle.html#genericsnaming): Names for references to generic values should be limited to a single uppercase letter.
+* [IdenticalCatchBranches](pmd_rules_java_codestyle.html#identicalcatchbranches): Identical 'catch' branches use up vertical space and increase the complexity of code without ...
+* [IfElseStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifelsestmtsmustusebraces): Deprecated Avoid using if..else statements without using surrounding braces. If the code formatting or inden...
+* [IfStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifstmtsmustusebraces): Deprecated Avoid using if statements without using braces to surround the code block. If the code formatting...
+* [LinguisticNaming](pmd_rules_java_codestyle.html#linguisticnaming): This rule finds Linguistic Naming Antipatterns. It checks for fields, that are named, as if they ...
+* [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.
+* [LocalVariableNamingConventions](pmd_rules_java_codestyle.html#localvariablenamingconventions): Configurable naming conventions for local variable declarations and other locally-scoped ...
+* [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): Configurable naming conventions for method declarations. This rule reports method decl...
+* [MIsLeadingVariableName](pmd_rules_java_codestyle.html#misleadingvariablename): Deprecated 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): Deprecated 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,...
+* [UnnecessaryAnnotationValueElement](pmd_rules_java_codestyle.html#unnecessaryannotationvalueelement): Avoid the use of value in annotations when it's the only element.
+* [UnnecessaryConstructor](pmd_rules_java_codestyle.html#unnecessaryconstructor): This rule detects when a constructor is not necessary; i.e., when there is only one constructor a...
+* [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): Reports qualified this usages in the same class.
+* [UseUnderscoresInNumericLiterals](pmd_rules_java_codestyle.html#useunderscoresinnumericliterals): Since Java 1.7, numeric literals can use underscores to separate digits. This rule enforces that ...
+* [VariableNamingConventions](pmd_rules_java_codestyle.html#variablenamingconventions): Deprecated A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina...
+* [WhileLoopsMustUseBraces](pmd_rules_java_codestyle.html#whileloopsmustusebraces): Deprecated Avoid using 'while' statements without using braces to surround the code block. If the code forma...
## Design
-* [AbstractClassWithoutAbstractMethod](pmd_rules_java_design.html#abstractclasswithoutabstractmethod): The abstract class does not contain any abstract methods. An abstract class suggestsan incomplete...
+
+{% 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...
-* [AccessorClassGeneration](pmd_rules_java_design.html#accessorclassgeneration): Instantiation by way of private constructors from outside of the constructor's class often causes...
-* [AccessorMethodGeneration](pmd_rules_java_design.html#accessormethodgeneration): When accessing a private field / method from another class, the Java compiler will generate a acc...
-* [AssignmentToNonFinalStatic](pmd_rules_java_design.html#assignmenttononfinalstatic): Identifies a possible unsafe usage of a static field.
+* [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 ...
-* [AvoidInstanceofChecksInCatchClause](pmd_rules_java_design.html#avoidinstanceofchecksincatchclause): Each caught exception type should be handled in its own catch clause.
-* [AvoidProtectedFieldInFinalClass](pmd_rules_java_design.html#avoidprotectedfieldinfinalclass): Do not use protected fields in final classes since they cannot be subclassed.Clarify your intent ...
-* [AvoidProtectedMethodInFinalClassNotExtending](pmd_rules_java_design.html#avoidprotectedmethodinfinalclassnotextending): Do not use protected methods in most final classes since they cannot be subclassed. This shouldon...
-* [AvoidReassigningParameters](pmd_rules_java_design.html#avoidreassigningparameters): Reassigning values to incoming parameters is not recommended. Use temporary local variables inst...
-* [AvoidSynchronizedAtMethodLevel](pmd_rules_java_design.html#avoidsynchronizedatmethodlevel): Method-level synchronization can cause problems when new code is added to the method.Block-level ...
-* [BadComparison](pmd_rules_java_design.html#badcomparison): Avoid equality comparisons with Double.NaN. Due to the implicit lack of representationprecision w...
+* [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 manually. These are confusing because most people will assum...
+* [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 ...
-* [CloseResource](pmd_rules_java_design.html#closeresource): Ensure that resources (like Connection, Statement, and ResultSet objects) are always closed after...
-* [CompareObjectsWithEquals](pmd_rules_java_design.html#compareobjectswithequals): Use equals() to compare object references; avoid comparing them with ==.
-* [ConfusingTernary](pmd_rules_java_design.html#confusingternary): Avoid negation within an "if" expression with an "else" clause. For example, rephrase:'if (x != ...
-* [ConstantsInInterface](pmd_rules_java_design.html#constantsininterface): Avoid constants in interfaces. Interfaces should define types, constants are implementation detai...
-* [ConstructorCallsOverridableMethod](pmd_rules_java_design.html#constructorcallsoverridablemethod): Calling overridable methods during construction poses a risk of invoking methods on an incomplete...
-* [DefaultLabelNotLastInSwitchStmt](pmd_rules_java_design.html#defaultlabelnotlastinswitchstmt): By convention, the default label should be the last label in a switch statement.
-* [EmptyMethodInAbstractClassShouldBeAbstract](pmd_rules_java_design.html#emptymethodinabstractclassshouldbeabstract): Empty or auto-generated methods in an abstract class should be tagged as abstract. This helps to ...
-* [EqualsNull](pmd_rules_java_design.html#equalsnull): Tests for null should not use the equals() method. The '==' operator should be used instead.
-* [FieldDeclarationsShouldBeAtStartOfClass](pmd_rules_java_design.html#fielddeclarationsshouldbeatstartofclass): Fields should be declared at the top of the class, before any method declarations, constructors, ...
+* [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...
-* [IdempotentOperations](pmd_rules_java_design.html#idempotentoperations): Avoid idempotent operations - they have no effect.
* [ImmutableField](pmd_rules_java_design.html#immutablefield): Identifies private fields whose values never change once they are initialized either in the decla...
-* [InstantiationToGetClass](pmd_rules_java_design.html#instantiationtogetclass): Avoid instantiating an object just to call getClass() on it; use the .class public member instead.
+* [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.
-* [MissingBreakInSwitch](pmd_rules_java_design.html#missingbreakinswitch): Switch statements without break or return statements for each case optionmay indicate problematic...
-* [MissingStaticMethodInNonInstantiatableClass](pmd_rules_java_design.html#missingstaticmethodinnoninstantiatableclass): A class that has private constructors and does not have any static methods or fields cannot be used.
-* [NonCaseLabelInSwitchStatement](pmd_rules_java_design.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_design.html#nonstaticinitializer): A non-static initializer block will be called any time a constructor is invoked (just prior toinv...
-* [NonThreadSafeSingleton](pmd_rules_java_design.html#nonthreadsafesingleton): Non-thread safe singletons can result in bad state changes. Eliminatestatic singletons if possibl...
-* [OptimizableToArrayCall](pmd_rules_java_design.html#optimizabletoarraycall): Calls to a collection's toArray() method should specify target arrays sized to match the size of ...
-* [PositionLiteralsFirstInCaseInsensitiveComparisons](pmd_rules_java_design.html#positionliteralsfirstincaseinsensitivecomparisons): Position literals first in comparisons, if the second argument is null then NullPointerExceptions...
-* [PositionLiteralsFirstInComparisons](pmd_rules_java_design.html#positionliteralsfirstincomparisons): Position literals first in comparisons, if the second argument is null then NullPointerExceptions...
-* [PreserveStackTrace](pmd_rules_java_design.html#preservestacktrace): Throwing a new exception from a catch block without passing the original exception into thenew ex...
-* [ReturnEmptyArrayRatherThanNull](pmd_rules_java_design.html#returnemptyarrayratherthannull): For any method that returns an array, it is a better to return an empty array rather than anull r...
-* [SimpleDateFormatNeedsLocale](pmd_rules_java_design.html#simpledateformatneedslocale): Be sure to specify a Locale when creating SimpleDateFormat instances to ensure that locale-approp...
+* [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): Deprecated Complexity directly affects maintenance costs is determined by the number of decision points in a...
+* [NcssConstructorCount](pmd_rules_java_design.html#ncssconstructorcount): Deprecated 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): Deprecated This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
+* [NcssTypeCount](pmd_rules_java_design.html#ncsstypecount): Deprecated 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...
-* [SingleMethodSingleton](pmd_rules_java_design.html#singlemethodsingleton): Some classes contain overloaded getInstance. The problem with overloaded getInstance methodsis th...
-* [SingletonClassReturningNewInstance](pmd_rules_java_design.html#singletonclassreturningnewinstance): Some classes contain overloaded getInstance. The problem with overloaded getInstance methodsis th...
* [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): Deprecated 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...
-* [SwitchStmtsShouldHaveDefault](pmd_rules_java_design.html#switchstmtsshouldhavedefault): All switch statements should include a default option to catch any unspecified values.
-* [TooFewBranchesForASwitchStatement](pmd_rules_java_design.html#toofewbranchesforaswitchstatement): Switch statements are intended to be used to support complex branching behaviour. Using a switch ...
-* [UncommentedEmptyConstructor](pmd_rules_java_design.html#uncommentedemptyconstructor): Uncommented Empty Constructor finds instances where a constructor does notcontain statements, but...
-* [UncommentedEmptyMethodBody](pmd_rules_java_design.html#uncommentedemptymethodbody): Uncommented Empty Method Body finds instances where a method body does not containstatements, but...
-* [UnnecessaryLocalBeforeReturn](pmd_rules_java_design.html#unnecessarylocalbeforereturn): Avoid the creation of unnecessary local variables
-* [UnsynchronizedStaticDateFormatter](pmd_rules_java_design.html#unsynchronizedstaticdateformatter): SimpleDateFormat instances are not synchronized. Sun recommends using separate format instancesfo...
-* [UseCollectionIsEmpty](pmd_rules_java_design.html#usecollectionisempty): The isEmpty() method on java.util.Collection is provided to determine if a collection has any ele...
-* [UseLocaleWithCaseConversions](pmd_rules_java_design.html#uselocalewithcaseconversions): When doing String.toLowerCase()/toUpperCase() conversions, use Locales to avoids problems with la...
-* [UseNotifyAllInsteadOfNotify](pmd_rules_java_design.html#usenotifyallinsteadofnotify): Thread.notify() awakens a thread monitoring the object. If more than one thread is monitoring, th...
+* [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...
-* [UseVarargs](pmd_rules_java_design.html#usevarargs): Java 5 introduced the varargs parameter declaration for methods and constructors. This syntactic...
-
-## Empty Code
-* [EmptyCatchBlock](pmd_rules_java_empty.html#emptycatchblock): Empty Catch Block finds instances where an exception is caught, but nothing is done. In most cir...
-* [EmptyFinallyBlock](pmd_rules_java_empty.html#emptyfinallyblock): Empty finally blocks serve no purpose and should be removed.
-* [EmptyIfStmt](pmd_rules_java_empty.html#emptyifstmt): Empty If Statement finds instances where a condition is checked but nothing is done about it.
-* [EmptyInitializer](pmd_rules_java_empty.html#emptyinitializer): Empty initializers serve no purpose and should be removed.
-* [EmptyStatementBlock](pmd_rules_java_empty.html#emptystatementblock): Empty block statements serve no purpose and should be removed.
-* [EmptyStatementNotInLoop](pmd_rules_java_empty.html#emptystatementnotinloop): An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for' or 'wh...
-* [EmptyStaticInitializer](pmd_rules_java_empty.html#emptystaticinitializer): An empty static initializer serve no purpose and should be removed.
-* [EmptySwitchStatements](pmd_rules_java_empty.html#emptyswitchstatements): Empty switch statements serve no purpose and should be removed.
-* [EmptySynchronizedBlock](pmd_rules_java_empty.html#emptysynchronizedblock): Empty synchronized blocks serve no purpose and should be removed.
-* [EmptyTryBlock](pmd_rules_java_empty.html#emptytryblock): Avoid empty try blocks - what's the point?
-* [EmptyWhileStmt](pmd_rules_java_empty.html#emptywhilestmt): Empty While Statement finds all instances where a while statement does nothing. If it is a timin...
-
-## Finalizer
-* [AvoidCallingFinalize](pmd_rules_java_finalizers.html#avoidcallingfinalize): The method Object.finalize() is called by the garbage collector on an object when garbage collect...
-* [EmptyFinalizer](pmd_rules_java_finalizers.html#emptyfinalizer): Empty finalize methods serve no purpose and should be removed.
-* [FinalizeDoesNotCallSuperFinalize](pmd_rules_java_finalizers.html#finalizedoesnotcallsuperfinalize): If the finalize() is implemented, its last action should be to call super.finalize.
-* [FinalizeOnlyCallsSuperFinalize](pmd_rules_java_finalizers.html#finalizeonlycallssuperfinalize): If the finalize() is implemented, it should do something besides just calling super.finalize().
-* [FinalizeOverloaded](pmd_rules_java_finalizers.html#finalizeoverloaded): Methods named finalize() should not have parameters. It is confusing and most likely an attempt ...
-* [FinalizeShouldBeProtected](pmd_rules_java_finalizers.html#finalizeshouldbeprotected): When overriding the finalize(), the new method should be set as protected. If made public, other...
-
-## Import Statements
-* [DontImportJavaLang](pmd_rules_java_imports.html#dontimportjavalang): Avoid importing anything from the package 'java.lang'. These classes are automatically imported ...
-* [DuplicateImports](pmd_rules_java_imports.html#duplicateimports): Duplicate or overlapping import statements should be avoided.
-* [ImportFromSamePackage](pmd_rules_java_imports.html#importfromsamepackage): There is no need to import a type that lives in the same package.
-* [TooManyStaticImports](pmd_rules_java_imports.html#toomanystaticimports): If you overuse the static import feature, it can make your program unreadable and unmaintainable,...
-* [UnnecessaryFullyQualifiedName](pmd_rules_java_imports.html#unnecessaryfullyqualifiedname): Import statements allow the use of non-fully qualified names. The use of a fully qualified namew...
-* [UnusedImports](pmd_rules_java_imports.html#unusedimports): Avoid the use of unused import statements to prevent unwanted dependencies.
-
-## J2EE
-* [DoNotCallSystemExit](pmd_rules_java_j2ee.html#donotcallsystemexit): Web applications should not call System.exit(), since only the web container or theapplication se...
-* [DoNotUseThreads](pmd_rules_java_j2ee.html#donotusethreads): The J2EE specification explicitly forbids the use of threads.
-* [LocalHomeNamingConvention](pmd_rules_java_j2ee.html#localhomenamingconvention): The Local Home interface of a Session EJB should be suffixed by 'LocalHome'.
-* [LocalInterfaceSessionNamingConvention](pmd_rules_java_j2ee.html#localinterfacesessionnamingconvention): The Local Interface of a Session EJB should be suffixed by 'Local'.
-* [MDBAndSessionBeanNamingConvention](pmd_rules_java_j2ee.html#mdbandsessionbeannamingconvention): The EJB Specification states that any MessageDrivenBean or SessionBean should be suffixed by 'Bean'.
-* [RemoteInterfaceNamingConvention](pmd_rules_java_j2ee.html#remoteinterfacenamingconvention): Remote Interface of a Session EJB should not have a suffix.
-* [RemoteSessionInterfaceNamingConvention](pmd_rules_java_j2ee.html#remotesessioninterfacenamingconvention): A Remote Home interface type of a Session EJB should be suffixed by 'Home'.
-* [StaticEJBFieldShouldBeFinal](pmd_rules_java_j2ee.html#staticejbfieldshouldbefinal): According to the J2EE specification, an EJB should not have any static fieldswith write access. H...
-* [UseProperClassLoader](pmd_rules_java_j2ee.html#useproperclassloader): In J2EE, the getClassLoader() method might not work as expected. Use Thread.currentThread().getCo...
-
-## Jakarta Commons Logging
-* [GuardDebugLogging](pmd_rules_java_logging-jakarta-commons.html#guarddebuglogging): When log messages are composed by concatenating strings, the whole section should be guardedby a ...
-* [GuardLogStatement](pmd_rules_java_logging-jakarta-commons.html#guardlogstatement): Whenever using a log level, one should check if the loglevel is actually enabled, orotherwise ski...
-* [ProperLogger](pmd_rules_java_logging-jakarta-commons.html#properlogger): A logger should normally be defined private static final and be associated with the correct class...
-* [UseCorrectExceptionLogging](pmd_rules_java_logging-jakarta-commons.html#usecorrectexceptionlogging): To make sure the full stacktrace is printed out, use the logging statement with two arguments: a ...
-
-## Java Logging
-* [AvoidPrintStackTrace](pmd_rules_java_logging-java.html#avoidprintstacktrace): Avoid printStackTrace(); use a logger call instead.
-* [GuardLogStatementJavaUtil](pmd_rules_java_logging-java.html#guardlogstatementjavautil): Whenever using a log level, one should check if the loglevel is actually enabled, orotherwise ski...
-* [InvalidSlf4jMessageFormat](pmd_rules_java_logging-java.html#invalidslf4jmessageformat): Check for messages in slf4j loggers with non matching number of arguments and placeholders.
-* [LoggerIsNotStaticFinal](pmd_rules_java_logging-java.html#loggerisnotstaticfinal): In most cases, the Logger reference can be declared as static and final.
-* [MoreThanOneLogger](pmd_rules_java_logging-java.html#morethanonelogger): Normally only one logger is used in each class.
-* [SystemPrintln](pmd_rules_java_logging-java.html#systemprintln): References to System.(out\|err).print are usually intended for debugging purposes and can remain ...
-
-## JavaBeans
-* [BeanMembersShouldSerialize](pmd_rules_java_javabeans.html#beanmembersshouldserialize): If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializab...
-* [MissingSerialVersionUID](pmd_rules_java_javabeans.html#missingserialversionuid): Serializable classes should provide a serialVersionUID field.
-
-## JUnit
-* [JUnitAssertionsShouldIncludeMessage](pmd_rules_java_junit.html#junitassertionsshouldincludemessage): JUnit assertions should include an informative message - i.e., use the three-argument version of ...
-* [JUnitSpelling](pmd_rules_java_junit.html#junitspelling): Some JUnit framework methods are easy to misspell.
-* [JUnitStaticSuite](pmd_rules_java_junit.html#junitstaticsuite): The suite() method in a JUnit test needs to be both public and static.
-* [JUnitTestContainsTooManyAsserts](pmd_rules_java_junit.html#junittestcontainstoomanyasserts): JUnit tests should not contain too many asserts. Many asserts are indicative of a complex test, ...
-* [JUnitTestsShouldIncludeAssert](pmd_rules_java_junit.html#junittestsshouldincludeassert): JUnit tests should include at least one assertion. This makes the tests more robust, and using a...
-* [SimplifyBooleanAssertion](pmd_rules_java_junit.html#simplifybooleanassertion): Avoid negation in an assertTrue or assertFalse test.For example, rephrase: assertTrue(!expr);a...
-* [TestClassWithoutTestCases](pmd_rules_java_junit.html#testclasswithouttestcases): Test classes end with the suffix Test. Having a non-test class with that name is not a good pract...
-* [UnnecessaryBooleanAssertion](pmd_rules_java_junit.html#unnecessarybooleanassertion): A JUnit test assertion with a boolean literal is unnecessary since it always will evaluate to the...
-* [UseAssertEqualsInsteadOfAssertTrue](pmd_rules_java_junit.html#useassertequalsinsteadofasserttrue): This rule detects JUnit assertions in object equality. These assertions should be made by more sp...
-* [UseAssertNullInsteadOfAssertTrue](pmd_rules_java_junit.html#useassertnullinsteadofasserttrue): This rule detects JUnit assertions in object references equality. These assertions should be made...
-* [UseAssertSameInsteadOfAssertTrue](pmd_rules_java_junit.html#useassertsameinsteadofasserttrue): This rule detects JUnit assertions in object references equality. These assertions should be made...
-* [UseAssertTrueInsteadOfAssertEquals](pmd_rules_java_junit.html#useasserttrueinsteadofassertequals): When asserting a value is the same as a literal or Boxed boolean, use assertTrue/assertFalse, ins...
-
-## Migration
-* [AvoidAssertAsIdentifier](pmd_rules_java_migrating.html#avoidassertasidentifier): Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
-* [AvoidEnumAsIdentifier](pmd_rules_java_migrating.html#avoidenumasidentifier): Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
-* [ByteInstantiation](pmd_rules_java_migrating.html#byteinstantiation): Calling new Byte() causes memory allocation that can be avoided by the static Byte.valueOf().It m...
-* [ForLoopCanBeForeach](pmd_rules_java_migrating.html#forloopcanbeforeach): Reports loops that can be safely replaced with the foreach syntax. The rule considers loops over ...
-* [IntegerInstantiation](pmd_rules_java_migrating.html#integerinstantiation): Calling new Integer() causes memory allocation that can be avoided by the static Integer.valueOf(...
-* [JUnit4SuitesShouldUseSuiteAnnotation](pmd_rules_java_migrating.html#junit4suitesshouldusesuiteannotation): In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicatedthro...
-* [JUnit4TestShouldUseAfterAnnotation](pmd_rules_java_migrating.html#junit4testshoulduseafterannotation): In JUnit 3, the tearDown method was used to clean up all data entities required in running tests....
-* [JUnit4TestShouldUseBeforeAnnotation](pmd_rules_java_migrating.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_migrating.html#junit4testshouldusetestannotation): In JUnit 3, the framework executed all methods which started with the word test as a unit test. I...
-* [JUnitUseExpected](pmd_rules_java_migrating.html#junituseexpected): In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions.
-* [LongInstantiation](pmd_rules_java_migrating.html#longinstantiation): Calling new Long() causes memory allocation that can be avoided by the static Long.valueOf().It m...
-* [ReplaceEnumerationWithIterator](pmd_rules_java_migrating.html#replaceenumerationwithiterator): Consider replacing Enumeration usages with the newer java.util.Iterator
-* [ReplaceHashtableWithMap](pmd_rules_java_migrating.html#replacehashtablewithmap): Consider replacing Hashtable usage with the newer java.util.Map if thread safety is not required.
-* [ReplaceVectorWithList](pmd_rules_java_migrating.html#replacevectorwithlist): Consider replacing Vector usages with the newer java.util.ArrayList if expensive thread-safe oper...
-* [ShortInstantiation](pmd_rules_java_migrating.html#shortinstantiation): Calling new Short() causes memory allocation that can be avoided by the static Short.valueOf().It...
-
-## Naming
-* [AbstractNaming](pmd_rules_java_naming.html#abstractnaming): Abstract classes should be named 'AbstractXXX'.
-* [AvoidDollarSigns](pmd_rules_java_naming.html#avoiddollarsigns): Avoid using dollar signs in variable/method/class/interface names.
-* [AvoidFieldNameMatchingMethodName](pmd_rules_java_naming.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_naming.html#avoidfieldnamematchingtypename): It is somewhat confusing to have a field name matching the declaring class name.This probably mea...
-* [BooleanGetMethodName](pmd_rules_java_naming.html#booleangetmethodname): Methods that return boolean results should be named as predicate statements to denote this.I.e, '...
-* [ClassNamingConventions](pmd_rules_java_naming.html#classnamingconventions): Class names should always begin with an upper case character.
-* [GenericsNaming](pmd_rules_java_naming.html#genericsnaming): Names for references to generic values should be limited to a single uppercase letter.
-* [LongVariable](pmd_rules_java_naming.html#longvariable): Fields, formal arguments, or local variable names that are too long can make the code difficult t...
-* [MethodNamingConventions](pmd_rules_java_naming.html#methodnamingconventions): Method names should always begin with a lower case character, and should not contain underscores.
-* [MethodWithSameNameAsEnclosingClass](pmd_rules_java_naming.html#methodwithsamenameasenclosingclass): Non-constructor methods should not have the same name as the enclosing class.
-* [MisleadingVariableName](pmd_rules_java_naming.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_naming.html#nopackage): Detects when a class or interface does not have a package definition.
-* [PackageCase](pmd_rules_java_naming.html#packagecase): Detects when a package definition contains uppercase characters.
-* [ShortClassName](pmd_rules_java_naming.html#shortclassname): Short Classnames with fewer than e.g. five characters are not recommended.
-* [ShortMethodName](pmd_rules_java_naming.html#shortmethodname): Method names that are very short are not helpful to the reader.
-* [ShortVariable](pmd_rules_java_naming.html#shortvariable): Fields, local variables, or parameter names that are very short are not helpful to the reader.
-* [SuspiciousConstantFieldName](pmd_rules_java_naming.html#suspiciousconstantfieldname): Field names using all uppercase characters - Sun's Java naming conventions indicating constants -...
-* [SuspiciousEqualsMethodName](pmd_rules_java_naming.html#suspiciousequalsmethodname): The method name and parameter number are suspiciously close to equals(Object), which can denote a...
-* [SuspiciousHashcodeMethodName](pmd_rules_java_naming.html#suspicioushashcodemethodname): The method name and return type are suspiciously close to hashCode(), which may denote an intenti...
-* [VariableNamingConventions](pmd_rules_java_naming.html#variablenamingconventions): A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina...
-
-## Optimization
-* [AddEmptyString](pmd_rules_java_optimizations.html#addemptystring): The conversion of literals to strings by concatenating them with empty strings is inefficient.It ...
-* [AvoidArrayLoops](pmd_rules_java_optimizations.html#avoidarrayloops): Instead of manually copying data between two arrays, use the efficient System.arraycopy method in...
-* [AvoidInstantiatingObjectsInLoops](pmd_rules_java_optimizations.html#avoidinstantiatingobjectsinloops): New objects created within loops should be checked to see if they can created outside them and re...
-* [LocalVariableCouldBeFinal](pmd_rules_java_optimizations.html#localvariablecouldbefinal): A local variable assigned only once can be declared final.
-* [MethodArgumentCouldBeFinal](pmd_rules_java_optimizations.html#methodargumentcouldbefinal): A method argument that is never re-assigned within the method can be declared final.
-* [PrematureDeclaration](pmd_rules_java_optimizations.html#prematuredeclaration): Checks for variables that are defined before they might be used. A reference is deemed to be prem...
-* [RedundantFieldInitializer](pmd_rules_java_optimizations.html#redundantfieldinitializer): Java will initialize fields with known default values so any explicit initialization of those sam...
-* [SimplifyStartsWith](pmd_rules_java_optimizations.html#simplifystartswith): Since it passes in a literal of length 1, calls to (string).startsWith can be rewritten using (st...
-* [UnnecessaryWrapperObjectCreation](pmd_rules_java_optimizations.html#unnecessarywrapperobjectcreation): Most wrapper classes provide static conversion methods that avoid the need to create intermediate...
-* [UseArrayListInsteadOfVector](pmd_rules_java_optimizations.html#usearraylistinsteadofvector): ArrayList is a much better Collection implementation than Vector if thread-safe operation is not ...
-* [UseArraysAsList](pmd_rules_java_optimizations.html#usearraysaslist): The java.util.Arrays class has a "asList" method that should be used when you want to create a ne...
-* [UseStringBufferForStringAppends](pmd_rules_java_optimizations.html#usestringbufferforstringappends): The use of the '+=' operator for appending strings causes the JVM to create and use an internal S...
-
-## Security Code Guidelines
-* [ArrayIsStoredDirectly](pmd_rules_java_sunsecure.html#arrayisstoreddirectly): Constructors and methods receiving arrays should clone objects and store the copy.This prevents f...
-* [MethodReturnsInternalArray](pmd_rules_java_sunsecure.html#methodreturnsinternalarray): Exposing internal arrays to the caller violates object encapsulation since elements can be remove...
-
-## Strict Exceptions
-* [AvoidCatchingGenericException](pmd_rules_java_strictexception.html#avoidcatchinggenericexception): Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in tr...
-* [AvoidCatchingNPE](pmd_rules_java_strictexception.html#avoidcatchingnpe): Code should never throw NullPointerExceptions under normal circumstances. A catch block may hide...
-* [AvoidCatchingThrowable](pmd_rules_java_strictexception.html#avoidcatchingthrowable): Catching Throwable errors is not recommended since its scope is very broad. It includes runtime i...
-* [AvoidLosingExceptionInformation](pmd_rules_java_strictexception.html#avoidlosingexceptioninformation): Statements in a catch block that invoke accessors on the exception without using the informationo...
-* [AvoidRethrowingException](pmd_rules_java_strictexception.html#avoidrethrowingexception): Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity.
-* [AvoidThrowingNewInstanceOfSameException](pmd_rules_java_strictexception.html#avoidthrowingnewinstanceofsameexception): Catch blocks that merely rethrow a caught exception wrapped inside a new instance of the same typ...
-* [AvoidThrowingNullPointerException](pmd_rules_java_strictexception.html#avoidthrowingnullpointerexception): Avoid throwing NullPointerExceptions. These are confusing because most people will assume that th...
-* [AvoidThrowingRawExceptionTypes](pmd_rules_java_strictexception.html#avoidthrowingrawexceptiontypes): Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable,Excep...
-* [DoNotExtendJavaLangError](pmd_rules_java_strictexception.html#donotextendjavalangerror): Errors are system exceptions. Do not extend them.
-* [DoNotThrowExceptionInFinally](pmd_rules_java_strictexception.html#donotthrowexceptioninfinally): Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions or...
-* [ExceptionAsFlowControl](pmd_rules_java_strictexception.html#exceptionasflowcontrol): Using Exceptions as form of flow control is not recommended as they obscure true exceptions when ...
-* [SignatureDeclareThrowsException](pmd_rules_java_strictexception.html#signaturedeclarethrowsexception): Methods that declare the generic Exception as a possible throwable are not very helpful since the...
-
-## String and StringBuffer
-* [AppendCharacterWithChar](pmd_rules_java_strings.html#appendcharacterwithchar): Avoid concatenating characters as strings in StringBuffer/StringBuilder.append methods.
-* [AvoidDuplicateLiterals](pmd_rules_java_strings.html#avoidduplicateliterals): Code containing duplicate String literals can usually be improved by declaring the String as a co...
-* [AvoidStringBufferField](pmd_rules_java_strings.html#avoidstringbufferfield): StringBuffers/StringBuilders can grow considerably, and so may become a source of memory leaksif ...
-* [ConsecutiveAppendsShouldReuse](pmd_rules_java_strings.html#consecutiveappendsshouldreuse): Consecutive calls to StringBuffer/StringBuilder .append should be chained, reusing the target obj...
-* [ConsecutiveLiteralAppends](pmd_rules_java_strings.html#consecutiveliteralappends): Consecutively calling StringBuffer/StringBuilder.append with String literals
-* [InefficientEmptyStringCheck](pmd_rules_java_strings.html#inefficientemptystringcheck): String.trim().length() is an inefficient way to check if a String is really empty, as itcreates a...
-* [InefficientStringBuffering](pmd_rules_java_strings.html#inefficientstringbuffering): Avoid concatenating non-literals in a StringBuffer constructor or append() since intermediate buf...
-* [InsufficientStringBufferDeclaration](pmd_rules_java_strings.html#insufficientstringbufferdeclaration): Failing to pre-size a StringBuffer or StringBuilder properly could cause it to re-size many times...
-* [StringBufferInstantiationWithChar](pmd_rules_java_strings.html#stringbufferinstantiationwithchar): Individual character values provided as initialization arguments will be converted into integers....
-* [StringInstantiation](pmd_rules_java_strings.html#stringinstantiation): Avoid instantiating String objects; this is usually unnecessary since they are immutable and can ...
-* [StringToString](pmd_rules_java_strings.html#stringtostring): Avoid calling toString() on objects already known to be string instances; this is unnecessary.
-* [UnnecessaryCaseChange](pmd_rules_java_strings.html#unnecessarycasechange): Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals()
-* [UseEqualsToCompareStrings](pmd_rules_java_strings.html#useequalstocomparestrings): Using '==' or '!=' to compare strings only works if intern version is used on both sides.Use the ...
-* [UseIndexOfChar](pmd_rules_java_strings.html#useindexofchar): Use String.indexOf(char) when checking for the index of a single character; it executes faster.
-* [UselessStringValueOf](pmd_rules_java_strings.html#uselessstringvalueof): No need to call String.valueOf to append to a string; just use the valueOf() argument directly.
-* [UseStringBufferLength](pmd_rules_java_strings.html#usestringbufferlength): Use StringBuffer.length() to determine StringBuffer length rather than using StringBuffer.toStrin...
-
-## Unnecessary
-* [UnnecessaryConversionTemporary](pmd_rules_java_unnecessary.html#unnecessaryconversiontemporary): Avoid the use temporary objects when converting primitives to Strings. Use the static conversion ...
-* [UnnecessaryFinalModifier](pmd_rules_java_unnecessary.html#unnecessaryfinalmodifier): When a class has the final modifier, all the methods are automatically final and do not need to b...
-* [UnnecessaryModifier](pmd_rules_java_unnecessary.html#unnecessarymodifier): Fields in interfaces and annotations are automatically 'public static final', and methods are 'pu...
-* [UnnecessaryReturn](pmd_rules_java_unnecessary.html#unnecessaryreturn): Avoid the use of unnecessary return statements.
-* [UnusedNullCheckInEquals](pmd_rules_java_unnecessary.html#unusednullcheckinequals): After checking an object reference for null, you should invoke equals() on that object rather tha...
-* [UselessOperationOnImmutable](pmd_rules_java_unnecessary.html#uselessoperationonimmutable): An operation on an Immutable object (String, BigDecimal or BigInteger) won't change the object it...
-* [UselessOverridingMethod](pmd_rules_java_unnecessary.html#uselessoverridingmethod): The overriding method merely calls the same method defined in a superclass.
-* [UselessParentheses](pmd_rules_java_unnecessary.html#uselessparentheses): Useless parentheses should be removed.
-* [UselessQualifiedThis](pmd_rules_java_unnecessary.html#uselessqualifiedthis): Look for qualified this usages in the same class.
-
-## Unused Code
-* [UnusedFormalParameter](pmd_rules_java_unusedcode.html#unusedformalparameter): Avoid passing parameters to methods or constructors without actually referencing them in the meth...
-* [UnusedLocalVariable](pmd_rules_java_unusedcode.html#unusedlocalvariable): Detects when a local variable is declared and/or assigned, but not used.
-* [UnusedPrivateField](pmd_rules_java_unusedcode.html#unusedprivatefield): Detects when a private field is declared and/or assigned a value, but not used.
-* [UnusedPrivateMethod](pmd_rules_java_unusedcode.html#unusedprivatemethod): Unused Private Method detects when a private method is declared but is unused.
+
+## 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. Note that Oracle has declared Obje...
+* [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. Note that Ora...
+* [FinalizeOnlyCallsSuperFinalize](pmd_rules_java_errorprone.html#finalizeonlycallssuperfinalize): If the finalize() is implemented, it should do something besides just calling super.finalize(). N...
+* [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.The serialVersionUID field is also n...
+* [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 Arrays.copyOf or System.ar...
+* [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 literals should be avoided.Sinc...
+* [InefficientEmptyStringCheck](pmd_rules_java_performance.html#inefficientemptystringcheck): String.trim().length() == 0 (or String.trim().isEmpty() for the same reason) is an inefficientway...
+* [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...
+
+## Security
+
+{% include callout.html content="Rules that flag potential security flaws." %}
+
+* [HardCodedCryptoKey](pmd_rules_java_security.html#hardcodedcryptokey): Do not use hard coded values for cryptographic operations. Please store keys outside of source code.
+* [InsecureCryptoIv](pmd_rules_java_security.html#insecurecryptoiv): Do not use hard coded initialization vector in cryptographic operations. Please use a randomly ge...
+
+## Additional rulesets
+
+* Android (`rulesets/java/android.xml`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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), [UnnecessaryParentheses](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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ 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`):
+
+ Deprecated 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`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ 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`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [AvoidAssertAsIdentifier](pmd_rules_java_errorprone.html#avoidassertasidentifier)
+
+* Migration15 (`rulesets/java/migrating_to_15.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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)
+
+* quickstart (`rulesets/java/quickstart.xml`):
+
+ Quickstart configuration of PMD. Includes the rules that are most likely to apply everywhere.
+
+ It contains the following rules:
+
+ [AbstractClassWithoutAnyMethod](pmd_rules_java_design.html#abstractclasswithoutanymethod), [AssignmentInOperand](pmd_rules_java_errorprone.html#assignmentinoperand), [AssignmentToNonFinalStatic](pmd_rules_java_errorprone.html#assignmenttononfinalstatic), [AvoidAccessibilityAlteration](pmd_rules_java_errorprone.html#avoidaccessibilityalteration), [AvoidBranchingStatementAsLastInLoop](pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop), [AvoidCatchingThrowable](pmd_rules_java_errorprone.html#avoidcatchingthrowable), [AvoidDecimalLiteralsInBigDecimalConstructor](pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor), [AvoidDollarSigns](pmd_rules_java_codestyle.html#avoiddollarsigns), [AvoidInstanceofChecksInCatchClause](pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause), [AvoidMultipleUnaryOperators](pmd_rules_java_errorprone.html#avoidmultipleunaryoperators), [AvoidProtectedFieldInFinalClass](pmd_rules_java_codestyle.html#avoidprotectedfieldinfinalclass), [AvoidProtectedMethodInFinalClassNotExtending](pmd_rules_java_codestyle.html#avoidprotectedmethodinfinalclassnotextending), [AvoidStringBufferField](pmd_rules_java_bestpractices.html#avoidstringbufferfield), [AvoidThreadGroup](pmd_rules_java_multithreading.html#avoidthreadgroup), [AvoidUsingHardCodedIP](pmd_rules_java_bestpractices.html#avoidusinghardcodedip), [AvoidUsingOctalValues](pmd_rules_java_errorprone.html#avoidusingoctalvalues), [AvoidUsingVolatile](pmd_rules_java_multithreading.html#avoidusingvolatile), [BadComparison](pmd_rules_java_errorprone.html#badcomparison), [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), [ClassNamingConventions](pmd_rules_java_codestyle.html#classnamingconventions), [ClassWithOnlyPrivateConstructorsShouldBeFinal](pmd_rules_java_design.html#classwithonlyprivateconstructorsshouldbefinal), [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), [CloseResource](pmd_rules_java_errorprone.html#closeresource), [CompareObjectsWithEquals](pmd_rules_java_errorprone.html#compareobjectswithequals), [ConstantsInInterface](pmd_rules_java_bestpractices.html#constantsininterface), [ControlStatementBraces](pmd_rules_java_codestyle.html#controlstatementbraces), [DefaultLabelNotLastInSwitchStmt](pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitchstmt), [DoNotCallGarbageCollectionExplicitly](pmd_rules_java_errorprone.html#donotcallgarbagecollectionexplicitly), [DoNotExtendJavaLangError](pmd_rules_java_design.html#donotextendjavalangerror), [DoNotExtendJavaLangThrowable](pmd_rules_java_errorprone.html#donotextendjavalangthrowable), [DontCallThreadRun](pmd_rules_java_multithreading.html#dontcallthreadrun), [DontImportJavaLang](pmd_rules_java_codestyle.html#dontimportjavalang), [DontUseFloatTypeForLoopIndices](pmd_rules_java_errorprone.html#dontusefloattypeforloopindices), [DoubleCheckedLocking](pmd_rules_java_multithreading.html#doublecheckedlocking), [DuplicateImports](pmd_rules_java_codestyle.html#duplicateimports), [EmptyCatchBlock](pmd_rules_java_errorprone.html#emptycatchblock), [EmptyFinalizer](pmd_rules_java_errorprone.html#emptyfinalizer), [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), [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), [EqualsNull](pmd_rules_java_errorprone.html#equalsnull), [ExtendsObject](pmd_rules_java_codestyle.html#extendsobject), [FinalFieldCouldBeStatic](pmd_rules_java_design.html#finalfieldcouldbestatic), [ForLoopCanBeForeach](pmd_rules_java_bestpractices.html#forloopcanbeforeach), [ForLoopShouldBeWhileLoop](pmd_rules_java_codestyle.html#forloopshouldbewhileloop), [FormalParameterNamingConventions](pmd_rules_java_codestyle.html#formalparameternamingconventions), [GenericsNaming](pmd_rules_java_codestyle.html#genericsnaming), [GuardLogStatement](pmd_rules_java_bestpractices.html#guardlogstatement), [IdempotentOperations](pmd_rules_java_errorprone.html#idempotentoperations), [IdenticalCatchBranches](pmd_rules_java_codestyle.html#identicalcatchbranches), [ImportFromSamePackage](pmd_rules_java_errorprone.html#importfromsamepackage), [InstantiationToGetClass](pmd_rules_java_errorprone.html#instantiationtogetclass), [JumbledIncrementer](pmd_rules_java_errorprone.html#jumbledincrementer), [LocalVariableNamingConventions](pmd_rules_java_codestyle.html#localvariablenamingconventions), [LogicInversion](pmd_rules_java_design.html#logicinversion), [LooseCoupling](pmd_rules_java_bestpractices.html#loosecoupling), [MethodNamingConventions](pmd_rules_java_codestyle.html#methodnamingconventions), [MisplacedNullCheck](pmd_rules_java_errorprone.html#misplacednullcheck), [MissingBreakInSwitch](pmd_rules_java_errorprone.html#missingbreakinswitch), [MissingOverride](pmd_rules_java_bestpractices.html#missingoverride), [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), [NoPackage](pmd_rules_java_codestyle.html#nopackage), [OneDeclarationPerLine](pmd_rules_java_bestpractices.html#onedeclarationperline), [OptimizableToArrayCall](pmd_rules_java_performance.html#optimizabletoarraycall), [OverrideBothEqualsAndHashcode](pmd_rules_java_errorprone.html#overridebothequalsandhashcode), [PackageCase](pmd_rules_java_codestyle.html#packagecase), [PositionLiteralsFirstInCaseInsensitiveComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincaseinsensitivecomparisons), [PositionLiteralsFirstInComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincomparisons), [PreserveStackTrace](pmd_rules_java_bestpractices.html#preservestacktrace), [ProperCloneImplementation](pmd_rules_java_errorprone.html#propercloneimplementation), [ProperLogger](pmd_rules_java_errorprone.html#properlogger), [ReturnEmptyArrayRatherThanNull](pmd_rules_java_errorprone.html#returnemptyarrayratherthannull), [ReturnFromFinallyBlock](pmd_rules_java_errorprone.html#returnfromfinallyblock), [SimplifiedTernary](pmd_rules_java_design.html#simplifiedternary), [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), [SuspiciousEqualsMethodName](pmd_rules_java_errorprone.html#suspiciousequalsmethodname), [SuspiciousHashcodeMethodName](pmd_rules_java_errorprone.html#suspicioushashcodemethodname), [SuspiciousOctalEscape](pmd_rules_java_errorprone.html#suspiciousoctalescape), [SwitchStmtsShouldHaveDefault](pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault), [UncommentedEmptyConstructor](pmd_rules_java_documentation.html#uncommentedemptyconstructor), [UncommentedEmptyMethodBody](pmd_rules_java_documentation.html#uncommentedemptymethodbody), [UnconditionalIfStatement](pmd_rules_java_errorprone.html#unconditionalifstatement), [UnnecessaryAnnotationValueElement](pmd_rules_java_codestyle.html#unnecessaryannotationvalueelement), [UnnecessaryConstructor](pmd_rules_java_codestyle.html#unnecessaryconstructor), [UnnecessaryConversionTemporary](pmd_rules_java_errorprone.html#unnecessaryconversiontemporary), [UnnecessaryFullyQualifiedName](pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname), [UnnecessaryLocalBeforeReturn](pmd_rules_java_codestyle.html#unnecessarylocalbeforereturn), [UnnecessaryModifier](pmd_rules_java_codestyle.html#unnecessarymodifier), [UnnecessaryReturn](pmd_rules_java_codestyle.html#unnecessaryreturn), [UnsynchronizedStaticDateFormatter](pmd_rules_java_multithreading.html#unsynchronizedstaticdateformatter), [UnusedFormalParameter](pmd_rules_java_bestpractices.html#unusedformalparameter), [UnusedImports](pmd_rules_java_bestpractices.html#unusedimports), [UnusedLocalVariable](pmd_rules_java_bestpractices.html#unusedlocalvariable), [UnusedNullCheckInEquals](pmd_rules_java_errorprone.html#unusednullcheckinequals), [UnusedPrivateField](pmd_rules_java_bestpractices.html#unusedprivatefield), [UnusedPrivateMethod](pmd_rules_java_bestpractices.html#unusedprivatemethod), [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), [UseCollectionIsEmpty](pmd_rules_java_bestpractices.html#usecollectionisempty), [UseEqualsToCompareStrings](pmd_rules_java_errorprone.html#useequalstocomparestrings), [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), [UseLocaleWithCaseConversions](pmd_rules_java_errorprone.html#uselocalewithcaseconversions), [UseNotifyAllInsteadOfNotify](pmd_rules_java_multithreading.html#usenotifyallinsteadofnotify), [UseUtilityClass](pmd_rules_java_design.html#useutilityclass)
+
+* Security Code Guidelines (`rulesets/java/sunsecure.xml`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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`):
+
+ Deprecated 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)
+
diff --git a/docs/pages/pmd/rules/java/android.md b/docs/pages/pmd/rules/java/android.md
deleted file mode 100644
index a2ae5d4ed4d..00000000000
--- a/docs/pages/pmd/rules/java/android.md
+++ /dev/null
@@ -1,124 +0,0 @@
----
-title: Android
-summary: These rules deal with the Android SDK, mostly related to best practices. To get better results, make sure that the auxclasspath is defined for type resolution to work.
-permalink: pmd_rules_java_android.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/android.xml
-keywords: Android, CallSuperFirst, CallSuperLast, DoNotHardCodeSDCard
----
-## CallSuperFirst
-
-**Since:** PMD 4.2.5
-
-**Priority:** Medium (3)
-
-Super should be called at the start of the method
-
-```
-//MethodDeclaration[MethodDeclarator[
- @Image='onCreate' or
- @Image='onConfigurationChanged' or
- @Image='onPostCreate' or
- @Image='onPostResume' or
- @Image='onRestart' or
- @Image='onRestoreInstanceState' or
- @Image='onResume' or
- @Image='onStart'
- ]]
- /Block[not(
- (BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier='true']]/PrimarySuffix[@Image= ancestor::MethodDeclaration/MethodDeclarator/@Image]))]
-[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
- typeof(@Image, 'android.app.Activity', 'Activity') or
- typeof(@Image, 'android.app.Application', 'Application') or
- typeof(@Image, 'android.app.Service', 'Service')
-]]]
-```
-
-**Example(s):**
-
-``` java
-public class DummyActivity extends Activity {
- public void onCreate(Bundle bundle) {
- // missing call to super.onCreate(bundle)
- foo();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CallSuperLast
-
-**Since:** PMD 4.2.5
-
-**Priority:** Medium (3)
-
-Super should be called at the end of the method
-
-```
-//MethodDeclaration[MethodDeclarator[
- @Image='finish' or
- @Image='onDestroy' or
- @Image='onPause' or
- @Image='onSaveInstanceState' or
- @Image='onStop' or
- @Image='onTerminate'
- ]]
- /Block/BlockStatement[last()]
- [not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier='true']]/PrimarySuffix[@Image= ancestor::MethodDeclaration/MethodDeclarator/@Image])]
-[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
- typeof(@Image, 'android.app.Activity', 'Activity') or
- typeof(@Image, 'android.app.Application', 'Application') or
- typeof(@Image, 'android.app.Service', 'Service')
-]]]
-```
-
-**Example(s):**
-
-``` java
-public class DummyActivity extends Activity {
- public void onPause() {
- foo();
- // missing call to super.onPause()
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DoNotHardCodeSDCard
-
-**Since:** PMD 4.2.6
-
-**Priority:** Medium (3)
-
-Use Environment.getExternalStorageDirectory() instead of "/sdcard"
-
-```
-//Literal[starts-with(@Image,'"/sdcard')]
-```
-
-**Example(s):**
-
-``` java
-public class MyActivity extends Activity {
- protected void foo() {
- String storageLocation = "/sdcard/mypackage"; // hard-coded, poor approach
-
- storageLocation = Environment.getExternalStorageDirectory() + "/mypackage"; // preferred approach
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/basic.md b/docs/pages/pmd/rules/java/basic.md
deleted file mode 100644
index 6399d7a262b..00000000000
--- a/docs/pages/pmd/rules/java/basic.md
+++ /dev/null
@@ -1,871 +0,0 @@
----
-title: Basic
-summary: The Basic ruleset contains a collection of good practices which should be followed.
-permalink: pmd_rules_java_basic.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/basic.xml
-keywords: Basic, JumbledIncrementer, ForLoopShouldBeWhileLoop, OverrideBothEqualsAndHashcode, DoubleCheckedLocking, ReturnFromFinallyBlock, UnconditionalIfStatement, BooleanInstantiation, CollapsibleIfStatements, ClassCastExceptionWithToArray, AvoidDecimalLiteralsInBigDecimalConstructor, MisplacedNullCheck, AvoidThreadGroup, BrokenNullCheck, BigIntegerInstantiation, AvoidUsingOctalValues, AvoidUsingHardCodedIP, CheckResultSet, AvoidMultipleUnaryOperators, ExtendsObject, CheckSkipResult, AvoidBranchingStatementAsLastInLoop, DontCallThreadRun, DontUseFloatTypeForLoopIndices, SimplifiedTernary
----
-## AvoidBranchingStatementAsLastInLoop
-
-**Since:** PMD 5.0
-
-**Priority:** Medium High (2)
-
-Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
-Ensure that the usage is not a bug, or consider using another approach.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.AvoidBranchingStatementAsLastInLoopRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/AvoidBranchingStatementAsLastInLoopRule.java)
-
-**Example(s):**
-
-``` java
-// unusual use of branching statement in a loop
-for (int i = 0; i < 10; i++) {
- if (i*i <= 25) {
- continue;
- }
- break;
-}
-
- // this makes more sense...
-for (int i = 0; i < 10; i++) {
- if (i*i > 25) {
- break;
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|checkReturnLoopTypes|[for, do, while]|Check for return statements in loop types|
-|checkContinueLoopTypes|[for, do, while]|Check for continue statements in loop types|
-|checkBreakLoopTypes|[for, do, while]|Check for break statements in loop types|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidDecimalLiteralsInBigDecimalConstructor
-
-**Since:** PMD 3.4
-
-**Priority:** Medium (3)
-
-One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
-equal to .1000000000000000055511151231257827021181583404541015625.
-This is because 0.1 cannot be represented exactly as a double (or 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 0.1,
-appearances notwithstanding.
-
-The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal("0.1")' is
-exactly equal to 0.1, as one would expect. Therefore, it is generally recommended that the
-(String) constructor be used in preference to this one.
-
-```
-//AllocationExpression
-[ClassOrInterfaceType[@Image="BigDecimal"]]
-[Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix
- [
- Literal[(not(ends-with(@Image,'"'))) and contains(@Image,".")]
- or
- Name[ancestor::Block/BlockStatement/LocalVariableDeclaration
- [Type[PrimitiveType[@Image='double' or @Image='float']
- or ReferenceType/ClassOrInterfaceType[@Image='Double' or @Image='Float']]]
- /VariableDeclarator/VariableDeclaratorId/@Image = @Image
- ]
- or
- Name[ancestor::MethodDeclaration/MethodDeclarator/FormalParameters/FormalParameter
- [Type[PrimitiveType[@Image='double' or @Image='float']
- or ReferenceType/ClassOrInterfaceType[@Image='Double' or @Image='Float']]]
- /VariableDeclaratorId/@Image = @Image
- ]
- ]
-]
-```
-
-**Example(s):**
-
-``` java
-BigDecimal bd = new BigDecimal(1.123); // loss of precision, this would trigger the rule
-
-BigDecimal bd = new BigDecimal("1.123"); // preferred approach
-
-BigDecimal bd = new BigDecimal(12); // preferred approach, ok for integer values
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidMultipleUnaryOperators
-
-**Since:** PMD 4.2
-
-**Priority:** Medium High (2)
-
-The use of multiple unary operators may be problematic, and/or confusing.
-Ensure that the intended usage is not a bug, or consider simplifying the expression.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.AvoidMultipleUnaryOperatorsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/AvoidMultipleUnaryOperatorsRule.java)
-
-**Example(s):**
-
-``` java
-// These are typo bugs, or at best needlessly complex and confusing:
-int i = - -1;
-int j = + - +1;
-int z = ~~2;
-boolean b = !!true;
-boolean c = !!!true;
-
-// These are better:
-int i = 1;
-int j = -1;
-int z = 2;
-boolean b = true;
-boolean c = false;
-
-// And these just make your brain hurt:
-int i = ~-2;
-int j = -~7;
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidThreadGroup
-
-**Since:** PMD 3.6
-
-**Priority:** Medium (3)
-
-Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environment
-it contains methods that are not thread-safe.
-
-```
-//AllocationExpression/ClassOrInterfaceType[pmd-java:typeof(@Image, 'java.lang.ThreadGroup')]|
-//PrimarySuffix[contains(@Image, 'getThreadGroup')]
-```
-
-**Example(s):**
-
-``` java
-public class Bar {
- void buz() {
- ThreadGroup tg = new ThreadGroup("My threadgroup");
- tg = new ThreadGroup(tg, "my thread group");
- tg = Thread.currentThread().getThreadGroup();
- tg = System.getSecurityManager().getThreadGroup();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidUsingHardCodedIP
-
-**Since:** PMD 4.1
-
-**Priority:** Medium (3)
-
-Application with hard-coded IP addresses can become impossible to deploy in some cases.
-Externalizing IP adresses is preferable.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.AvoidUsingHardCodedIPRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/AvoidUsingHardCodedIPRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- private String ip = "127.0.0.1"; // not recommended
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|checkAddressTypes|[IPv4, IPv6, IPv4 mapped IPv6]|Check for IP address types.|
-|pattern|^"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"$|Regular Expression|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidUsingOctalValues
-
-**Since:** PMD 3.9
-
-**Priority:** Medium (3)
-
-Integer literals should not start with zero since this denotes that the rest of literal will be
-interpreted as an octal value.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.AvoidUsingOctalValuesRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/AvoidUsingOctalValuesRule.java)
-
-**Example(s):**
-
-``` java
-int i = 012; // set i with 10 not 12
-int j = 010; // set j with 8 not 10
-k = i * j; // set k with 80 not 120
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|strict|false|Detect violations between 00 and 07|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## BigIntegerInstantiation
-
-**Since:** PMD 3.9
-
-**Priority:** Medium (3)
-
-Don't create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) and
-for Java 1.5 onwards, BigInteger.TEN and BigDecimal (BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN)
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.BigIntegerInstantiationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/BigIntegerInstantiationRule.java)
-
-**Example(s):**
-
-``` java
-BigInteger bi = new BigInteger(1); // reference BigInteger.ONE instead
-BigInteger bi2 = new BigInteger("0"); // reference BigInteger.ZERO instead
-BigInteger bi3 = new BigInteger(0.0); // reference BigInteger.ZERO instead
-BigInteger bi4;
-bi4 = new BigInteger(0); // reference BigInteger.ZERO instead
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## BooleanInstantiation
-
-**Since:** PMD 1.2
-
-**Priority:** Medium High (2)
-
-Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boolean.valueOf() instead.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.BooleanInstantiationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/BooleanInstantiationRule.java)
-
-**Example(s):**
-
-``` java
-Boolean bar = new Boolean("true"); // unnecessary creation, just reference Boolean.TRUE;
-Boolean buz = Boolean.valueOf(false); // ...., just reference Boolean.FALSE;
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## BrokenNullCheck
-
-**Since:** PMD 3.8
-
-**Priority:** Medium High (2)
-
-The null check is broken since it will throw a NullPointerException itself.
-It is likely that you used || instead of && or vice versa.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.BrokenNullCheckRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/BrokenNullCheckRule.java)
-
-**Example(s):**
-
-``` java
-public String bar(String string) {
- // should be &&
- if (string!=null || !string.equals(""))
- return string;
- // should be ||
- if (string==null && string.equals(""))
- return string;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CheckResultSet
-
-**Since:** PMD 4.1
-
-**Priority:** Medium (3)
-
-Always check the return values of navigation methods (next, previous, first, last) of a ResultSet.
-If the value return is 'false', it should be handled properly.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.CheckResultSetRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/CheckResultSetRule.java)
-
-**Example(s):**
-
-``` java
-Statement stat = conn.createStatement();
-ResultSet rst = stat.executeQuery("SELECT name FROM person");
-rst.next(); // what if it returns false? bad form
-String firstName = rst.getString(1);
-
-Statement stat = conn.createStatement();
-ResultSet rst = stat.executeQuery("SELECT name FROM person");
-if (rst.next()) { // result is properly examined and used
- String firstName = rst.getString(1);
- } else {
- // handle missing data
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CheckSkipResult
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-The skip() method may skip a smaller number of bytes than requested. Check the returned value to find out if it was the case or not.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.CheckSkipResultRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/CheckSkipResultRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
-
- private FileInputStream _s = new FileInputStream("file");
-
- public void skip(int n) throws IOException {
- _s.skip(n); // You are not sure that exactly n bytes are skipped
- }
-
- public void skipExactly(int n) throws IOException {
- while (n != 0) {
- long skipped = _s.skip(n);
- if (skipped == 0)
- throw new EOFException();
- n -= skipped;
- }
- }
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ClassCastExceptionWithToArray
-
-**Since:** PMD 3.4
-
-**Priority:** Medium (3)
-
-When deriving an array of a specific class from your Collection, one should provide an array of
-the same class as the parameter of the toArray() method. Doing otherwise you will will result
-in a ClassCastException.
-
-```
-//CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image !=
-"Object"]]/PrimaryExpression
-[
- PrimaryPrefix/Name[ends-with(@Image, '.toArray')]
- and
- PrimarySuffix/Arguments[count(*) = 0]
-and
-count(PrimarySuffix) = 1
-]
-```
-
-**Example(s):**
-
-``` java
-Collection c = new ArrayList();
-Integer obj = new Integer(1);
-c.add(obj);
-
- // this would trigger the rule (and throw a ClassCastException if executed)
-Integer[] a = (Integer [])c.toArray();
-
- // this is fine and will not trigger the rule
-Integer[] b = (Integer [])c.toArray(new Integer[c.size()]);
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CollapsibleIfStatements
-
-**Since:** PMD 3.1
-
-**Priority:** Medium (3)
-
-Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
-
-```
-//IfStatement[@Else='false']/Statement
- /IfStatement[@Else='false']
- |
-//IfStatement[@Else='false']/Statement
- /Block[count(BlockStatement)=1]/BlockStatement
- /Statement/IfStatement[@Else='false']
-```
-
-**Example(s):**
-
-``` java
-void bar() {
- if (x) { // original implementation
- if (y) {
- // do stuff
- }
- }
-}
-
-void bar() {
- if (x && y) { // optimized implementation
- // do stuff
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DontCallThreadRun
-
-**Since:** PMD 4.3
-
-**Priority:** Medium Low (4)
-
-Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior.
-
-```
-//StatementExpression/PrimaryExpression
-[
- PrimaryPrefix
- [
- ./Name[ends-with(@Image, '.run') or @Image = 'run']
- and substring-before(Name/@Image, '.') =//VariableDeclarator/VariableDeclaratorId/@Image
- [../../../Type/ReferenceType/ClassOrInterfaceType[typeof(@Image, 'java.lang.Thread', 'Thread')]]
- or (./AllocationExpression/ClassOrInterfaceType[typeof(@Image, 'java.lang.Thread', 'Thread')]
- and ../PrimarySuffix[@Image = 'run'])
- ]
-]
-```
-
-**Example(s):**
-
-``` java
-Thread t = new Thread();
-t.run(); // use t.start() instead
-new Thread().run(); // same violation
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DontUseFloatTypeForLoopIndices
-
-**Since:** PMD 4.3
-
-**Priority:** Medium (3)
-
-Don't use floating point for loop indices. If you must use floating point, use double
-unless you're certain that float provides enough precision and you have a compelling
-performance need (space or time).
-
-```
-//ForStatement/ForInit/LocalVariableDeclaration
-/Type/PrimitiveType[@Image="float"]
-```
-
-**Example(s):**
-
-``` java
-public class Count {
- public static void main(String[] args) {
- final int START = 2000000000;
- int count = 0;
- for (float f = START; f < START + 50; f++)
- count++;
- //Prints 0 because (float) START == (float) (START + 50).
- System.out.println(count);
- //The termination test misbehaves due to floating point granularity.
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DoubleCheckedLocking
-
-**Since:** PMD 1.04
-
-**Priority:** High (1)
-
-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 calls the constructor of the object the
-reference points to.
-
-Note: With Java 5, you can make Double checked locking work, if you declare the variable to be `volatile`.
-
-For more details refer to:
-or
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.DoubleCheckedLockingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/DoubleCheckedLockingRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- /*volatile */ Object baz = null; // fix for Java5 and later: volatile
- Object bar() {
- if (baz == null) { // baz may be non-null yet not fully created
- synchronized(this) {
- if (baz == null) {
- baz = new Object();
- }
- }
- }
- return baz;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExtendsObject
-
-**Since:** PMD 5.0
-
-**Priority:** Medium Low (4)
-
-No need to explicitly extend Object.
-
-```
-//ExtendsList/ClassOrInterfaceType[@Image='Object' or @Image='java.lang.Object']
-```
-
-**Example(s):**
-
-``` java
-public class Foo extends Object { // not required
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ForLoopShouldBeWhileLoop
-
-**Since:** PMD 1.02
-
-**Priority:** Medium (3)
-
-Some for loops can be simplified to while loops, this makes them more concise.
-
-```
-//ForStatement
- [count(*) > 1]
- [not(LocalVariableDeclaration)]
- [not(ForInit)]
- [not(ForUpdate)]
- [not(Type and Expression and Statement)]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- void bar() {
- for (;true;) true; // No Init or Update part, may as well be: while (true)
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JumbledIncrementer
-
-**Since:** PMD 1.0
-
-**Priority:** Medium (3)
-
-Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
-
-```
-//ForStatement
- [
- ForUpdate/StatementExpressionList/StatementExpression/PostfixExpression/PrimaryExpression/PrimaryPrefix/Name/@Image
- =
- ancestor::ForStatement/ForInit//VariableDeclaratorId/@Image
- ]
-```
-
-**Example(s):**
-
-``` java
-public class JumbledIncrementerRule1 {
- public void foo() {
- for (int i = 0; i < 10; i++) { // only references 'i'
- for (int k = 0; k < 20; i++) { // references both 'i' and 'k'
- System.out.println("Hello");
- }
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MisplacedNullCheck
-
-**Since:** PMD 3.5
-
-**Priority:** Medium (3)
-
-The null check here is misplaced. If the variable is null a NullPointerException will be thrown.
-Either the check is useless (the variable will never be "null") or it is incorrect.
-
-```
-//Expression
- /*[self::ConditionalOrExpression or self::ConditionalAndExpression]
- /descendant::PrimaryExpression/PrimaryPrefix
- /Name[starts-with(@Image,
- concat(ancestor::PrimaryExpression/following-sibling::EqualityExpression
- [./PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
- /PrimaryExpression/PrimaryPrefix
- /Name[count(../../PrimarySuffix)=0]/@Image,".")
- )
- ]
- [count(ancestor::ConditionalAndExpression/EqualityExpression
- [@Image='!=']
- [./PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
- [starts-with(following-sibling::*/PrimaryExpression/PrimaryPrefix/Name/@Image,
- concat(./PrimaryExpression/PrimaryPrefix/Name/@Image, '.'))]
- ) = 0
- ]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- void bar() {
- if (a.equals(baz) && a != null) {}
- }
-}
-```
-
-``` java
-public class Foo {
- void bar() {
- if (a.equals(baz) || a == null) {}
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## OverrideBothEqualsAndHashcode
-
-**Since:** PMD 0.4
-
-**Priority:** Medium (3)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.basic.OverrideBothEqualsAndHashcodeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/basic/OverrideBothEqualsAndHashcodeRule.java)
-
-**Example(s):**
-
-``` java
-public class Bar { // poor, missing a hashcode() method
- public boolean equals(Object o) {
- // do some comparison
- }
-}
-
-public class Baz { // poor, missing an equals() method
- public int hashCode() {
- // return some hash value
- }
-}
-
-public class Foo { // perfect, both methods provided
- public boolean equals(Object other) {
- // do some comparison
- }
- public int hashCode() {
- // return some hash value
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ReturnFromFinallyBlock
-
-**Since:** PMD 1.05
-
-**Priority:** Medium (3)
-
-Avoid returning from a finally block, this can discard exceptions.
-
-```
-//FinallyStatement//ReturnStatement
-```
-
-**Example(s):**
-
-``` java
-public class Bar {
- public String foo() {
- try {
- throw new Exception( "My Exception" );
- } catch (Exception e) {
- throw e;
- } finally {
- return "A. O. K."; // return not recommended here
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SimplifiedTernary
-
-**Since:** PMD 5.4.0
-
-**Priority:** Medium (3)
-
-Look for ternary operators with the form `condition ? literalBoolean : foo`
-or `condition ? foo : literalBoolean`.
-
-These expressions can be simplified respectively to
-`condition || foo` when the literalBoolean is true
-`!condition && foo` when the literalBoolean is false
-or
-`!condition || foo` when the literalBoolean is true
-`condition && foo` when the literalBoolean is false
-
-```
-//ConditionalExpression[@Ternary='true'][not(PrimaryExpression/*/Literal) and (Expression/PrimaryExpression/*/Literal/BooleanLiteral)]
-|
-//ConditionalExpression[@Ternary='true'][not(Expression/PrimaryExpression/*/Literal) and (PrimaryExpression/*/Literal/BooleanLiteral)]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public boolean test() {
- return condition ? true : something(); // can be as simple as return condition || something();
- }
-
- public void test2() {
- final boolean value = condition ? false : something(); // can be as simple as value = !condition && something();
- }
-
- public boolean test3() {
- return condition ? something() : true; // can be as simple as return !condition || something();
- }
-
- public void test4() {
- final boolean otherValue = condition ? something() : false; // can be as simple as condition && something();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnconditionalIfStatement
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-Do not use "if" statements whose conditionals are always true or always false.
-
-```
-//IfStatement/Expression
- [count(PrimaryExpression)=1]
- /PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void close() {
- if (true) { // fixed conditional, not recommended
- // ...
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/bestpractices.md b/docs/pages/pmd/rules/java/bestpractices.md
new file mode 100644
index 00000000000..4c46a7a429a
--- /dev/null
+++ b/docs/pages/pmd/rules/java/bestpractices.md
@@ -0,0 +1,1594 @@
+---
+title: Best Practices
+summary: Rules which enforce generally accepted best practices.
+permalink: pmd_rules_java_bestpractices.html
+folder: pmd/rules/java
+sidebaractiveurl: /pmd_rules_java.html
+editmepath: ../pmd-java/src/main/resources/category/java/bestpractices.xml
+keywords: Best Practices, AbstractClassWithoutAbstractMethod, AccessorClassGeneration, AccessorMethodGeneration, ArrayIsStoredDirectly, AvoidPrintStackTrace, AvoidReassigningParameters, AvoidStringBufferField, AvoidUsingHardCodedIP, CheckResultSet, ConstantsInInterface, DefaultLabelNotLastInSwitchStmt, ForLoopCanBeForeach, GuardLogStatement, JUnit4SuitesShouldUseSuiteAnnotation, JUnit4TestShouldUseAfterAnnotation, JUnit4TestShouldUseBeforeAnnotation, JUnit4TestShouldUseTestAnnotation, JUnitAssertionsShouldIncludeMessage, JUnitTestContainsTooManyAsserts, JUnitTestsShouldIncludeAssert, JUnitUseExpected, LooseCoupling, MethodReturnsInternalArray, MissingOverride, OneDeclarationPerLine, PositionLiteralsFirstInCaseInsensitiveComparisons, PositionLiteralsFirstInComparisons, PreserveStackTrace, ReplaceEnumerationWithIterator, ReplaceHashtableWithMap, ReplaceVectorWithList, SwitchStmtsShouldHaveDefault, SystemPrintln, UnusedFormalParameter, UnusedImports, UnusedLocalVariable, UnusedPrivateField, UnusedPrivateMethod, UseAssertEqualsInsteadOfAssertTrue, UseAssertNullInsteadOfAssertTrue, UseAssertSameInsteadOfAssertTrue, UseAssertTrueInsteadOfAssertEquals, UseCollectionIsEmpty, UseVarargs
+language: Java
+---
+## AbstractClassWithoutAbstractMethod
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+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
+directly) a protected constructor can be provided prevent direct instantiation.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration
+ [@Abstract='true'
+ and count( .//MethodDeclaration[@Abstract='true'] )=0 ]
+ [count(ImplementsList)=0]
+ [count(.//ExtendsList)=0]
+```
+
+**Example(s):**
+
+``` java
+public abstract class Foo {
+ void int method1() { ... }
+ void int method2() { ... }
+ // consider using abstract methods or removing
+ // the abstract modifier and adding protected constructors
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AccessorClassGeneration
+
+**Since:** PMD 1.04
+
+**Priority:** Medium (3)
+
+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-privatization 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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.AccessorClassGenerationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorClassGenerationRule.java)
+
+**Example(s):**
+
+``` java
+public class Outer {
+ void method(){
+ Inner ic = new Inner();//Causes generation of accessor class
+ }
+ public class Inner {
+ private Inner(){}
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AccessorMethodGeneration
+
+**Since:** PMD 5.5.4
+
+**Priority:** Medium (3)
+
+When accessing a private field / method from another class, the Java compiler will generate a accessor methods
+with package-private visibility. This adds overhead, and to the dex method count on Android. This situation can
+be avoided by changing the visibility of the field / method from private to package-private.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.AccessorMethodGenerationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorMethodGenerationRule.java)
+
+**Example(s):**
+
+``` java
+public class OuterClass {
+ private int counter;
+ /* package */ int id;
+
+ public class InnerClass {
+ InnerClass() {
+ OuterClass.this.counter++; // wrong accessor method will be generated
+ }
+
+ public int getOuterClassId() {
+ return OuterClass.this.id; // id is package-private, no accessor method needed
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ArrayIsStoredDirectly
+
+**Since:** PMD 2.2
+
+**Priority:** Medium (3)
+
+Constructors and methods receiving arrays should clone objects and store the copy.
+This prevents future changes from the user from affecting the original array.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.ArrayIsStoredDirectlyRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ArrayIsStoredDirectlyRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private String [] x;
+ public void foo (String [] param) {
+ // Don't do this, make a copy of the array at least
+ this.x=param;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidPrintStackTrace
+
+**Since:** PMD 3.2
+
+**Priority:** Medium (3)
+
+Avoid printStackTrace(); use a logger call instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression
+ [PrimaryPrefix/Name[contains(@Image,'printStackTrace')]]
+ [PrimarySuffix[not(boolean(Arguments/ArgumentList/Expression))]]
+```
+
+**Example(s):**
+
+``` java
+class Foo {
+ void bar() {
+ try {
+ // do something
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidReassigningParameters
+
+**Since:** PMD 1.0
+
+**Priority:** Medium High (2)
+
+Reassigning values to incoming parameters is not recommended. Use temporary local variables instead.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningParametersRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidReassigningParametersRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private void foo(String bar) {
+ bar = "something else";
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidStringBufferField
+
+**Since:** PMD 4.2
+
+**Priority:** Medium (3)
+
+StringBuffers/StringBuilders can grow considerably, and so may become a source of memory leaks
+if held within objects with long lifetimes.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//FieldDeclaration/Type/ReferenceType/ClassOrInterfaceType[@Image = 'StringBuffer' or @Image = 'StringBuilder']
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private StringBuffer buffer; // potential memory leak as an instance variable;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidUsingHardCodedIP
+
+**Since:** PMD 4.1
+
+**Priority:** Medium (3)
+
+Application with hard-coded IP addresses can become impossible to deploy in some cases.
+Externalizing IP adresses is preferable.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidUsingHardCodedIPRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private String ip = "127.0.0.1"; // not recommended
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|checkAddressTypes|IPv4 \| IPv6 \| IPv4 mapped IPv6|Check for IP address types.|yes. Delimiter is '\|'.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CheckResultSet
+
+**Since:** PMD 4.1
+
+**Priority:** Medium (3)
+
+Always check the return values of navigation methods (next, previous, first, last) of a ResultSet.
+If the value return is 'false', it should be handled properly.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.CheckResultSetRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/CheckResultSetRule.java)
+
+**Example(s):**
+
+``` java
+Statement stat = conn.createStatement();
+ResultSet rst = stat.executeQuery("SELECT name FROM person");
+rst.next(); // what if it returns false? bad form
+String firstName = rst.getString(1);
+
+Statement stat = conn.createStatement();
+ResultSet rst = stat.executeQuery("SELECT name FROM person");
+if (rst.next()) { // result is properly examined and used
+ String firstName = rst.getString(1);
+ } else {
+ // handle missing data
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ConstantsInInterface
+
+**Since:** PMD 5.5
+
+**Priority:** Medium (3)
+
+Avoid constants in interfaces. Interfaces should define types, constants are implementation details
+better placed in classes or enums. See Effective Java, item 19.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[@Interface='true'][$ignoreIfHasMethods='false' or not(.//MethodDeclaration)]//FieldDeclaration
+```
+
+**Example(s):**
+
+``` java
+public interface ConstantInterface {
+ public static final int CONST1 = 1; // violation, no fields allowed in interface!
+ static final int CONST2 = 1; // violation, no fields allowed in interface!
+ final int CONST3 = 1; // violation, no fields allowed in interface!
+ int CONST4 = 1; // violation, no fields allowed in interface!
+}
+
+// with ignoreIfHasMethods = false
+public interface AnotherConstantInterface {
+ public static final int CONST1 = 1; // violation, no fields allowed in interface!
+
+ int anyMethod();
+}
+
+// with ignoreIfHasMethods = true
+public interface YetAnotherConstantInterface {
+ public static final int CONST1 = 1; // no violation
+
+ int anyMethod();
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoreIfHasMethods|true|Whether to ignore constants in interfaces if the interface defines any methods|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DefaultLabelNotLastInSwitchStmt
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+By convention, the default label should be the last label in a switch statement.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//SwitchStatement
+ [not(SwitchLabel[position() = last()][@Default='true'])]
+ [SwitchLabel[@Default='true']]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void bar(int a) {
+ switch (a) {
+ case 1: // do something
+ break;
+ default: // the default case should be last, by convention
+ break;
+ case 2:
+ break;
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ForLoopCanBeForeach
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+**Minimum Language Version:** Java 1.5
+
+Reports loops that can be safely replaced with the foreach syntax. The rule considers loops over
+lists, arrays and iterators. A loop is safe to replace if it only uses the index variable to
+access an element of the list or array, only has one update statement, and loops through *every*
+element of the list or array left to right.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.ForLoopCanBeForeachRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ForLoopCanBeForeachRule.java)
+
+**Example(s):**
+
+``` java
+public class MyClass {
+ void loop(List l) {
+ for (int i = 0; i < l.size(); i++) { // pre Java 1.5
+ System.out.println(l.get(i));
+ }
+
+ for (String s : l) { // post Java 1.5
+ System.out.println(s);
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## GuardLogStatement
+
+**Since:** PMD 5.1.0
+
+**Priority:** Medium High (2)
+
+Whenever using a log level, one should check if the loglevel is actually enabled, or
+otherwise skip the associate String creation and manipulation.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.GuardLogStatementRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/GuardLogStatementRule.java)
+
+**Example(s):**
+
+``` java
+// Add this for performance
+ if (log.isDebugEnabled() { ...
+ log.debug("log something" + " and " + "concat strings");
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|guardsMethods|isTraceEnabled , isDebugEnabled , isInfoEnabled , isWarnEnabled , isErrorEnabled , isLoggable|method use to guard the log statement|yes. Delimiter is ','.|
+|logLevels|trace , debug , info , warn , error , log , finest , finer , fine , info , warning , severe|LogLevels to guard|yes. Delimiter is ','.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnit4SuitesShouldUseSuiteAnnotation
+
+**Since:** PMD 4.0
+
+**Priority:** Medium (3)
+
+In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicated
+through the @RunWith(Suite.class) annotation.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceBodyDeclaration[MethodDeclaration/MethodDeclarator[@Image='suite']]
+[MethodDeclaration/ResultType/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.Test')]]
+[not(MethodDeclaration/Block//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.JUnit4TestAdapter')])]
+```
+
+**Example(s):**
+
+``` java
+public class BadExample extends TestCase{
+
+ public static Test suite(){
+ return new Suite();
+ }
+}
+
+@RunWith(Suite.class)
+@SuiteClasses( { TestOne.class, TestTwo.class })
+public class GoodTest {
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnit4TestShouldUseAfterAnnotation
+
+**Since:** PMD 4.0
+
+**Priority:** Medium (3)
+
+In JUnit 3, the tearDown method was used to clean up all data entities required in running tests.
+JUnit 4 skips the tearDown method and executes all methods annotated with @After after running each test.
+JUnit 5 introduced @AfterEach and @AfterAll annotations to execute methods after each test or after all tests in the class, respectively.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceBodyDeclaration
+ [MethodDeclaration/MethodDeclarator[@Image='tearDown']]
+ [count(Annotation//Name[
+ pmd-java:typeIs('org.junit.After')
+ or pmd-java:typeIs('org.junit.jupiter.api.AfterEach')
+ or pmd-java:typeIs('org.junit.jupiter.api.AfterAll')
+ or pmd-java:typeIs('org.testng.annotations.AfterMethod')])=0]
+```
+
+**Example(s):**
+
+``` java
+public class MyTest {
+ public void tearDown() {
+ bad();
+ }
+}
+public class MyTest2 {
+ @After public void tearDown() {
+ good();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnit4TestShouldUseBeforeAnnotation
+
+**Since:** PMD 4.0
+
+**Priority:** Medium (3)
+
+In JUnit 3, the setUp method was used to set up all data entities required in running tests.
+JUnit 4 skips the setUp method and executes all methods annotated with @Before before all tests.
+JUnit 5 introduced @BeforeEach and @BeforeAll annotations to execute methods before each test or before all tests in the class, respectively.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceBodyDeclaration
+ [MethodDeclaration/MethodDeclarator[@Image='setUp']]
+ [count(Annotation//Name[
+ pmd-java:typeIs('org.junit.Before')
+ or pmd-java:typeIs('org.junit.jupiter.api.BeforeEach')
+ or pmd-java:typeIs('org.junit.jupiter.api.BeforeAll')
+ or pmd-java:typeIs('org.testng.annotations.BeforeMethod')])=0]
+```
+
+**Example(s):**
+
+``` java
+public class MyTest {
+ public void setUp() {
+ bad();
+ }
+}
+public class MyTest2 {
+ @Before public void setUp() {
+ good();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnit4TestShouldUseTestAnnotation
+
+**Since:** PMD 4.0
+
+**Priority:** Medium (3)
+
+In JUnit 3, the framework executed all methods which started with the word test as a unit test.
+In JUnit 4, only methods annotated with the @Test annotation are executed.
+In JUnit 5, one of the following annotations should be used for tests: @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[
+ matches(@Image, $testClassPattern)
+ or ExtendsList/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]]
+
+ /ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[MethodDeclaration[@Public=true()]/MethodDeclarator[starts-with(@Image, 'test')]]
+ [not(Annotation//Name[
+ pmd-java:typeIs('org.junit.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+ or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+ ])]
+```
+
+**Example(s):**
+
+``` java
+public class MyTest {
+ public void testBad() {
+ doSomething();
+ }
+
+ @Test
+ public void testGood() {
+ doSomething();
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|testClassPattern|Test|The regex pattern used to identify test classes|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnitAssertionsShouldIncludeMessage
+
+**Since:** PMD 1.04
+
+**Priority:** Medium (3)
+
+JUnit assertions should include an informative message - i.e., use the three-argument version of
+assertEquals(), not the two-argument version.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitAssertionsShouldIncludeMessageRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitAssertionsShouldIncludeMessageRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo extends TestCase {
+ public void testSomething() {
+ assertEquals("foo", "bar");
+ // Use the form:
+ // assertEquals("Foo does not equals bar", "foo", "bar");
+ // instead
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnitTestContainsTooManyAsserts
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Unit tests should not contain too many asserts. Many asserts are indicative of a complex test, for which
+it is harder to verify correctness. Consider breaking the test scenario into multiple, shorter test scenarios.
+Customize the maximum number of assertions used by this Rule to suit your needs.
+
+This rule checks for JUnit4, JUnit5 and TestNG Tests, as well as methods starting with "test".
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclarator[@Image[fn:matches(.,'^test')] or ../../Annotation/MarkerAnnotation/Name[
+ pmd-java:typeIs('org.junit.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestFactory')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+ or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+ or pmd-java:typeIs('org.testng.annotations.Test')
+ ]]
+ [count(..//PrimaryPrefix/Name[@Image[fn:matches(.,'^assert')]]) > $maximumAsserts]
+```
+
+**Example(s):**
+
+``` java
+public class MyTestCase extends TestCase {
+ // Ok
+ public void testMyCaseWithOneAssert() {
+ boolean myVar = false;
+ assertFalse("should be false", myVar);
+ }
+
+ // Bad, too many asserts (assuming max=1)
+ public void testMyCaseWithMoreAsserts() {
+ boolean myVar = false;
+ assertFalse("myVar should be false", myVar);
+ assertEquals("should equals false", false, myVar);
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|maximumAsserts|1|Maximum number of Asserts in a test method|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnitTestsShouldIncludeAssert
+
+**Since:** PMD 2.0
+
+**Priority:** Medium (3)
+
+JUnit tests should include at least one assertion. This makes the tests more robust, and using assert
+with messages provide the developer a clearer idea of what the test does.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitTestsShouldIncludeAssertRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitTestsShouldIncludeAssertRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo extends TestCase {
+ public void testSomething() {
+ Bar b = findBar();
+ // This is better than having a NullPointerException
+ // assertNotNull("bar not found", b);
+ b.work();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnitUseExpected
+
+**Since:** PMD 4.0
+
+**Priority:** Medium (3)
+
+In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitUseExpectedRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitUseExpectedRule.java)
+
+**Example(s):**
+
+``` java
+public class MyTest {
+ @Test
+ public void testBad() {
+ try {
+ doSomething();
+ fail("should have thrown an exception");
+ } catch (Exception e) {
+ }
+ }
+
+ @Test(expected=Exception.class)
+ public void testGood() {
+ doSomething();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## LooseCoupling
+
+**Since:** PMD 0.7
+
+**Priority:** Medium (3)
+
+The use of implementation types (i.e., HashSet) as object references limits your ability to use alternate
+implementations in the future as requirements change. Whenever available, referencing objects
+by their interface types (i.e, Set) provides much more flexibility.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.LooseCouplingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/LooseCouplingRule.java)
+
+**Example(s):**
+
+``` java
+import java.util.ArrayList;
+import java.util.HashSet;
+
+public class Bar {
+ // sub-optimal approach
+ private ArrayList list = new ArrayList<>();
+
+ public HashSet getFoo() {
+ return new HashSet();
+ }
+
+ // preferred approach
+ private List list = new ArrayList<>();
+
+ public Set getFoo() {
+ return new HashSet();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MethodReturnsInternalArray
+
+**Since:** PMD 2.2
+
+**Priority:** Medium (3)
+
+Exposing internal arrays to the caller violates object encapsulation since elements can be
+removed or replaced outside of the object that owns it. It is safer to return a copy of the array.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.MethodReturnsInternalArrayRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/MethodReturnsInternalArrayRule.java)
+
+**Example(s):**
+
+``` java
+public class SecureSystem {
+ UserData [] ud;
+ public UserData [] getUserData() {
+ // Don't return directly the internal array, return a copy
+ return ud;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MissingOverride
+
+**Since:** PMD 6.2.0
+
+**Priority:** Medium (3)
+
+**Minimum Language Version:** Java 1.5
+
+Annotating overridden methods with @Override ensures at compile time that
+the method really overrides one, which helps refactoring and clarifies intent.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/MissingOverrideRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo implements Runnable {
+ // This method is overridden, and should have an @Override annotation
+ public void run() {
+
+ }
+ }
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## OneDeclarationPerLine
+
+**Since:** PMD 5.0
+
+**Priority:** Medium Low (4)
+
+Java allows the use of several variables declaration of the same type on one line. However, it
+can lead to quite messy code. This rule looks for several declarations on the same line.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//LocalVariableDeclaration
+ [count(VariableDeclarator) > 1]
+ [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)]
+|
+//FieldDeclaration
+ [count(VariableDeclarator) > 1]
+ [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)]
+```
+
+**Example(s):**
+
+``` java
+String name; // separate declarations
+String lastname;
+
+String name, lastname; // combined declaration, a violation
+
+String name,
+ lastname; // combined declaration on multiple lines, no violation by default.
+ // Set property strictMode to true to mark this as violation.
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|strictMode|false|If true, mark combined declaration even if the declarations are on separate lines.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## PositionLiteralsFirstInCaseInsensitiveComparisons
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Position literals first in comparisons, if the second argument is null then NullPointerExceptions
+can be avoided, they will just return false.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression[
+ PrimaryPrefix[Name
+ [
+ (ends-with(@Image, '.equalsIgnoreCase'))
+ ]
+ ]
+ [
+ (../PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Literal)
+ and
+ ( count(../PrimarySuffix/Arguments/ArgumentList/Expression) = 1 )
+ ]
+]
+[not(ancestor::Expression/ConditionalAndExpression//EqualityExpression[@Image='!=']//NullLiteral)]
+[not(ancestor::Expression/ConditionalOrExpression//EqualityExpression[@Image='==']//NullLiteral)]
+```
+
+**Example(s):**
+
+``` java
+class Foo {
+ boolean bar(String x) {
+ return x.equalsIgnoreCase("2"); // should be "2".equalsIgnoreCase(x)
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## PositionLiteralsFirstInComparisons
+
+**Since:** PMD 3.3
+
+**Priority:** Medium (3)
+
+Position literals first in comparisons, if the second argument is null then NullPointerExceptions
+can be avoided, they will just return false.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression[
+ PrimaryPrefix[Name[(ends-with(@Image, '.equals'))]]
+ [
+ (../PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true'])
+ and
+ ( count(../PrimarySuffix/Arguments/ArgumentList/Expression) = 1 )
+ ]
+]
+[not(ancestor::Expression/ConditionalAndExpression//EqualityExpression[@Image='!=']//NullLiteral)]
+[not(ancestor::Expression/ConditionalOrExpression//EqualityExpression[@Image='==']//NullLiteral)]
+```
+
+**Example(s):**
+
+``` java
+class Foo {
+ boolean bar(String x) {
+ return x.equals("2"); // should be "2".equals(x)
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## PreserveStackTrace
+
+**Since:** PMD 3.7
+
+**Priority:** Medium (3)
+
+Throwing a new exception from a catch block without passing the original exception into the
+new exception will cause the original stack trace to be lost making it difficult to debug
+effectively.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.PreserveStackTraceRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/PreserveStackTraceRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void good() {
+ try{
+ Integer.parseInt("a");
+ } catch (Exception e) {
+ throw new Exception(e); // first possibility to create exception chain
+ }
+ try {
+ Integer.parseInt("a");
+ } catch (Exception e) {
+ throw (IllegalStateException)new IllegalStateException().initCause(e); // second possibility to create exception chain.
+ }
+ }
+ void bad() {
+ try{
+ Integer.parseInt("a");
+ } catch (Exception e) {
+ throw new Exception(e.getMessage());
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ReplaceEnumerationWithIterator
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+Consider replacing Enumeration usages with the newer java.util.Iterator
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ImplementsList/ClassOrInterfaceType[@Image='Enumeration']
+```
+
+**Example(s):**
+
+``` java
+public class Foo implements Enumeration {
+ private int x = 42;
+ public boolean hasMoreElements() {
+ return true;
+ }
+ public Object nextElement() {
+ return String.valueOf(i++);
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ReplaceHashtableWithMap
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+Consider replacing Hashtable usage with the newer java.util.Map if thread safety is not required.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Type/ReferenceType/ClassOrInterfaceType[@Image='Hashtable']
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void bar() {
+ Hashtable h = new Hashtable();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ReplaceVectorWithList
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+Consider replacing Vector usages with the newer java.util.ArrayList if expensive thread-safe operations are not required.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Type/ReferenceType/ClassOrInterfaceType[@Image='Vector']
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void bar() {
+ Vector v = new Vector();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SwitchStmtsShouldHaveDefault
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+All switch statements should include a default option to catch any unspecified values.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//SwitchStatement[@DefaultCase = false() and @ExhaustiveEnumSwitch = false()]
+```
+
+**Example(s):**
+
+``` java
+public void bar() {
+ int x = 2;
+ switch (x) {
+ case 1: int j = 6;
+ case 2: int j = 8;
+ // missing default: here
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SystemPrintln
+
+**Since:** PMD 2.1
+
+**Priority:** Medium High (2)
+
+References to System.(out|err).print are usually intended for debugging purposes and can remain in
+the codebase even in production code. By using a logger one can enable/disable this behaviour at
+will (and by priority) and avoid clogging the Standard out log.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Name[
+ starts-with(@Image, 'System.out.print')
+ or
+ starts-with(@Image, 'System.err.print')
+ ]
+```
+
+**Example(s):**
+
+``` java
+class Foo{
+ Logger log = Logger.getLogger(Foo.class.getName());
+ public void testA () {
+ System.out.println("Entering test");
+ // Better use this
+ log.fine("Entering test");
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnusedFormalParameter
+
+**Since:** PMD 0.8
+
+**Priority:** Medium (3)
+
+Avoid passing parameters to methods or constructors without actually referencing them in the method body.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedFormalParameterRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedFormalParameterRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private void bar(String howdy) {
+ // howdy is not used
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|checkAll|false|Check all methods, including non-private ones|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnusedImports
+
+**Since:** PMD 1.0
+
+**Priority:** Medium Low (4)
+
+Avoid unused import statements to prevent unwanted dependencies.
+This rule will also find unused on demand imports, i.e. import com.foo.*.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedImportsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedImportsRule.java)
+
+**Example(s):**
+
+``` java
+import java.io.File; // not referenced or required
+import java.util.*; // not referenced or required
+
+public class Foo {}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnusedLocalVariable
+
+**Since:** PMD 0.1
+
+**Priority:** Medium (3)
+
+Detects when a local variable is declared and/or assigned, but not used.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedLocalVariableRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedLocalVariableRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void doSomething() {
+ int i = 5; // Unused
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnusedPrivateField
+
+**Since:** PMD 0.1
+
+**Priority:** Medium (3)
+
+Detects when a private field is declared and/or assigned a value, but not used.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedPrivateFieldRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedPrivateFieldRule.java)
+
+**Example(s):**
+
+``` java
+public class Something {
+ private static int FOO = 2; // Unused
+ private int i = 5; // Unused
+ private int j = 6;
+ public int addOne() {
+ return j++;
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoredAnnotations|lombok.Setter \| lombok.Getter \| lombok.Builder \| lombok.Data \| lombok.RequiredArgsConstructor \| lombok.AllArgsConstructor \| lombok.Value \| lombok.NoArgsConstructor \| java.lang.Deprecated \| javafx.fxml.FXML|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnusedPrivateMethod
+
+**Since:** PMD 0.7
+
+**Priority:** Medium (3)
+
+Unused Private Method detects when a private method is declared but is unused.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedPrivateMethodRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedPrivateMethodRule.java)
+
+**Example(s):**
+
+``` java
+public class Something {
+ private void foo() {} // unused
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoredAnnotations|java.lang.Deprecated|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseAssertEqualsInsteadOfAssertTrue
+
+**Since:** PMD 3.1
+
+**Priority:** Medium (3)
+
+This rule detects JUnit assertions in object equality. These assertions should be made by more specific methods, like assertEquals.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression[
+ PrimaryPrefix/Name[@Image = 'assertTrue']
+][
+ PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Name
+ [ends-with(@Image, '.equals')]
+]
+[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]
+ or //MarkerAnnotation/Name[
+ pmd-java:typeIs('org.junit.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+ or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+ ]
+]]
+```
+
+**Example(s):**
+
+``` java
+public class FooTest extends TestCase {
+ void testCode() {
+ Object a, b;
+ assertTrue(a.equals(b)); // bad usage
+ assertEquals(?a should equals b?, a, b); // good usage
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseAssertNullInsteadOfAssertTrue
+
+**Since:** PMD 3.5
+
+**Priority:** Medium (3)
+
+This rule detects JUnit assertions in object references equality. These assertions should be made by
+more specific methods, like assertNull, assertNotNull.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression[
+ PrimaryPrefix/Name[@Image = 'assertTrue' or @Image = 'assertFalse']
+][
+ PrimarySuffix/Arguments/ArgumentList[
+ Expression/EqualityExpression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral
+ ]
+]
+[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]
+ or //MarkerAnnotation/Name[
+ pmd-java:typeIs('org.junit.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+ or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+ ]
+]]
+```
+
+**Example(s):**
+
+``` java
+public class FooTest extends TestCase {
+ void testCode() {
+ Object a = doSomething();
+ assertTrue(a==null); // bad usage
+ assertNull(a); // good usage
+ assertTrue(a != null); // bad usage
+ assertNotNull(a); // good usage
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseAssertSameInsteadOfAssertTrue
+
+**Since:** PMD 3.1
+
+**Priority:** Medium (3)
+
+This rule detects JUnit assertions in object references equality. These assertions should be made
+by more specific methods, like assertSame, assertNotSame.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression[
+ PrimaryPrefix/Name
+ [@Image = 'assertTrue' or @Image = 'assertFalse']
+]
+[PrimarySuffix/Arguments
+ /ArgumentList/Expression
+ /EqualityExpression[count(.//NullLiteral) = 0]]
+[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]
+ or //MarkerAnnotation/Name[
+ pmd-java:typeIs('org.junit.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+ or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+ ]
+]]
+```
+
+**Example(s):**
+
+``` java
+public class FooTest extends TestCase {
+ void testCode() {
+ Object a, b;
+ assertTrue(a == b); // bad usage
+ assertSame(a, b); // good usage
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseAssertTrueInsteadOfAssertEquals
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+When asserting a value is the same as a literal or Boxed boolean, use assertTrue/assertFalse, instead of assertEquals.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression[PrimaryPrefix/Name[@Image = 'assertEquals']]
+[
+ PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral
+ or
+ PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix
+ /Name[(@Image = 'Boolean.TRUE' or @Image = 'Boolean.FALSE')]
+]
+```
+
+**Example(s):**
+
+``` java
+public class MyTestCase extends TestCase {
+ public void testMyCase() {
+ boolean myVar = true;
+ // Ok
+ assertTrue("myVar is true", myVar);
+ // Bad
+ assertEquals("myVar is true", true, myVar);
+ // Bad
+ assertEquals("myVar is false", false, myVar);
+ // Bad
+ assertEquals("myVar is true", Boolean.TRUE, myVar);
+ // Bad
+ assertEquals("myVar is false", Boolean.FALSE, myVar);
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseCollectionIsEmpty
+
+**Since:** PMD 3.9
+
+**Priority:** Medium (3)
+
+The isEmpty() method on java.util.Collection is provided to determine if a collection has any elements.
+Comparing the value of size() to 0 does not convey intent as well as the isEmpty() method.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.UseCollectionIsEmptyRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UseCollectionIsEmptyRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void good() {
+ List foo = getList();
+ if (foo.isEmpty()) {
+ // blah
+ }
+ }
+
+ void bad() {
+ List foo = getList();
+ if (foo.size() == 0) {
+ // blah
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseVarargs
+
+**Since:** PMD 5.0
+
+**Priority:** Medium Low (4)
+
+**Minimum Language Version:** Java 1.5
+
+Java 5 introduced the varargs parameter declaration for methods and constructors. This syntactic
+sugar provides flexibility for users of these methods and constructors, allowing them to avoid
+having to deal with the creation of an array.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//FormalParameters/FormalParameter
+ [position()=last()]
+ [@Array='true']
+ [@Varargs='false']
+ [not (./Type/ReferenceType[@Array='true'][PrimitiveType[@Image='byte']])]
+ [not (./Type/ReferenceType[ClassOrInterfaceType[@Image='Byte']])]
+ [not (./Type/PrimitiveType[@Image='byte'])]
+ [not (ancestor::MethodDeclaration/preceding-sibling::Annotation/*/Name[@Image='Override'])]
+ [not(
+ ancestor::MethodDeclaration
+ [@Public='true' and @Static='true']
+ [child::ResultType[@Void='true']] and
+ ancestor::MethodDeclarator[@Image='main'] and
+ ..[@ParameterCount='1'] and
+ ./Type/ReferenceType[ClassOrInterfaceType[@Image='String']]
+ )]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void foo(String s, Object[] args) {
+ // Do something here...
+ }
+
+ public void bar(String s, Object... args) {
+ // Ahh, varargs tastes much better...
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/java/braces.md b/docs/pages/pmd/rules/java/braces.md
deleted file mode 100644
index a2ea2bab6b5..00000000000
--- a/docs/pages/pmd/rules/java/braces.md
+++ /dev/null
@@ -1,130 +0,0 @@
----
-title: Braces
-summary: The Braces ruleset contains rules regarding the use and placement of braces.
-permalink: pmd_rules_java_braces.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/braces.xml
-keywords: Braces, IfStmtsMustUseBraces, WhileLoopsMustUseBraces, IfElseStmtsMustUseBraces, ForLoopsMustUseBraces
----
-## ForLoopsMustUseBraces
-
-**Since:** PMD 0.7
-
-**Priority:** Medium (3)
-
-Avoid using 'for' statements without using curly braces. If the code formatting or
-indentation is lost then it becomes difficult to separate the code being controlled
-from the rest.
-
-```
-//ForStatement[not(Statement/Block)]
-```
-
-**Example(s):**
-
-``` java
-for (int i = 0; i < 42; i++)
- foo();
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## IfElseStmtsMustUseBraces
-
-**Since:** PMD 0.2
-
-**Priority:** Medium (3)
-
-Avoid using if..else statements without using surrounding braces. If the code formatting
-or indentation is lost then it becomes difficult to separate the code being controlled
-from the rest.
-
-```
-//Statement
- [parent::IfStatement[@Else='true']]
- [not(child::Block)]
- [not(child::IfStatement)]
-```
-
-**Example(s):**
-
-``` java
-// this is OK
-if (foo) x++;
-
- // but this is not
-if (foo)
- x = x+1;
- else
- x = x-1;
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## IfStmtsMustUseBraces
-
-**Since:** PMD 1.0
-
-**Priority:** Medium (3)
-
-Avoid using if statements without using braces to surround the code block. If the code
-formatting or indentation is lost then it becomes difficult to separate the code being
-controlled from the rest.
-
-```
-//IfStatement[count(*) < 3][not(Statement/Block)]
-```
-
-**Example(s):**
-
-``` java
-if (foo) // not recommended
- x++;
-
-if (foo) { // preferred approach
- x++;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## WhileLoopsMustUseBraces
-
-**Since:** PMD 0.7
-
-**Priority:** Medium (3)
-
-Avoid using 'while' statements without using braces to surround the code block. If the code
-formatting or indentation is lost then it becomes difficult to separate the code being
-controlled from the rest.
-
-```
-//WhileStatement[not(Statement/Block)]
-```
-
-**Example(s):**
-
-``` java
-while (true) // not recommended
- x++;
-
-while (true) { // preferred approach
- x++;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/clone.md b/docs/pages/pmd/rules/java/clone.md
deleted file mode 100644
index 7091400db39..00000000000
--- a/docs/pages/pmd/rules/java/clone.md
+++ /dev/null
@@ -1,203 +0,0 @@
----
-title: Clone Implementation
-summary: The Clone Implementation ruleset contains a collection of rules that find questionable usages of the clone() method.
-permalink: pmd_rules_java_clone.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/clone.xml
-keywords: Clone Implementation, ProperCloneImplementation, CloneThrowsCloneNotSupportedException, CloneMethodMustImplementCloneable, CloneMethodReturnTypeMustMatchClassName, CloneMethodMustBePublic
----
-## CloneMethodMustBePublic
-
-**Since:** PMD 5.4.0
-
-**Priority:** Medium (3)
-
-The java Manual says "By convention, classes that implement this interface should override
-Object.clone (which is protected) with a public method."
-
-```
-//MethodDeclaration[@Public='false']
- [MethodDeclarator/@Image = 'clone']
- [MethodDeclarator/FormalParameters/@ParameterCount = 0]
-```
-
-**Example(s):**
-
-``` java
-public class Foo implements Cloneable {
- @Override
- protected Object clone() throws CloneNotSupportedException { // Violation, must be public
- }
-}
-
-public class Foo implements Cloneable {
- @Override
- protected Foo clone() { // Violation, must be public
- }
-}
-
-public class Foo implements Cloneable {
- @Override
- public Object clone() // Ok
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CloneMethodMustImplementCloneable
-
-**Since:** PMD 1.9
-
-**Priority:** Medium (3)
-
-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.
-
-```
-//ClassOrInterfaceDeclaration
-[not(./ExtendsList/ClassOrInterfaceType[@Image='Cloneable'])]
-[not(./ImplementsList/ClassOrInterfaceType[@Image='Cloneable'])]
-/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
-[MethodDeclaration
-[MethodDeclarator[@Image
-= 'clone' and count(FormalParameters/*) = 0]]
-[not((../MethodDeclaration[@Final = 'true'] or ancestor::ClassOrInterfaceDeclaration[1][@Final = 'true'])
-and Block[count(BlockStatement)=1]
-/BlockStatement/Statement/ThrowStatement/Expression
-/PrimaryExpression/PrimaryPrefix/AllocationExpression
-/ClassOrInterfaceType[@Image = 'CloneNotSupportedException'])]]
-```
-
-**Example(s):**
-
-``` java
-public class MyClass {
- public Object clone() throws CloneNotSupportedException {
- return foo;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CloneMethodReturnTypeMustMatchClassName
-
-**Since:** PMD 5.4.0
-
-**Priority:** Medium (3)
-
-**Minimum Language Version:** Java 1.5
-
-If a class implements cloneable the return type of the method clone() must be the class name. That way, the caller
-of the clone method doesn't need to cast the returned clone to the correct type.
-
-Note: This is only possible with Java 1.5 or higher.
-
-```
-//MethodDeclaration
-[
-MethodDeclarator/@Image = 'clone'
-and MethodDeclarator/FormalParameters/@ParameterCount = 0
-and not (ResultType//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration[1]/@Image)
-]
-```
-
-**Example(s):**
-
-``` java
-public class Foo implements Cloneable {
- @Override
- protected Object clone() { // Violation, Object must be Foo
- }
-}
-
-public class Foo implements Cloneable {
- @Override
- public Foo clone() { //Ok
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CloneThrowsCloneNotSupportedException
-
-**Since:** PMD 1.9
-
-**Priority:** Medium (3)
-
-The method clone() should throw a CloneNotSupportedException.
-
-```
-//MethodDeclaration
-[
-MethodDeclarator/@Image = 'clone'
-and count(MethodDeclarator/FormalParameters/*) = 0
-and count(NameList/Name[contains
-(@Image,'CloneNotSupportedException')]) = 0
-]
-[
-../../../../ClassOrInterfaceDeclaration[@Final = 'false']
-]
-```
-
-**Example(s):**
-
-``` java
-public class MyClass implements Cloneable{
- public Object clone() { // will cause an error
- MyClass clone = (MyClass)super.clone();
- return clone;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ProperCloneImplementation
-
-**Since:** PMD 1.4
-
-**Priority:** Medium High (2)
-
-Object clone() should be implemented with super.clone().
-
-```
-//MethodDeclarator
-[@Image = 'clone']
-[count(FormalParameters/*) = 0]
-[count(../Block//*[
- (self::AllocationExpression) and
- (./ClassOrInterfaceType/@Image = ancestor::
-ClassOrInterfaceDeclaration[1]/@Image)
- ])> 0
-]
-```
-
-**Example(s):**
-
-``` java
-class Foo{
- public Object clone(){
- return new Foo(); // This is bad
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/codesize.md b/docs/pages/pmd/rules/java/codesize.md
deleted file mode 100644
index de62bd2e1dd..00000000000
--- a/docs/pages/pmd/rules/java/codesize.md
+++ /dev/null
@@ -1,699 +0,0 @@
----
-title: Code Size
-summary: The Code Size ruleset contains rules that find problems related to code size or complexity.
-permalink: pmd_rules_java_codesize.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/codesize.xml
-keywords: Code Size, NPathComplexity, ExcessiveMethodLength, ExcessiveParameterList, ExcessiveClassLength, CyclomaticComplexity, StdCyclomaticComplexity, ModifiedCyclomaticComplexity, ExcessivePublicCount, TooManyFields, NcssMethodCount, NcssTypeCount, NcssConstructorCount, NcssCount, TooManyMethods
----
-## CyclomaticComplexity
-
-Deprecated
-
-**Since:** PMD 1.03
-
-**Priority:** Medium (3)
-
-Complexity directly affects maintenance costs is determined by the number of decision points in a method
-plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
-Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
-high complexity, and 11+ is very high complexity.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.CyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/CyclomaticComplexityRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo { // This has a Cyclomatic Complexity = 12
-1 public void example() {
-2 if (a == b) {
-3 if (a1 == b1) {
- fiddle();
-4 } else if a2 == b2) {
- fiddle();
- } else {
- fiddle();
- }
-5 } else if (c == d) {
-6 while (c == d) {
- fiddle();
- }
-7 } else if (e == f) {
-8 for (int n = 0; n < h; n++) {
- fiddle();
- }
- } else{
- switch (z) {
-9 case 1:
- fiddle();
- break;
-10 case 2:
- fiddle();
- break;
-11 case 3:
- fiddle();
- break;
-12 default:
- fiddle();
- break;
- }
- }
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|showMethodsComplexity|true|Add method average violations to the report|
-|showClassesComplexity|true|Add class average violations to the report|
-|reportLevel|10|Cyclomatic Complexity reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveClassLength
-
-**Since:** PMD 0.6
-
-**Priority:** Medium (3)
-
-Excessive class file lengths are usually indications that the class may be burdened with excessive
-responsibilities that could be provided by external classes or functions. In breaking these methods
-apart the code becomes more manageable and ripe for reuse.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.ExcessiveClassLengthRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/ExcessiveClassLengthRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar1() {
- // 1000 lines of code
- }
- public void bar2() {
- // 1000 lines of code
- }
- public void bar3() {
- // 1000 lines of code
- }
-
- public void barN() {
- // 1000 lines of code
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveMethodLength
-
-**Since:** PMD 0.6
-
-**Priority:** Medium (3)
-
-When methods are excessively long this usually indicates that the method is doing more than its
-name/signature might suggest. They also become challenging for others to digest since excessive
-scrolling causes readers to lose focus.
-Try to reduce the method length by creating helper methods and removing any copy/pasted code.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.ExcessiveMethodLengthRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/ExcessiveMethodLengthRule.java)
-
-**Example(s):**
-
-``` java
-public void doSomething() {
- System.out.println("Hello world!");
- System.out.println("Hello world!");
- // 98 copies omitted for brevity.
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveParameterList
-
-**Since:** PMD 0.9
-
-**Priority:** Medium (3)
-
-Methods with numerous parameters are a challenge to maintain, especially if most of them share the
-same datatype. These situations usually denote the need for new objects to wrap the numerous parameters.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.ExcessiveParameterListRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/ExcessiveParameterListRule.java)
-
-**Example(s):**
-
-``` java
-public void addPerson( // too many arguments liable to be mixed up
- int birthYear, int birthMonth, int birthDate, int height, int weight, int ssn) {
-
- . . . .
-}
-
-public void addPerson( // preferred approach
- Date birthdate, BodyMeasurements measurements, int ssn) {
-
- . . . .
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessivePublicCount
-
-**Since:** PMD 1.04
-
-**Priority:** Medium (3)
-
-Classes with large numbers of public methods and attributes require disproportionate testing efforts
-since combinational side effects grow rapidly and increase risk. Refactoring these classes into
-smaller ones not only increases testability and reliability but also allows new variations to be
-developed easily.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.ExcessivePublicCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/ExcessivePublicCountRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public String value;
- public Bar something;
- public Variable var;
- // [... more more public attributes ...]
-
- public void doWork() {}
- public void doMoreWork() {}
- public void doWorkAgain() {}
- // [... more more public methods ...]
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ModifiedCyclomaticComplexity
-
-Deprecated
-
-**Since:** PMD 5.1.2
-
-**Priority:** Medium (3)
-
-Complexity directly affects maintenance costs is determined by the number of decision points in a method
-plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
-Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
-high complexity, and 11+ is very high complexity. Modified complexity treats switch statements as a single
-decision point.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.ModifiedCyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/ModifiedCyclomaticComplexityRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo { // This has a Cyclomatic Complexity = 9
-1 public void example() {
-2 if (a == b) {
-3 if (a1 == b1) {
- fiddle();
-4 } else if a2 == b2) {
- fiddle();
- } else {
- fiddle();
- }
-5 } else if (c == d) {
-6 while (c == d) {
- fiddle();
- }
-7 } else if (e == f) {
-8 for (int n = 0; n < h; n++) {
- fiddle();
- }
- } else{
-9 switch (z) {
- case 1:
- fiddle();
- break;
- case 2:
- fiddle();
- break;
- case 3:
- fiddle();
- break;
- default:
- fiddle();
- break;
- }
- }
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|showMethodsComplexity|true|Add method average violations to the report|
-|showClassesComplexity|true|Add class average violations to the report|
-|reportLevel|10|Cyclomatic Complexity reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NcssConstructorCount
-
-Deprecated
-
-**Since:** PMD 3.9
-
-**Priority:** Medium (3)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.NcssConstructorCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/NcssConstructorCountRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo extends Bar {
- public Foo() {
- super();
-
-
-
-
-
- //this constructor only has 1 NCSS lines
- super.foo();
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NcssCount
-
-**Since:** PMD 6.0
-
-**Priority:** Medium (3)
-
-This rule uses the NCSS (Non-Commenting Source Statements) metric to determine the number of lines
- of code in a class, method or constructor. NCSS ignores comments, blank lines, and only counts actual
- statements. For more details on the calculation, see the documentation of
- the [NCSS metric](/pmd_java_metrics_index.html#non-commenting-source-statements-ncss).
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.NcssCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/NcssCountRule.java)
-
-**Example(s):**
-
-``` java
-import java.util.Collections; // +0
-import java.io.IOException; // +0
-
-class Foo { // +1, total Ncss = 12
-
- public void bigMethod() // +1
- throws IOException {
- int x = 0, y = 2; // +1
- boolean a = false, b = true; // +1
-
- if (a || b) { // +1
- try { // +1
- do { // +1
- x += 2; // +1
- } while (x < 12);
-
- System.exit(0); // +1
- } catch (IOException ioe) { // +1
- throw new PatheticFailException(ioe); // +1
- }
- } else {
- assert false; // +1
- }
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|ncssOptions|[]|Choose options for the calculation of Ncss|
-|methodReportLevel|12|Metric reporting threshold for methods|
-|classReportLevel|250|Metric reporting threshold for classes|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NcssMethodCount
-
-Deprecated
-
-**Since:** PMD 3.9
-
-**Priority:** Medium (3)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.NcssMethodCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/NcssMethodCountRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo extends Bar {
- public int methd() {
- super.methd();
-
-
-
-
- //this method only has 1 NCSS lines
- return 1;
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NcssTypeCount
-
-Deprecated
-
-**Since:** PMD 3.9
-
-**Priority:** Medium (3)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.NcssTypeCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/NcssTypeCountRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo extends Bar {
- public Foo() {
- //this class only has 6 NCSS lines
- super();
-
-
-
-
-
- super.foo();
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NPathComplexity
-
-**Since:** PMD 3.9
-
-**Priority:** Medium (3)
-
-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 and increase readability.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.NPathComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/NPathComplexityRule.java)
-
-**Example(s):**
-
-``` java
-void bar() { // this is something more complex than it needs to be,
- if (y) { // it should be broken down into smaller methods or functions
- for (j = 0; j < m; j++) {
- if (j > r) {
- doSomething();
- while (f < 5 ) {
- anotherThing();
- f -= 27;
- }
- } else {
- tryThis();
- }
- }
- }
- if ( r - n > 45) {
- while (doMagic()) {
- findRabbits();
- }
- }
- try {
- doSomethingDangerous();
- } catch (Exception ex) {
- makeAmends();
- } finally {
- dontDoItAgain();
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## StdCyclomaticComplexity
-
-Deprecated
-
-**Since:** PMD 5.1.2
-
-**Priority:** Medium (3)
-
-Complexity directly affects maintenance costs is determined by the number of decision points in a method
-plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
-Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
-high complexity, and 11+ is very high complexity.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.StdCyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/StdCyclomaticComplexityRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo { // This has a Cyclomatic Complexity = 12
-1 public void example() {
-2 if (a == b || (c == d && e == f)) { // Only one
-3 if (a1 == b1) {
- fiddle();
-4 } else if a2 == b2) {
- fiddle();
- } else {
- fiddle();
- }
-5 } else if (c == d) {
-6 while (c == d) {
- fiddle();
- }
-7 } else if (e == f) {
-8 for (int n = 0; n < h; n++) {
- fiddle();
- }
- } else{
- switch (z) {
-9 case 1:
- fiddle();
- break;
-10 case 2:
- fiddle();
- break;
-11 case 3:
- fiddle();
- break;
-12 default:
- fiddle();
- break;
- }
- }
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|showMethodsComplexity|true|Add method average violations to the report|
-|showClassesComplexity|true|Add class average violations to the report|
-|reportLevel|10|Cyclomatic Complexity reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TooManyFields
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields,
-possibly through grouping related fields in new objects. For example, a class with individual
-city/state/zip fields could park them within a single Address field.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codesize.TooManyFieldsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codesize/TooManyFieldsRule.java)
-
-**Example(s):**
-
-``` java
-public class Person { // too many separate fields
- int birthYear;
- int birthMonth;
- int birthDate;
- float height;
- float weight;
-}
-
-public class Person { // this is more manageable
- Date birthDate;
- BodyMeasurements measurements;
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|maxfields|15|Max allowable fields|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TooManyMethods
-
-**Since:** PMD 4.2
-
-**Priority:** Medium (3)
-
-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.
-
-```
-//ClassOrInterfaceDeclaration/ClassOrInterfaceBody
- [
- count(./ClassOrInterfaceBodyDeclaration/MethodDeclaration/MethodDeclarator[
- not (
- starts-with(@Image,'get')
- or
- starts-with(@Image,'set')
- or
- starts-with(@Image,'is')
- )
- ]) > $maxmethods
- ]
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|maxmethods|10|The method count reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/codestyle.md b/docs/pages/pmd/rules/java/codestyle.md
new file mode 100644
index 00000000000..4341da7a735
--- /dev/null
+++ b/docs/pages/pmd/rules/java/codestyle.md
@@ -0,0 +1,2340 @@
+---
+title: Code Style
+summary: Rules which enforce a specific coding style.
+permalink: pmd_rules_java_codestyle.html
+folder: pmd/rules/java
+sidebaractiveurl: /pmd_rules_java.html
+editmepath: ../pmd-java/src/main/resources/category/java/codestyle.xml
+keywords: Code Style, AbstractNaming, AtLeastOneConstructor, AvoidDollarSigns, AvoidFinalLocalVariable, AvoidPrefixingMethodParameters, AvoidProtectedFieldInFinalClass, AvoidProtectedMethodInFinalClassNotExtending, AvoidUsingNativeCode, BooleanGetMethodName, CallSuperInConstructor, ClassNamingConventions, CommentDefaultAccessModifier, ConfusingTernary, ControlStatementBraces, DefaultPackage, DontImportJavaLang, DuplicateImports, EmptyMethodInAbstractClassShouldBeAbstract, ExtendsObject, FieldDeclarationsShouldBeAtStartOfClass, FieldNamingConventions, ForLoopShouldBeWhileLoop, ForLoopsMustUseBraces, FormalParameterNamingConventions, GenericsNaming, IdenticalCatchBranches, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LinguisticNaming, LocalHomeNamingConvention, LocalInterfaceSessionNamingConvention, LocalVariableCouldBeFinal, LocalVariableNamingConventions, LongVariable, MDBAndSessionBeanNamingConvention, MethodArgumentCouldBeFinal, MethodNamingConventions, MIsLeadingVariableName, NoPackage, UseUnderscoresInNumericLiterals, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryAnnotationValueElement, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
+language: Java
+---
+## AbstractNaming
+
+Deprecated
+
+**Since:** PMD 1.4
+
+**Priority:** Medium (3)
+
+Abstract classes should be named 'AbstractXXX'.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration
+ [@Abstract='true' and @Interface='false']
+ [not (starts-with(@Image,'Abstract'))]
+|
+//ClassOrInterfaceDeclaration
+ [@Abstract='false']
+ [$strict='true']
+ [starts-with(@Image, 'Abstract')]
+```
+
+**Example(s):**
+
+``` java
+public abstract class Foo { // should be AbstractFoo
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|strict|true|Also flag classes, that are named Abstract, but are not abstract.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AtLeastOneConstructor
+
+**Since:** PMD 1.04
+
+**Priority:** Medium (3)
+
+Each non-static class should declare at least one constructor.
+Classes with solely static members are ignored, refer to [UseUtilityClassRule](pmd_rules_java_design.html#useutilityclass) to detect those.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.AtLeastOneConstructorRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/AtLeastOneConstructorRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ // missing constructor
+ public void doSomething() { ... }
+ public void doOtherThing { ... }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoredAnnotations|lombok.Data \| lombok.Value \| lombok.Builder \| lombok.NoArgsConstructor \| lombok.RequiredArgsConstructor \| lombok.AllArgsConstructorAtLeastOneConstructor|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidDollarSigns
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+Avoid using dollar signs in variable/method/class/interface names.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.AvoidDollarSignsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/AvoidDollarSignsRule.java)
+
+**Example(s):**
+
+``` java
+public class Fo$o { // not a recommended name
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidFinalLocalVariable
+
+**Since:** PMD 4.1
+
+**Priority:** Medium (3)
+
+Avoid using final local variables, turn them into fields.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//LocalVariableDeclaration[
+ @Final = 'true'
+ and not(../../ForStatement)
+ and
+ (
+ (count(VariableDeclarator/VariableInitializer) = 0)
+ or
+ (VariableDeclarator/VariableInitializer/Expression/PrimaryExpression/PrimaryPrefix/Literal)
+ )
+]
+```
+
+**Example(s):**
+
+``` java
+public class MyClass {
+ public void foo() {
+ final String finalLocalVariable;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidPrefixingMethodParameters
+
+Deprecated
+
+**Since:** PMD 5.0
+
+**Priority:** Medium Low (4)
+
+Prefixing parameters by 'in' or 'out' pollutes the name of the parameters and reduces code readability.
+To indicate whether or not a parameter will be modify in a method, its better to document method
+behavior with Javadoc.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration/MethodDeclarator/FormalParameters/FormalParameter/VariableDeclaratorId[
+ pmd:matches(@Image,'^in[A-Z].*','^out[A-Z].*','^in$','^out$')
+]
+```
+
+**Example(s):**
+
+``` java
+// Not really clear
+public class Foo {
+ public void bar(
+ int inLeftOperand,
+ Result outRightOperand) {
+ outRightOperand.setValue(inLeftOperand * outRightOperand.getValue());
+ }
+}
+```
+
+``` java
+// Far more useful
+public class Foo {
+ /**
+ *
+ * @param leftOperand, (purpose), not modified by method.
+ * @param rightOperand (purpose), will be modified by the method: contains the result.
+ */
+ public void bar(
+ int leftOperand,
+ Result rightOperand) {
+ rightOperand.setValue(leftOperand * rightOperand.getValue());
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidProtectedFieldInFinalClass
+
+**Since:** PMD 2.1
+
+**Priority:** Medium (3)
+
+Do not use protected fields in final classes since they cannot be subclassed.
+Clarify your intent by using private or package access modifiers instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[@Final='true']
+/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
+/FieldDeclaration[@Protected='true']
+```
+
+**Example(s):**
+
+``` java
+public final class Bar {
+ private int x;
+ protected int y; // bar cannot be subclassed, so is y really private or package visible?
+ Bar() {}
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidProtectedMethodInFinalClassNotExtending
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Do not use protected methods in most final classes since they cannot be subclassed. This should
+only be allowed in final classes that extend other classes with protected methods (whose
+visibility cannot be reduced). Clarify your intent by using private or package access modifiers instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[@Final='true' and not(ExtendsList)]
+/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
+/MethodDeclaration[@Protected='true'][MethodDeclarator/@Image != 'finalize']
+```
+
+**Example(s):**
+
+``` java
+public final class Foo {
+ private int bar() {}
+ protected int baz() {} // Foo cannot be subclassed, and doesn't extend anything, so is baz() really private or package visible?
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidUsingNativeCode
+
+**Since:** PMD 4.1
+
+**Priority:** Medium High (2)
+
+Unnecessary reliance on Java Native Interface (JNI) calls directly reduces application portability
+and increases the maintenance burden.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Name[starts-with(@Image,'System.loadLibrary')]
+```
+
+**Example(s):**
+
+``` java
+public class SomeJNIClass {
+
+ public SomeJNIClass() {
+ System.loadLibrary("nativelib");
+ }
+
+ static {
+ System.loadLibrary("nativelib");
+ }
+
+ public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+ System.loadLibrary("nativelib");
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## BooleanGetMethodName
+
+**Since:** PMD 4.0
+
+**Priority:** Medium Low (4)
+
+Methods that return boolean results should be named as predicate statements to denote this.
+I.e, 'isReady()', 'hasValues()', 'canCommit()', 'willFail()', etc. Avoid the use of the 'get'
+prefix for these methods.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[
+MethodDeclarator[count(FormalParameters/FormalParameter) = 0 or $checkParameterizedMethods = 'true']
+ [starts-with(@Image, 'get')]
+and
+ResultType/Type/PrimitiveType[@Image = 'boolean']
+and not(../Annotation//Name[@Image = 'Override'])
+]
+```
+
+**Example(s):**
+
+``` java
+public boolean getFoo(); // bad
+public boolean isFoo(); // ok
+public boolean getFoo(boolean bar); // ok, unless checkParameterizedMethods=true
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|checkParameterizedMethods|false|Check parameterized methods|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CallSuperInConstructor
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[ count (ExtendsList/*) > 0 ]
+/ClassOrInterfaceBody
+ /ClassOrInterfaceBodyDeclaration
+ /ConstructorDeclaration[ count (.//ExplicitConstructorInvocation)=0 ]
+```
+
+**Example(s):**
+
+``` java
+public class Foo extends Bar{
+ public Foo() {
+ // call the constructor of Bar
+ super();
+ }
+ public Foo(int code) {
+ // do something with code
+ this();
+ // no problem with this
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ClassNamingConventions
+
+**Since:** PMD 1.2
+
+**Priority:** High (1)
+
+Configurable naming conventions for type declarations. This rule reports
+type declarations which do not match the regex that applies to their
+specific kind (e.g. enum or interface). Each regex can be configured through
+properties.
+
+By default this rule uses the standard Java naming convention (Pascal case),
+and reports utility class names not ending with 'Util'.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.ClassNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/ClassNamingConventionsRule.java)
+
+**Example(s):**
+
+``` java
+// This is Pascal case, the recommended naming convention in Java
+// Note that the default values of this rule don't allow underscores
+// or accented characters in type names
+public class FooBar {}
+
+// You may want abstract classes to be named 'AbstractXXX',
+// in which case you can customize the regex for abstract
+// classes to 'Abstract[A-Z]\w+'
+public abstract class Thing {}
+
+// This class doesn't respect the convention, and will be flagged
+public class Éléphant {}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|classPattern|\[A-Z\]\[a-zA-Z0-9\]\*|Regex which applies to concrete class names|no|
+|abstractClassPattern|\[A-Z\]\[a-zA-Z0-9\]\*|Regex which applies to abstract class names|no|
+|interfacePattern|\[A-Z\]\[a-zA-Z0-9\]\*|Regex which applies to interface names|no|
+|enumPattern|\[A-Z\]\[a-zA-Z0-9\]\*|Regex which applies to enum names|no|
+|annotationPattern|\[A-Z\]\[a-zA-Z0-9\]\*|Regex which applies to annotation names|no|
+|utilityClassPattern|\[A-Z\]\[a-zA-Z0-9\]+(Utils?\|Helper)|Regex which applies to utility class names|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CommentDefaultAccessModifier
+
+**Since:** PMD 5.4.0
+
+**Priority:** Medium (3)
+
+To avoid mistakes if we want that a Method, Constructor, Field or Nested class have a default access modifier
+we must add a comment at the beginning of it's declaration.
+By default the comment must be /* default */ or /* package */, if you want another, you have to provide a regular expression.
+This rule ignores by default all cases that have a @VisibleForTesting annotation. Use the
+property "ignoredAnnotations" to customize the recognized annotations.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.CommentDefaultAccessModifierRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ final String stringValue = "some string";
+ String getString() {
+ return stringValue;
+ }
+
+ class NestedFoo {
+ }
+}
+
+// should be
+public class Foo {
+ /* default */ final String stringValue = "some string";
+ /* default */ String getString() {
+ return stringValue;
+ }
+
+ /* default */ class NestedFoo {
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|regex|\\/\\\*\\s+(default\|package)\\s+\\\*\\/|Regular expression|no|
+|ignoredAnnotations|com.google.common.annotations.VisibleForTesting \| android.support.annotation.VisibleForTesting|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ConfusingTernary
+
+**Since:** PMD 1.9
+
+**Priority:** Medium (3)
+
+Avoid negation within an "if" expression with an "else" clause. 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?".
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.ConfusingTernaryRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/ConfusingTernaryRule.java)
+
+**Example(s):**
+
+``` java
+boolean bar(int x, int y) {
+ return (x != y) ? diff : same;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoreElseIf|false|Ignore conditions with an else-if case|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ControlStatementBraces
+
+**Since:** PMD 6.2.0
+
+**Priority:** Medium (3)
+
+Enforce a policy for braces on control statements. It is recommended to use braces on 'if ... else'
+statements and loop statements, even if they are optional. This usually makes the code clearer, and
+helps prepare the future when you need to add another statement. That said, this rule lets you control
+which statements are required to have braces via properties.
+
+From 6.2.0 on, this rule supersedes WhileLoopMustUseBraces, ForLoopMustUseBraces, IfStmtMustUseBraces,
+and IfElseStmtMustUseBraces.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//WhileStatement[$checkWhileStmt and not(Statement/Block) and not($allowEmptyLoop and Statement/EmptyStatement)]
+ |
+ //ForStatement[$checkForStmt and not(Statement/Block) and not($allowEmptyLoop and Statement/EmptyStatement)]
+ |
+ //DoStatement[$checkDoWhileStmt and not(Statement/Block) and not($allowEmptyLoop and Statement/EmptyStatement)]
+ |
+ (: The violation is reported on the sub statement -- not the if statement :)
+ //Statement[$checkIfElseStmt and parent::IfStatement and not(child::Block or child::IfStatement)
+ (: Whitelists single if statements :)
+ and ($checkSingleIfStmt
+ (: Inside this not(...) is the definition of a "single if statement" :)
+ or not(count(../Statement) = 1 (: No else stmt :)
+ (: Not the last branch of an 'if ... else if' chain :)
+ and not(parent::IfStatement[parent::Statement[parent::IfStatement]])))]
+ |
+ (: Reports case labels if one of their subordinate statements is not braced :)
+ //SwitchLabel[$checkCaseStmt]
+ [count(following-sibling::BlockStatement except following-sibling::SwitchLabel[1]/following-sibling::BlockStatement) > 1
+ or (some $stmt (: in only the block statements until the next label :)
+ in following-sibling::BlockStatement except following-sibling::SwitchLabel[1]/following-sibling::BlockStatement
+ satisfies not($stmt/Statement/Block))]
+```
+
+**Example(s):**
+
+``` java
+while (true) // not recommended
+ x++;
+
+while (true) { // preferred approach
+ x++;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|checkIfElseStmt|true|Require that 'if ... else' statements use braces|no|
+|checkSingleIfStmt|true|Require that 'if' statements with a single branch use braces|no|
+|checkWhileStmt|true|Require that 'while' loops use braces|no|
+|checkForStmt|true|Require that 'for' loops should use braces|no|
+|checkDoWhileStmt|true|Require that 'do ... while' loops use braces|no|
+|checkCaseStmt|false|Require that cases of a switch have braces|no|
+|allowEmptyLoop|false|Allow loops with an empty statement, e.g. 'while(true);'|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DefaultPackage
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+Use explicit scoping instead of accidental usage of default package private level.
+The rule allows methods and fields annotated with Guava's @VisibleForTesting.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[@Interface='false']
+/ClassOrInterfaceBody
+/ClassOrInterfaceBodyDeclaration
+[not(Annotation//Name[ends-with(@Image, 'VisibleForTesting')])]
+[
+FieldDeclaration[@PackagePrivate='true']
+or MethodDeclaration[@PackagePrivate='true']
+]
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DontImportJavaLang
+
+**Since:** PMD 0.5
+
+**Priority:** Medium Low (4)
+
+Avoid importing anything from the package 'java.lang'. These classes are automatically imported (JLS 7.5.3).
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.DontImportJavaLangRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/DontImportJavaLangRule.java)
+
+**Example(s):**
+
+``` java
+import java.lang.String; // this is unnecessary
+
+public class Foo {}
+
+// --- in another source code file...
+
+import java.lang.*; // this is bad
+
+public class Foo {}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DuplicateImports
+
+**Since:** PMD 0.5
+
+**Priority:** Medium Low (4)
+
+Duplicate or overlapping import statements should be avoided.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.DuplicateImportsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/DuplicateImportsRule.java)
+
+**Example(s):**
+
+``` java
+import java.lang.String;
+import java.lang.*;
+public class Foo {}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyMethodInAbstractClassShouldBeAbstract
+
+**Since:** PMD 4.1
+
+**Priority:** High (1)
+
+Empty or auto-generated methods in an abstract class should be tagged as abstract. This helps to remove their inapproprate
+usage by developers who should be implementing their own versions in the concrete subclasses.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[@Abstract = 'true']
+ /ClassOrInterfaceBody
+ /ClassOrInterfaceBodyDeclaration
+ /MethodDeclaration[@Abstract = 'false' and @Native = 'false']
+ [
+ ( boolean(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral) = 'true' )
+ or
+ ( boolean(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal[@Image = '0']) = 'true' )
+ or
+ ( boolean(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal[string-length(@Image) = 2]) = 'true' )
+ or
+ (./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/EmptyStatement)
+ or
+ ( count (./Block/*) = 0 )
+ ]
+```
+
+**Example(s):**
+
+``` java
+public abstract class ShouldBeAbstract {
+ public Object couldBeAbstract() {
+ // Should be abstract method ?
+ return null;
+ }
+
+ public void couldBeAbstract() {
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExtendsObject
+
+**Since:** PMD 5.0
+
+**Priority:** Medium Low (4)
+
+No need to explicitly extend Object.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ExtendsList/ClassOrInterfaceType[@Image='Object' or @Image='java.lang.Object']
+```
+
+**Example(s):**
+
+``` java
+public class Foo extends Object { // not required
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## FieldDeclarationsShouldBeAtStartOfClass
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.FieldDeclarationsShouldBeAtStartOfClassRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/FieldDeclarationsShouldBeAtStartOfClassRule.java)
+
+**Example(s):**
+
+``` java
+public class HelloWorldBean {
+
+ // Field declared before methods / inner classes - OK
+ private String _thing;
+
+ public String getMessage() {
+ return "Hello World!";
+ }
+
+ // Field declared after methods / inner classes - avoid this
+ private String _fieldInWrongLocation;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoreInterfaceDeclarations|false|Ignore Interface Declarations that precede fields.|no|
+|ignoreAnonymousClassDeclarations|true|Ignore Field Declarations, that are initialized with anonymous class declarations|no|
+|ignoreEnumDeclarations|true|Ignore Enum Declarations that precede fields.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## FieldNamingConventions
+
+**Since:** PMD 6.7.0
+
+**Priority:** High (1)
+
+Configurable naming conventions for field declarations. This rule reports variable declarations
+which do not match the regex that applies to their specific kind ---e.g. constants (static final),
+enum constant, final field. Each regex can be configured through properties.
+
+By default this rule uses the standard Java naming convention (Camel case), and uses the ALL_UPPER
+convention for constants and enum constants.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.FieldNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/FieldNamingConventionsRule.java)
+
+**Example(s):**
+
+``` java
+class Foo {
+ int myField = 1; // This is in camel case, so it's ok
+ int my_Field = 1; // This contains an underscore, it's not ok by default
+ // but you may allow it, or even require the "my_" prefix
+
+ final int FinalField = 1; // you may configure a different convention for final fields,
+ // e.g. here PascalCase: [A-Z][a-zA-Z0-9]*
+
+ interface Interface {
+ double PI = 3.14; // interface "fields" use the constantPattern property
+ }
+
+ enum AnEnum {
+ ORG, NET, COM; // These use a separate property but are set to ALL_UPPER by default
+ }
+ }
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|publicConstantPattern|\[A-Z\]\[A-Z\_0-9\]\*|Regex which applies to public constant names|no|
+|constantPattern|\[A-Z\]\[A-Z\_0-9\]\*|Regex which applies to non-public static final field names|no|
+|enumConstantPattern|\[A-Z\]\[A-Z\_0-9\]\*|Regex which applies to enum constant names|no|
+|finalFieldPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to final field names|no|
+|staticFieldPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to static field names|no|
+|defaultFieldPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to field names|no|
+|exclusions|serialVersionUID|Names of fields to whitelist.|yes. Delimiter is '\|'.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ForLoopShouldBeWhileLoop
+
+**Since:** PMD 1.02
+
+**Priority:** Medium (3)
+
+Some for loops can be simplified to while loops, this makes them more concise.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ForStatement
+ [not(LocalVariableDeclaration)]
+ [not(ForInit)]
+ [not(ForUpdate)]
+ [Expression]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void bar() {
+ for (;true;) true; // No Init or Update part, may as well be: while (true)
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ForLoopsMustUseBraces
+
+Deprecated
+
+**Since:** PMD 0.7
+
+**Priority:** Medium (3)
+
+Avoid using 'for' statements without using curly braces. If the code formatting or
+indentation is lost then it becomes difficult to separate the code being controlled
+from the rest.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ForStatement[not(Statement/Block)]
+```
+
+**Example(s):**
+
+``` java
+for (int i = 0; i < 42; i++)
+ foo();
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## FormalParameterNamingConventions
+
+**Since:** PMD 6.6.0
+
+**Priority:** High (1)
+
+Configurable naming conventions for formal parameters of methods and lambdas.
+This rule reports formal parameters which do not match the regex that applies to their
+specific kind (e.g. lambda parameter, or final formal parameter). Each regex can be
+configured through properties.
+
+By default this rule uses the standard Java naming convention (Camel case).
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.FormalParameterNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/FormalParameterNamingConventionsRule.java)
+
+**Example(s):**
+
+``` java
+class Foo {
+
+ abstract void bar(int myInt); // This is Camel case, so it's ok
+
+ void bar(int my_i) { // this will be reported
+
+ }
+
+ void lambdas() {
+
+ // lambdas parameters can be configured separately
+ Consumer lambda1 = s_str -> { };
+
+ // lambda parameters with an explicit type can be configured separately
+ Consumer lambda1 = (String str) -> { };
+
+ }
+
+ }
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|methodParameterPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to formal parameter names|no|
+|finalMethodParameterPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to final formal parameter names|no|
+|lambdaParameterPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to inferred-type lambda parameter names|no|
+|explicitLambdaParameterPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to explicitly-typed lambda parameter names|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## GenericsNaming
+
+**Since:** PMD 4.2.6
+
+**Priority:** Medium Low (4)
+
+Names for references to generic values should be limited to a single uppercase letter.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//TypeDeclaration/ClassOrInterfaceDeclaration/TypeParameters/TypeParameter[
+ string-length(@Image) > 1
+ or
+ string:upper-case(@Image) != @Image
+]
+```
+
+**Example(s):**
+
+``` java
+public interface GenericDao extends BaseDao {
+ // This is ok...
+}
+
+public interface GenericDao {
+ // Also this
+}
+
+public interface GenericDao {
+ // 'e' should be an 'E'
+}
+
+public interface GenericDao {
+ // 'EF' is not ok.
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## IdenticalCatchBranches
+
+**Since:** PMD 6.4.0
+
+**Priority:** Medium (3)
+
+**Minimum Language Version:** Java 1.7
+
+Identical `catch` branches use up vertical space and increase the complexity of code without
+adding functionality. It's better style to collapse identical branches into a single multi-catch
+branch.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.IdenticalCatchBranchesRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/IdenticalCatchBranchesRule.java)
+
+**Example(s):**
+
+``` java
+try {
+ // do something
+} catch (IllegalArgumentException e) {
+ throw e;
+} catch (IllegalStateException e) { // Can be collapsed into the previous block
+ throw e;
+}
+
+try {
+ // do something
+} catch (IllegalArgumentException | IllegalStateException e) { // This is better
+ throw e;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## IfElseStmtsMustUseBraces
+
+Deprecated
+
+**Since:** PMD 0.2
+
+**Priority:** Medium (3)
+
+Avoid using if..else statements without using surrounding braces. If the code formatting
+or indentation is lost then it becomes difficult to separate the code being controlled
+from the rest.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Statement
+ [parent::IfStatement[@Else='true']]
+ [not(child::Block)]
+ [not(child::IfStatement)]
+```
+
+**Example(s):**
+
+``` java
+// this is OK
+if (foo) x++;
+
+ // but this is not
+if (foo)
+ x = x+1;
+ else
+ x = x-1;
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## IfStmtsMustUseBraces
+
+Deprecated
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+Avoid using if statements without using braces to surround the code block. If the code
+formatting or indentation is lost then it becomes difficult to separate the code being
+controlled from the rest.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfStatement[count(*) < 3][not(Statement/Block)]
+```
+
+**Example(s):**
+
+``` java
+if (foo) // not recommended
+ x++;
+
+if (foo) { // preferred approach
+ x++;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## LinguisticNaming
+
+**Since:** PMD 6.7.0
+
+**Priority:** Medium (3)
+
+This rule finds Linguistic Naming Antipatterns. It checks for fields, that are named, as if they should
+be boolean but have a different type. It also checks for methods, that according to their name, should
+return a boolean, but don't. Further, it checks, that getters return something and setters won't.
+Finally, it checks that methods, that start with "to" - so called transform methods - actually return
+something, since according to their name, they should convert or transform one object into another.
+There is additionally an option, to check for methods that contain "To" in their name - which are
+also transform methods. However, this is disabled by default, since this detection is prone to
+false positives.
+
+For more information, see [Linguistic Antipatterns - What They Are and How
+Developers Perceive Them](https://doi.org/10.1007/s10664-014-9350-8).
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.LinguisticNamingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java)
+
+**Example(s):**
+
+``` java
+public class LinguisticNaming {
+ int isValid; // the field name indicates a boolean, but it is an int.
+ boolean isTrue; // correct type of the field
+
+ void myMethod() {
+ int hasMoneyLocal; // the local variable name indicates a boolean, but it is an int.
+ boolean hasSalaryLocal; // correct naming and type
+ }
+
+ // the name of the method indicates, it is a boolean, but the method returns an int.
+ int isValid() {
+ return 1;
+ }
+ // correct naming and return type
+ boolean isSmall() {
+ return true;
+ }
+
+ // the name indicates, this is a setter, but it returns something
+ int setName() {
+ return 1;
+ }
+
+ // the name indicates, this is a getter, but it doesn't return anything
+ void getName() {
+ // nothing to return?
+ }
+
+ // the name indicates, it transforms an object and should return the result
+ void toDataType() {
+ // nothing to return?
+ }
+ // the name indicates, it transforms an object and should return the result
+ void grapeToWine() {
+ // nothing to return?
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|booleanFieldPrefixes|is \| has \| can \| have \| will \| should|The prefixes of fields and variables that indicate boolean.|yes. Delimiter is '\|'.|
+|checkVariables|true|Check local variable names and types for inconsistent naming.|no|
+|checkFields|true|Check field names and types for inconsistent naming.|no|
+|transformMethodNames|to \| as|The prefixes and infixes that indicate a transform method.|yes. Delimiter is '\|'.|
+|booleanMethodPrefixes|is \| has \| can \| have \| will \| should|The prefixes of methods that return boolean.|yes. Delimiter is '\|'.|
+|checkPrefixedTransformMethods|true|Check return type of methods whose names start with the configured prefix (see transformMethodNames property).|no|
+|checkTransformMethods|false|Check return type of methods which contain the configured infix in their name (see transformMethodNames property).|no|
+|checkSetters|true|Check return type of setters.|no|
+|checkGetters|true|Check return type of getters.|no|
+|checkBooleanMethod|true|Check method names and types for inconsistent naming.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## LocalHomeNamingConvention
+
+**Since:** PMD 4.0
+
+**Priority:** Medium Low (4)
+
+The Local Home interface of a Session EJB should be suffixed by 'LocalHome'.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration
+[
+ (
+ (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalHome')])
+ )
+ and
+ not
+ (
+ ends-with(@Image,'LocalHome')
+ )
+]
+```
+
+**Example(s):**
+
+``` java
+public interface MyBeautifulLocalHome extends javax.ejb.EJBLocalHome {} // proper name
+
+public interface MissingProperSuffix extends javax.ejb.EJBLocalHome {} // non-standard name
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## LocalInterfaceSessionNamingConvention
+
+**Since:** PMD 4.0
+
+**Priority:** Medium Low (4)
+
+The Local Interface of a Session EJB should be suffixed by 'Local'.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration
+[
+ (
+ (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalObject')])
+ )
+ and
+ not
+ (
+ ends-with(@Image,'Local')
+ )
+]
+```
+
+**Example(s):**
+
+``` java
+public interface MyLocal extends javax.ejb.EJBLocalObject {} // proper name
+
+public interface MissingProperSuffix extends javax.ejb.EJBLocalObject {} // non-standard name
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## LocalVariableCouldBeFinal
+
+**Since:** PMD 2.2
+
+**Priority:** Medium (3)
+
+A local variable assigned only once can be declared final.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.LocalVariableCouldBeFinalRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LocalVariableCouldBeFinalRule.java)
+
+**Example(s):**
+
+``` java
+public class Bar {
+ public void foo () {
+ String txtA = "a"; // if txtA will not be assigned again it is better to do this:
+ final String txtB = "b";
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## LocalVariableNamingConventions
+
+**Since:** PMD 6.6.0
+
+**Priority:** High (1)
+
+Configurable naming conventions for local variable declarations and other locally-scoped
+variables. This rule reports variable declarations which do not match the regex that applies to their
+specific kind (e.g. final variable, or catch-clause parameter). Each regex can be configured through
+properties.
+
+By default this rule uses the standard Java naming convention (Camel case).
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.LocalVariableNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LocalVariableNamingConventionsRule.java)
+
+**Example(s):**
+
+``` java
+class Foo {
+ void bar() {
+ int localVariable = 1; // This is in camel case, so it's ok
+ int local_variable = 1; // This will be reported unless you change the regex
+
+ final int i_var = 1; // final local variables can be configured separately
+
+ try {
+ foo();
+ } catch (IllegalArgumentException e_illegal) {
+ // exception block parameters can be configured separately
+ }
+
+ }
+ }
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|localVarPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to non-final local variable names|no|
+|finalVarPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to final local variable names|no|
+|catchParameterPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to exception block parameter names|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## LongVariable
+
+**Since:** PMD 0.3
+
+**Priority:** Medium (3)
+
+Fields, formal arguments, or local variable names that are too long can make the code difficult to follow.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//VariableDeclaratorId[string-length(@Image) > $minimum]
+```
+
+**Example(s):**
+
+``` java
+public class Something {
+ int reallyLongIntName = -3; // VIOLATION - Field
+ public static void main( String argumentsList[] ) { // VIOLATION - Formal
+ int otherReallyLongName = -5; // VIOLATION - Local
+ for (int interestingIntIndex = 0; // VIOLATION - For
+ interestingIntIndex < 10;
+ interestingIntIndex ++ ) {
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|minimum|17|The variable length reporting threshold|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MDBAndSessionBeanNamingConvention
+
+**Since:** PMD 4.0
+
+**Priority:** Medium Low (4)
+
+The EJB Specification states that any MessageDrivenBean or SessionBean should be suffixed by 'Bean'.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//TypeDeclaration/ClassOrInterfaceDeclaration
+[
+ (
+ (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'SessionBean')])
+ or
+ (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'MessageDrivenBean')])
+ )
+ and
+ not
+ (
+ ends-with(@Image,'Bean')
+ )
+]
+```
+
+**Example(s):**
+
+``` java
+public class SomeBean implements SessionBean{} // proper name
+
+public class MissingTheProperSuffix implements SessionBean {} // non-standard name
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MethodArgumentCouldBeFinal
+
+**Since:** PMD 2.2
+
+**Priority:** Medium (3)
+
+A method argument that is never re-assigned within the method can be declared final.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.MethodArgumentCouldBeFinalRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/MethodArgumentCouldBeFinalRule.java)
+
+**Example(s):**
+
+``` java
+public void foo1 (String param) { // do stuff with param never assigning it
+
+}
+
+public void foo2 (final String param) { // better, do stuff with param never assigning it
+
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MethodNamingConventions
+
+**Since:** PMD 1.2
+
+**Priority:** High (1)
+
+Configurable naming conventions for method declarations. This rule reports
+method declarations which do not match the regex that applies to their
+specific kind (e.g. JUnit test or native method). Each regex can be
+configured through properties.
+
+By default this rule uses the standard Java naming convention (Camel case).
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.MethodNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/MethodNamingConventionsRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void fooStuff() {
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|checkNativeMethods|true|Deprecated Check native methods|no|
+|methodPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to instance method names|no|
+|staticPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to static method names|no|
+|nativePattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to native method names|no|
+|junit3TestPattern|test\[A-Z0-9\]\[a-zA-Z0-9\]\*|Regex which applies to JUnit 3 test method names|no|
+|junit4TestPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to JUnit 4 test method names|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MIsLeadingVariableName
+
+Deprecated
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+Detects when a non-field has a name starting with 'm_'. This usually denotes a field and could be confusing.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//VariableDeclaratorId
+[starts-with(@Image, 'm_')]
+[not (../../../FieldDeclaration)]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private int m_foo; // OK
+ public void bar(String m_baz) { // Bad
+ int m_boz = 42; // Bad
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoPackage
+
+**Since:** PMD 3.3
+
+**Priority:** Medium (3)
+
+Detects when a class or interface does not have a package definition.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[count(preceding::PackageDeclaration) = 0]
+```
+
+**Example(s):**
+
+``` java
+// no package declaration
+public class ClassInDefaultPackage {
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## OnlyOneReturn
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+A method should have only one exit point, and that should be the last statement in the method.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.OnlyOneReturnRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/OnlyOneReturnRule.java)
+
+**Example(s):**
+
+``` java
+public class OneReturnOnly1 {
+ public void foo(int x) {
+ if (x > 0) {
+ return "hey"; // first exit
+ }
+ return "hi"; // second exit
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## PackageCase
+
+**Since:** PMD 3.3
+
+**Priority:** Medium (3)
+
+Detects when a package definition contains uppercase characters.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PackageDeclaration/Name[lower-case(@Image)!=@Image]
+```
+
+**Example(s):**
+
+``` java
+package com.MyCompany; // should be lowercase name
+
+public class SomeClass {
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## PrematureDeclaration
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Checks for variables that are defined before they might be used. A reference is deemed to be premature if it is created right before a block of code that doesn't use it that also has the ability to return or throw an exception.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.PrematureDeclarationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/PrematureDeclarationRule.java)
+
+**Example(s):**
+
+``` java
+public int getLength(String[] strings) {
+
+ int length = 0; // declared prematurely
+
+ if (strings == null || strings.length == 0) return 0;
+
+ for (String str : strings) {
+ length += str.length();
+ }
+
+ return length;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## RemoteInterfaceNamingConvention
+
+**Since:** PMD 4.0
+
+**Priority:** Medium Low (4)
+
+Remote Interface of a Session EJB should not have a suffix.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration
+[
+ (
+ (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBObject')])
+ )
+ and
+ (
+ ends-with(@Image,'Session')
+ or
+ ends-with(@Image,'EJB')
+ or
+ ends-with(@Image,'Bean')
+ )
+]
+```
+
+**Example(s):**
+
+``` java
+/* Poor Session suffix */
+public interface BadSuffixSession extends javax.ejb.EJBObject {}
+
+/* Poor EJB suffix */
+public interface BadSuffixEJB extends javax.ejb.EJBObject {}
+
+/* Poor Bean suffix */
+public interface BadSuffixBean extends javax.ejb.EJBObject {}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## RemoteSessionInterfaceNamingConvention
+
+**Since:** PMD 4.0
+
+**Priority:** Medium Low (4)
+
+A Remote Home interface type of a Session EJB should be suffixed by 'Home'.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration
+[
+ (
+ (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBHome')])
+ )
+ and
+ not
+ (
+ ends-with(@Image,'Home')
+ )
+]
+```
+
+**Example(s):**
+
+``` java
+public interface MyBeautifulHome extends javax.ejb.EJBHome {} // proper name
+
+public interface MissingProperSuffix extends javax.ejb.EJBHome {} // non-standard name
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ShortClassName
+
+**Since:** PMD 5.0
+
+**Priority:** Medium Low (4)
+
+Short Classnames with fewer than e.g. five characters are not recommended.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[string-length(@Image) < $minimum]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|minimum|5|Number of characters that are required as a minimum for a class name.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ShortMethodName
+
+**Since:** PMD 0.3
+
+**Priority:** Medium (3)
+
+Method names that are very short are not helpful to the reader.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclarator[string-length(@Image) < $minimum]
+```
+
+**Example(s):**
+
+``` java
+public class ShortMethod {
+ public void a( int i ) { // Violation
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|minimum|3|Number of characters that are required as a minimum for a method name.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ShortVariable
+
+**Since:** PMD 0.3
+
+**Priority:** Medium (3)
+
+Fields, local variables, or parameter names that are very short are not helpful to the reader.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//VariableDeclaratorId[string-length(@Image) < $minimum]
+ (: ForStatement :)
+ [not(../../..[self::ForInit])]
+ (: Foreach statement :)
+ [not(../../..[self::ForStatement])]
+ (: Catch statement parameter :)
+ [not(../..[self::CatchStatement])]
+ (: Lambda expression parameter :)
+ [not(parent::LambdaExpression or ../../..[self::LambdaExpression])]
+```
+
+**Example(s):**
+
+``` java
+public class Something {
+ private int q = 15; // field - too short
+ public static void main( String as[] ) { // formal arg - too short
+ int r = 20 + q; // local var - too short
+ for (int i = 0; i < 10; i++) { // not a violation (inside 'for' loop)
+ r += q;
+ }
+ for (Integer i : numbers) { // not a violation (inside 'for-each' loop)
+ r += q;
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|minimum|3|Number of characters that are required as a minimum for a variable name.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SuspiciousConstantFieldName
+
+Deprecated
+
+**Since:** PMD 2.0
+
+**Priority:** Medium (3)
+
+Field names using all uppercase characters - Sun's Java naming conventions indicating constants - should
+be declared as final.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[@Interface='false']
+ /ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/FieldDeclaration
+ [@Final='false']
+ [VariableDeclarator/VariableDeclaratorId[upper-case(@Image)=@Image]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ // this is bad, since someone could accidentally
+ // do PI = 2.71828; which is actually e
+ // final double PI = 3.16; is ok
+ double PI = 3.16;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## TooManyStaticImports
+
+**Since:** PMD 4.1
+
+**Priority:** Medium (3)
+
+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).
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+.[count(ImportDeclaration[@Static = 'true']) > $maximumStaticImports]
+```
+
+**Example(s):**
+
+``` java
+import static Lennon;
+import static Ringo;
+import static George;
+import static Paul;
+import static Yoko; // Too much !
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|maximumStaticImports|4|All static imports can be disallowed by setting this to 0|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryAnnotationValueElement
+
+**Since:** PMD 6.2.0
+
+**Priority:** Medium (3)
+
+Avoid the use of value in annotations when it's the only element.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryAnnotationValueElementRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryAnnotationValueElementRule.java)
+
+**Example(s):**
+
+``` java
+@TestClassAnnotation(value = "TEST")
+public class Foo {
+
+ @TestMemberAnnotation(value = "TEST")
+ private String y;
+
+ @TestMethodAnnotation(value = "TEST")
+ public void bar() {
+ int x = 42;
+ return;
+ }
+}
+
+// should be
+
+@TestClassAnnotation("TEST")
+public class Foo {
+
+ @TestMemberAnnotation("TEST")
+ private String y;
+
+ @TestMethodAnnotation("TEST")
+ public void bar() {
+ int x = 42;
+ return;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryConstructor
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+This rule detects when a constructor is not necessary; i.e., when there is only one constructor and the
+constructor is identical to the default constructor. The default constructor should has same access
+modifier as the declaring class. In an enum type, the default constructor is implicitly private.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryConstructorRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryConstructorRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public Foo() {}
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoredAnnotations|javax.inject.Inject|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryFullyQualifiedName
+
+**Since:** PMD 5.0
+
+**Priority:** Medium Low (4)
+
+Import statements allow the use of non-fully qualified names. The use of a fully qualified name
+which is covered by an import statement is redundant. Consider using the non-fully qualified name.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryFullyQualifiedNameRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryFullyQualifiedNameRule.java)
+
+**Example(s):**
+
+``` java
+import java.util.List;
+
+public class Foo {
+ private java.util.List list1; // Unnecessary FQN
+ private List list2; // More appropriate given import of 'java.util.List'
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryLocalBeforeReturn
+
+**Since:** PMD 3.3
+
+**Priority:** Medium (3)
+
+Avoid the creation of unnecessary local variables
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryLocalBeforeReturnRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryLocalBeforeReturnRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public int foo() {
+ int x = doSomething();
+ return x; // instead, just 'return doSomething();'
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|statementOrderMatters|true|If set to false this rule no longer requires the variable declaration and return statement to be on consecutive lines. Any variable that is used solely in a return statement will be reported.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryModifier
+
+**Since:** PMD 1.02
+
+**Priority:** Medium (3)
+
+Fields in interfaces and annotations are automatically `public static final`, and methods are `public abstract`.
+Classes, interfaces or annotations nested in an interface or annotation are automatically `public static`
+(all nested interfaces and annotations are automatically static).
+Nested enums are automatically `static`.
+For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryModifierRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryModifierRule.java)
+
+**Example(s):**
+
+``` java
+public @interface Annotation {
+ public abstract void bar(); // both abstract and public are ignored by the compiler
+ public static final int X = 0; // public, static, and final all ignored
+ public static class Bar {} // public, static ignored
+ public static interface Baz {} // ditto
+}
+public interface Foo {
+ public abstract void bar(); // both abstract and public are ignored by the compiler
+ public static final int X = 0; // public, static, and final all ignored
+ public static class Bar {} // public, static ignored
+ public static interface Baz {} // ditto
+}
+public class Bar {
+ public static interface Baz {} // static ignored
+ public static enum FoorBar { // static ignored
+ FOO;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryReturn
+
+**Since:** PMD 1.3
+
+**Priority:** Medium (3)
+
+Avoid the use of unnecessary return statements.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryReturnRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryReturnRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar() {
+ int x = 42;
+ return;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UselessParentheses
+
+**Since:** PMD 5.0
+
+**Priority:** Medium Low (4)
+
+Useless parentheses should be removed.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Expression[not(parent::PrimaryPrefix)]/PrimaryExpression[count(*)>1]
+ /PrimaryPrefix/Expression
+ [not(./CastExpression)]
+ [not(./ConditionalExpression)]
+ [not(./AdditiveExpression)]
+ [not(./AssignmentOperator)]
+|
+//Expression[not(parent::PrimaryPrefix)]/PrimaryExpression[count(*)=1]
+ /PrimaryPrefix/Expression
+|
+//Expression/ConditionalAndExpression/PrimaryExpression/PrimaryPrefix/Expression[
+ count(*)=1 and
+ count(./CastExpression)=0 and
+ count(./EqualityExpression/MultiplicativeExpression)=0 and
+ count(./ConditionalExpression)=0 and
+ count(./ConditionalOrExpression)=0]
+|
+//Expression/ConditionalOrExpression/PrimaryExpression/PrimaryPrefix/Expression[
+ count(*)=1 and
+ not(./CastExpression) and
+ not(./ConditionalExpression) and
+ not(./EqualityExpression/MultiplicativeExpression)]
+|
+//Expression/ConditionalExpression/PrimaryExpression/PrimaryPrefix/Expression[
+ count(*)=1 and
+ not(./CastExpression) and
+ not(./EqualityExpression)]
+|
+//Expression/AdditiveExpression[not(./PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true'])]
+ /PrimaryExpression[1]/PrimaryPrefix/Expression[
+ count(*)=1 and
+ not(./CastExpression) and
+ not(./AdditiveExpression[@Image = '-']) and
+ not(./ShiftExpression) and
+ not(./RelationalExpression) and
+ not(./InstanceOfExpression) and
+ not(./EqualityExpression) and
+ not(./AndExpression) and
+ not(./ExclusiveOrExpression) and
+ not(./InclusiveOrExpression) and
+ not(./ConditionalAndExpression) and
+ not(./ConditionalOrExpression) and
+ not(./ConditionalExpression)]
+|
+//Expression/EqualityExpression/PrimaryExpression/PrimaryPrefix/Expression[
+ count(*)=1 and
+ not(./CastExpression) and
+ not(./AndExpression) and
+ not(./InclusiveOrExpression) and
+ not(./ExclusiveOrExpression) and
+ not(./ConditionalExpression) and
+ not(./ConditionalAndExpression) and
+ not(./ConditionalOrExpression) and
+ not(./EqualityExpression)]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+
+ private int _bar1;
+ private Integer _bar2;
+
+ public void setBar(int n) {
+ _bar1 = Integer.valueOf((n)); // here
+ _bar2 = (n); // and here
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UselessQualifiedThis
+
+**Since:** PMD 5.4.0
+
+**Priority:** Medium (3)
+
+Reports qualified this usages in the same class.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression
+[PrimaryPrefix/Name[@Image]]
+[PrimarySuffix[@Arguments='false' and @ArrayDereference = 'false']]
+[not(PrimarySuffix/MemberSelector)]
+[ancestor::ClassOrInterfaceBodyDeclaration[1][@AnonymousInnerClass='false']]
+/PrimaryPrefix/Name[@Image = ancestor::ClassOrInterfaceDeclaration[1]/@Image]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ final Foo otherFoo = Foo.this; // use "this" directly
+
+ public void doSomething() {
+ final Foo anotherFoo = Foo.this; // use "this" directly
+ }
+
+ private ActionListener returnListener() {
+ return new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ doSomethingWithQualifiedThis(Foo.this); // This is fine
+ }
+ };
+ }
+
+ private class Foo3 {
+ final Foo myFoo = Foo.this; // This is fine
+ }
+
+ private class Foo2 {
+ final Foo2 myFoo2 = Foo2.this; // Use "this" direclty
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseUnderscoresInNumericLiterals
+
+**Since:** PMD 6.10.0
+
+**Priority:** Medium (3)
+
+**Minimum Language Version:** Java 1.7
+
+Since Java 1.7, numeric literals can use underscores to separate digits. This rule enforces that
+numeric literals above a certain length use these underscores to increase readability.
+
+The rule only supports decimal (base 10) literals for now. The acceptable length under which literals
+are not required to have underscores is configurable via a property. Even under that length, underscores
+that are misplaced (not making groups of 3 digits) are reported.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Literal[
+ @IntLiteral = true()
+ or @LongLiteral = true()
+ or @DoubleLiteral = true()
+ or @FloatLiteral = true()
+]
+ (: Filter out literals in base other than 10 :)
+ [not(matches(@Image, "^0[^.]"))]
+ (: Filter out ignored field name :)
+ [not(ancestor::VariableDeclarator[1][@Name = 'serialVersionUID'])]
+ [
+ some $num in tokenize(@Image, "[.dDfFlLeE+\-]")
+ satisfies not(
+ string-length($num) <= $acceptableDecimalLength
+ and not(contains($num,"_"))
+ or matches($num, "^[0-9]{1,3}(_[0-9]{3})*$")
+ )
+ ]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private int num = 1000000; // should be 1_000_000
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|acceptableDecimalLength|4|Length under which literals in base 10 are not required to have underscores|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## VariableNamingConventions
+
+Deprecated
+
+**Since:** PMD 1.2
+
+**Priority:** High (1)
+
+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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.VariableNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/VariableNamingConventionsRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public static final int MY_NUM = 0;
+ public String myTest = "";
+ DataModule dmTest = new DataModule();
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|parameterSuffix||Method parameter variable suffixes|yes. Delimiter is ','.|
+|parameterPrefix||Method parameter variable prefixes|yes. Delimiter is ','.|
+|localSuffix||Local variable suffixes|yes. Delimiter is ','.|
+|localPrefix||Local variable prefixes|yes. Delimiter is ','.|
+|memberSuffix||Member variable suffixes|yes. Delimiter is ','.|
+|memberPrefix||Member variable prefixes|yes. Delimiter is ','.|
+|staticSuffix||Static variable suffixes|yes. Delimiter is ','.|
+|checkParameters|true|Check constructor and method parameter variables|no|
+|checkNativeMethodParameters|true|Check method parameter of native methods|no|
+|staticPrefix||Static variable prefixes|yes. Delimiter is ','.|
+|checkLocals|true|Check local variables|no|
+|checkMembers|true|Check member variables|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## WhileLoopsMustUseBraces
+
+Deprecated
+
+**Since:** PMD 0.7
+
+**Priority:** Medium (3)
+
+Avoid using 'while' statements without using braces to surround the code block. If the code
+formatting or indentation is lost then it becomes difficult to separate the code being
+controlled from the rest.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//WhileStatement[not(Statement/Block)]
+```
+
+**Example(s):**
+
+``` java
+while (true) // not recommended
+ x++;
+
+while (true) { // preferred approach
+ x++;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/java/comments.md b/docs/pages/pmd/rules/java/comments.md
deleted file mode 100644
index ac237f75f6c..00000000000
--- a/docs/pages/pmd/rules/java/comments.md
+++ /dev/null
@@ -1,165 +0,0 @@
----
-title: Comments
-summary: Rules intended to catch errors related to code comments
-permalink: pmd_rules_java_comments.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/comments.xml
-keywords: Comments, CommentRequired, CommentSize, CommentContent, CommentDefaultAccessModifier
----
-## CommentContent
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-A rule for the politically correct... we don't want to offend anyone.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.comments.CommentContentRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/comments/CommentContentRule.java)
-
-**Example(s):**
-
-``` java
-//OMG, this is horrible, Bob is an idiot !!!
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|disallowedTerms|[idiot, jerk]|Illegal terms or phrases|
-|caseSensitive|false|Case sensitive|
-|wordsAreRegex|false|Use regular expressions|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CommentDefaultAccessModifier
-
-**Since:** PMD 5.4.0
-
-**Priority:** Medium (3)
-
-To avoid mistakes if we want that a Method, Constructor, Field or Nested class have a default access modifier
- we must add a comment at the beginning of it's declaration.
- By default the comment must be /* default */, if you want another, you have to provide a regexp.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.comments.CommentDefaultAccessModifierRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/comments/CommentDefaultAccessModifierRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- final String stringValue = "some string";
- String getString() {
- return stringValue;
- }
-
- class NestedFoo {
- }
- }
-
- // should be
- public class Foo {
- /* default */ final String stringValue = "some string";
- /* default */ String getString() {
- return stringValue;
- }
-
- /* default */ class NestedFoo {
- }
- }
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|regex||Regular expression|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CommentRequired
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Denotes whether comments are required (or unwanted) for specific language elements.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.comments.CommentRequiredRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/comments/CommentRequiredRule.java)
-
-**Example(s):**
-
-``` java
-/**
-*
-*
-* @author Jon Doe
-*/
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|serialVersionUIDCommentRequired|Ignored|serial version UID commts. Possible values: [Required, Ignored, Unwanted]|
-|enumCommentRequirement|Required|Enum comments. Possible values: [Required, Ignored, Unwanted]|
-|protectedMethodCommentRequirement|Required|Protected method constructor comments. Possible values: [Required, Ignored, Unwanted]|
-|publicMethodCommentRequirement|Required|Public method and constructor comments. Possible values: [Required, Ignored, Unwanted]|
-|fieldCommentRequirement|Required|Field comments. Possible values: [Required, Ignored, Unwanted]|
-|headerCommentRequirement|Required|Header comments. Possible values: [Required, Ignored, Unwanted]|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CommentSize
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Determines whether the dimensions of non-header comments found are within the specified limits.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.comments.CommentSizeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/comments/CommentSizeRule.java)
-
-**Example(s):**
-
-``` java
-/**
-*
-* too many lines!
-*
-*
-*
-*
-*
-*
-*
-*
-*
-*
-*
-*
-*/
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|maxLines|6|Maximum lines|
-|maxLineLength|80|Maximum line length|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/controversial.md b/docs/pages/pmd/rules/java/controversial.md
deleted file mode 100644
index ec1ec4e7f6f..00000000000
--- a/docs/pages/pmd/rules/java/controversial.md
+++ /dev/null
@@ -1,888 +0,0 @@
----
-title: Controversial
-summary: The Controversial ruleset contains rules that, for whatever reason, are considered controversial. They are held here to allow people to include them as they see fit within their custom rulesets.
-permalink: pmd_rules_java_controversial.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/controversial.xml
-keywords: Controversial, UnnecessaryConstructor, NullAssignment, OnlyOneReturn, AssignmentInOperand, AtLeastOneConstructor, DontImportSun, SuspiciousOctalEscape, CallSuperInConstructor, UnnecessaryParentheses, DefaultPackage, DataflowAnomalyAnalysis, AvoidFinalLocalVariable, AvoidUsingShortType, AvoidUsingVolatile, AvoidUsingNativeCode, AvoidAccessibilityAlteration, DoNotCallGarbageCollectionExplicitly, OneDeclarationPerLine, AvoidPrefixingMethodParameters, AvoidLiteralsInIfCondition, UseObjectForClearerAPI, UseConcurrentHashMap
----
-## AssignmentInOperand
-
-**Since:** PMD 1.03
-
-**Priority:** Medium (3)
-
-Avoid assignments in operands; this can make code more complicated and harder to read.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.controversial.AssignmentInOperandRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/controversial/AssignmentInOperandRule.java)
-
-**Example(s):**
-
-``` java
-public void bar() {
- int x = 2;
- if ((x = getX()) == 3) {
- System.out.println("3!");
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|allowIncrementDecrement|false|Allow increment or decrement operators within the conditional expression of an if, for, or while statement|
-|allowWhile|false|Allow assignment within the conditional expression of a while statement|
-|allowFor|false|Allow assignment within the conditional expression of a for statement|
-|allowIf|false|Allow assignment within the conditional expression of an if statement|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AtLeastOneConstructor
-
-**Since:** PMD 1.04
-
-**Priority:** Medium (3)
-
-Each class should declare at least one constructor.
-
-```
-//ClassOrInterfaceDeclaration[
- not(ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration)
- and
- (@Static = 'false')
- and
- (count(./descendant::MethodDeclaration[@Static = 'true']) < 1)
-]
- [@Interface='false']
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- // missing constructor
- public void doSomething() { ... }
- public void doOtherThing { ... }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidAccessibilityAlteration
-
-**Since:** PMD 4.1
-
-**Priority:** Medium (3)
-
-Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
-as the interface PrivilegedAction, allows for the runtime alteration of variable, class, or
-method visibility, even if they are private. This violates the principle of encapsulation.
-
-```
-//PrimaryExpression[
- (
- (PrimarySuffix[
- ends-with(@Image,'getDeclaredConstructors')
- or
- ends-with(@Image,'getDeclaredConstructor')
- or
- ends-with(@Image,'setAccessible')
- ])
- or
- (PrimaryPrefix/Name[
- ends-with(@Image,'getDeclaredConstructor')
- or
- ends-with(@Image,'getDeclaredConstructors')
- or
- starts-with(@Image,'AccessibleObject.setAccessible')
- ])
- )
- and
- (//ImportDeclaration/Name[
- contains(@Image,'java.security.PrivilegedAction')])
- ]
-```
-
-**Example(s):**
-
-``` java
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Method;
-import java.security.PrivilegedAction;
-
-public class Violation {
- public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
- // Possible call to forbidden getDeclaredConstructors
- Class[] arrayOfClass = new Class[1];
- this.getClass().getDeclaredConstructors();
- this.getClass().getDeclaredConstructor(arrayOfClass);
- Class clazz = this.getClass();
- clazz.getDeclaredConstructor(arrayOfClass);
- clazz.getDeclaredConstructors();
- // Possible call to forbidden setAccessible
- clazz.getMethod("", arrayOfClass).setAccessible(false);
- AccessibleObject.setAccessible(null, false);
- Method.setAccessible(null, false);
- Method[] methodsArray = clazz.getMethods();
- int nbMethod;
- for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
- methodsArray[nbMethod].setAccessible(false);
- }
-
- // Possible call to forbidden PrivilegedAction
- PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidFinalLocalVariable
-
-**Since:** PMD 4.1
-
-**Priority:** Medium (3)
-
-Avoid using final local variables, turn them into fields.
-
-```
-//LocalVariableDeclaration[
- @Final = 'true'
- and not(../../ForStatement)
- and
- (
- (count(VariableDeclarator/VariableInitializer) = 0)
- or
- (VariableDeclarator/VariableInitializer/Expression/PrimaryExpression/PrimaryPrefix/Literal)
- )
-]
-```
-
-**Example(s):**
-
-``` java
-public class MyClass {
- public void foo() {
- final String finalLocalVariable;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidLiteralsInIfCondition
-
-**Since:** PMD 4.2.6
-
-**Priority:** Medium (3)
-
-Avoid using hard-coded literals in conditional statements. By declaring them as static variables
-or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored.
-More exceptions can be defined with the property "ignoreMagicNumbers".
-
-```
-//IfStatement/Expression/*/PrimaryExpression/PrimaryPrefix/Literal
-[not(NullLiteral)]
-[not(BooleanLiteral)]
-[empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
-```
-
-**Example(s):**
-
-``` java
-private static final int MAX_NUMBER_OF_REQUESTS = 10;
-
-public void checkRequests() {
-
- if (i == 10) { // magic number, buried in a method
- doSomething();
- }
-
- if (i == MAX_NUMBER_OF_REQUESTS) { // preferred approach
- doSomething();
- }
-
- if (aString.indexOf('.') != -1) {} // magic number -1, by default ignored
- if (aString.indexOf('.') >= 0) { } // alternative approach
-
- if (aDouble > 0.0) {} // magic number 0.0
- if (aDouble >= Double.MIN_VALUE) {} // preferred approach
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|ignoreMagicNumbers|-1,0|Comma-separated list of magic numbers, that should be ignored|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidPrefixingMethodParameters
-
-**Since:** PMD 5.0
-
-**Priority:** Medium Low (4)
-
-Prefixing parameters by 'in' or 'out' pollutes the name of the parameters and reduces code readability.
-To indicate whether or not a parameter will be modify in a method, its better to document method
-behavior with Javadoc.
-
-```
-//MethodDeclaration/MethodDeclarator/FormalParameters/FormalParameter/VariableDeclaratorId[
- pmd:matches(@Image,'^in[A-Z].*','^out[A-Z].*','^in$','^out$')
-]
-```
-
-**Example(s):**
-
-``` java
-// Not really clear
-public class Foo {
- public void bar(
- int inLeftOperand,
- Result outRightOperand) {
- outRightOperand.setValue(inLeftOperand * outRightOperand.getValue());
- }
-}
-```
-
-``` java
-// Far more useful
-public class Foo {
- /**
- *
- * @param leftOperand, (purpose), not modified by method.
- * @param rightOperand (purpose), will be modified by the method: contains the result.
- */
- public void bar(
- int leftOperand,
- Result rightOperand) {
- rightOperand.setValue(leftOperand * rightOperand.getValue());
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidUsingNativeCode
-
-**Since:** PMD 4.1
-
-**Priority:** Medium High (2)
-
-Unnecessary reliance on Java Native Interface (JNI) calls directly reduces application portability
-and increases the maintenance burden.
-
-```
-//Name[starts-with(@Image,'System.loadLibrary')]
-```
-
-**Example(s):**
-
-``` java
-public class SomeJNIClass {
-
- public SomeJNIClass() {
- System.loadLibrary("nativelib");
- }
-
- static {
- System.loadLibrary("nativelib");
- }
-
- public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
- System.loadLibrary("nativelib");
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidUsingShortType
-
-**Since:** PMD 4.1
-
-**Priority:** High (1)
-
-Java uses the 'short' type to reduce memory usage, not to optimize calculation. In fact, the JVM does not have any
-arithmetic capabilities for the short type: the JVM must convert the short into an int, do the proper calculation
-and convert the int back to a short. Thus any storage gains found through use of the 'short' type may be offset by
-adverse impacts on performance.
-
-```
-//PrimitiveType[@Image = 'short'][name(../..) != 'CastExpression']
-```
-
-**Example(s):**
-
-``` java
-public class UsingShort {
- private short doNotUseShort = 0;
-
- public UsingShort() {
- short shouldNotBeUsed = 1;
- doNotUseShort += shouldNotBeUsed;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidUsingVolatile
-
-**Since:** PMD 4.1
-
-**Priority:** Medium High (2)
-
-Use of the keyword 'volatile' is generally used to fine tune a Java application, and therefore, requires
-a good expertise of the Java Memory Model. Moreover, its range of action is somewhat misknown. Therefore,
-the volatile keyword should not be used for maintenance purpose and portability.
-
-```
-//FieldDeclaration[contains(@Volatile,'true')]
-```
-
-**Example(s):**
-
-``` java
-public class ThrDeux {
- private volatile String var1; // not suggested
- private String var2; // preferred
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CallSuperInConstructor
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-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.
-
-```
-//ClassOrInterfaceDeclaration[ count (ExtendsList/*) > 0 ]
-/ClassOrInterfaceBody
- /ClassOrInterfaceBodyDeclaration
- /ConstructorDeclaration[ count (.//ExplicitConstructorInvocation)=0 ]
-```
-
-**Example(s):**
-
-``` java
-public class Foo extends Bar{
- public Foo() {
- // call the constructor of Bar
- super();
- }
- public Foo(int code) {
- // do something with code
- this();
- // no problem with this
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DataflowAnomalyAnalysis
-
-**Since:** PMD 3.9
-
-**Priority:** Low (5)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.controversial.DataflowAnomalyAnalysisRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/controversial/DataflowAnomalyAnalysisRule.java)
-
-**Example(s):**
-
-``` java
-public void foo() {
- int buz = 5;
- buz = 6; // redefinition of buz -> dd-anomaly
- foo(buz);
- buz = 2;
-} // buz is undefined when leaving scope -> du-anomaly
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|maxViolations|100|Maximum number of anomalies per class|
-|maxPaths|1000|Maximum number of checked paths per method. A lower value will increase the performance of the rule but may decrease anomalies found.|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DefaultPackage
-
-**Since:** PMD 3.4
-
-**Priority:** Medium (3)
-
-Use explicit scoping instead of accidental usage of default package private level.
-The rule allows methods and fields annotated with Guava's @VisibleForTesting.
-
-```
-//ClassOrInterfaceDeclaration[@Interface='false']
-/ClassOrInterfaceBody
-/ClassOrInterfaceBodyDeclaration
-[not(Annotation//Name[ends-with(@Image, 'VisibleForTesting')])]
-[
-FieldDeclaration[@PackagePrivate='true']
-or MethodDeclaration[@PackagePrivate='true']
-]
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DoNotCallGarbageCollectionExplicitly
-
-**Since:** PMD 4.2
-
-**Priority:** Medium High (2)
-
-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.
-
-```
-//Name[
-(starts-with(@Image, 'System.') and
-(starts-with(@Image, 'System.gc') or
-starts-with(@Image, 'System.runFinalization'))) or
-(
-starts-with(@Image,'Runtime.getRuntime') and
-../../PrimarySuffix[ends-with(@Image,'gc')]
-)
-]
-```
-
-**Example(s):**
-
-``` java
-public class GCCall {
- public GCCall() {
- // Explicit gc call !
- System.gc();
- }
-
- public void doSomething() {
- // Explicit gc call !
- Runtime.getRuntime().gc();
- }
-
- public explicitGCcall() {
- // Explicit gc call !
- System.gc();
- }
-
- public void doSomething() {
- // Explicit gc call !
- Runtime.getRuntime().gc();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DontImportSun
-
-**Since:** PMD 1.5
-
-**Priority:** Medium Low (4)
-
-Avoid importing anything from the 'sun.*' packages. These packages are not portable and are likely to change.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.controversial.DontImportSunRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/controversial/DontImportSunRule.java)
-
-**Example(s):**
-
-``` java
-import sun.misc.foo;
-public class Foo {}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NullAssignment
-
-**Since:** PMD 1.02
-
-**Priority:** Medium (3)
-
-Assigning a "null" to a variable (outside of its declaration) is usually bad form. Sometimes, this type
-of assignment is an indication that the programmer doesn't completely understand what is going on in the code.
-
-NOTE: This sort of assignment may used in some cases to dereference objects and encourage garbage collection.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.controversial.NullAssignmentRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/controversial/NullAssignmentRule.java)
-
-**Example(s):**
-
-``` java
-public void bar() {
- Object x = null; // this is OK
- x = new Object();
- // big, complex piece of code here
- x = null; // this is not required
- // big, complex piece of code here
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## OneDeclarationPerLine
-
-**Since:** PMD 5.0
-
-**Priority:** Medium Low (4)
-
-Java allows the use of several variables declaration of the same type on one line. However, it
-can lead to quite messy code. This rule looks for several declarations on the same line.
-
-```
-//LocalVariableDeclaration
- [count(VariableDeclarator) > 1]
- [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)]
-```
-
-**Example(s):**
-
-``` java
-String name; // separate declarations
-String lastname;
-
-String name, lastname; // combined declaration, a violation
-
-String name,
- lastname; // combined declaration on multiple lines, no violation by default.
- // Set property strictMode to true to mark this as violation.
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|strictMode|false|If true, mark combined declaration even if the declarations are on separate lines.|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## OnlyOneReturn
-
-**Since:** PMD 1.0
-
-**Priority:** Medium (3)
-
-A method should have only one exit point, and that should be the last statement in the method.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.controversial.OnlyOneReturnRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/controversial/OnlyOneReturnRule.java)
-
-**Example(s):**
-
-``` java
-public class OneReturnOnly1 {
- public void foo(int x) {
- if (x > 0) {
- return "hey"; // first exit
- }
- return "hi"; // second exit
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SuspiciousOctalEscape
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-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".
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.controversial.SuspiciousOctalEscapeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/controversial/SuspiciousOctalEscapeRule.java)
-
-**Example(s):**
-
-``` java
-public void foo() {
- // interpreted as octal 12, followed by character '8'
- System.out.println("suspicious: \128");
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryConstructor
-
-**Since:** PMD 1.0
-
-**Priority:** Medium (3)
-
-This rule detects when a constructor is not necessary; i.e., when there is only one constructor,
-it's public, has an empty body, and takes no arguments.
-
-```
-//ClassOrInterfaceBody[count(ClassOrInterfaceBodyDeclaration/ConstructorDeclaration)=1]
-/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration
-[@Public='true']
-[not(FormalParameters/*)]
-[not(BlockStatement)]
-[not(NameList)]
-[count(ExplicitConstructorInvocation/Arguments/ArgumentList/Expression)=0]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public Foo() {}
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryParentheses
-
-Deprecated
-
-The rule has been moved to another ruleset. Use instead: [UselessParentheses](pmd_rules_java_unnecessary.html#uselessparentheses)
-
-Deprecated
-
-**Since:** PMD 5.0
-
-**Priority:** Medium Low (4)
-
-Useless parentheses should be removed.
-
-```
-//Expression[not(parent::PrimaryPrefix)]/PrimaryExpression[count(*)>1]
- /PrimaryPrefix/Expression
- [not(./CastExpression)]
- [not(./ConditionalExpression[@Ternary='true'])]
- [not(./AdditiveExpression[//Literal[@StringLiteral='true']])]
-|
-//Expression[not(parent::PrimaryPrefix)]/PrimaryExpression[count(*)=1]
- /PrimaryPrefix/Expression
-|
-//Expression/ConditionalAndExpression/PrimaryExpression/PrimaryPrefix/Expression[
- count(*)=1 and
- count(./CastExpression)=0 and
- count(./EqualityExpression/MultiplicativeExpression)=0 and
- count(./ConditionalExpression[@Ternary='true'])=0 and
- count(./ConditionalOrExpression)=0]
-|
-//Expression/ConditionalOrExpression/PrimaryExpression/PrimaryPrefix/Expression[
- count(*)=1 and
- not(./CastExpression) and
- not(./ConditionalExpression[@Ternary='true']) and
- not(./EqualityExpression/MultiplicativeExpression)]
-|
-//Expression/ConditionalExpression/PrimaryExpression/PrimaryPrefix/Expression[
- count(*)=1 and
- not(./CastExpression) and
- not(./EqualityExpression)]
-|
-//Expression/AdditiveExpression[not(./PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true'])]
- /PrimaryExpression[1]/PrimaryPrefix/Expression[
- count(*)=1 and
- not(./CastExpression) and
- not(./AdditiveExpression[@Image = '-']) and
- not(./ShiftExpression) and
- not(./RelationalExpression) and
- not(./InstanceOfExpression) and
- not(./EqualityExpression) and
- not(./AndExpression) and
- not(./ExclusiveOrExpression) and
- not(./InclusiveOrExpression) and
- not(./ConditionalAndExpression) and
- not(./ConditionalOrExpression) and
- not(./ConditionalExpression)]
-|
-//Expression/EqualityExpression/PrimaryExpression/PrimaryPrefix/Expression[
- count(*)=1 and
- not(./CastExpression) and
- not(./AndExpression) and
- not(./InclusiveOrExpression) and
- not(./ExclusiveOrExpression) and
- not(./ConditionalExpression) and
- not(./ConditionalAndExpression) and
- not(./ConditionalOrExpression) and
- not(./EqualityExpression)]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
-
- private int _bar1;
- private Integer _bar2;
-
- public void setBar(int n) {
- _bar1 = Integer.valueOf((n)); // here
- _bar2 = (n); // and here
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseConcurrentHashMap
-
-**Since:** PMD 4.2.6
-
-**Priority:** Medium (3)
-
-Since Java5 brought a new implementation of the Map designed for multi-threaded access, you can
-perform efficient map reads without blocking other threads.
-
-```
-//Type[../VariableDeclarator/VariableInitializer//AllocationExpression/ClassOrInterfaceType[@Image != 'ConcurrentHashMap']]
-/ReferenceType/ClassOrInterfaceType[@Image = 'Map']
-```
-
-**Example(s):**
-
-``` java
-public class ConcurrentApp {
- public void getMyInstance() {
- Map map1 = new HashMap(); // fine for single-threaded access
- Map map2 = new ConcurrentHashMap(); // preferred for use with multiple threads
-
- // the following case will be ignored by this rule
- Map map3 = someModule.methodThatReturnMap(); // might be OK, if the returned map is already thread-safe
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseObjectForClearerAPI
-
-**Since:** PMD 4.2.6
-
-**Priority:** Medium (3)
-
-When you write a public method, you should be thinking in terms of an API. If your method is public, it means other class
-will use it, therefore, you want (or need) to offer a comprehensive and evolutive API. If you pass a lot of information
-as a simple series of Strings, you may think of using an Object to represent all those information. You'll get a simpler
-API (such as doWork(Workload workload), rather than a tedious series of Strings) and more importantly, if you need at some
-point to pass extra data, you'll be able to do so by simply modifying or extending Workload without any modification to
-your API.
-
-```
-//MethodDeclaration[@Public]/MethodDeclarator/FormalParameters[
- count(FormalParameter/Type/ReferenceType/ClassOrInterfaceType[@Image = 'String']) > 3
-]
-```
-
-**Example(s):**
-
-``` java
-public class MyClass {
- public void connect(String username,
- String pssd,
- String databaseName,
- String databaseAdress)
- // Instead of those parameters object
- // would ensure a cleaner API and permit
- // to add extra data transparently (no code change):
- // void connect(UserData data);
- {
-
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/coupling.md b/docs/pages/pmd/rules/java/coupling.md
deleted file mode 100644
index 2139ff4786a..00000000000
--- a/docs/pages/pmd/rules/java/coupling.md
+++ /dev/null
@@ -1,207 +0,0 @@
----
-title: Coupling
-summary: Rules which find instances of high or inappropriate coupling between objects and packages.
-permalink: pmd_rules_java_coupling.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/coupling.xml
-keywords: Coupling, CouplingBetweenObjects, ExcessiveImports, LooseCoupling, LoosePackageCoupling, LawOfDemeter
----
-## CouplingBetweenObjects
-
-**Since:** PMD 1.04
-
-**Priority:** Medium (3)
-
-This rule counts the number of unique attributes, local variables, and return types within an object.
-A number higher than the specified threshold can indicate a high degree of coupling.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.coupling.CouplingBetweenObjectsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/coupling/CouplingBetweenObjectsRule.java)
-
-**Example(s):**
-
-``` java
-import com.Blah;
-import org.Bar;
-import org.Bardo;
-
-public class Foo {
- private Blah var1;
- private Bar var2;
-
- //followed by many imports of unique objects
- void ObjectC doWork() {
- Bardo var55;
- ObjectA var44;
- ObjectZ var93;
- return something;
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|threshold|20|Unique type reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveImports
-
-**Since:** PMD 1.04
-
-**Priority:** Medium (3)
-
-A high number of imports can indicate a high degree of coupling within an object. This rule
-counts the number of unique imports and reports a violation if the count is above the
-user-specified threshold.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.coupling.ExcessiveImportsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/coupling/ExcessiveImportsRule.java)
-
-**Example(s):**
-
-``` java
-import blah.blah.Baz;
-import blah.blah.Bif;
-// 18 others from the same package elided
-public class Foo {
- public void doWork() {}
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## LawOfDemeter
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-The Law of Demeter is a simple rule, that says "only talk to friends". It helps to reduce coupling between classes
-or objects.
-
-See also the references:
-
-* Andrew Hunt, David Thomas, and Ward Cunningham. The Pragmatic Programmer. From Journeyman to Master. Addison-Wesley Longman, Amsterdam, October 1999.;
-* K.J. Lieberherr and I.M. Holland. Assuring good style for object-oriented programs. Software, IEEE, 6(5):38–48, 1989.;
-*
-*
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.coupling.LawOfDemeterRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/coupling/LawOfDemeterRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- /**
- * This example will result in two violations.
- */
- public void example(Bar b) {
- // this method call is ok, as b is a parameter of "example"
- C c = b.getC();
-
- // this method call is a violation, as we are using c, which we got from B.
- // We should ask b directly instead, e.g. "b.doItOnC();"
- c.doIt();
-
- // this is also a violation, just expressed differently as a method chain without temporary variables.
- b.getC().doIt();
-
- // a constructor call, not a method call.
- D d = new D();
- // this method call is ok, because we have create the new instance of D locally.
- d.doSomethingElse();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## LooseCoupling
-
-**Since:** PMD 0.7
-
-**Priority:** Medium (3)
-
-The use of implementation types as object references limits your ability to use alternate
-implementations in the future as requirements change. Whenever available, referencing objects
-by their interface types provides much more flexibility.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.coupling.LooseCouplingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/coupling/LooseCouplingRule.java)
-
-**Example(s):**
-
-``` java
-// sub-optimal approach
-private ArrayList list = new ArrayList<>();
-
-public HashSet getFoo() {
- return new HashSet();
-}
-
-// preferred approach
-private List list = new ArrayList<>();
-
-public Set getFoo() {
- return new HashSet();
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## LoosePackageCoupling
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Avoid using classes from the configured package hierarchy outside of the package hierarchy,
-except when using one of the configured allowed classes.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.coupling.LoosePackageCouplingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/coupling/LoosePackageCouplingRule.java)
-
-**Example(s):**
-
-``` java
-package some.package;
-
-import some.other.package.subpackage.subsubpackage.DontUseThisClass;
-
-public class Bar {
- DontUseThisClass boo = new DontUseThisClass();
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|classes|[]|Allowed classes|
-|packages|[]|Restricted packages|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/design.md b/docs/pages/pmd/rules/java/design.md
index a7f58258a69..f0eb4ed8431 100644
--- a/docs/pages/pmd/rules/java/design.md
+++ b/docs/pages/pmd/rules/java/design.md
@@ -1,47 +1,13 @@
---
title: Design
-summary: The Design ruleset contains rules that flag suboptimal code implementations. Alternate approaches are suggested.
+summary: Rules that help you discover design issues.
permalink: pmd_rules_java_design.html
folder: pmd/rules/java
sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/design.xml
-keywords: Design, UseUtilityClass, SimplifyBooleanReturns, SimplifyBooleanExpressions, SwitchStmtsShouldHaveDefault, AvoidDeeplyNestedIfStmts, AvoidReassigningParameters, SwitchDensity, ConstructorCallsOverridableMethod, AccessorClassGeneration, FinalFieldCouldBeStatic, CloseResource, NonStaticInitializer, DefaultLabelNotLastInSwitchStmt, NonCaseLabelInSwitchStatement, OptimizableToArrayCall, BadComparison, EqualsNull, ConfusingTernary, InstantiationToGetClass, IdempotentOperations, SimpleDateFormatNeedsLocale, ImmutableField, UseLocaleWithCaseConversions, AvoidProtectedFieldInFinalClass, AssignmentToNonFinalStatic, MissingStaticMethodInNonInstantiatableClass, AvoidSynchronizedAtMethodLevel, MissingBreakInSwitch, UseNotifyAllInsteadOfNotify, AvoidInstanceofChecksInCatchClause, AbstractClassWithoutAbstractMethod, SimplifyConditional, CompareObjectsWithEquals, PositionLiteralsFirstInComparisons, PositionLiteralsFirstInCaseInsensitiveComparisons, UnnecessaryLocalBeforeReturn, NonThreadSafeSingleton, SingleMethodSingleton, SingletonClassReturningNewInstance, UncommentedEmptyMethodBody, UncommentedEmptyConstructor, UnsynchronizedStaticDateFormatter, PreserveStackTrace, UseCollectionIsEmpty, ClassWithOnlyPrivateConstructorsShouldBeFinal, EmptyMethodInAbstractClassShouldBeAbstract, SingularField, ReturnEmptyArrayRatherThanNull, AbstractClassWithoutAnyMethod, TooFewBranchesForASwitchStatement, LogicInversion, UseVarargs, FieldDeclarationsShouldBeAtStartOfClass, GodClass, AvoidProtectedMethodInFinalClassNotExtending, ConstantsInInterface, AccessorMethodGeneration
+editmepath: ../pmd-java/src/main/resources/category/java/design.xml
+keywords: Design, AbstractClassWithoutAnyMethod, AvoidCatchingGenericException, AvoidDeeplyNestedIfStmts, AvoidRethrowingException, AvoidThrowingNewInstanceOfSameException, AvoidThrowingNullPointerException, AvoidThrowingRawExceptionTypes, ClassWithOnlyPrivateConstructorsShouldBeFinal, CollapsibleIfStatements, CouplingBetweenObjects, CyclomaticComplexity, DataClass, DoNotExtendJavaLangError, ExceptionAsFlowControl, ExcessiveClassLength, ExcessiveImports, ExcessiveMethodLength, ExcessiveParameterList, ExcessivePublicCount, FinalFieldCouldBeStatic, GodClass, ImmutableField, LawOfDemeter, LogicInversion, LoosePackageCoupling, ModifiedCyclomaticComplexity, NcssConstructorCount, NcssCount, NcssMethodCount, NcssTypeCount, NPathComplexity, SignatureDeclareThrowsException, SimplifiedTernary, SimplifyBooleanAssertion, SimplifyBooleanExpressions, SimplifyBooleanReturns, SimplifyConditional, SingularField, StdCyclomaticComplexity, SwitchDensity, TooManyFields, TooManyMethods, UselessOverridingMethod, UseObjectForClearerAPI, UseUtilityClass
+language: Java
---
-## AbstractClassWithoutAbstractMethod
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-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
-directly) a protected constructor can be provided prevent direct instantiation.
-
-```
-//ClassOrInterfaceDeclaration
- [@Abstract='true'
- and count( .//MethodDeclaration[@Abstract='true'] )=0 ]
- [count(ImplementsList)=0]
- [count(.//ExtendsList)=0]
-```
-
-**Example(s):**
-
-``` java
-public abstract class Foo {
- void int method1() { ... }
- void int method2() { ... }
- // consider using abstract methods or removing
- // the abstract modifier and adding protected constructors
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
## AbstractClassWithoutAnyMethod
**Since:** PMD 4.2
@@ -52,17 +18,18 @@ If an abstract class does not provides any methods, it may be acting as a simple
that is not meant to be instantiated. In this case, it is probably better to use a private or
protected constructor in order to prevent instantiation than make the class misleadingly abstract.
-```
+**This rule is defined by the following XPath expression:**
+``` xpath
//ClassOrInterfaceDeclaration
[@Abstract = 'true']
[count(//MethodDeclaration) + count(//ConstructorDeclaration) = 0]
- [not(../Annotation/MarkerAnnotation/Name[typeof(@Image, 'com.google.auto.value.AutoValue', 'AutoValue')])]
+ [not(../Annotation/MarkerAnnotation/Name[pmd-java:typeIs('com.google.auto.value.AutoValue')])]
```
**Example(s):**
``` java
-public class abstract Example {
+public abstract class Example {
String field;
int otherField;
}
@@ -70,67 +37,41 @@ public class abstract Example {
**Use this rule by referencing it:**
``` xml
-
+
```
-## AccessorClassGeneration
+## AvoidCatchingGenericException
-**Since:** PMD 1.04
+**Since:** PMD 4.2.6
**Priority:** Medium (3)
-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-privatization 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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.AccessorClassGenerationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/AccessorClassGenerationRule.java)
-
-**Example(s):**
-
-``` java
-public class Outer {
- void method(){
- Inner ic = new Inner();//Causes generation of accessor class
- }
- public class Inner {
- private Inner(){}
- }
-}
-```
+Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
-**Use this rule by referencing it:**
-``` xml
-
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CatchStatement/FormalParameter/Type/ReferenceType/ClassOrInterfaceType[
+ @Image='NullPointerException' or
+ @Image='Exception' or
+ @Image='RuntimeException']
```
-## AccessorMethodGeneration
-
-**Since:** PMD 5.5.4
-
-**Priority:** Medium (3)
-
-When accessing a private field / method from another class, the Java compiler will generate a accessor methods
-with package-private visibility. This adds overhead, and to the dex method count on Android. This situation can
-be avoided by changing the visibility of the field / method from private to package-private.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.AccessorMethodGenerationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/AccessorMethodGenerationRule.java)
-
**Example(s):**
``` java
-public class OuterClass {
- private int counter;
- /* package */ int id;
+package com.igate.primitive;
- public class InnerClass {
- InnerClass() {
- OuterClass.this.counter++; // wrong accessor method will be generated
- }
+public class PrimitiveType {
- public int getOuterClassId() {
- return OuterClass.this.id; // id is package-private, no accessor method needed
+ public void downCastPrimitiveType() {
+ try {
+ System.out.println(" i [" + i + "]");
+ } catch(Exception e) {
+ e.printStackTrace();
+ } catch(RuntimeException e) {
+ e.printStackTrace();
+ } catch(NullPointerException e) {
+ e.printStackTrace();
}
}
}
@@ -138,33 +79,7 @@ public class OuterClass {
**Use this rule by referencing it:**
``` xml
-
-```
-
-## AssignmentToNonFinalStatic
-
-**Since:** PMD 2.2
-
-**Priority:** Medium (3)
-
-Identifies a possible unsafe usage of a static field.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.AssignmentToNonFinalStaticRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/AssignmentToNonFinalStaticRule.java)
-
-**Example(s):**
-
-``` java
-public class StaticField {
- static int x;
- public FinalFields(int y) {
- x = y; // unsafe
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
+
```
## AvoidDeeplyNestedIfStmts
@@ -195,208 +110,178 @@ public class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|problemDepth|3|The if statement depth reporting threshold|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|problemDepth|3|The if statement depth reporting threshold|no|
**Use this rule by referencing it:**
``` xml
-
+
```
-## AvoidInstanceofChecksInCatchClause
+## AvoidRethrowingException
-**Since:** PMD 3.0
+**Since:** PMD 3.8
**Priority:** Medium (3)
-Each caught exception type should be handled in its own catch clause.
+Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity.
-```
-//CatchStatement/FormalParameter
- /following-sibling::Block//InstanceOfExpression/PrimaryExpression/PrimaryPrefix
- /Name[
- @Image = ./ancestor::Block/preceding-sibling::FormalParameter
- /VariableDeclaratorId/@Image
- ]
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CatchStatement[FormalParameter
+ /VariableDeclaratorId/@Image = Block/BlockStatement/Statement
+ /ThrowStatement/Expression/PrimaryExpression[count(PrimarySuffix)=0]/PrimaryPrefix/Name/@Image
+ and count(Block/BlockStatement/Statement) =1]
```
**Example(s):**
``` java
-try { // Avoid this
- // do something
-} catch (Exception ee) {
- if (ee instanceof IOException) {
- cleanup();
+public void bar() {
+ try {
+ // do something
+ } catch (SomeException se) {
+ throw se;
}
}
-
-try { // Prefer this:
- // do something
-} catch (IOException ee) {
- cleanup();
-}
```
**Use this rule by referencing it:**
``` xml
-
+
```
-## AvoidProtectedFieldInFinalClass
+## AvoidThrowingNewInstanceOfSameException
-**Since:** PMD 2.1
+**Since:** PMD 4.2.5
**Priority:** Medium (3)
-Do not use protected fields in final classes since they cannot be subclassed.
-Clarify your intent by using private or package access modifiers instead.
+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.
-```
-//ClassOrInterfaceDeclaration[@Final='true']
-/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
-/FieldDeclaration[@Protected='true']
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CatchStatement[
+ count(Block/BlockStatement/Statement) = 1
+ and
+ FormalParameter/Type/ReferenceType/ClassOrInterfaceType/@Image = Block/BlockStatement/Statement/ThrowStatement/Expression/PrimaryExpression/PrimaryPrefix/AllocationExpression/ClassOrInterfaceType/@Image
+ and
+ count(Block/BlockStatement/Statement/ThrowStatement/Expression/PrimaryExpression/PrimaryPrefix/AllocationExpression/Arguments/ArgumentList/Expression) = 1
+ and
+ FormalParameter/VariableDeclaratorId = Block/BlockStatement/Statement/ThrowStatement/Expression/PrimaryExpression/PrimaryPrefix/AllocationExpression/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Name
+ ]
```
**Example(s):**
``` java
-public final class Bar {
- private int x;
- protected int y; // bar cannot be subclassed, so is y really private or package visible?
- Bar() {}
+public void bar() {
+ try {
+ // do something
+ } catch (SomeException se) {
+ // harmless comment
+ throw new SomeException(se);
+ }
}
```
**Use this rule by referencing it:**
``` xml
-
+
```
-## AvoidProtectedMethodInFinalClassNotExtending
+## AvoidThrowingNullPointerException
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
+**Since:** PMD 1.8
-Do not use protected methods in most final classes since they cannot be subclassed. This should
-only be allowed in final classes that extend other classes with protected methods (whose
-visibility cannot be reduced). Clarify your intent by using private or package access modifiers instead.
+**Priority:** High (1)
-```
-//ClassOrInterfaceDeclaration[@Final='true' and not(ExtendsList)]
-/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
-/MethodDeclaration[@Protected='true'][MethodDeclarator/@Image != 'finalize']
-```
+Avoid throwing NullPointerExceptions manually. These are confusing because most people will assume that the
+virtual machine threw it. To avoid a method being called with a null parameter, you may consider
+using an IllegalArgumentException instead, making it clearly seen as a programmer-initiated exception.
+However, there are better ways to handle this:
-**Example(s):**
+>*Effective Java, 3rd Edition, Item 72: Favor the use of standard exceptions*
+>
+>Arguably, every erroneous method invocation boils down to an illegal argument or state,
+but other exceptions are standardly used for certain kinds of illegal arguments and states.
+If a caller passes null in some parameter for which null values are prohibited, convention dictates that
+NullPointerException be thrown rather than IllegalArgumentException.
-``` java
-public final class Foo {
- private int bar() {}
- protected int baz() {} // Foo cannot be subclassed, and doesn't extend anything, so is baz() really private or package visible?
-}
-```
+To implement that, you are encouraged to use `java.util.Objects.requireNonNull()`
+(introduced in Java 1.7). This method is designed primarily for doing parameter
+validation in methods and constructors with multiple parameters.
-**Use this rule by referencing it:**
-``` xml
-
+Your parameter validation could thus look like the following:
```
-
-## AvoidReassigningParameters
-
-**Since:** PMD 1.0
-
-**Priority:** Medium High (2)
-
-Reassigning values to incoming parameters is not recommended. Use temporary local variables instead.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.AvoidReassigningParametersRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/AvoidReassigningParametersRule.java)
-
-**Example(s):**
-
-``` java
public class Foo {
- private void foo(String bar) {
- bar = "something else";
+ private String exampleValue;
+
+ void setExampleValue(String exampleValue) {
+ // check, throw and assignment in a single standard call
+ this.exampleValue = Objects.requireNonNull(exampleValue, "exampleValue must not be null!");
+ }
}
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
```
-## AvoidSynchronizedAtMethodLevel
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-Method-level synchronization can cause problems when new code is added to the method.
-Block-level synchronization helps to ensure that only the code that needs synchronization
-gets it.
-
-```
-//MethodDeclaration[@Synchronized='true']
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AllocationExpression/ClassOrInterfaceType[@Image='NullPointerException']
```
**Example(s):**
``` java
public class Foo {
- // Try to avoid this:
- synchronized void foo() {
- }
- // Prefer this:
- void bar() {
- synchronized(this) {
- }
- }
-
- // Try to avoid this for static methods:
- static synchronized void fooStatic() {
- }
-
- // Prefer this:
- static void barStatic() {
- synchronized(Foo.class) {
+ void bar() {
+ throw new NullPointerException();
}
- }
}
```
**Use this rule by referencing it:**
``` xml
-
+
```
-## BadComparison
+## AvoidThrowingRawExceptionTypes
**Since:** PMD 1.8
-**Priority:** Medium (3)
+**Priority:** High (1)
-Avoid equality comparisons with Double.NaN. Due to the implicit lack of representation
-precision when comparing floating point numbers these are likely to cause logic errors.
+Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable,
+Exception, or Error, use a subclassed exception or error instead.
-```
-//EqualityExpression[@Image='==']
- /PrimaryExpression/PrimaryPrefix
- /Name[@Image='Double.NaN' or @Image='Float.NaN']
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ThrowStatement//AllocationExpression
+ /ClassOrInterfaceType[
+ pmd-java:typeIsExactly('java.lang.Throwable')
+or
+ pmd-java:typeIsExactly('java.lang.Exception')
+or
+ pmd-java:typeIsExactly('java.lang.Error')
+or
+ pmd-java:typeIsExactly('java.lang.RuntimeException')
+]
```
**Example(s):**
``` java
-boolean x = (y == Double.NaN);
+public class Foo {
+ public void bar() throws Exception {
+ throw new Exception();
+ }
+}
```
**Use this rule by referencing it:**
``` xml
-
+
```
## ClassWithOnlyPrivateConstructorsShouldBeFinal
@@ -408,7 +293,8 @@ boolean x = (y == Double.NaN);
A class with only private constructors should be final, unless the private constructor
is invoked by a inner class.
-```
+**This rule is defined by the following XPath expression:**
+``` xpath
TypeDeclaration[count(../TypeDeclaration) = 1]/ClassOrInterfaceDeclaration
[@Final = 'false']
[count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Private = 'true']) >= 1 ]
@@ -426,365 +312,455 @@ public class Foo { //Should be final
**Use this rule by referencing it:**
``` xml
-
+
```
-## CloseResource
+## CollapsibleIfStatements
-**Since:** PMD 1.2.2
+**Since:** PMD 3.1
**Priority:** Medium (3)
-Ensure that resources (like Connection, Statement, and ResultSet objects) are always closed after use.
+Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.CloseResourceRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CloseResourceRule.java)
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfStatement[@Else='false']/Statement
+ /IfStatement[@Else='false']
+ |
+//IfStatement[@Else='false']/Statement
+ /Block[count(BlockStatement)=1]/BlockStatement
+ /Statement/IfStatement[@Else='false']
+```
**Example(s):**
``` java
-public class Bar {
- public void foo() {
- Connection c = pool.getConnection();
- try {
- // do stuff
- } catch (SQLException ex) {
- // handle exception
- } finally {
- // oops, should close the connection using 'close'!
- // c.close();
+void bar() {
+ if (x) { // original implementation
+ if (y) {
+ // do stuff
+ }
}
- }
}
-```
-
-**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|closeAsDefaultTarget|true|Consider 'close' as a target by default|
-|types|[java.sql.Connection, java.sql.Statement, java.sql.ResultSet]|Affected types|
-|closeTargets|[]|Methods which may close this resource|
+void bar() {
+ if (x && y) { // optimized implementation
+ // do stuff
+ }
+}
+```
**Use this rule by referencing it:**
``` xml
-
+
```
-## CompareObjectsWithEquals
+## CouplingBetweenObjects
-**Since:** PMD 3.2
+**Since:** PMD 1.04
**Priority:** Medium (3)
-Use equals() to compare object references; avoid comparing them with ==.
+This rule counts the number of unique attributes, local variables, and return types within an object.
+A number higher than the specified threshold can indicate a high degree of coupling.
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.CompareObjectsWithEqualsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CompareObjectsWithEqualsRule.java)
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.CouplingBetweenObjectsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CouplingBetweenObjectsRule.java)
**Example(s):**
``` java
-class Foo {
- boolean bar(String a, String b) {
- return a == b;
- }
+import com.Blah;
+import org.Bar;
+import org.Bardo;
+
+public class Foo {
+ private Blah var1;
+ private Bar var2;
+
+ //followed by many imports of unique objects
+ void ObjectC doWork() {
+ Bardo var55;
+ ObjectA var44;
+ ObjectZ var93;
+ return something;
+ }
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|threshold|20|Unique type reporting threshold|no|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## ConfusingTernary
+## CyclomaticComplexity
-**Since:** PMD 1.9
+**Since:** PMD 1.03
**Priority:** Medium (3)
-Avoid negation within an "if" expression with an "else" clause. For example, rephrase:
-`if (x != y) diff(); else same();` as: `if (x == y) same(); else diff();`.
+The complexity of methods directly affects maintenance costs and readability. Concentrating too much decisional logic
+in a single method makes its behaviour hard to read and change.
-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?".
+Cyclomatic complexity assesses the complexity of a method by counting the number of decision points in a method,
+plus one for the method entry. Decision points are places where the control flow jumps to another place in the
+program. As such, they include all control flow statements, such as `if`, `while`, `for`, and `case`. For more
+details on the calculation, see the documentation of the [Cyclo metric](/pmd_java_metrics_index.html#cyclomatic-complexity-cyclo).
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ConfusingTernaryRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ConfusingTernaryRule.java)
+Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
+high complexity, and 11+ is very high complexity. By default, this rule reports methods with a complexity >= 10.
+Additionnally, classes with many methods of moderate complexity get reported as well once the total of their
+methods' complexities reaches 80, even if none of the methods was directly reported.
+
+Reported methods should be broken down into several smaller methods. Reported classes should probably be broken down
+into subcomponents.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.CyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CyclomaticComplexityRule.java)
**Example(s):**
``` java
-boolean bar(int x, int y) {
- return (x != y) ? diff : same;
+class Foo {
+ void baseCyclo() { // Cyclo = 1
+ highCyclo();
+ }
+
+ void highCyclo() { // Cyclo = 10: reported!
+ int x = 0, y = 2;
+ boolean a = false, b = true;
+
+ if (a && (y == 1 ? b : true)) { // +3
+ if (y == x) { // +1
+ while (true) { // +1
+ if (x++ < 20) { // +1
+ break; // +1
+ }
+ }
+ } else if (y == t && !d) { // +2
+ x = a ? y : x; // +1
+ } else {
+ x = 2;
+ }
+ }
+ }
}
```
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|ignoreElseIf|false|Ignore conditions with an else-if case|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|cycloOptions||Choose options for the computation of Cyclo|yes. Delimiter is '\|'.|
+|classReportLevel|80|Total class complexity reporting threshold|no|
+|methodReportLevel|10|Cyclomatic complexity reporting threshold|no|
+|reportLevel|10|Deprecated Cyclomatic Complexity reporting threshold|no|
**Use this rule by referencing it:**
``` xml
-
+
```
-## ConstantsInInterface
+## DataClass
-**Since:** PMD 5.5
+**Since:** PMD 6.0.0
**Priority:** Medium (3)
-Avoid constants in interfaces. Interfaces should define types, constants are implementation details
-better placed in classes or enums. See Effective Java, item 19.
+Data Classes are simple data holders, which reveal most of their state, and
+without complex functionality. The lack of functionality may indicate that
+their behaviour is defined elsewhere, which is a sign of poor data-behaviour
+proximity. By directly exposing their internals, Data Classes break encapsulation,
+and therefore reduce the system's maintainability and understandability. Moreover,
+classes tend to strongly rely on their data representation, which makes for a brittle
+design.
-```
-//ClassOrInterfaceDeclaration[@Interface='true'][$ignoreIfHasMethods='false' or not(.//MethodDeclaration)]//FieldDeclaration
-```
+Refactoring a Data Class should focus on restoring a good data-behaviour proximity. In
+most cases, that means moving the operations defined on the data back into the class.
+In some other cases it may make sense to remove entirely the class and move the data
+into the former client classes.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.DataClassRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/DataClassRule.java)
**Example(s):**
``` java
-public interface ConstantInterface {
- public static final int CONST1 = 1; // violation, no fields allowed in interface!
- static final int CONST2 = 1; // violation, no fields allowed in interface!
- final int CONST3 = 1; // violation, no fields allowed in interface!
- int CONST4 = 1; // violation, no fields allowed in interface!
-}
+public class DataClass {
-// with ignoreIfHasMethods = false
-public interface AnotherConstantInterface {
- public static final int CONST1 = 1; // violation, no fields allowed in interface!
+ public int bar = 0;
+ public int na = 0;
+ private int bee = 0;
- int anyMethod();
+ public void setBee(int n) {
+ bee = n;
+ }
}
+```
-// with ignoreIfHasMethods = true
-public interface YetAnotherConstantInterface {
- public static final int CONST1 = 1; // no violation
+**Use this rule by referencing it:**
+``` xml
+
+```
- int anyMethod();
-}
+## DoNotExtendJavaLangError
+
+**Since:** PMD 4.0
+
+**Priority:** Medium (3)
+
+Errors are system exceptions. Do not extend them.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType
+ [pmd-java:typeIs('java.lang.Error')]
```
-**This rule has the following properties:**
+**Example(s):**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|ignoreIfHasMethods|true|Whether to ignore constants in interfaces if the interface defines any methods|
+``` java
+public class Foo extends Error { }
+```
**Use this rule by referencing it:**
``` xml
-
+
```
-## ConstructorCallsOverridableMethod
+## ExceptionAsFlowControl
-**Since:** PMD 1.04
+**Since:** PMD 1.8
-**Priority:** High (1)
+**Priority:** Medium (3)
-Calling overridable methods during construction poses a risk of invoking methods on an incompletely
-constructed object and can be difficult to debug.
-It may leave the sub-class unable to construct its superclass or forced to replicate the construction
-process completely within itself, losing the ability to call super(). If the default constructor
-contains a call to an overridable method, the subclass may be completely uninstantiable. Note that
-this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls a
-private method bar() that calls a public method buz(), this denotes a problem.
+Using Exceptions as form of flow control is not recommended as they obscure true exceptions when debugging.
+Either add the necessary validation or use an alternate control structure.
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ConstructorCallsOverridableMethodRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ConstructorCallsOverridableMethodRule.java)
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ExceptionAsFlowControlRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ExceptionAsFlowControlRule.java)
**Example(s):**
``` java
-public class SeniorClass {
- public SeniorClass(){
- toString(); //may throw NullPointerException if overridden
- }
- public String toString(){
- return "IAmSeniorClass";
- }
-}
-public class JuniorClass extends SeniorClass {
- private String name;
- public JuniorClass(){
- super(); //Automatic call leads to NullPointerException
- name = "JuniorClass";
- }
- public String toString(){
- return name.toUpperCase();
- }
+public void bar() {
+ try {
+ try {
+ } catch (Exception e) {
+ throw new WrapperException(e);
+ // this is essentially a GOTO to the WrapperException catch block
+ }
+ } catch (WrapperException e) {
+ // do some more stuff
+ }
}
```
**Use this rule by referencing it:**
``` xml
-
+
```
-## DefaultLabelNotLastInSwitchStmt
+## ExcessiveClassLength
-**Since:** PMD 1.5
+**Since:** PMD 0.6
**Priority:** Medium (3)
-By convention, the default label should be the last label in a switch statement.
+Excessive class file lengths are usually indications that the class may be burdened with excessive
+responsibilities that could be provided by external classes or functions. In breaking these methods
+apart the code becomes more manageable and ripe for reuse.
-```
-//SwitchStatement
- [not(SwitchLabel[position() = last()][@Default='true'])]
- [SwitchLabel[@Default='true']]
-```
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ExcessiveClassLengthRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ExcessiveClassLengthRule.java)
**Example(s):**
``` java
public class Foo {
- void bar(int a) {
- switch (a) {
- case 1: // do something
- break;
- default: // the default case should be last, by convention
- break;
- case 2:
- break;
- }
- }
+ public void bar1() {
+ // 1000 lines of code
+ }
+ public void bar2() {
+ // 1000 lines of code
+ }
+ public void bar3() {
+ // 1000 lines of code
+ }
+
+ public void barN() {
+ // 1000 lines of code
+ }
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## EmptyMethodInAbstractClassShouldBeAbstract
+## ExcessiveImports
-**Since:** PMD 4.1
+**Since:** PMD 1.04
-**Priority:** High (1)
+**Priority:** Medium (3)
-Empty or auto-generated methods in an abstract class should be tagged as abstract. This helps to remove their inapproprate
-usage by developers who should be implementing their own versions in the concrete subclasses.
+A high number of imports can indicate a high degree of coupling within an object. This rule
+counts the number of unique imports and reports a violation if the count is above the
+user-specified threshold.
-```
-//ClassOrInterfaceDeclaration[@Abstract = 'true']
- /ClassOrInterfaceBody
- /ClassOrInterfaceBodyDeclaration
- /MethodDeclaration[@Abstract = 'false' and @Native = 'false']
- [
- ( boolean(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral) = 'true' )
- or
- ( boolean(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal[@Image = '0']) = 'true' )
- or
- ( boolean(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal[string-length(@Image) = 2]) = 'true' )
- or
- (./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/EmptyStatement)
- or
- ( count (./Block/*) = 0 )
- ]
-```
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ExcessiveImportsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ExcessiveImportsRule.java)
**Example(s):**
``` java
-public abstract class ShouldBeAbstract {
- public Object couldBeAbstract() {
- // Should be abstract method ?
- return null;
- }
-
- public void couldBeAbstract() {
- }
+import blah.blah.Baz;
+import blah.blah.Bif;
+// 18 others from the same package elided
+public class Foo {
+ public void doWork() {}
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## EqualsNull
+## ExcessiveMethodLength
-**Since:** PMD 1.9
+**Since:** PMD 0.6
-**Priority:** High (1)
+**Priority:** Medium (3)
+
+When methods are excessively long this usually indicates that the method is doing more than its
+name/signature might suggest. They also become challenging for others to digest since excessive
+scrolling causes readers to lose focus.
+Try to reduce the method length by creating helper methods and removing any copy/pasted code.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ExcessiveMethodLengthRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ExcessiveMethodLengthRule.java)
-Tests for null should not use the equals() method. The '==' operator should be used instead.
+**Example(s):**
+``` java
+public void doSomething() {
+ System.out.println("Hello world!");
+ System.out.println("Hello world!");
+ // 98 copies omitted for brevity.
+}
```
-//PrimaryExpression
- [
- PrimaryPrefix[Name[ends-with(@Image, 'equals')]]
- [following-sibling::node()/Arguments/ArgumentList[count(Expression)=1]
- /Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
- or
+**This rule has the following properties:**
- PrimarySuffix[ends-with(@Image, 'equals')]
- [following-sibling::node()/Arguments/ArgumentList[count(Expression)=1]
- /Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
- ]
+**Use this rule by referencing it:**
+``` xml
+
```
+## ExcessiveParameterList
+
+**Since:** PMD 0.9
+
+**Priority:** Medium (3)
+
+Methods with numerous parameters are a challenge to maintain, especially if most of them share the
+same datatype. These situations usually denote the need for new objects to wrap the numerous parameters.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ExcessiveParameterListRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ExcessiveParameterListRule.java)
+
**Example(s):**
``` java
-String x = "foo";
+public void addPerson( // too many arguments liable to be mixed up
+ int birthYear, int birthMonth, int birthDate, int height, int weight, int ssn) {
-if (x.equals(null)) { // bad form
- doSomething();
+ . . . .
}
+
+public void addPerson( // preferred approach
+ Date birthdate, BodyMeasurements measurements, int ssn) {
-if (x == null) { // preferred
- doSomething();
+ . . . .
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## FieldDeclarationsShouldBeAtStartOfClass
+## ExcessivePublicCount
-**Since:** PMD 5.0
+**Since:** PMD 1.04
**Priority:** Medium (3)
-Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
+Classes with large numbers of public methods and attributes require disproportionate testing efforts
+since combinational side effects grow rapidly and increase risk. Refactoring these classes into
+smaller ones not only increases testability and reliability but also allows new variations to be
+developed easily.
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.FieldDeclarationsShouldBeAtStartOfClassRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/FieldDeclarationsShouldBeAtStartOfClassRule.java)
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ExcessivePublicCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ExcessivePublicCountRule.java)
**Example(s):**
``` java
-public class HelloWorldBean {
-
- // Field declared before methods / inner classes - OK
- private String _thing;
-
- public String getMessage() {
- return "Hello World!";
- }
-
- // Field declared after methods / inner classes - avoid this
- private String _fieldInWrongLocation;
+public class Foo {
+ public String value;
+ public Bar something;
+ public Variable var;
+ // [... more more public attributes ...]
+
+ public void doWork() {}
+ public void doMoreWork() {}
+ public void doWorkAgain() {}
+ // [... more more public methods ...]
}
```
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|ignoreInterfaceDeclarations|false|Ignore Interface Declarations that precede fields.|
-|ignoreAnonymousClassDeclarations|true|Ignore Field Declarations, that are initialized with anonymous class declarations|
-|ignoreEnumDeclarations|true|Ignore Enum Declarations that precede fields.|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## FinalFieldCouldBeStatic
@@ -796,7 +772,8 @@ public class HelloWorldBean {
If a final field is assigned to a compile-time constant, it could be made static, thus saving overhead
in each object at runtime.
-```
+**This rule is defined by the following XPath expression:**
+``` xpath
//FieldDeclaration
[@Final='true' and @Static='false']
/VariableDeclarator/VariableInitializer/Expression
@@ -813,7 +790,7 @@ public class Foo {
**Use this rule by referencing it:**
``` xml
-
+
```
## GodClass
@@ -837,45 +814,19 @@ of Object-Oriented Systems. Springer, Berlin, 1 edition, October 2006. Page 80.
**Use this rule by referencing it:**
``` xml
-
+
```
-## IdempotentOperations
+## ImmutableField
**Since:** PMD 2.0
**Priority:** Medium (3)
-Avoid idempotent operations - they have no effect.
+Identifies private fields whose values never change once they are initialized either in the declaration
+of the field or by a constructor. This helps in converting existing classes to becoming immutable ones.
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.IdempotentOperationsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/IdempotentOperationsRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar() {
- int x = 2;
- x = x;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ImmutableField
-
-**Since:** PMD 2.0
-
-**Priority:** Medium (3)
-
-Identifies private fields whose values never change once they are initialized either in the declaration
-of the field or by a constructor. This helps in converting existing classes to becoming immutable ones.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ImmutableFieldRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ImmutableFieldRule.java)
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ImmutableFieldRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ImmutableFieldRule.java)
**Example(s):**
@@ -891,41 +842,64 @@ public class Foo {
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoredAnnotations|lombok.Setter \| lombok.Getter \| lombok.Builder \| lombok.Data \| lombok.RequiredArgsConstructor \| lombok.AllArgsConstructor \| lombok.Value \| lombok.NoArgsConstructor|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## InstantiationToGetClass
+## LawOfDemeter
-**Since:** PMD 2.0
+**Since:** PMD 5.0
-**Priority:** Medium Low (4)
+**Priority:** Medium (3)
-Avoid instantiating an object just to call getClass() on it; use the .class public member instead.
+The Law of Demeter is a simple rule, that says "only talk to friends". It helps to reduce coupling between classes
+or objects.
-```
-//PrimarySuffix
- [@Image='getClass']
- [parent::PrimaryExpression
- [PrimaryPrefix/AllocationExpression]
- [count(PrimarySuffix) = 2]
- ]
-```
+See also the references:
+
+* Andrew Hunt, David Thomas, and Ward Cunningham. The Pragmatic Programmer. From Journeyman to Master. Addison-Wesley Longman, Amsterdam, October 1999.;
+* K.J. Lieberherr and I.M. Holland. Assuring good style for object-oriented programs. Software, IEEE, 6(5):38–48, 1989.;
+*
+*
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.LawOfDemeterRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/LawOfDemeterRule.java)
**Example(s):**
``` java
-// replace this
-Class c = new String().getClass();
+public class Foo {
+ /**
+ * This example will result in two violations.
+ */
+ public void example(Bar b) {
+ // this method call is ok, as b is a parameter of "example"
+ C c = b.getC();
+
+ // this method call is a violation, as we are using c, which we got from B.
+ // We should ask b directly instead, e.g. "b.doItOnC();"
+ c.doIt();
-// with this:
-Class c = String.class;
+ // this is also a violation, just expressed differently as a method chain without temporary variables.
+ b.getC().doIt();
+
+ // a constructor call, not a method call.
+ D d = new D();
+ // this method call is ok, because we have create the new instance of D locally.
+ d.doSomethingElse();
+ }
+}
```
**Use this rule by referencing it:**
``` xml
-
+
```
## LogicInversion
@@ -936,7 +910,8 @@ Class c = String.class;
Use opposite operator instead of negating the whole expression with a logic complement operator.
-```
+**This rule is defined by the following XPath expression:**
+``` xpath
//UnaryExpressionNotPlusMinus[@Image='!']/PrimaryExpression/PrimaryPrefix/Expression[EqualityExpression or RelationalExpression]
```
@@ -959,450 +934,502 @@ public boolean bar(int a, int b) {
**Use this rule by referencing it:**
``` xml
-
+
```
-## MissingBreakInSwitch
+## LoosePackageCoupling
-**Since:** PMD 3.0
+**Since:** PMD 5.0
**Priority:** Medium (3)
-Switch statements without break or return statements for each case option
-may indicate problematic behaviour. Empty cases are ignored as these indicate an intentional fall-through.
+Avoid using classes from the configured package hierarchy outside of the package hierarchy,
+except when using one of the configured allowed classes.
-```
-//SwitchStatement
-[(count(.//BreakStatement)
- + count(BlockStatement//Statement/ReturnStatement)
- + count(BlockStatement//Statement/ContinueStatement)
- + count(BlockStatement//Statement/ThrowStatement)
- + count(BlockStatement//Statement/IfStatement[@Else='true' and Statement[2][ReturnStatement|ContinueStatement|ThrowStatement]]/Statement[1][ReturnStatement|ContinueStatement|ThrowStatement])
- + count(SwitchLabel[name(following-sibling::node()) = 'SwitchLabel'])
- + count(SwitchLabel[count(following-sibling::node()) = 0])
- < count (SwitchLabel))]
-```
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.LoosePackageCouplingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/LoosePackageCouplingRule.java)
**Example(s):**
``` java
-public void bar(int status) {
- switch(status) {
- case CANCELLED:
- doCancelled();
- // break; hm, should this be commented out?
- case NEW:
- doNew();
- // is this really a fall-through?
- case REMOVED:
- doRemoved();
- // what happens if you add another case after this one?
- case OTHER: // empty case - this is interpreted as an intentional fall-through
- case ERROR:
- doErrorHandling();
- break;
- }
+package some.package;
+
+import some.other.package.subpackage.subsubpackage.DontUseThisClass;
+
+public class Bar {
+ DontUseThisClass boo = new DontUseThisClass();
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|classes||Allowed classes|yes. Delimiter is ','.|
+|packages||Restricted packages|yes. Delimiter is ','.|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## MissingStaticMethodInNonInstantiatableClass
+## ModifiedCyclomaticComplexity
-**Since:** PMD 3.0
+Deprecated
+
+**Since:** PMD 5.1.2
**Priority:** Medium (3)
-A class that has private constructors and does not have any static methods or fields cannot be used.
+Complexity directly affects maintenance costs is determined by the number of decision points in a method
+plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
+Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
+high complexity, and 11+ is very high complexity. Modified complexity treats switch statements as a single
+decision point.
-```
-//ClassOrInterfaceDeclaration[@Nested='false']
-[
- (
- ./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration
- and
- count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration) = count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Private='true'])
- )
- and
- not(.//MethodDeclaration[@Static='true'])
- and
- not(.//FieldDeclaration[@Private='false'][@Static='true'])
- and
- not(.//ClassOrInterfaceDeclaration[@Nested='true']
- [@Public='true']
- [@Static='true']
- [not(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration) or ./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Public='true']]
- [./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/MethodDeclaration
- [@Public='true']
- [./ResultType/Type/ReferenceType/ClassOrInterfaceType
- [@Image = //ClassOrInterfaceDeclaration[@Nested='false']/@Image]
- ]
- ]
- )
-]
-```
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.ModifiedCyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ModifiedCyclomaticComplexityRule.java)
**Example(s):**
``` java
-// This class is unusable, since it cannot be
-// instantiated (private constructor),
-// and no static method can be called.
-
-public class Foo {
- private Foo() {}
- void foo() {}
+public class Foo { // This has a Cyclomatic Complexity = 9
+1 public void example() {
+2 if (a == b) {
+3 if (a1 == b1) {
+ fiddle();
+4 } else if a2 == b2) {
+ fiddle();
+ } else {
+ fiddle();
+ }
+5 } else if (c == d) {
+6 while (c == d) {
+ fiddle();
+ }
+7 } else if (e == f) {
+8 for (int n = 0; n < h; n++) {
+ fiddle();
+ }
+ } else{
+9 switch (z) {
+ case 1:
+ fiddle();
+ break;
+ case 2:
+ fiddle();
+ break;
+ case 3:
+ fiddle();
+ break;
+ default:
+ fiddle();
+ break;
+ }
+ }
+ }
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|showMethodsComplexity|true|Add method average violations to the report|no|
+|showClassesComplexity|true|Add class average violations to the report|no|
+|reportLevel|10|Cyclomatic Complexity reporting threshold|no|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## NonCaseLabelInSwitchStatement
+## NcssConstructorCount
+
+Deprecated
-**Since:** PMD 1.5
+**Since:** PMD 3.9
**Priority:** Medium (3)
-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.
+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.
-```
-//SwitchStatement//BlockStatement/Statement/LabeledStatement
-```
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.NcssConstructorCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssConstructorCountRule.java)
**Example(s):**
``` java
-public class Foo {
- void bar(int a) {
- switch (a) {
- case 1:
- // do something
- break;
- mylabel: // this is legal, but confusing!
- break;
- default:
- break;
+public class Foo extends Bar {
+ public Foo() {
+ super();
+
+
+
+
+
+ //this constructor only has 1 NCSS lines
+ super.foo();
}
- }
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## NonStaticInitializer
+## NcssCount
-**Since:** PMD 1.5
+**Since:** PMD 6.0.0
**Priority:** Medium (3)
-A non-static 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.
+This rule uses the NCSS (Non-Commenting Source Statements) metric to determine the number of lines
+of code in a class, method or constructor. NCSS ignores comments, blank lines, and only counts actual
+statements. For more details on the calculation, see the documentation of
+the [NCSS metric](/pmd_java_metrics_index.html#non-commenting-source-statements-ncss).
-```
-//Initializer[@Static='false']
-```
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.NcssCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java)
**Example(s):**
``` java
-public class MyClass {
- // this block gets run before any call to a constructor
- {
- System.out.println("I am about to construct myself");
+import java.util.Collections; // +0
+import java.io.IOException; // +0
+
+class Foo { // +1, total Ncss = 12
+
+ public void bigMethod() // +1
+ throws IOException {
+ int x = 0, y = 2; // +1
+ boolean a = false, b = true; // +1
+
+ if (a || b) { // +1
+ try { // +1
+ do { // +1
+ x += 2; // +1
+ } while (x < 12);
+
+ System.exit(0); // +1
+ } catch (IOException ioe) { // +1
+ throw new PatheticFailException(ioe); // +1
+ }
+ } else {
+ assert false; // +1
+ }
}
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ncssOptions||Choose options for the calculation of Ncss|yes. Delimiter is '\|'.|
+|methodReportLevel|60|NCSS reporting threshold for methods|no|
+|classReportLevel|1500|NCSS reporting threshold for classes|no|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## NonThreadSafeSingleton
-
-**Since:** PMD 3.4
+## NcssMethodCount
-**Priority:** Medium (3)
+Deprecated
-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](https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom).
+**Since:** PMD 3.9
-Refrain from using the double-checked locking pattern. The Java Memory Model doesn't
-guarantee it to work unless the variable is declared as `volatile`, adding an uneeded
-performance penalty. [Reference](http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html)
+**Priority:** Medium (3)
-See Effective Java, item 48.
+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.
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.NonThreadSafeSingletonRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NonThreadSafeSingletonRule.java)
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.NcssMethodCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssMethodCountRule.java)
**Example(s):**
``` java
-private static Foo foo = null;
+public class Foo extends Bar {
+ public int methd() {
+ super.methd();
+
+
+
-//multiple simultaneous callers may see partially initialized objects
-public static Foo getFoo() {
- if (foo==null) {
- foo = new Foo();
+
+
+ //this method only has 1 NCSS lines
+ return 1;
}
- return foo;
}
```
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|checkNonStaticFields|false|Check for non-static fields. Do not set this to true and checkNonStaticMethods to false.|
-|checkNonStaticMethods|true|Check for non-static methods. Do not set this to false and checkNonStaticFields to true.|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
**Use this rule by referencing it:**
``` xml
-
+
```
-## OptimizableToArrayCall
+## NcssTypeCount
-**Since:** PMD 1.8
+Deprecated
+
+**Since:** PMD 3.9
**Priority:** Medium (3)
-Calls to a collection's toArray() method should specify target arrays sized to match the size of the
-collection. Initial arrays that are too small are discarded in favour of new ones that have to be created
-that are the proper size.
+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.
-```
-//PrimaryExpression
-[PrimaryPrefix/Name[ends-with(@Image, 'toArray')]]
-[
-PrimarySuffix/Arguments/ArgumentList/Expression
- /PrimaryExpression/PrimaryPrefix/AllocationExpression
- /ArrayDimsAndInits/Expression/PrimaryExpression/PrimaryPrefix/Literal[@Image='0']
-]
-```
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.NcssTypeCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssTypeCountRule.java)
**Example(s):**
``` java
-List foos = getFoos();
-
- // inefficient, the array will be discarded
-Foo[] fooArray = foos.toArray(new Foo[0]);
-
- // much better; this one sizes the destination array,
- // avoiding of a new one via reflection
-Foo[] fooArray = foos.toArray(new Foo[foos.size()]);
-```
+public class Foo extends Bar {
+ public Foo() {
+ //this class only has 6 NCSS lines
+ super();
-**Use this rule by referencing it:**
-``` xml
-
-```
-## PositionLiteralsFirstInCaseInsensitiveComparisons
-**Since:** PMD 5.1
-**Priority:** Medium (3)
-Position literals first in comparisons, if the second argument is null then NullPointerExceptions
-can be avoided, they will just return false.
-
-```
-//PrimaryExpression[
- PrimaryPrefix[Name
- [
- (ends-with(@Image, '.equalsIgnoreCase'))
- ]
- ]
- [
- (../PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Literal)
- and
- ( count(../PrimarySuffix/Arguments/ArgumentList/Expression) = 1 )
- ]
-]
-[not(ancestor::Expression/ConditionalAndExpression//EqualityExpression[@Image='!=']//NullLiteral)]
-[not(ancestor::Expression/ConditionalOrExpression//EqualityExpression[@Image='==']//NullLiteral)]
+ super.foo();
+ }
+}
```
-**Example(s):**
+**This rule has the following properties:**
-``` java
-class Foo {
- boolean bar(String x) {
- return x.equalsIgnoreCase("2"); // should be "2".equalsIgnoreCase(x)
- }
-}
-```
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
**Use this rule by referencing it:**
``` xml
-
+
```
-## PositionLiteralsFirstInComparisons
+## NPathComplexity
-**Since:** PMD 3.3
+**Since:** PMD 3.9
**Priority:** Medium (3)
-Position literals first in comparisons, if the second argument is null then NullPointerExceptions
-can be avoided, they will just return false.
+The NPath complexity of a method is the number of acyclic execution paths through that method.
+While cyclomatic complexity counts the number of decision points in a method, NPath counts the number of
+full paths from the beginning to the end of the block of the method. That metric grows exponentially, as
+it multiplies the complexity of statements in the same block. For more details on the calculation, see the
+documentation of the [NPath metric](/pmd_java_metrics_index.html#npath-complexity-npath).
-```
-//PrimaryExpression[
- PrimaryPrefix[Name[(ends-with(@Image, '.equals'))]]
- [
- (../PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true'])
- and
- ( count(../PrimarySuffix/Arguments/ArgumentList/Expression) = 1 )
- ]
-]
-[not(ancestor::Expression/ConditionalAndExpression//EqualityExpression[@Image='!=']//NullLiteral)]
-[not(ancestor::Expression/ConditionalOrExpression//EqualityExpression[@Image='==']//NullLiteral)]
-```
+A threshold of 200 is generally considered the point where measures should be taken to reduce
+complexity and increase readability.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.NPathComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NPathComplexityRule.java)
**Example(s):**
``` java
-class Foo {
- boolean bar(String x) {
- return x.equals("2"); // should be "2".equals(x)
+public class Foo {
+ public static void bar() { // Ncss = 252: reported!
+ boolean a, b = true;
+ try { // 2 * 2 + 2 = 6
+ if (true) { // 2
+ List buz = new ArrayList();
+ }
+
+ for(int i = 0; i < 19; i++) { // * 2
+ List buz = new ArrayList();
+ }
+ } catch(Exception e) {
+ if (true) { // 2
+ e.printStackTrace();
+ }
+ }
+
+ while (j++ < 20) { // * 2
+ List buz = new ArrayList();
+ }
+
+ switch(j) { // * 7
+ case 1:
+ case 2: break;
+ case 3: j = 5; break;
+ case 4: if (b && a) { bar(); } break;
+ default: break;
+ }
+
+ do { // * 3
+ List buz = new ArrayList();
+ } while (a && j++ < 30);
}
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|minimum|200.0|Deprecated Minimum reporting threshold|no|
+|reportLevel|200|N-Path Complexity reporting threshold|no|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## PreserveStackTrace
+## SignatureDeclareThrowsException
-**Since:** PMD 3.7
+**Since:** PMD 1.2
**Priority:** Medium (3)
-Throwing a new exception from a catch block without passing the original exception into the
-new exception will cause the original stack trace to be lost making it difficult to debug
-effectively.
+A method/constructor shouldn't explicitly throw the generic java.lang.Exception, since it
+is unclear which exceptions that can be thrown from the methods. It might be
+difficult to document and understand such vague interfaces. Use either a class
+derived from RuntimeException or a checked exception.
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.PreserveStackTraceRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/PreserveStackTraceRule.java)
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.SignatureDeclareThrowsExceptionRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SignatureDeclareThrowsExceptionRule.java)
**Example(s):**
``` java
-public class Foo {
- void good() {
- try{
- Integer.parseInt("a");
- } catch (Exception e) {
- throw new Exception(e); // first possibility to create exception chain
- }
- try {
- Integer.parseInt("a");
- } catch (Exception e) {
- throw (IllegalStateException)new IllegalStateException().initCause(e); // second possibility to create exception chain.
- }
- }
- void bad() {
- try{
- Integer.parseInt("a");
- } catch (Exception e) {
- throw new Exception(e.getMessage());
- }
- }
+public void foo() throws Exception {
}
```
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|IgnoreJUnitCompletely|false|Allow all methods in a JUnit testcase to throw Exceptions|no|
+
**Use this rule by referencing it:**
``` xml
-
+
```
-## ReturnEmptyArrayRatherThanNull
+## SimplifiedTernary
-**Since:** PMD 4.2
+**Since:** PMD 5.4.0
-**Priority:** High (1)
+**Priority:** Medium (3)
-For any method that returns an array, it is a better to return an empty array rather than a
-null reference. This removes the need for null checking all results and avoids inadvertent
-NullPointerExceptions.
+Look for ternary operators with the form `condition ? literalBoolean : foo`
+or `condition ? foo : literalBoolean`.
-```
-//MethodDeclaration
- [
- (./ResultType/Type[@Array='true'])
- and
- (./Block/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral)
- ]
+These expressions can be simplified respectively to
+`condition || foo` when the literalBoolean is true
+`!condition && foo` when the literalBoolean is false
+or
+`!condition || foo` when the literalBoolean is true
+`condition && foo` when the literalBoolean is false
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ConditionalExpression[not(PrimaryExpression/*/Literal) and (Expression/PrimaryExpression/*/Literal/BooleanLiteral)]
+|
+//ConditionalExpression[not(Expression/PrimaryExpression/*/Literal) and (PrimaryExpression/*/Literal/BooleanLiteral)]
```
**Example(s):**
``` java
-public class Example {
- // Not a good idea...
- public int[] badBehavior() {
- // ...
- return null;
+public class Foo {
+ public boolean test() {
+ return condition ? true : something(); // can be as simple as return condition || something();
+ }
+
+ public void test2() {
+ final boolean value = condition ? false : something(); // can be as simple as value = !condition && something();
}
- // Good behavior
- public String[] bonnePratique() {
- //...
- return new String[0];
+ public boolean test3() {
+ return condition ? something() : true; // can be as simple as return !condition || something();
+ }
+
+ public void test4() {
+ final boolean otherValue = condition ? something() : false; // can be as simple as condition && something();
}
}
```
**Use this rule by referencing it:**
``` xml
-
+
```
-## SimpleDateFormatNeedsLocale
+## SimplifyBooleanAssertion
-**Since:** PMD 2.0
+**Since:** PMD 3.6
**Priority:** Medium (3)
-Be sure to specify a Locale when creating SimpleDateFormat instances to ensure that locale-appropriate
-formatting is used.
+Avoid negation in an assertTrue or assertFalse test.
-```
-//AllocationExpression
- [ClassOrInterfaceType[@Image='SimpleDateFormat']]
- [Arguments[@ArgumentCount=1]]
+For example, rephrase:
+
+ assertTrue(!expr);
+
+as:
+
+ assertFalse(expr);
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//StatementExpression
+[
+.//Name[@Image='assertTrue' or @Image='assertFalse']
+and
+PrimaryExpression/PrimarySuffix/Arguments/ArgumentList
+ /Expression/UnaryExpressionNotPlusMinus[@Image='!']
+/PrimaryExpression/PrimaryPrefix
+]
+[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]
+ or //MarkerAnnotation/Name[
+ pmd-java:typeIs('org.junit.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+ or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+ ]
+]]
```
**Example(s):**
``` java
-public class Foo {
- // Should specify Locale.US (or whatever)
- private SimpleDateFormat sdf = new SimpleDateFormat("pattern");
+public class SimpleTest extends TestCase {
+ public void testX() {
+ assertTrue("not empty", !r.isEmpty()); // replace with assertFalse("not empty", r.isEmpty())
+ assertFalse(!r.isEmpty()); // replace with assertTrue(r.isEmpty())
+ }
}
```
**Use this rule by referencing it:**
``` xml
-
+
```
## SimplifyBooleanExpressions
@@ -1413,7 +1440,8 @@ public class Foo {
Avoid unnecessary comparisons in boolean expressions, they serve no purpose and impacts readability.
-```
+**This rule is defined by the following XPath expression:**
+``` xpath
//EqualityExpression/PrimaryExpression
/PrimaryPrefix/Literal/BooleanLiteral
```
@@ -1432,7 +1460,7 @@ public class Bar {
**Use this rule by referencing it:**
``` xml
-
+
```
## SimplifyBooleanReturns
@@ -1464,7 +1492,7 @@ public boolean isBarEqualTo(int x) {
**Use this rule by referencing it:**
``` xml
-
+
```
## SimplifyConditional
@@ -1475,7 +1503,8 @@ public boolean isBarEqualTo(int x) {
No need to check for null before an instanceof; the instanceof keyword returns false when given a null argument.
-```
+**This rule is defined by the following XPath expression:**
+``` xpath
//Expression
[ConditionalOrExpression
[EqualityExpression[@Image='==']
@@ -1516,110 +1545,113 @@ class Foo {
**Use this rule by referencing it:**
``` xml
-
+
```
-## SingleMethodSingleton
+## SingularField
-**Since:** PMD 5.4
+**Since:** PMD 3.1
-**Priority:** Medium High (2)
+**Priority:** Medium (3)
-Some classes contain overloaded getInstance. The problem with overloaded getInstance methods
-is that the instance created using the overloaded method is not cached and so,
-for each call and new objects will be created for every invocation.
+Fields whose scopes are limited to just single methods do not rely on the containing
+object to provide them to other methods. They may be better implemented as local variables
+within those methods.
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.SingleMethodSingletonRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SingleMethodSingletonRule.java)
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.SingularFieldRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SingularFieldRule.java)
**Example(s):**
``` java
-public class Singleton {
-
- private static Singleton singleton = new Singleton( );
-
- private Singleton(){ }
-
- public static Singleton getInstance( ) {
- return singleton;
- }
-
- public static Singleton getInstance(Object obj){
- Singleton singleton = (Singleton) obj;
- return singleton; //violation
+public class Foo {
+ private int x; // no reason to exist at the Foo instance level
+ public void foo(int y) {
+ x = y + 5;
+ return x;
}
}
```
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SingletonClassReturningNewInstance
-
-**Since:** PMD 5.4
-
-**Priority:** Medium High (2)
-
-Some classes contain overloaded getInstance. The problem with overloaded getInstance methods
-is that the instance created using the overloaded method is not cached and so,
-for each call and new objects will be created for every invocation.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.SingletonClassReturningNewInstanceRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SingletonClassReturningNewInstanceRule.java)
-
-**Example(s):**
+**This rule has the following properties:**
-``` java
-class Singleton {
- private static Singleton instance = null;
- public static Singleton getInstance() {
- synchronized(Singleton.class) {
- return new Singleton();
- }
- }
-}
-```
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|disallowNotAssignment|false|Disallow violations where the first usage is not an assignment|no|
+|checkInnerClasses|false|Check inner classes|no|
+|ignoredAnnotations|lombok.Setter \| lombok.Getter \| lombok.Builder \| lombok.Data \| lombok.RequiredArgsConstructor \| lombok.AllArgsConstructor \| lombok.Value \| lombok.NoArgsConstructor|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.|
**Use this rule by referencing it:**
``` xml
-
+
```
-## SingularField
+## StdCyclomaticComplexity
-**Since:** PMD 3.1
+Deprecated
+
+**Since:** PMD 5.1.2
**Priority:** Medium (3)
-Fields whose scopes are limited to just single methods do not rely on the containing
-object to provide them to other methods. They may be better implemented as local variables
-within those methods.
+Complexity directly affects maintenance costs is determined by the number of decision points in a method
+plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
+Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
+high complexity, and 11+ is very high complexity.
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.SingularFieldRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SingularFieldRule.java)
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.StdCyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/StdCyclomaticComplexityRule.java)
**Example(s):**
``` java
-public class Foo {
- private int x; // no reason to exist at the Foo instance level
- public void foo(int y) {
- x = y + 5;
- return x;
+public class Foo { // This has a Cyclomatic Complexity = 12
+1 public void example() {
+2 if (a == b || (c == d && e == f)) { // Only one
+3 if (a1 == b1) {
+ fiddle();
+4 } else if a2 == b2) {
+ fiddle();
+ } else {
+ fiddle();
+ }
+5 } else if (c == d) {
+6 while (c == d) {
+ fiddle();
+ }
+7 } else if (e == f) {
+8 for (int n = 0; n < h; n++) {
+ fiddle();
+ }
+ } else{
+ switch (z) {
+9 case 1:
+ fiddle();
+ break;
+10 case 2:
+ fiddle();
+ break;
+11 case 3:
+ fiddle();
+ break;
+12 default:
+ fiddle();
+ break;
+ }
+ }
}
}
```
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|disallowNotAssignment|false|Disallow violations where the first usage is not an assignment|
-|checkInnerClasses|false|Check inner classes|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|showMethodsComplexity|true|Add method average violations to the report|no|
+|showClassesComplexity|true|Add class average violations to the report|no|
+|reportLevel|10|Cyclomatic Complexity reporting threshold|no|
**Use this rule by referencing it:**
``` xml
-
+
```
## SwitchDensity
@@ -1654,337 +1686,172 @@ public class Foo {
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
**Use this rule by referencing it:**
``` xml
-
+
```
-## SwitchStmtsShouldHaveDefault
+## TooManyFields
-**Since:** PMD 1.0
+**Since:** PMD 3.0
**Priority:** Medium (3)
-All switch statements should include a default option to catch any unspecified values.
+Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields,
+possibly through grouping related fields in new objects. For example, a class with individual
+city/state/zip fields could park them within a single Address field.
-```
-//SwitchStatement[not(SwitchLabel[@Default='true'])]
-```
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.TooManyFieldsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/TooManyFieldsRule.java)
**Example(s):**
``` java
-public void bar() {
- int x = 2;
- switch (x) {
- case 1: int j = 6;
- case 2: int j = 8;
- // missing default: here
- }
+public class Person { // too many separate fields
+ int birthYear;
+ int birthMonth;
+ int birthDate;
+ float height;
+ float weight;
}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TooFewBranchesForASwitchStatement
-**Since:** PMD 4.2
-
-**Priority:** Medium (3)
-
-Switch statements are intended to be used to support complex branching behaviour. Using a switch for only a few
-cases is ill-advised, since switches are not as easy to understand as if-then statements. In these cases use the
-if-then statement to increase code readability.
-
-```
-//SwitchStatement[
- (count(.//SwitchLabel) < $minimumNumberCaseForASwitch)
-]
-```
-
-**Example(s):**
-
-``` java
-// With a minimumNumberCaseForASwitch of 3
-public class Foo {
- public void bar() {
- switch (condition) {
- case ONE:
- instruction;
- break;
- default:
- break; // not enough for a 'switch' stmt, a simple 'if' stmt would have been more appropriate
- }
- }
+public class Person { // this is more manageable
+ Date birthDate;
+ BodyMeasurements measurements;
}
```
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|minimumNumberCaseForASwitch|3|Minimum number of branches for a switch|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|maxfields|15|Max allowable fields|no|
**Use this rule by referencing it:**
``` xml
-
+
```
-## UncommentedEmptyConstructor
+## TooManyMethods
-**Since:** PMD 3.4
+**Since:** PMD 4.2
**Priority:** Medium (3)
-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.
-
-```
-//ConstructorDeclaration[@Private='false']
- [count(BlockStatement) = 0 and ($ignoreExplicitConstructorInvocation = 'true' or not(ExplicitConstructorInvocation)) and @containsComment = 'false']
- [not(../Annotation/MarkerAnnotation/Name[typeof(@Image, 'javax.inject.Inject', 'Inject')])]
-```
-
-**Example(s):**
-
-``` java
-public Foo() {
- // This constructor is intentionally empty. Nothing special is needed here.
-}
+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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration/ClassOrInterfaceBody
+ [
+ count(./ClassOrInterfaceBodyDeclaration/MethodDeclaration/MethodDeclarator[
+ not (
+ starts-with(@Image,'get')
+ or
+ starts-with(@Image,'set')
+ or
+ starts-with(@Image,'is')
+ )
+ ]) > $maxmethods
+ ]
```
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|ignoreExplicitConstructorInvocation|false|Ignore explicit constructor invocation when deciding whether constructor is empty or not|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|maxmethods|10|The method count reporting threshold|no|
**Use this rule by referencing it:**
``` xml
-
+
```
-## UncommentedEmptyMethodBody
+## UselessOverridingMethod
-**Since:** PMD 3.4
+**Since:** PMD 3.3
**Priority:** Medium (3)
-Uncommented Empty Method Body finds instances where a method body does not contain
-statements, but there is no comment. By explicitly commenting empty method bodies
-it is easier to distinguish between intentional (commented) and unintentional
-empty methods.
+The overriding method merely calls the same method defined in a superclass.
-```
-//MethodDeclaration/Block[count(BlockStatement) = 0 and @containsComment = 'false']
-```
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.UselessOverridingMethodRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/UselessOverridingMethodRule.java)
**Example(s):**
``` java
-public void doSomething() {
+public void foo(String bar) {
+ super.foo(bar); // why bother overriding?
}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryLocalBeforeReturn
-
-**Since:** PMD 3.3
-**Priority:** Medium (3)
-
-Avoid the creation of unnecessary local variables
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.UnnecessaryLocalBeforeReturnRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/UnnecessaryLocalBeforeReturnRule.java)
-
-**Example(s):**
+public String foo() {
+ return super.foo(); // why bother overriding?
+}
-``` java
-public class Foo {
- public int foo() {
- int x = doSomething();
- return x; // instead, just 'return doSomething();'
- }
+@Id
+public Long getId() {
+ return super.getId(); // OK if 'ignoreAnnotations' is false, which is the default behavior
}
```
**This rule has the following properties:**
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|statementOrderMatters|true|If set to false this rule no longer requires the variable declaration and return statement to be on consecutive lines. Any variable that is used solely in a return statement will be reported.|
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoreAnnotations|false|Ignore annotations|no|
**Use this rule by referencing it:**
``` xml
-
+
```
-## UnsynchronizedStaticDateFormatter
+## UseObjectForClearerAPI
-**Since:** PMD 3.6
+**Since:** PMD 4.2.6
**Priority:** Medium (3)
-SimpleDateFormat instances are not synchronized. Sun recommends using 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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.UnsynchronizedStaticDateFormatterRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/UnsynchronizedStaticDateFormatterRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- private static final SimpleDateFormat sdf = new SimpleDateFormat();
- void bar() {
- sdf.format(); // poor, no thread-safety
- }
- synchronized void foo() {
- sdf.format(); // preferred
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
+When you write a public method, you should be thinking in terms of an API. If your method is public, it means other class
+will use it, therefore, you want (or need) to offer a comprehensive and evolutive API. If you pass a lot of information
+as a simple series of Strings, you may think of using an Object to represent all those information. You'll get a simpler
+API (such as doWork(Workload workload), rather than a tedious series of Strings) and more importantly, if you need at some
+point to pass extra data, you'll be able to do so by simply modifying or extending Workload without any modification to
+your API.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[@Public]/MethodDeclarator/FormalParameters[
+ count(FormalParameter/Type/ReferenceType/ClassOrInterfaceType[@Image = 'String']) > 3
+]
```
-## UseCollectionIsEmpty
-
-**Since:** PMD 3.9
-
-**Priority:** Medium (3)
-
-The isEmpty() method on java.util.Collection is provided to determine if a collection has any elements.
-Comparing the value of size() to 0 does not convey intent as well as the isEmpty() method.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.design.UseCollectionIsEmptyRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/UseCollectionIsEmptyRule.java)
-
**Example(s):**
``` java
-public class Foo {
- void good() {
- List foo = getList();
- if (foo.isEmpty()) {
- // blah
- }
- }
+public class MyClass {
+ public void connect(String username,
+ String pssd,
+ String databaseName,
+ String databaseAdress)
+ // Instead of those parameters object
+ // would ensure a cleaner API and permit
+ // to add extra data transparently (no code change):
+ // void connect(UserData data);
+ {
- void bad() {
- List foo = getList();
- if (foo.size() == 0) {
- // blah
- }
}
}
```
**Use this rule by referencing it:**
``` xml
-
-```
-
-## UseLocaleWithCaseConversions
-
-**Since:** PMD 2.0
-
-**Priority:** Medium (3)
-
-When doing String.toLowerCase()/toUpperCase() conversions, use Locales to avoids problems with languages that
-have unusual conventions, i.e. Turkish.
-
-```
-//PrimaryExpression
-[
-PrimaryPrefix
-[Name[ends-with(@Image, 'toLowerCase') or ends-with(@Image, 'toUpperCase')]]
-[following-sibling::PrimarySuffix[position() = 1]/Arguments[@ArgumentCount=0]]
-
-or
-
-PrimarySuffix
-[ends-with(@Image, 'toLowerCase') or ends-with(@Image, 'toUpperCase')]
-[following-sibling::PrimarySuffix[position() = 1]/Arguments[@ArgumentCount=0]]
-]
-[not(PrimaryPrefix/Name[ends-with(@Image, 'toHexString')])]
-```
-
-**Example(s):**
-
-``` java
-class Foo {
- // BAD
- if (x.toLowerCase().equals("list")) { }
-
- /*
- * This will not match "LIST" when in Turkish locale
- * The above could be
- * if (x.toLowerCase(Locale.US).equals("list")) { }
- * or simply
- * if (x.equalsIgnoreCase("list")) { }
- */
- // GOOD
- String z = a.toLowerCase(Locale.EN);
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseNotifyAllInsteadOfNotify
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-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 its usually safer to call notifyAll() instead.
-
-```
-//StatementExpression/PrimaryExpression
-[PrimarySuffix/Arguments[@ArgumentCount = '0']]
-[
- PrimaryPrefix[
- ./Name[@Image='notify' or ends-with(@Image,'.notify')]
- or ../PrimarySuffix/@Image='notify'
- or (./AllocationExpression and ../PrimarySuffix[@Image='notify'])
- ]
-]
-```
-
-**Example(s):**
-
-``` java
-void bar() {
- x.notify();
- // If many threads are monitoring x, only one (and you won't know which) will be notified.
- // use instead:
- x.notifyAll();
- }
-```
-
-**Use this rule by referencing it:**
-``` xml
-
+
```
## UseUtilityClass
@@ -2012,56 +1879,6 @@ public class MaybeAUtility {
**Use this rule by referencing it:**
``` xml
-
-```
-
-## UseVarargs
-
-**Since:** PMD 5.0
-
-**Priority:** Medium Low (4)
-
-**Minimum Language Version:** Java 1.5
-
-Java 5 introduced the varargs parameter declaration for methods and constructors. This syntactic
-sugar provides flexibility for users of these methods and constructors, allowing them to avoid
-having to deal with the creation of an array.
-
-```
-//FormalParameters/FormalParameter
- [position()=last()]
- [@Array='true']
- [@Varargs='false']
- [not (./Type/ReferenceType[@Array='true'][PrimitiveType[@Image='byte']])]
- [not (./Type/ReferenceType[ClassOrInterfaceType[@Image='Byte']])]
- [not (./Type/PrimitiveType[@Image='byte'])]
- [not (ancestor::MethodDeclaration/preceding-sibling::Annotation/*/Name[@Image='Override'])]
- [not(
- ancestor::MethodDeclaration
- [@Public='true' and @Static='true']
- [child::ResultType[@Void='true']] and
- ancestor::MethodDeclarator[@Image='main'] and
- ..[@ParameterCount='1'] and
- ./Type/ReferenceType[ClassOrInterfaceType[@Image='String']]
- )]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void foo(String s, Object[] args) {
- // Do something here...
- }
-
- public void bar(String s, Object... args) {
- // Ahh, varargs tastes much better...
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
+
```
diff --git a/docs/pages/pmd/rules/java/documentation.md b/docs/pages/pmd/rules/java/documentation.md
new file mode 100644
index 00000000000..98d9988decb
--- /dev/null
+++ b/docs/pages/pmd/rules/java/documentation.md
@@ -0,0 +1,184 @@
+---
+title: Documentation
+summary: Rules that are related to code documentation.
+permalink: pmd_rules_java_documentation.html
+folder: pmd/rules/java
+sidebaractiveurl: /pmd_rules_java.html
+editmepath: ../pmd-java/src/main/resources/category/java/documentation.xml
+keywords: Documentation, CommentContent, CommentRequired, CommentSize, UncommentedEmptyConstructor, UncommentedEmptyMethodBody
+language: Java
+---
+## CommentContent
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+A rule for the politically correct... we don't want to offend anyone.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.documentation.CommentContentRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentContentRule.java)
+
+**Example(s):**
+
+``` java
+//OMG, this is horrible, Bob is an idiot !!!
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|disallowedTerms|idiot \| jerk|Illegal terms or phrases|yes. Delimiter is '\|'.|
+|caseSensitive|false|Case sensitive|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CommentRequired
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Denotes whether comments are required (or unwanted) for specific language elements.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.documentation.CommentRequiredRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredRule.java)
+
+**Example(s):**
+
+``` java
+/**
+*
+*
+* @author Jon Doe
+*/
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|serialVersionUIDCommentRequired|Ignored|Serial version UID comments. Possible values: [Required, Ignored, Unwanted]|no|
+|enumCommentRequirement|Required|Enum comments. Possible values: [Required, Ignored, Unwanted]|no|
+|protectedMethodCommentRequirement|Required|Protected method constructor comments. Possible values: [Required, Ignored, Unwanted]|no|
+|publicMethodCommentRequirement|Required|Public method and constructor comments. Possible values: [Required, Ignored, Unwanted]|no|
+|fieldCommentRequirement|Required|Field comments. Possible values: [Required, Ignored, Unwanted]|no|
+|headerCommentRequirement|Required|Header comments. Possible values: [Required, Ignored, Unwanted]|no|
+|methodWithOverrideCommentRequirement|Ignored|Comments on @Override methods. Possible values: [Required, Ignored, Unwanted]|no|
+|accessorCommentRequirement|Ignored|Comments on getters and setters". Possible values: [Required, Ignored, Unwanted]|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CommentSize
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Determines whether the dimensions of non-header comments found are within the specified limits.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.documentation.CommentSizeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java)
+
+**Example(s):**
+
+``` java
+/**
+*
+* too many lines!
+*
+*
+*
+*
+*
+*
+*
+*
+*
+*
+*
+*
+*/
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|maxLines|6|Maximum lines|no|
+|maxLineLength|80|Maximum line length|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UncommentedEmptyConstructor
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ConstructorDeclaration[@Private='false']
+ [count(BlockStatement) = 0 and ($ignoreExplicitConstructorInvocation = 'true' or not(ExplicitConstructorInvocation)) and @containsComment = 'false']
+ [not(../Annotation/MarkerAnnotation/Name[pmd-java:typeIs('javax.inject.Inject')])]
+```
+
+**Example(s):**
+
+``` java
+public Foo() {
+ // This constructor is intentionally empty. Nothing special is needed here.
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoreExplicitConstructorInvocation|false|Ignore explicit constructor invocation when deciding whether constructor is empty or not|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UncommentedEmptyMethodBody
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+Uncommented Empty Method Body finds instances where a method body does not contain
+statements, but there is no comment. By explicitly commenting empty method bodies
+it is easier to distinguish between intentional (commented) and unintentional
+empty methods.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration/Block[count(BlockStatement) = 0 and @containsComment = 'false']
+```
+
+**Example(s):**
+
+``` java
+public void doSomething() {
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/java/empty.md b/docs/pages/pmd/rules/java/empty.md
deleted file mode 100644
index 818df1c477a..00000000000
--- a/docs/pages/pmd/rules/java/empty.md
+++ /dev/null
@@ -1,357 +0,0 @@
----
-title: Empty Code
-summary: The Empty Code ruleset contains rules that find empty statements of any kind (empty method, empty block statement, empty try or catch block,...).
-permalink: pmd_rules_java_empty.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/empty.xml
-keywords: Empty Code, EmptyCatchBlock, EmptyIfStmt, EmptyWhileStmt, EmptyTryBlock, EmptyFinallyBlock, EmptySwitchStatements, EmptySynchronizedBlock, EmptyStatementNotInLoop, EmptyInitializer, EmptyStatementBlock, EmptyStaticInitializer
----
-## EmptyCatchBlock
-
-**Since:** PMD 0.1
-
-**Priority:** Medium (3)
-
-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.
-
-```
-//CatchStatement
- [count(Block/BlockStatement) = 0 and ($allowCommentedBlocks != 'true' or Block/@containsComment = 'false')]
- [FormalParameter/Type/ReferenceType
- /ClassOrInterfaceType[@Image != 'InterruptedException' and @Image != 'CloneNotSupportedException']
- ]
- [FormalParameter/VariableDeclaratorId[not(matches(@Image, $allowExceptionNameRegex))]]
-```
-
-**Example(s):**
-
-``` java
-public void doSomething() {
- try {
- FileInputStream fis = new FileInputStream("/tmp/bugger");
- } catch (IOException ioe) {
- // not good
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|allowCommentedBlocks|false|Empty blocks containing comments will be skipped|
-|allowExceptionNameRegex|^$|Empty blocks catching exceptions with names matching this regular expression will be skipped|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyFinallyBlock
-
-**Since:** PMD 0.4
-
-**Priority:** Medium (3)
-
-Empty finally blocks serve no purpose and should be removed.
-
-```
-//FinallyStatement[count(Block/BlockStatement) = 0]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar() {
- try {
- int x=2;
- } finally {
- // empty!
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyIfStmt
-
-**Since:** PMD 0.1
-
-**Priority:** Medium (3)
-
-Empty If Statement finds instances where a condition is checked but nothing is done about it.
-
-```
-//IfStatement/Statement
- [EmptyStatement or Block[count(*) = 0]]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- void bar(int x) {
- if (x == 0) {
- // empty!
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyInitializer
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Empty initializers serve no purpose and should be removed.
-
-```
-//Initializer/Block[count(*)=0]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
-
- static {} // Why ?
-
- {} // Again, why ?
-
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyStatementBlock
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Empty block statements serve no purpose and should be removed.
-
-```
-//BlockStatement/Statement/Block[count(*) = 0]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
-
- private int _bar;
-
- public void setBar(int bar) {
- { _bar = bar; } // Why not?
- {} // But remove this.
- }
-
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyStatementNotInLoop
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for'
-or 'while' loop is probably a bug. It could also be a double semicolon, which has no purpose
-and should be removed.
-
-```
-//EmptyStatement
- [not(
- ../../../ForStatement
- or ../../../WhileStatement
- or ../../../BlockStatement/ClassOrInterfaceDeclaration
- or ../../../../../../ForStatement/Statement[1]
- /Block[1]/BlockStatement[1]/Statement/EmptyStatement
- or ../../../../../../WhileStatement/Statement[1]
- /Block[1]/BlockStatement[1]/Statement/EmptyStatement)
- ]
-```
-
-**Example(s):**
-
-``` java
-public void doit() {
- // this is probably not what you meant to do
- ;
- // the extra semicolon here this is not necessary
- System.out.println("look at the extra semicolon");;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyStaticInitializer
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-An empty static initializer serve no purpose and should be removed.
-
-```
-//Initializer[@Static='true']/Block[count(*)=0]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- static {
- // empty
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptySwitchStatements
-
-**Since:** PMD 1.0
-
-**Priority:** Medium (3)
-
-Empty switch statements serve no purpose and should be removed.
-
-```
-//SwitchStatement[count(*) = 1]
-```
-
-**Example(s):**
-
-``` java
-public void bar() {
- int x = 2;
- switch (x) {
- // once there was code here
- // but it's been commented out or something
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptySynchronizedBlock
-
-**Since:** PMD 1.3
-
-**Priority:** Medium (3)
-
-Empty synchronized blocks serve no purpose and should be removed.
-
-```
-//SynchronizedStatement/Block[1][count(*) = 0]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar() {
- synchronized (this) {
- // empty!
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyTryBlock
-
-**Since:** PMD 0.4
-
-**Priority:** Medium (3)
-
-Avoid empty try blocks - what's the point?
-
-```
-//TryStatement[not(ResourceSpecification)]/Block[1][count(*) = 0]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar() {
- try {
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyWhileStmt
-
-**Since:** PMD 0.2
-
-**Priority:** Medium (3)
-
-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 is
-a while loop that does a lot in the exit expression, rewrite it to make it clearer.
-
-```
-//WhileStatement/Statement[./Block[count(*) = 0] or ./EmptyStatement]
-```
-
-**Example(s):**
-
-``` java
-void bar(int a, int b) {
- while (a == b) {
- // empty!
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/errorprone.md b/docs/pages/pmd/rules/java/errorprone.md
new file mode 100644
index 00000000000..b81d6b9f201
--- /dev/null
+++ b/docs/pages/pmd/rules/java/errorprone.md
@@ -0,0 +1,3529 @@
+---
+title: Error Prone
+summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+permalink: pmd_rules_java_errorprone.html
+folder: pmd/rules/java
+sidebaractiveurl: /pmd_rules_java.html
+editmepath: ../pmd-java/src/main/resources/category/java/errorprone.xml
+keywords: Error Prone, AssignmentInOperand, AssignmentToNonFinalStatic, AvoidAccessibilityAlteration, AvoidAssertAsIdentifier, AvoidBranchingStatementAsLastInLoop, AvoidCallingFinalize, AvoidCatchingNPE, AvoidCatchingThrowable, AvoidDecimalLiteralsInBigDecimalConstructor, AvoidDuplicateLiterals, AvoidEnumAsIdentifier, AvoidFieldNameMatchingMethodName, AvoidFieldNameMatchingTypeName, AvoidInstanceofChecksInCatchClause, AvoidLiteralsInIfCondition, AvoidLosingExceptionInformation, AvoidMultipleUnaryOperators, AvoidUsingOctalValues, BadComparison, BeanMembersShouldSerialize, BrokenNullCheck, CallSuperFirst, CallSuperLast, CheckSkipResult, ClassCastExceptionWithToArray, CloneMethodMustBePublic, CloneMethodMustImplementCloneable, CloneMethodReturnTypeMustMatchClassName, CloneThrowsCloneNotSupportedException, CloseResource, CompareObjectsWithEquals, ConstructorCallsOverridableMethod, DataflowAnomalyAnalysis, DoNotCallGarbageCollectionExplicitly, DoNotCallSystemExit, DoNotExtendJavaLangThrowable, DoNotHardCodeSDCard, DoNotThrowExceptionInFinally, DontImportSun, DontUseFloatTypeForLoopIndices, EmptyCatchBlock, EmptyFinalizer, EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock, EmptyStatementNotInLoop, EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, EmptyWhileStmt, EqualsNull, FinalizeDoesNotCallSuperFinalize, FinalizeOnlyCallsSuperFinalize, FinalizeOverloaded, FinalizeShouldBeProtected, IdempotentOperations, ImportFromSamePackage, InstantiationToGetClass, InvalidSlf4jMessageFormat, JumbledIncrementer, JUnitSpelling, JUnitStaticSuite, LoggerIsNotStaticFinal, MethodWithSameNameAsEnclosingClass, MisplacedNullCheck, MissingBreakInSwitch, MissingSerialVersionUID, MissingStaticMethodInNonInstantiatableClass, MoreThanOneLogger, NonCaseLabelInSwitchStatement, NonStaticInitializer, NullAssignment, OverrideBothEqualsAndHashcode, ProperCloneImplementation, ProperLogger, ReturnEmptyArrayRatherThanNull, ReturnFromFinallyBlock, SimpleDateFormatNeedsLocale, SingleMethodSingleton, SingletonClassReturningNewInstance, StaticEJBFieldShouldBeFinal, StringBufferInstantiationWithChar, SuspiciousEqualsMethodName, SuspiciousHashcodeMethodName, SuspiciousOctalEscape, TestClassWithoutTestCases, UnconditionalIfStatement, UnnecessaryBooleanAssertion, UnnecessaryCaseChange, UnnecessaryConversionTemporary, UnusedNullCheckInEquals, UseCorrectExceptionLogging, UseEqualsToCompareStrings, UselessOperationOnImmutable, UseLocaleWithCaseConversions, UseProperClassLoader
+language: Java
+---
+## AssignmentInOperand
+
+**Since:** PMD 1.03
+
+**Priority:** Medium (3)
+
+Avoid assignments in operands; this can make code more complicated and harder to read.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentInOperandRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AssignmentInOperandRule.java)
+
+**Example(s):**
+
+``` java
+public void bar() {
+ int x = 2;
+ if ((x = getX()) == 3) {
+ System.out.println("3!");
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|allowIncrementDecrement|false|Allow increment or decrement operators within the conditional expression of an if, for, or while statement|no|
+|allowWhile|false|Allow assignment within the conditional expression of a while statement|no|
+|allowFor|false|Allow assignment within the conditional expression of a for statement|no|
+|allowIf|false|Allow assignment within the conditional expression of an if statement|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AssignmentToNonFinalStatic
+
+**Since:** PMD 2.2
+
+**Priority:** Medium (3)
+
+Identifies a possible unsafe usage of a static field.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentToNonFinalStaticRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AssignmentToNonFinalStaticRule.java)
+
+**Example(s):**
+
+``` java
+public class StaticField {
+ static int x;
+ public FinalFields(int y) {
+ x = y; // unsafe
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidAccessibilityAlteration
+
+**Since:** PMD 4.1
+
+**Priority:** Medium (3)
+
+Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
+as the interface PrivilegedAction, allow for the runtime alteration of variable, class, or
+method visibility, even if they are private. This violates the principle of encapsulation.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression[
+(
+(PrimarySuffix[
+ ends-with(@Image,'getDeclaredConstructors')
+ or
+ ends-with(@Image,'getDeclaredConstructor')
+ or
+ ends-with(@Image,'setAccessible')
+ ])
+or
+(PrimaryPrefix/Name[
+ ends-with(@Image,'getDeclaredConstructor')
+ or
+ ends-with(@Image,'getDeclaredConstructors')
+ or
+ starts-with(@Image,'AccessibleObject.setAccessible')
+ ])
+)
+and
+(//ImportDeclaration/Name[
+ contains(@Image,'java.security.PrivilegedAction')])
+]
+```
+
+**Example(s):**
+
+``` java
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+
+public class Violation {
+ public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+ // Possible call to forbidden getDeclaredConstructors
+ Class[] arrayOfClass = new Class[1];
+ this.getClass().getDeclaredConstructors();
+ this.getClass().getDeclaredConstructor(arrayOfClass);
+ Class clazz = this.getClass();
+ clazz.getDeclaredConstructor(arrayOfClass);
+ clazz.getDeclaredConstructors();
+ // Possible call to forbidden setAccessible
+ clazz.getMethod("", arrayOfClass).setAccessible(false);
+ AccessibleObject.setAccessible(null, false);
+ Method.setAccessible(null, false);
+ Method[] methodsArray = clazz.getMethods();
+ int nbMethod;
+ for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
+ methodsArray[nbMethod].setAccessible(false);
+ }
+
+ // Possible call to forbidden PrivilegedAction
+ PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidAssertAsIdentifier
+
+**Since:** PMD 3.4
+
+**Priority:** Medium High (2)
+
+Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//VariableDeclaratorId[@Image='assert']
+```
+
+**Example(s):**
+
+``` java
+public class A {
+ public class Foo {
+ String assert = "foo";
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidBranchingStatementAsLastInLoop
+
+**Since:** PMD 5.0
+
+**Priority:** Medium High (2)
+
+Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
+Ensure that the usage is not a bug, or consider using another approach.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AvoidBranchingStatementAsLastInLoopRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidBranchingStatementAsLastInLoopRule.java)
+
+**Example(s):**
+
+``` java
+// unusual use of branching statement in a loop
+for (int i = 0; i < 10; i++) {
+ if (i*i <= 25) {
+ continue;
+ }
+ break;
+}
+
+// this makes more sense...
+for (int i = 0; i < 10; i++) {
+ if (i*i > 25) {
+ break;
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|checkReturnLoopTypes|for \| do \| while|Check for return statements in loop types|yes. Delimiter is '\|'.|
+|checkContinueLoopTypes|for \| do \| while|Check for continue statements in loop types|yes. Delimiter is '\|'.|
+|checkBreakLoopTypes|for \| do \| while|Check for break statements in loop types|yes. Delimiter is '\|'.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidCallingFinalize
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
+that there are no more references to the object. It should not be invoked by application logic.
+
+Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCallingFinalizeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidCallingFinalizeRule.java)
+
+**Example(s):**
+
+``` java
+void foo() {
+ Bar b = new Bar();
+ b.finalize();
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidCatchingNPE
+
+**Since:** PMD 1.8
+
+**Priority:** Medium (3)
+
+Code should never throw NullPointerExceptions under normal circumstances. A catch block may hide the
+original error, causing other, more subtle problems later on.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='NullPointerException']
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void bar() {
+ try {
+ // do something
+ } catch (NullPointerException npe) {
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidCatchingThrowable
+
+**Since:** PMD 1.2
+
+**Priority:** Medium (3)
+
+Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
+OutOfMemoryError that should be exposed and managed separately.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCatchingThrowableRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidCatchingThrowableRule.java)
+
+**Example(s):**
+
+``` java
+public void bar() {
+ try {
+ // do something
+ } catch (Throwable th) { // should not catch Throwable
+ th.printStackTrace();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidDecimalLiteralsInBigDecimalConstructor
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
+equal to .1000000000000000055511151231257827021181583404541015625.
+This is because 0.1 cannot be represented exactly as a double (or 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 0.1,
+appearances notwithstanding.
+
+The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal("0.1")' is
+exactly equal to 0.1, as one would expect. Therefore, it is generally recommended that the
+(String) constructor be used in preference to this one.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AllocationExpression
+[ClassOrInterfaceType[@Image="BigDecimal"]]
+[Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix
+ [
+ Literal[(not(ends-with(@Image,'"'))) and contains(@Image,".")]
+ or
+ Name[ancestor::Block/BlockStatement/LocalVariableDeclaration
+ [Type[PrimitiveType[@Image='double' or @Image='float']
+ or ReferenceType/ClassOrInterfaceType[@Image='Double' or @Image='Float']]]
+ /VariableDeclarator/VariableDeclaratorId/@Image = @Image
+ ]
+ or
+ Name[ancestor::MethodDeclaration/MethodDeclarator/FormalParameters/FormalParameter
+ [Type[PrimitiveType[@Image='double' or @Image='float']
+ or ReferenceType/ClassOrInterfaceType[@Image='Double' or @Image='Float']]]
+ /VariableDeclaratorId/@Image = @Image
+ ]
+ ]
+]
+```
+
+**Example(s):**
+
+``` java
+BigDecimal bd = new BigDecimal(1.123); // loss of precision, this would trigger the rule
+
+BigDecimal bd = new BigDecimal("1.123"); // preferred approach
+
+BigDecimal bd = new BigDecimal(12); // preferred approach, ok for integer values
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidDuplicateLiterals
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AvoidDuplicateLiteralsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidDuplicateLiteralsRule.java)
+
+**Example(s):**
+
+``` java
+private void bar() {
+ buz("Howdy");
+ buz("Howdy");
+ buz("Howdy");
+ buz("Howdy");
+}
+private void buz(String x) {}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|exceptionfile||File containing strings to skip (one string per line), only used if ignore list is not set|no|
+|separator|,|Ignore list separator|no|
+|exceptionList||Strings to ignore|no|
+|maxDuplicateLiterals|4|Max duplicate literals|no|
+|minimumLength|3|Minimum string length to check|no|
+|skipAnnotations|false|Skip literals within annotations|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidEnumAsIdentifier
+
+**Since:** PMD 3.4
+
+**Priority:** Medium High (2)
+
+Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//VariableDeclaratorId[@Image='enum']
+```
+
+**Example(s):**
+
+``` java
+public class A {
+ public class Foo {
+ String enum = "foo";
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidFieldNameMatchingMethodName
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+It can be confusing to have a field name with the same name as a method. While this is permitted,
+having information (field) and actions (method) is not clear naming. Developers versed in
+Smalltalk often prefer this approach as the methods denote accessor methods.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingMethodNameRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidFieldNameMatchingMethodNameRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ Object bar;
+ // bar is data or an action or both?
+ void bar() {
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidFieldNameMatchingTypeName
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+It is somewhat confusing to have a field name matching the declaring class name.
+This probably means that type and/or field names should be chosen more carefully.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingTypeNameRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidFieldNameMatchingTypeNameRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo extends Bar {
+ int foo; // There is probably a better name that can be used
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidInstanceofChecksInCatchClause
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+Each caught exception type should be handled in its own catch clause.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CatchStatement/FormalParameter
+ /following-sibling::Block//InstanceOfExpression/PrimaryExpression/PrimaryPrefix
+ /Name[
+ @Image = ./ancestor::Block/preceding-sibling::FormalParameter
+ /VariableDeclaratorId/@Image
+ ]
+```
+
+**Example(s):**
+
+``` java
+try { // Avoid this
+ // do something
+} catch (Exception ee) {
+ if (ee instanceof IOException) {
+ cleanup();
+ }
+}
+
+try { // Prefer this:
+ // do something
+} catch (IOException ee) {
+ cleanup();
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidLiteralsInIfCondition
+
+**Since:** PMD 4.2.6
+
+**Priority:** Medium (3)
+
+Avoid using hard-coded literals in conditional statements. By declaring them as static variables
+or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored.
+More exceptions can be defined with the property "ignoreMagicNumbers".
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfStatement/Expression/*/PrimaryExpression/PrimaryPrefix/Literal
+[not(NullLiteral)]
+[not(BooleanLiteral)]
+[empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+```
+
+**Example(s):**
+
+``` java
+private static final int MAX_NUMBER_OF_REQUESTS = 10;
+
+public void checkRequests() {
+
+ if (i == 10) { // magic number, buried in a method
+ doSomething();
+ }
+
+ if (i == MAX_NUMBER_OF_REQUESTS) { // preferred approach
+ doSomething();
+ }
+
+ if (aString.indexOf('.') != -1) {} // magic number -1, by default ignored
+ if (aString.indexOf('.') >= 0) { } // alternative approach
+
+ if (aDouble > 0.0) {} // magic number 0.0
+ if (aDouble >= Double.MIN_VALUE) {} // preferred approach
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|ignoreMagicNumbers|-1,0|Comma-separated list of magic numbers, that should be ignored|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidLosingExceptionInformation
+
+**Since:** PMD 4.2.6
+
+**Priority:** Medium High (2)
+
+Statements in a catch block that invoke accessors on the exception without using the information
+only add to code size. Either remove the invocation, or use the return result.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
+[
+ @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getMessage')
+ or
+ @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getLocalizedMessage')
+ or
+ @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getCause')
+ or
+ @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getStackTrace')
+ or
+ @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.toString')
+]
+```
+
+**Example(s):**
+
+``` java
+public void bar() {
+ try {
+ // do something
+ } catch (SomeException se) {
+ se.getMessage();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidMultipleUnaryOperators
+
+**Since:** PMD 4.2
+
+**Priority:** Medium High (2)
+
+The use of multiple unary operators may be problematic, and/or confusing.
+Ensure that the intended usage is not a bug, or consider simplifying the expression.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AvoidMultipleUnaryOperatorsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidMultipleUnaryOperatorsRule.java)
+
+**Example(s):**
+
+``` java
+// These are typo bugs, or at best needlessly complex and confusing:
+int i = - -1;
+int j = + - +1;
+int z = ~~2;
+boolean b = !!true;
+boolean c = !!!true;
+
+// These are better:
+int i = 1;
+int j = -1;
+int z = 2;
+boolean b = true;
+boolean c = false;
+
+// And these just make your brain hurt:
+int i = ~-2;
+int j = -~7;
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidUsingOctalValues
+
+**Since:** PMD 3.9
+
+**Priority:** Medium (3)
+
+Integer literals should not start with zero since this denotes that the rest of literal will be
+interpreted as an octal value.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.AvoidUsingOctalValuesRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidUsingOctalValuesRule.java)
+
+**Example(s):**
+
+``` java
+int i = 012; // set i with 10 not 12
+int j = 010; // set j with 8 not 10
+k = i * j; // set k with 80 not 120
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|strict|false|Detect violations between 00 and 07|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## BadComparison
+
+**Since:** PMD 1.8
+
+**Priority:** Medium (3)
+
+Avoid equality comparisons with Double.NaN. Due to the implicit lack of representation
+precision when comparing floating point numbers these are likely to cause logic errors.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//EqualityExpression[@Image='==']
+ /PrimaryExpression/PrimaryPrefix
+ /Name[@Image='Double.NaN' or @Image='Float.NaN']
+```
+
+**Example(s):**
+
+``` java
+boolean x = (y == Double.NaN);
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## BeanMembersShouldSerialize
+
+**Since:** PMD 1.1
+
+**Priority:** Medium (3)
+
+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. for a variable named foo, getFoo() and setFoo() accessor methods should be provided.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/BeanMembersShouldSerializeRule.java)
+
+**Example(s):**
+
+``` java
+private transient int someFoo; // good, it's transient
+private static int otherFoo; // also OK
+private int moreFoo; // OK, has proper accessors, see below
+private int badFoo; // bad, should be marked transient
+
+private void setMoreFoo(int moreFoo){
+ this.moreFoo = moreFoo;
+}
+
+private int getMoreFoo(){
+ return this.moreFoo;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|prefix||A variable prefix to skip, i.e., m_|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## BrokenNullCheck
+
+**Since:** PMD 3.8
+
+**Priority:** Medium High (2)
+
+The null check is broken since it will throw a NullPointerException itself.
+It is likely that you used || instead of && or vice versa.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.BrokenNullCheckRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/BrokenNullCheckRule.java)
+
+**Example(s):**
+
+``` java
+public String bar(String string) {
+ // should be &&
+ if (string!=null || !string.equals(""))
+ return string;
+ // should be ||
+ if (string==null && string.equals(""))
+ return string;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CallSuperFirst
+
+**Since:** PMD 4.2.5
+
+**Priority:** Medium (3)
+
+Super should be called at the start of the method
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[MethodDeclarator[
+ @Image='onCreate' or
+ @Image='onConfigurationChanged' or
+ @Image='onPostCreate' or
+ @Image='onPostResume' or
+ @Image='onRestart' or
+ @Image='onRestoreInstanceState' or
+ @Image='onResume' or
+ @Image='onStart'
+ ]]
+ /Block[not(
+ (BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier='true']]/PrimarySuffix[@Image= ancestor::MethodDeclaration/MethodDeclarator/@Image]))]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+ pmd-java:typeIs('android.app.Activity') or
+ pmd-java:typeIs('android.app.Application') or
+ pmd-java:typeIs('android.app.Service')
+]]]
+```
+
+**Example(s):**
+
+``` java
+public class DummyActivity extends Activity {
+ public void onCreate(Bundle bundle) {
+ // missing call to super.onCreate(bundle)
+ foo();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CallSuperLast
+
+**Since:** PMD 4.2.5
+
+**Priority:** Medium (3)
+
+Super should be called at the end of the method
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[MethodDeclarator[
+ @Image='finish' or
+ @Image='onDestroy' or
+ @Image='onPause' or
+ @Image='onSaveInstanceState' or
+ @Image='onStop' or
+ @Image='onTerminate'
+ ]]
+ /Block/BlockStatement[last()]
+ [not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier='true']]/PrimarySuffix[@Image= ancestor::MethodDeclaration/MethodDeclarator/@Image])]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+ pmd-java:typeIs('android.app.Activity') or
+ pmd-java:typeIs('android.app.Application') or
+ pmd-java:typeIs('android.app.Service')
+]]]
+```
+
+**Example(s):**
+
+``` java
+public class DummyActivity extends Activity {
+ public void onPause() {
+ foo();
+ // missing call to super.onPause()
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CheckSkipResult
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+The skip() method may skip a smaller number of bytes than requested. Check the returned value to find out if it was the case or not.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.CheckSkipResultRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CheckSkipResultRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+
+ private FileInputStream _s = new FileInputStream("file");
+
+ public void skip(int n) throws IOException {
+ _s.skip(n); // You are not sure that exactly n bytes are skipped
+ }
+
+ public void skipExactly(int n) throws IOException {
+ while (n != 0) {
+ long skipped = _s.skip(n);
+ if (skipped == 0)
+ throw new EOFException();
+ n -= skipped;
+ }
+ }
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ClassCastExceptionWithToArray
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+When deriving an array of a specific class from your Collection, one should provide an array of
+the same class as the parameter of the toArray() method. Doing otherwise you will will result
+in a ClassCastException.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image !=
+"Object"]]/PrimaryExpression
+[
+ PrimaryPrefix/Name[ends-with(@Image, '.toArray')]
+ and
+ PrimarySuffix/Arguments[count(*) = 0]
+and
+count(PrimarySuffix) = 1
+]
+```
+
+**Example(s):**
+
+``` java
+Collection c = new ArrayList();
+Integer obj = new Integer(1);
+c.add(obj);
+
+ // this would trigger the rule (and throw a ClassCastException if executed)
+Integer[] a = (Integer [])c.toArray();
+
+ // this is fine and will not trigger the rule
+Integer[] b = (Integer [])c.toArray(new Integer[c.size()]);
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CloneMethodMustBePublic
+
+**Since:** PMD 5.4.0
+
+**Priority:** Medium (3)
+
+The java Manual says "By convention, classes that implement this interface should override
+Object.clone (which is protected) with a public method."
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[@Public='false']
+ [MethodDeclarator/@Image = 'clone']
+ [MethodDeclarator/FormalParameters/@ParameterCount = 0]
+```
+
+**Example(s):**
+
+``` java
+public class Foo implements Cloneable {
+ @Override
+ protected Object clone() throws CloneNotSupportedException { // Violation, must be public
+ }
+}
+
+public class Foo implements Cloneable {
+ @Override
+ protected Foo clone() { // Violation, must be public
+ }
+}
+
+public class Foo implements Cloneable {
+ @Override
+ public Object clone() // Ok
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CloneMethodMustImplementCloneable
+
+**Since:** PMD 1.9
+
+**Priority:** Medium (3)
+
+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.
+
+The rule can also detect, if the class implements or extends a Cloneable class.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.CloneMethodMustImplementCloneableRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloneMethodMustImplementCloneableRule.java)
+
+**Example(s):**
+
+``` java
+public class MyClass {
+ public Object clone() throws CloneNotSupportedException {
+ return foo;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CloneMethodReturnTypeMustMatchClassName
+
+**Since:** PMD 5.4.0
+
+**Priority:** Medium (3)
+
+**Minimum Language Version:** Java 1.5
+
+If a class implements cloneable the return type of the method clone() must be the class name. That way, the caller
+of the clone method doesn't need to cast the returned clone to the correct type.
+
+Note: This is only possible with Java 1.5 or higher.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration
+[
+MethodDeclarator/@Image = 'clone'
+and MethodDeclarator/FormalParameters/@ParameterCount = 0
+and not (ResultType//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration[1]/@Image)
+]
+```
+
+**Example(s):**
+
+``` java
+public class Foo implements Cloneable {
+ @Override
+ protected Object clone() { // Violation, Object must be Foo
+ }
+}
+
+public class Foo implements Cloneable {
+ @Override
+ public Foo clone() { //Ok
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CloneThrowsCloneNotSupportedException
+
+**Since:** PMD 1.9
+
+**Priority:** Medium (3)
+
+The method clone() should throw a CloneNotSupportedException.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration
+[
+MethodDeclarator/@Image = 'clone'
+and count(MethodDeclarator/FormalParameters/*) = 0
+and count(NameList/Name[contains
+(@Image,'CloneNotSupportedException')]) = 0
+]
+[
+../../../../ClassOrInterfaceDeclaration[@Final = 'false']
+]
+```
+
+**Example(s):**
+
+``` java
+public class MyClass implements Cloneable{
+ public Object clone() { // will cause an error
+ MyClass clone = (MyClass)super.clone();
+ return clone;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CloseResource
+
+**Since:** PMD 1.2.2
+
+**Priority:** Medium (3)
+
+Ensure that resources (like Connection, Statement, and ResultSet objects) are always closed after use.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java)
+
+**Example(s):**
+
+``` java
+public class Bar {
+ public void foo() {
+ Connection c = pool.getConnection();
+ try {
+ // do stuff
+ } catch (SQLException ex) {
+ // handle exception
+ } finally {
+ // oops, should close the connection using 'close'!
+ // c.close();
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|closeAsDefaultTarget|true|Consider 'close' as a target by default|no|
+|types|java.sql.Connection , java.sql.Statement , java.sql.ResultSet|Affected types|yes. Delimiter is ','.|
+|closeTargets||Methods which may close this resource|yes. Delimiter is ','.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CompareObjectsWithEquals
+
+**Since:** PMD 3.2
+
+**Priority:** Medium (3)
+
+Use equals() to compare object references; avoid comparing them with ==.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.CompareObjectsWithEqualsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CompareObjectsWithEqualsRule.java)
+
+**Example(s):**
+
+``` java
+class Foo {
+ boolean bar(String a, String b) {
+ return a == b;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ConstructorCallsOverridableMethod
+
+**Since:** PMD 1.04
+
+**Priority:** High (1)
+
+Calling overridable methods during construction poses a risk of invoking methods on an incompletely
+constructed object and can be difficult to debug.
+It may leave the sub-class unable to construct its superclass or forced to replicate the construction
+process completely within itself, losing the ability to call super(). If the default constructor
+contains a call to an overridable method, the subclass may be completely uninstantiable. Note that
+this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls a
+private method bar() that calls a public method buz(), this denotes a problem.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.ConstructorCallsOverridableMethodRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ConstructorCallsOverridableMethodRule.java)
+
+**Example(s):**
+
+``` java
+public class SeniorClass {
+ public SeniorClass(){
+ toString(); //may throw NullPointerException if overridden
+ }
+ public String toString(){
+ return "IAmSeniorClass";
+ }
+}
+public class JuniorClass extends SeniorClass {
+ private String name;
+ public JuniorClass(){
+ super(); //Automatic call leads to NullPointerException
+ name = "JuniorClass";
+ }
+ public String toString(){
+ return name.toUpperCase();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DataflowAnomalyAnalysis
+
+**Since:** PMD 3.9
+
+**Priority:** Low (5)
+
+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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.DataflowAnomalyAnalysisRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DataflowAnomalyAnalysisRule.java)
+
+**Example(s):**
+
+``` java
+public void foo() {
+ int buz = 5;
+ buz = 6; // redefinition of buz -> dd-anomaly
+ foo(buz);
+ buz = 2;
+} // buz is undefined when leaving scope -> du-anomaly
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|maxViolations|100|Maximum number of anomalies per class|no|
+|maxPaths|1000|Maximum number of checked paths per method. A lower value will increase the performance of the rule but may decrease anomalies found.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DoNotCallGarbageCollectionExplicitly
+
+**Since:** PMD 4.2
+
+**Priority:** Medium High (2)
+
+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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Name[
+(starts-with(@Image, 'System.') and
+(starts-with(@Image, 'System.gc') or
+starts-with(@Image, 'System.runFinalization'))) or
+(
+starts-with(@Image,'Runtime.getRuntime') and
+../../PrimarySuffix[ends-with(@Image,'gc')]
+)
+]
+```
+
+**Example(s):**
+
+``` java
+public class GCCall {
+ public GCCall() {
+ // Explicit gc call !
+ System.gc();
+ }
+
+ public void doSomething() {
+ // Explicit gc call !
+ Runtime.getRuntime().gc();
+ }
+
+ public explicitGCcall() {
+ // Explicit gc call !
+ System.gc();
+ }
+
+ public void doSomething() {
+ // Explicit gc call !
+ Runtime.getRuntime().gc();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DoNotCallSystemExit
+
+**Since:** PMD 4.1
+
+**Priority:** Medium (3)
+
+Web applications should not call System.exit(), since only the web container or the
+application server should stop the JVM. This rule also checks for the equivalent call Runtime.getRuntime().exit().
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Name[
+ starts-with(@Image,'System.exit')
+ or
+ (starts-with(@Image,'Runtime.getRuntime') and ../../PrimarySuffix[ends-with(@Image,'exit')])
+]
+```
+
+**Example(s):**
+
+``` java
+public void bar() {
+ System.exit(0); // never call this when running in an application server!
+}
+public void foo() {
+ Runtime.getRuntime().exit(0); // never stop the JVM manually, the container will do this.
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DoNotExtendJavaLangThrowable
+
+**Since:** PMD 6.0.0
+
+**Priority:** Medium (3)
+
+Extend Exception or RuntimeException instead of Throwable.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType
+ [@Image="Throwable" or @Image="java.lang.Throwable"]
+```
+
+**Example(s):**
+
+``` java
+public class Foo extends Throwable { }
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DoNotHardCodeSDCard
+
+**Since:** PMD 4.2.6
+
+**Priority:** Medium (3)
+
+Use Environment.getExternalStorageDirectory() instead of "/sdcard"
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Literal[starts-with(@Image,'"/sdcard')]
+```
+
+**Example(s):**
+
+``` java
+public class MyActivity extends Activity {
+ protected void foo() {
+ String storageLocation = "/sdcard/mypackage"; // hard-coded, poor approach
+
+ storageLocation = Environment.getExternalStorageDirectory() + "/mypackage"; // preferred approach
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DoNotThrowExceptionInFinally
+
+**Since:** PMD 4.2
+
+**Priority:** Medium Low (4)
+
+Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions
+or code defects.
+Note: This is a PMD implementation of the Lint4j rule "A throw in a finally block"
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//FinallyStatement[descendant::ThrowStatement]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar() {
+ try {
+ // Here do some stuff
+ } catch( Exception e) {
+ // Handling the issue
+ } finally {
+ // is this really a good idea ?
+ throw new Exception();
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DontImportSun
+
+**Since:** PMD 1.5
+
+**Priority:** Medium Low (4)
+
+Avoid importing anything from the 'sun.*' packages. These packages are not portable and are likely to change.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.DontImportSunRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DontImportSunRule.java)
+
+**Example(s):**
+
+``` java
+import sun.misc.foo;
+public class Foo {}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DontUseFloatTypeForLoopIndices
+
+**Since:** PMD 4.3
+
+**Priority:** Medium (3)
+
+Don't use floating point for loop indices. If you must use floating point, use double
+unless you're certain that float provides enough precision and you have a compelling
+performance need (space or time).
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ForStatement/ForInit/LocalVariableDeclaration
+/Type/PrimitiveType[@Image="float"]
+```
+
+**Example(s):**
+
+``` java
+public class Count {
+ public static void main(String[] args) {
+ final int START = 2000000000;
+ int count = 0;
+ for (float f = START; f < START + 50; f++)
+ count++;
+ //Prints 0 because (float) START == (float) (START + 50).
+ System.out.println(count);
+ //The termination test misbehaves due to floating point granularity.
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyCatchBlock
+
+**Since:** PMD 0.1
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CatchStatement
+ [count(Block/BlockStatement) = 0 and ($allowCommentedBlocks != 'true' or Block/@containsComment = 'false')]
+ [FormalParameter/Type/ReferenceType
+ /ClassOrInterfaceType[@Image != 'InterruptedException' and @Image != 'CloneNotSupportedException']
+ ]
+ [FormalParameter/VariableDeclaratorId[not(matches(@Image, $allowExceptionNameRegex))]]
+```
+
+**Example(s):**
+
+``` java
+public void doSomething() {
+ try {
+ FileInputStream fis = new FileInputStream("/tmp/bugger");
+ } catch (IOException ioe) {
+ // not good
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|allowCommentedBlocks|false|Empty blocks containing comments will be skipped|no|
+|allowExceptionNameRegex|^(ignored\|expected)$|Empty blocks catching exceptions with names matching this regular expression will be skipped|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyFinalizer
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+Empty finalize methods serve no purpose and should be removed. Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[MethodDeclarator[@Image='finalize'][not(FormalParameters/*)]]
+ /Block[count(*)=0]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ protected void finalize() {}
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyFinallyBlock
+
+**Since:** PMD 0.4
+
+**Priority:** Medium (3)
+
+Empty finally blocks serve no purpose and should be removed.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//FinallyStatement[count(Block/BlockStatement) = 0]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar() {
+ try {
+ int x=2;
+ } finally {
+ // empty!
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyIfStmt
+
+**Since:** PMD 0.1
+
+**Priority:** Medium (3)
+
+Empty If Statement finds instances where a condition is checked but nothing is done about it.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfStatement/Statement
+ [EmptyStatement or Block[count(*) = 0]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void bar(int x) {
+ if (x == 0) {
+ // empty!
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyInitializer
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Empty initializers serve no purpose and should be removed.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Initializer/Block[count(*)=0]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+
+ static {} // Why ?
+
+ {} // Again, why ?
+
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyStatementBlock
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Empty block statements serve no purpose and should be removed.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//BlockStatement/Statement/Block[count(*) = 0]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+
+ private int _bar;
+
+ public void setBar(int bar) {
+ { _bar = bar; } // Why not?
+ {} // But remove this.
+ }
+
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyStatementNotInLoop
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for'
+or 'while' loop is probably a bug. It could also be a double semicolon, which has no purpose
+and should be removed.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//EmptyStatement
+ [not(
+ ../../../ForStatement
+ or ../../../WhileStatement
+ or ../../../BlockStatement/ClassOrInterfaceDeclaration
+ or ../../../../../../ForStatement/Statement[1]
+ /Block[1]/BlockStatement[1]/Statement/EmptyStatement
+ or ../../../../../../WhileStatement/Statement[1]
+ /Block[1]/BlockStatement[1]/Statement/EmptyStatement)
+ ]
+```
+
+**Example(s):**
+
+``` java
+public void doit() {
+ // this is probably not what you meant to do
+ ;
+ // the extra semicolon here this is not necessary
+ System.out.println("look at the extra semicolon");;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptySwitchStatements
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+Empty switch statements serve no purpose and should be removed.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//SwitchStatement[count(*) = 1]
+```
+
+**Example(s):**
+
+``` java
+public void bar() {
+ int x = 2;
+ switch (x) {
+ // once there was code here
+ // but it's been commented out or something
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptySynchronizedBlock
+
+**Since:** PMD 1.3
+
+**Priority:** Medium (3)
+
+Empty synchronized blocks serve no purpose and should be removed.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//SynchronizedStatement/Block[1][count(*) = 0]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar() {
+ synchronized (this) {
+ // empty!
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyTryBlock
+
+**Since:** PMD 0.4
+
+**Priority:** Medium (3)
+
+Avoid empty try blocks - what's the point?
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//TryStatement[not(ResourceSpecification)]/Block[1][count(*) = 0]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar() {
+ try {
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyWhileStmt
+
+**Since:** PMD 0.2
+
+**Priority:** Medium (3)
+
+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 is
+a while loop that does a lot in the exit expression, rewrite it to make it clearer.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//WhileStatement/Statement[./Block[count(*) = 0] or ./EmptyStatement]
+```
+
+**Example(s):**
+
+``` java
+void bar(int a, int b) {
+ while (a == b) {
+ // empty!
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EqualsNull
+
+**Since:** PMD 1.9
+
+**Priority:** High (1)
+
+Tests for null should not use the equals() method. The '==' operator should be used instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression
+ [
+ PrimaryPrefix[Name[ends-with(@Image, 'equals')]]
+ [following-sibling::node()/Arguments/ArgumentList[count(Expression)=1]
+ /Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+
+ or
+
+ PrimarySuffix[ends-with(@Image, 'equals')]
+ [following-sibling::node()/Arguments/ArgumentList[count(Expression)=1]
+ /Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+
+ ]
+```
+
+**Example(s):**
+
+``` java
+String x = "foo";
+
+if (x.equals(null)) { // bad form
+ doSomething();
+}
+
+if (x == null) { // preferred
+ doSomething();
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## FinalizeDoesNotCallSuperFinalize
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+If the finalize() is implemented, its last action should be to call super.finalize. Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[MethodDeclarator[@Image='finalize'][not(FormalParameters/*)]]
+ /Block
+ /BlockStatement[last()]
+ [not(Statement/StatementExpression/PrimaryExpression
+ [./PrimaryPrefix[@SuperModifier='true']]
+ [./PrimarySuffix[@Image='finalize']]
+ )
+ ]
+ [not(Statement/TryStatement/FinallyStatement
+ /Block/BlockStatement/Statement/StatementExpression/PrimaryExpression
+ [./PrimaryPrefix[@SuperModifier='true']]
+ [./PrimarySuffix[@Image='finalize']]
+ )
+ ]
+```
+
+**Example(s):**
+
+``` java
+protected void finalize() {
+ something();
+ // neglected to call super.finalize()
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## FinalizeOnlyCallsSuperFinalize
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+If the finalize() is implemented, it should do something besides just calling super.finalize(). Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[MethodDeclarator[@Image="finalize"][not(FormalParameters/*)]]
+ /Block[count(BlockStatement)=1]
+ /BlockStatement[
+ Statement/StatementExpression/PrimaryExpression
+ [./PrimaryPrefix[@SuperModifier='true']]
+ [./PrimarySuffix[@Image='finalize']]
+ ]
+```
+
+**Example(s):**
+
+``` java
+protected void finalize() {
+ super.finalize();
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## FinalizeOverloaded
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+Methods named finalize() should not have parameters. It is confusing and most likely an attempt to
+overload Object.finalize(). It will not be called by the VM.
+
+Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration
+ /MethodDeclarator[@Image='finalize'][FormalParameters[count(*)>0]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ // this is confusing and probably a bug
+ protected void finalize(int a) {
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## FinalizeShouldBeProtected
+
+**Since:** PMD 1.1
+
+**Priority:** Medium (3)
+
+When overriding the finalize(), the new method should be set as protected. If made public,
+other classes may invoke it at inappropriate times.
+
+Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[@Protected="false"]
+ /MethodDeclarator[@Image="finalize"]
+ [not(FormalParameters/*)]
+```
+
+**Example(s):**
+
+``` java
+public void finalize() {
+ // do something
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## IdempotentOperations
+
+**Since:** PMD 2.0
+
+**Priority:** Medium (3)
+
+Avoid idempotent operations - they have no effect.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.IdempotentOperationsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/IdempotentOperationsRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void bar() {
+ int x = 2;
+ x = x;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ImportFromSamePackage
+
+**Since:** PMD 1.02
+
+**Priority:** Medium (3)
+
+There is no need to import a type that lives in the same package.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.ImportFromSamePackageRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ImportFromSamePackageRule.java)
+
+**Example(s):**
+
+``` java
+package foo;
+
+import foo.Buz; // no need for this
+import foo.*; // or this
+
+public class Bar{}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## InstantiationToGetClass
+
+**Since:** PMD 2.0
+
+**Priority:** Medium Low (4)
+
+Avoid instantiating an object just to call getClass() on it; use the .class public member instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimarySuffix
+ [@Image='getClass']
+ [parent::PrimaryExpression
+ [PrimaryPrefix/AllocationExpression]
+ [count(PrimarySuffix) = 2]
+ ]
+```
+
+**Example(s):**
+
+``` java
+// replace this
+Class c = new String().getClass();
+
+// with this:
+Class c = String.class;
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## InvalidSlf4jMessageFormat
+
+**Since:** PMD 5.5.0
+
+**Priority:** Low (5)
+
+Check for messages in slf4j loggers with non matching number of arguments and placeholders.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.InvalidSlf4jMessageFormatRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/InvalidSlf4jMessageFormatRule.java)
+
+**Example(s):**
+
+``` java
+LOGGER.error("forget the arg {}");
+LOGGER.error("too many args {}", "arg1", "arg2");
+LOGGER.error("param {}", "arg1", new IllegalStateException("arg")); //The exception is shown separately, so is correct.
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JumbledIncrementer
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ForStatement
+ [
+ ForUpdate/StatementExpressionList/StatementExpression/PostfixExpression/PrimaryExpression/PrimaryPrefix/Name/@Image
+ =
+ ancestor::ForStatement/ForInit//VariableDeclaratorId/@Image
+ ]
+```
+
+**Example(s):**
+
+``` java
+public class JumbledIncrementerRule1 {
+ public void foo() {
+ for (int i = 0; i < 10; i++) { // only references 'i'
+ for (int k = 0; k < 20; i++) { // references both 'i' and 'k'
+ System.out.println("Hello");
+ }
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnitSpelling
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+Some JUnit framework methods are easy to misspell.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclarator[(not(@Image = 'setUp')
+ and translate(@Image, 'SETuP', 'setUp') = 'setUp')
+ or (not(@Image = 'tearDown')
+ and translate(@Image, 'TEARdOWN', 'tearDown') = 'tearDown')]
+ [FormalParameters[count(*) = 0]]
+[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]
+ or //MarkerAnnotation/Name[
+ pmd-java:typeIs('org.junit.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+ or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+ ]
+]]
+```
+
+**Example(s):**
+
+``` java
+import junit.framework.*;
+
+public class Foo extends TestCase {
+ public void setup() {} // oops, should be setUp
+ public void TearDown() {} // oops, should be tearDown
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## JUnitStaticSuite
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+The suite() method in a JUnit test needs to be both public and static.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[not(@Static='true') or not(@Public='true')]
+[MethodDeclarator/@Image='suite']
+[MethodDeclarator/FormalParameters/@ParameterCount=0]
+[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]
+ or //MarkerAnnotation/Name[
+ pmd-java:typeIs('org.junit.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+ or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+ ]
+]]
+```
+
+**Example(s):**
+
+``` java
+import junit.framework.*;
+
+public class Foo extends TestCase {
+ public void suite() {} // oops, should be static
+ private static void suite() {} // oops, should be public
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## LoggerIsNotStaticFinal
+
+**Since:** PMD 2.0
+
+**Priority:** Medium High (2)
+
+In most cases, the Logger reference can be declared as static and final.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//VariableDeclarator
+ [parent::FieldDeclaration]
+ [../Type/ReferenceType
+ /ClassOrInterfaceType[@Image='Logger']
+ and
+ (..[@Final='false'] or ..[@Static = 'false'] ) ]
+```
+
+**Example(s):**
+
+``` java
+public class Foo{
+ Logger log = Logger.getLogger(Foo.class.getName()); // not recommended
+
+ static final Logger log = Logger.getLogger(Foo.class.getName()); // preferred approach
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MethodWithSameNameAsEnclosingClass
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+Non-constructor methods should not have the same name as the enclosing class.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.MethodWithSameNameAsEnclosingClassRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/MethodWithSameNameAsEnclosingClassRule.java)
+
+**Example(s):**
+
+``` java
+public class MyClass {
+
+ public MyClass() {} // this is OK because it is a constructor
+
+ public void MyClass() {} // this is bad because it is a method
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MisplacedNullCheck
+
+**Since:** PMD 3.5
+
+**Priority:** Medium (3)
+
+The null check here is misplaced. If the variable is null a NullPointerException will be thrown.
+Either the check is useless (the variable will never be "null") or it is incorrect.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Expression
+ /*[self::ConditionalOrExpression or self::ConditionalAndExpression]
+ /descendant::PrimaryExpression/PrimaryPrefix
+ /Name[starts-with(@Image,
+ concat(ancestor::PrimaryExpression/following-sibling::EqualityExpression
+ [./PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+ /PrimaryExpression/PrimaryPrefix
+ /Name[count(../../PrimarySuffix)=0]/@Image,".")
+ )
+ ]
+ [count(ancestor::ConditionalAndExpression/EqualityExpression
+ [@Image='!=']
+ [./PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+ [starts-with(following-sibling::*/PrimaryExpression/PrimaryPrefix/Name/@Image,
+ concat(./PrimaryExpression/PrimaryPrefix/Name/@Image, '.'))]
+ ) = 0
+ ]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void bar() {
+ if (a.equals(baz) && a != null) {}
+ }
+}
+```
+
+``` java
+public class Foo {
+ void bar() {
+ if (a.equals(baz) || a == null) {}
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MissingBreakInSwitch
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+Switch statements without break or return statements for each case option
+may indicate problematic behaviour. Empty cases are ignored as these indicate an intentional fall-through.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//SwitchStatement
+[(count(.//BreakStatement)
+ + count(BlockStatement//Statement/ReturnStatement)
+ + count(BlockStatement//Statement/ContinueStatement)
+ + count(BlockStatement//Statement/ThrowStatement)
+ + count(BlockStatement//Statement/IfStatement[@Else='true' and Statement[2][ReturnStatement|ContinueStatement|ThrowStatement]]/Statement[1][ReturnStatement|ContinueStatement|ThrowStatement])
+ + count(SwitchLabel[name(following-sibling::node()) = 'SwitchLabel'])
+ + count(SwitchLabel[count(following-sibling::node()) = 0])
+ < count (SwitchLabel))]
+```
+
+**Example(s):**
+
+``` java
+public void bar(int status) {
+ switch(status) {
+ case CANCELLED:
+ doCancelled();
+ // break; hm, should this be commented out?
+ case NEW:
+ doNew();
+ // is this really a fall-through?
+ case REMOVED:
+ doRemoved();
+ // what happens if you add another case after this one?
+ case OTHER: // empty case - this is interpreted as an intentional fall-through
+ case ERROR:
+ doErrorHandling();
+ break;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MissingSerialVersionUID
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+Serializable classes should provide a serialVersionUID field.
+The serialVersionUID field is also needed for abstract base classes. Each individual class in the inheritance
+chain needs an own serialVersionUID field. See also [Should an abstract class have a serialVersionUID](https://stackoverflow.com/questions/893259/should-an-abstract-class-have-a-serialversionuid).
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration
+ [@Interface = 'false']
+ [count(ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
+ /FieldDeclaration/VariableDeclarator/VariableDeclaratorId[@Image='serialVersionUID']) = 0]
+ [(ImplementsList | ExtendsList)/ClassOrInterfaceType[pmd-java:typeIs('java.io.Serializable')]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo implements java.io.Serializable {
+ String name;
+ // Define serialization id to avoid serialization related bugs
+ // i.e., public static final long serialVersionUID = 4328743;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MissingStaticMethodInNonInstantiatableClass
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+A class that has private constructors and does not have any static methods or fields cannot be used.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[@Nested='false']
+[
+ (
+ ./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration
+ and
+ count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration) = count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Private='true'])
+ )
+ and
+ not(.//MethodDeclaration[@Static='true'])
+ and
+ not(.//FieldDeclaration[@Private='false'][@Static='true'])
+ and
+ not(.//ClassOrInterfaceDeclaration[@Nested='true']
+ [@Public='true']
+ [@Static='true']
+ [not(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration) or ./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Public='true']]
+ [./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/MethodDeclaration
+ [@Public='true']
+ [./ResultType/Type/ReferenceType/ClassOrInterfaceType
+ [@Image = //ClassOrInterfaceDeclaration[@Nested='false']/@Image]
+ ]
+ ]
+ )
+]
+```
+
+**Example(s):**
+
+``` java
+// This class is unusable, since it cannot be
+// instantiated (private constructor),
+// and no static method can be called.
+
+public class Foo {
+ private Foo() {}
+ void foo() {}
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MoreThanOneLogger
+
+**Since:** PMD 2.0
+
+**Priority:** Medium High (2)
+
+Normally only one logger is used in each class.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.MoreThanOneLoggerRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/MoreThanOneLoggerRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ Logger log = Logger.getLogger(Foo.class.getName());
+ // It is very rare to see two loggers on a class, normally
+ // log information is multiplexed by levels
+ Logger log2= Logger.getLogger(Foo.class.getName());
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NonCaseLabelInSwitchStatement
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//SwitchStatement//BlockStatement/Statement/LabeledStatement
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void bar(int a) {
+ switch (a) {
+ case 1:
+ // do something
+ break;
+ mylabel: // this is legal, but confusing!
+ break;
+ default:
+ break;
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NonStaticInitializer
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+A non-static 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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Initializer[@Static='false']
+```
+
+**Example(s):**
+
+``` java
+public class MyClass {
+ // this block gets run before any call to a constructor
+ {
+ System.out.println("I am about to construct myself");
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NullAssignment
+
+**Since:** PMD 1.02
+
+**Priority:** Medium (3)
+
+Assigning a "null" to a variable (outside of its declaration) is usually bad form. Sometimes, this type
+of assignment is an indication that the programmer doesn't completely understand what is going on in the code.
+
+NOTE: This sort of assignment may used in some cases to dereference objects and encourage garbage collection.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.NullAssignmentRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NullAssignmentRule.java)
+
+**Example(s):**
+
+``` java
+public void bar() {
+ Object x = null; // this is OK
+ x = new Object();
+ // big, complex piece of code here
+ x = null; // this is not required
+ // big, complex piece of code here
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## OverrideBothEqualsAndHashcode
+
+**Since:** PMD 0.4
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.OverrideBothEqualsAndHashcodeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java)
+
+**Example(s):**
+
+``` java
+public class Bar { // poor, missing a hashcode() method
+ public boolean equals(Object o) {
+ // do some comparison
+ }
+}
+
+public class Baz { // poor, missing an equals() method
+ public int hashCode() {
+ // return some hash value
+ }
+}
+
+public class Foo { // perfect, both methods provided
+ public boolean equals(Object other) {
+ // do some comparison
+ }
+ public int hashCode() {
+ // return some hash value
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ProperCloneImplementation
+
+**Since:** PMD 1.4
+
+**Priority:** Medium High (2)
+
+Object clone() should be implemented with super.clone().
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclarator
+[@Image = 'clone']
+[count(FormalParameters/*) = 0]
+[count(../Block//*[
+ (self::AllocationExpression) and
+ (./ClassOrInterfaceType/@Image = ancestor::
+ClassOrInterfaceDeclaration[1]/@Image)
+ ])> 0
+]
+```
+
+**Example(s):**
+
+``` java
+class Foo{
+ public Object clone(){
+ return new Foo(); // This is bad
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ProperLogger
+
+**Since:** PMD 3.3
+
+**Priority:** Medium (3)
+
+A logger should normally be defined private static final and be associated with the correct class.
+Private final Log log; is also allowed for rare cases where loggers need to be passed around,
+with the restriction that the logger needs to be passed into the constructor.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceBodyDeclaration[FieldDeclaration//ClassOrInterfaceType[@Image='Log']
+ and
+ not(FieldDeclaration[@Final='true'][@Static='true'][@Private='true'][.//VariableDeclaratorId[@Image=$staticLoggerName]]
+ and
+ //ArgumentList//ClassOrInterfaceType[@Image = ancestor::ClassOrInterfaceDeclaration/@Image or @Image = ancestor::EnumDeclaration/@Image])
+ and
+ not(FieldDeclaration[@Final='true'][@Private='true'][.//VariableDeclaratorId[@Image='log']]
+ [count(.//VariableInitializer)=0]
+ [ancestor::ClassOrInterfaceBody//StatementExpression[.//PrimaryExpression/descendant::*[@Image='log']][count(.//AllocationExpression)=0]]
+ )]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+
+ private static final Log LOG = LogFactory.getLog(Foo.class); // proper way
+
+ protected Log LOG = LogFactory.getLog(Testclass.class); // wrong approach
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|staticLoggerName|LOG|Name of the static Logger variable|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ReturnEmptyArrayRatherThanNull
+
+**Since:** PMD 4.2
+
+**Priority:** High (1)
+
+For any method that returns an array, it is a better to return an empty array rather than a
+null reference. This removes the need for null checking all results and avoids inadvertent
+NullPointerExceptions.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration
+[
+(./ResultType/Type[@Array='true'])
+and
+(./Block/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral)
+]
+```
+
+**Example(s):**
+
+``` java
+public class Example {
+ // Not a good idea...
+ public int[] badBehavior() {
+ // ...
+ return null;
+ }
+
+ // Good behavior
+ public String[] bonnePratique() {
+ //...
+ return new String[0];
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ReturnFromFinallyBlock
+
+**Since:** PMD 1.05
+
+**Priority:** Medium (3)
+
+Avoid returning from a finally block, this can discard exceptions.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//FinallyStatement//ReturnStatement
+```
+
+**Example(s):**
+
+``` java
+public class Bar {
+ public String foo() {
+ try {
+ throw new Exception( "My Exception" );
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ return "A. O. K."; // return not recommended here
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SimpleDateFormatNeedsLocale
+
+**Since:** PMD 2.0
+
+**Priority:** Medium (3)
+
+Be sure to specify a Locale when creating SimpleDateFormat instances to ensure that locale-appropriate
+formatting is used.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AllocationExpression
+ [ClassOrInterfaceType[@Image='SimpleDateFormat']]
+ [Arguments[@ArgumentCount=1]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ // Should specify Locale.US (or whatever)
+ private SimpleDateFormat sdf = new SimpleDateFormat("pattern");
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SingleMethodSingleton
+
+**Since:** PMD 5.4
+
+**Priority:** Medium High (2)
+
+Some classes contain overloaded getInstance. The problem with overloaded getInstance methods
+is that the instance created using the overloaded method is not cached and so,
+for each call and new objects will be created for every invocation.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.SingleMethodSingletonRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingleMethodSingletonRule.java)
+
+**Example(s):**
+
+``` java
+public class Singleton {
+
+ private static Singleton singleton = new Singleton( );
+
+ private Singleton(){ }
+
+ public static Singleton getInstance( ) {
+ return singleton;
+ }
+
+ public static Singleton getInstance(Object obj){
+ Singleton singleton = (Singleton) obj;
+ return singleton; //violation
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SingletonClassReturningNewInstance
+
+**Since:** PMD 5.4
+
+**Priority:** Medium High (2)
+
+Some classes contain overloaded getInstance. The problem with overloaded getInstance methods
+is that the instance created using the overloaded method is not cached and so,
+for each call and new objects will be created for every invocation.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.SingletonClassReturningNewInstanceRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingletonClassReturningNewInstanceRule.java)
+
+**Example(s):**
+
+``` java
+class Singleton {
+ private static Singleton instance = null;
+ public static Singleton getInstance() {
+ synchronized(Singleton.class) {
+ return new Singleton();
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## StaticEJBFieldShouldBeFinal
+
+**Since:** PMD 4.1
+
+**Priority:** Medium (3)
+
+According to the J2EE specification, 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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceDeclaration[
+ (
+ (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'SessionBean')])
+ or
+ (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'EJBHome')])
+ or
+ (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalObject')])
+ or
+ (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalHome')])
+ or
+ (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBObject')])
+ )
+ and
+ (./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[
+ (./FieldDeclaration[@Static = 'true'])
+ and
+ (./FieldDeclaration[@Final = 'false'])
+ ])
+]
+```
+
+**Example(s):**
+
+``` java
+public class SomeEJB extends EJBObject implements EJBLocalHome {
+
+ private static int CountA; // poor, field can be edited
+
+ private static final int CountB; // preferred, read-only access
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## StringBufferInstantiationWithChar
+
+**Since:** PMD 3.9
+
+**Priority:** Medium Low (4)
+
+Individual character values provided as initialization arguments will be converted into integers.
+This can lead to internal buffer sizes that are larger than expected. Some examples:
+
+```
+new StringBuffer() // 16
+new StringBuffer(6) // 6
+new StringBuffer("hello world") // 11 + 16 = 27
+new StringBuffer('A') // chr(A) = 65
+new StringBuffer("A") // 1 + 16 = 17
+
+new StringBuilder() // 16
+new StringBuilder(6) // 6
+new StringBuilder("hello world") // 11 + 16 = 27
+new StringBuilder('C') // chr(C) = 67
+new StringBuilder("A") // 1 + 16 = 17
+```
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AllocationExpression/ClassOrInterfaceType
+[@Image='StringBuffer' or @Image='StringBuilder']
+/../Arguments/ArgumentList/Expression/PrimaryExpression
+/PrimaryPrefix/
+Literal
+ [starts-with(@Image, "'")]
+ [ends-with(@Image, "'")]
+```
+
+**Example(s):**
+
+``` java
+// misleading instantiation, these buffers
+// are actually sized to 99 characters long
+StringBuffer sb1 = new StringBuffer('c');
+StringBuilder sb2 = new StringBuilder('c');
+
+// in these forms, just single characters are allocated
+StringBuffer sb3 = new StringBuffer("c");
+StringBuilder sb4 = new StringBuilder("c");
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SuspiciousEqualsMethodName
+
+**Since:** PMD 2.0
+
+**Priority:** Medium High (2)
+
+The method name and parameter number are suspiciously close to equals(Object), which can denote an
+intention to override the equals(Object) method.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclarator[@Image = 'equals']
+[
+ (count(FormalParameters/*) = 1
+ and not (FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
+ [@Image = 'Object' or @Image = 'java.lang.Object'])
+ or not (../ResultType/Type/PrimitiveType[@Image = 'boolean'])
+ ) or (
+ count(FormalParameters/*) = 2
+ and ../ResultType/Type/PrimitiveType[@Image = 'boolean']
+ and FormalParameters//ClassOrInterfaceType[@Image = 'Object' or @Image = 'java.lang.Object']
+ and not(../../Annotation/MarkerAnnotation/Name[@Image='Override'])
+ )
+]
+| //MethodDeclarator[@Image = 'equal']
+[
+ count(FormalParameters/*) = 1
+ and FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
+ [@Image = 'Object' or @Image = 'java.lang.Object']
+]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public int equals(Object o) {
+ // oops, this probably was supposed to be boolean equals
+ }
+ public boolean equals(String s) {
+ // oops, this probably was supposed to be equals(Object)
+ }
+ public boolean equals(Object o1, Object o2) {
+ // oops, this probably was supposed to be equals(Object)
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SuspiciousHashcodeMethodName
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+The method name and return type are suspiciously close to hashCode(), which may denote an intention
+to override the hashCode() method.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.SuspiciousHashcodeMethodNameRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SuspiciousHashcodeMethodNameRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public int hashcode() { // oops, this probably was supposed to be 'hashCode'
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SuspiciousOctalEscape
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+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".
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.SuspiciousOctalEscapeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SuspiciousOctalEscapeRule.java)
+
+**Example(s):**
+
+``` java
+public void foo() {
+ // interpreted as octal 12, followed by character '8'
+ System.out.println("suspicious: \128");
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## TestClassWithoutTestCases
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+Test classes end with the suffix Test. Having a non-test class with that name is not a good practice,
+since most people will assume it is a test case. Test classes have test methods named testXXX.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.TestClassWithoutTestCasesRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/TestClassWithoutTestCasesRule.java)
+
+**Example(s):**
+
+``` java
+//Consider changing the name of the class if it is not a test
+//Consider adding test methods if it is a test
+public class CarTest {
+ public static void main(String[] args) {
+ // do something
+ }
+ // code
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnconditionalIfStatement
+
+**Since:** PMD 1.5
+
+**Priority:** Medium (3)
+
+Do not use "if" statements whose conditionals are always true or always false.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//IfStatement/Expression
+ [count(PrimaryExpression)=1]
+ /PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ public void close() {
+ if (true) { // fixed conditional, not recommended
+ // ...
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryBooleanAssertion
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+A JUnit test assertion with a boolean literal is unnecessary since it always will evaluate to the same thing.
+Consider using flow control (in case of assertTrue(false) or similar) or simply removing
+statements like assertTrue(true) and assertFalse(false). If you just want a test to halt after finding
+an error, use the fail() method and provide an indication message of why it did.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//StatementExpression
+[
+PrimaryExpression/PrimaryPrefix/Name[@Image='assertTrue' or @Image='assertFalse']
+and
+PrimaryExpression/PrimarySuffix/Arguments/ArgumentList/Expression
+[PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral
+or
+UnaryExpressionNotPlusMinus[@Image='!']
+/PrimaryExpression/PrimaryPrefix[Literal/BooleanLiteral or Name[count(../../*)=1]]]
+]
+[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]
+ or //MarkerAnnotation/Name[
+ pmd-java:typeIs('org.junit.Test')
+ or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+ or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+ or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+ ]
+]]
+```
+
+**Example(s):**
+
+``` java
+public class SimpleTest extends TestCase {
+ public void testX() {
+ assertTrue(true); // serves no real purpose
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryCaseChange
+
+**Since:** PMD 3.3
+
+**Priority:** Medium (3)
+
+Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals()
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.UnnecessaryCaseChangeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UnnecessaryCaseChangeRule.java)
+
+**Example(s):**
+
+``` java
+boolean answer1 = buz.toUpperCase().equals("baz"); // should be buz.equalsIgnoreCase("baz")
+
+boolean answer2 = buz.toUpperCase().equalsIgnoreCase("baz"); // another unnecessary toUpperCase()
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryConversionTemporary
+
+**Since:** PMD 0.1
+
+**Priority:** Medium (3)
+
+Avoid the use temporary objects when converting primitives to Strings. Use the static conversion methods
+on the wrapper classes instead.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.UnnecessaryConversionTemporaryRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UnnecessaryConversionTemporaryRule.java)
+
+**Example(s):**
+
+``` java
+public String convert(int x) {
+ String foo = new Integer(x).toString(); // this wastes an object
+
+ return Integer.toString(x); // preferred approach
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnusedNullCheckInEquals
+
+**Since:** PMD 3.5
+
+**Priority:** Medium (3)
+
+After checking an object reference for null, you should invoke equals() on that object rather than passing it to another object's equals() method.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+(//PrimaryPrefix[ends-with(Name/@Image, '.equals') and Name/@Image != 'Arrays.equals'] | //PrimarySuffix[@Image='equals' and not(../PrimaryPrefix/Literal)])
+ /following-sibling::PrimarySuffix/Arguments/ArgumentList/Expression
+ /PrimaryExpression[count(PrimarySuffix)=0]/PrimaryPrefix
+ /Name[@Image = ./../../../../../../../../../../Expression/ConditionalAndExpression
+ /EqualityExpression[@Image="!=" and count(./preceding-sibling::*)=0 and
+ ./PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+ /PrimaryExpression/PrimaryPrefix/Name/@Image]
+```
+
+**Example(s):**
+
+``` java
+public class Test {
+
+ public String method1() { return "ok";}
+ public String method2() { return null;}
+
+ public void method(String a) {
+ String b;
+ // I don't know it method1() can be "null"
+ // but I know "a" is not null..
+ // I'd better write a.equals(method1())
+
+ if (a!=null && method1().equals(a)) { // will trigger the rule
+ //whatever
+ }
+
+ if (method1().equals(a) && a != null) { // won't trigger the rule
+ //whatever
+ }
+
+ if (a!=null && method1().equals(b)) { // won't trigger the rule
+ //whatever
+ }
+
+ if (a!=null && "LITERAL".equals(a)) { // won't trigger the rule
+ //whatever
+ }
+
+ if (a!=null && !a.equals("go")) { // won't trigger the rule
+ a=method2();
+ if (method1().equals(a)) {
+ //whatever
+ }
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseCorrectExceptionLogging
+
+**Since:** PMD 3.2
+
+**Priority:** Medium (3)
+
+To make sure the full stacktrace is printed out, use the logging statement with two arguments: a String and a Throwable.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression
+/PrimaryExpression[PrimaryPrefix/Name[starts-with(@Image,
+concat(ancestor::ClassOrInterfaceDeclaration/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/FieldDeclaration
+[Type//ClassOrInterfaceType[@Image='Log']]
+/VariableDeclarator/VariableDeclaratorId/@Image, '.'))]]
+[PrimarySuffix/Arguments[@ArgumentCount='1']]
+[PrimarySuffix/Arguments//Name/@Image = ancestor::CatchStatement/FormalParameter/VariableDeclaratorId/@Image]
+```
+
+**Example(s):**
+
+``` java
+public class Main {
+ private static final Log _LOG = LogFactory.getLog( Main.class );
+ void bar() {
+ try {
+ } catch( Exception e ) {
+ _LOG.error( e ); //Wrong!
+ } catch( OtherException oe ) {
+ _LOG.error( oe.getMessage(), oe ); //Correct
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseEqualsToCompareStrings
+
+**Since:** PMD 4.1
+
+**Priority:** Medium (3)
+
+Using '==' or '!=' to compare strings only works if intern version is used on both sides.
+Use the equals() method instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//EqualityExpression/PrimaryExpression
+[(PrimaryPrefix/Literal
+ [starts-with(@Image, '"')]
+ [ends-with(@Image, '"')]
+and count(PrimarySuffix) = 0)]
+```
+
+**Example(s):**
+
+``` java
+public boolean test(String s) {
+ if (s == "one") return true; // unreliable
+ if ("two".equals(s)) return true; // better
+ return false;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UselessOperationOnImmutable
+
+**Since:** PMD 3.5
+
+**Priority:** Medium (3)
+
+An operation on an Immutable object (String, BigDecimal or BigInteger) won't change the object itself
+since the result of the operation is a new object. Therefore, ignoring the operation result is an error.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.errorprone.UselessOperationOnImmutableRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UselessOperationOnImmutableRule.java)
+
+**Example(s):**
+
+``` java
+import java.math.*;
+
+class Test {
+ void method1() {
+ BigDecimal bd=new BigDecimal(10);
+ bd.add(new BigDecimal(5)); // this will trigger the rule
+ }
+ void method2() {
+ BigDecimal bd=new BigDecimal(10);
+ bd = bd.add(new BigDecimal(5)); // this won't trigger the rule
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseLocaleWithCaseConversions
+
+**Since:** PMD 2.0
+
+**Priority:** Medium (3)
+
+When doing String.toLowerCase()/toUpperCase() conversions, use Locales to avoids problems with languages that
+have unusual conventions, i.e. Turkish.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression
+[
+PrimaryPrefix
+[Name[ends-with(@Image, 'toLowerCase') or ends-with(@Image, 'toUpperCase')]]
+[following-sibling::PrimarySuffix[position() = 1]/Arguments[@ArgumentCount=0]]
+
+or
+
+PrimarySuffix
+[ends-with(@Image, 'toLowerCase') or ends-with(@Image, 'toUpperCase')]
+[following-sibling::PrimarySuffix[position() = 1]/Arguments[@ArgumentCount=0]]
+]
+[not(PrimaryPrefix/Name[ends-with(@Image, 'toHexString')])]
+```
+
+**Example(s):**
+
+``` java
+class Foo {
+ // BAD
+ if (x.toLowerCase().equals("list")) { }
+
+ /*
+ * This will not match "LIST" when in Turkish locale
+ * The above could be
+ * if (x.toLowerCase(Locale.US).equals("list")) { }
+ * or simply
+ * if (x.equalsIgnoreCase("list")) { }
+ */
+ // GOOD
+ String z = a.toLowerCase(Locale.EN);
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseProperClassLoader
+
+**Since:** PMD 3.7
+
+**Priority:** Medium (3)
+
+In J2EE, the getClassLoader() method might not work as expected. Use
+Thread.currentThread().getContextClassLoader() instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimarySuffix[@Image='getClassLoader']
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ ClassLoader cl = Bar.class.getClassLoader();
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/java/finalizers.md b/docs/pages/pmd/rules/java/finalizers.md
deleted file mode 100644
index 019fe9e0511..00000000000
--- a/docs/pages/pmd/rules/java/finalizers.md
+++ /dev/null
@@ -1,187 +0,0 @@
----
-title: Finalizer
-summary: These rules deal with different problems that can occur with finalizers.
-permalink: pmd_rules_java_finalizers.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/finalizers.xml
-keywords: Finalizer, EmptyFinalizer, FinalizeOnlyCallsSuperFinalize, FinalizeOverloaded, FinalizeDoesNotCallSuperFinalize, FinalizeShouldBeProtected, AvoidCallingFinalize
----
-## AvoidCallingFinalize
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
-that there are no more references to the object. It should not be invoked by application logic.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.finalizers.AvoidCallingFinalizeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/finalizers/AvoidCallingFinalizeRule.java)
-
-**Example(s):**
-
-``` java
-void foo() {
- Bar b = new Bar();
- b.finalize();
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyFinalizer
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-Empty finalize methods serve no purpose and should be removed.
-
-```
-//MethodDeclaration[MethodDeclarator[@Image='finalize'][not(FormalParameters/*)]]
- /Block[count(*)=0]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- protected void finalize() {}
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## FinalizeDoesNotCallSuperFinalize
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-If the finalize() is implemented, its last action should be to call super.finalize.
-
-```
-//MethodDeclaration[MethodDeclarator[@Image='finalize'][not(FormalParameters/*)]]
- /Block
- /BlockStatement[last()]
- [not(Statement/StatementExpression/PrimaryExpression
- [./PrimaryPrefix[@SuperModifier='true']]
- [./PrimarySuffix[@Image='finalize']]
- )
- ]
- [not(Statement/TryStatement/FinallyStatement
- /Block/BlockStatement/Statement/StatementExpression/PrimaryExpression
- [./PrimaryPrefix[@SuperModifier='true']]
- [./PrimarySuffix[@Image='finalize']]
- )
- ]
-```
-
-**Example(s):**
-
-``` java
-protected void finalize() {
- something();
- // neglected to call super.finalize()
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## FinalizeOnlyCallsSuperFinalize
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-If the finalize() is implemented, it should do something besides just calling super.finalize().
-
-```
-//MethodDeclaration[MethodDeclarator[@Image="finalize"][not(FormalParameters/*)]]
- /Block[count(BlockStatement)=1]
- /BlockStatement[
- Statement/StatementExpression/PrimaryExpression
- [./PrimaryPrefix[@SuperModifier='true']]
- [./PrimarySuffix[@Image='finalize']]
- ]
-```
-
-**Example(s):**
-
-``` java
-protected void finalize() {
- super.finalize();
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## FinalizeOverloaded
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-Methods named finalize() should not have parameters. It is confusing and most likely an attempt to
-overload Object.finalize(). It will not be called by the VM.
-
-```
-//MethodDeclaration
- /MethodDeclarator[@Image='finalize'][FormalParameters[count(*)>0]]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- // this is confusing and probably a bug
- protected void finalize(int a) {
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## FinalizeShouldBeProtected
-
-**Since:** PMD 1.1
-
-**Priority:** Medium (3)
-
-When overriding the finalize(), the new method should be set as protected. If made public,
-other classes may invoke it at inappropriate times.
-
-```
-//MethodDeclaration[@Protected="false"]
- /MethodDeclarator[@Image="finalize"]
- [not(FormalParameters/*)]
-```
-
-**Example(s):**
-
-``` java
-public void finalize() {
- // do something
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/imports.md b/docs/pages/pmd/rules/java/imports.md
deleted file mode 100644
index d9fb36d2ef2..00000000000
--- a/docs/pages/pmd/rules/java/imports.md
+++ /dev/null
@@ -1,173 +0,0 @@
----
-title: Import Statements
-summary: These rules deal with different problems that can occur with import statements.
-permalink: pmd_rules_java_imports.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/imports.xml
-keywords: Import Statements, DuplicateImports, DontImportJavaLang, UnusedImports, ImportFromSamePackage, TooManyStaticImports, UnnecessaryFullyQualifiedName
----
-## DontImportJavaLang
-
-**Since:** PMD 0.5
-
-**Priority:** Medium Low (4)
-
-Avoid importing anything from the package 'java.lang'. These classes are automatically imported (JLS 7.5.3).
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.imports.DontImportJavaLangRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/imports/DontImportJavaLangRule.java)
-
-**Example(s):**
-
-``` java
-import java.lang.String; // this is unnecessary
-
-public class Foo {}
-
-// --- in another source code file...
-
-import java.lang.*; // this is bad
-
-public class Foo {}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DuplicateImports
-
-**Since:** PMD 0.5
-
-**Priority:** Medium Low (4)
-
-Duplicate or overlapping import statements should be avoided.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.imports.DuplicateImportsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/imports/DuplicateImportsRule.java)
-
-**Example(s):**
-
-``` java
-import java.lang.String;
-import java.lang.*;
-public class Foo {}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ImportFromSamePackage
-
-**Since:** PMD 1.02
-
-**Priority:** Medium (3)
-
-There is no need to import a type that lives in the same package.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.imports.ImportFromSamePackageRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/imports/ImportFromSamePackageRule.java)
-
-**Example(s):**
-
-``` java
-package foo;
-
-import foo.Buz; // no need for this
-import foo.*; // or this
-
-public class Bar{}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TooManyStaticImports
-
-**Since:** PMD 4.1
-
-**Priority:** Medium (3)
-
-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).
-
-```
-.[count(ImportDeclaration[@Static = 'true']) > $maximumStaticImports]
-```
-
-**Example(s):**
-
-``` java
-import static Lennon;
-import static Ringo;
-import static George;
-import static Paul;
-import static Yoko; // Too much !
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|maximumStaticImports|4|All static imports can be disallowed by setting this to 0|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryFullyQualifiedName
-
-**Since:** PMD 5.0
-
-**Priority:** Medium Low (4)
-
-Import statements allow the use of non-fully qualified names. The use of a fully qualified name
-which is covered by an import statement is redundant. Consider using the non-fully qualified name.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.imports.UnnecessaryFullyQualifiedNameRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/imports/UnnecessaryFullyQualifiedNameRule.java)
-
-**Example(s):**
-
-``` java
-import java.util.List;
-
-public class Foo {
- private java.util.List list1; // Unnecessary FQN
- private List list2; // More appropriate given import of 'java.util.List'
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnusedImports
-
-**Since:** PMD 1.0
-
-**Priority:** Medium Low (4)
-
-Avoid the use of unused import statements to prevent unwanted dependencies.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.imports.UnusedImportsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/imports/UnusedImportsRule.java)
-
-**Example(s):**
-
-``` java
-// this is bad
-import java.io.File;
-public class Foo {}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/j2ee.md b/docs/pages/pmd/rules/java/j2ee.md
deleted file mode 100644
index b9a697099f6..00000000000
--- a/docs/pages/pmd/rules/java/j2ee.md
+++ /dev/null
@@ -1,335 +0,0 @@
----
-title: J2EE
-summary: Rules specific to the use of J2EE implementations.
-permalink: pmd_rules_java_j2ee.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/j2ee.xml
-keywords: J2EE, UseProperClassLoader, MDBAndSessionBeanNamingConvention, RemoteSessionInterfaceNamingConvention, LocalInterfaceSessionNamingConvention, LocalHomeNamingConvention, RemoteInterfaceNamingConvention, DoNotCallSystemExit, StaticEJBFieldShouldBeFinal, DoNotUseThreads
----
-## DoNotCallSystemExit
-
-**Since:** PMD 4.1
-
-**Priority:** Medium (3)
-
-Web applications should not call System.exit(), since only the web container or the
-application server should stop the JVM. This rule also checks for the equivalent call Runtime.getRuntime().exit().
-
-```
-//Name[
- starts-with(@Image,'System.exit')
- or
- (starts-with(@Image,'Runtime.getRuntime') and ../../PrimarySuffix[ends-with(@Image,'exit')])
-]
-```
-
-**Example(s):**
-
-``` java
-public void bar() {
- System.exit(0); // never call this when running in an application server!
-}
-public void foo() {
- Runtime.getRuntime().exit(0); // never stop the JVM manually, the container will do this.
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DoNotUseThreads
-
-**Since:** PMD 4.1
-
-**Priority:** Medium (3)
-
-The J2EE specification explicitly forbids the use of threads.
-
-```
-//ClassOrInterfaceType[@Image = 'Thread' or @Image = 'Runnable']
-```
-
-**Example(s):**
-
-``` java
-// This is not allowed
-public class UsingThread extends Thread {
-
-}
-
-// Neither this,
-public class OtherThread implements Runnable {
- // Nor this ...
- public void methode() {
- Runnable thread = new Thread(); thread.run();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## LocalHomeNamingConvention
-
-**Since:** PMD 4.0
-
-**Priority:** Medium Low (4)
-
-The Local Home interface of a Session EJB should be suffixed by 'LocalHome'.
-
-```
-//ClassOrInterfaceDeclaration
-[
- (
- (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalHome')])
- )
- and
- not
- (
- ends-with(@Image,'LocalHome')
- )
-]
-```
-
-**Example(s):**
-
-``` java
-public interface MyBeautifulLocalHome extends javax.ejb.EJBLocalHome {} // proper name
-
-public interface MissingProperSuffix extends javax.ejb.EJBLocalHome {} // non-standard name
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## LocalInterfaceSessionNamingConvention
-
-**Since:** PMD 4.0
-
-**Priority:** Medium Low (4)
-
-The Local Interface of a Session EJB should be suffixed by 'Local'.
-
-```
-//ClassOrInterfaceDeclaration
-[
- (
- (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalObject')])
- )
- and
- not
- (
- ends-with(@Image,'Local')
- )
-]
-```
-
-**Example(s):**
-
-``` java
-public interface MyLocal extends javax.ejb.EJBLocalObject {} // proper name
-
-public interface MissingProperSuffix extends javax.ejb.EJBLocalObject {} // non-standard name
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MDBAndSessionBeanNamingConvention
-
-**Since:** PMD 4.0
-
-**Priority:** Medium Low (4)
-
-The EJB Specification states that any MessageDrivenBean or SessionBean should be suffixed by 'Bean'.
-
-```
-//TypeDeclaration/ClassOrInterfaceDeclaration
-[
- (
- (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'SessionBean')])
- or
- (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'MessageDrivenBean')])
- )
- and
- not
- (
- ends-with(@Image,'Bean')
- )
-]
-```
-
-**Example(s):**
-
-``` java
-public class SomeBean implements SessionBean{} // proper name
-
-public class MissingTheProperSuffix implements SessionBean {} // non-standard name
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## RemoteInterfaceNamingConvention
-
-**Since:** PMD 4.0
-
-**Priority:** Medium Low (4)
-
-Remote Interface of a Session EJB should not have a suffix.
-
-```
-//ClassOrInterfaceDeclaration
-[
- (
- (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBObject')])
- )
- and
- (
- ends-with(@Image,'Session')
- or
- ends-with(@Image,'EJB')
- or
- ends-with(@Image,'Bean')
- )
-]
-```
-
-**Example(s):**
-
-``` java
-/* Poor Session suffix */
-public interface BadSuffixSession extends javax.ejb.EJBObject {}
-
-/* Poor EJB suffix */
-public interface BadSuffixEJB extends javax.ejb.EJBObject {}
-
-/* Poor Bean suffix */
-public interface BadSuffixBean extends javax.ejb.EJBObject {}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## RemoteSessionInterfaceNamingConvention
-
-**Since:** PMD 4.0
-
-**Priority:** Medium Low (4)
-
-A Remote Home interface type of a Session EJB should be suffixed by 'Home'.
-
-```
-//ClassOrInterfaceDeclaration
-[
- (
- (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBHome')])
- )
- and
- not
- (
- ends-with(@Image,'Home')
- )
-]
-```
-
-**Example(s):**
-
-``` java
-public interface MyBeautifulHome extends javax.ejb.EJBHome {} // proper name
-
-public interface MissingProperSuffix extends javax.ejb.EJBHome {} // non-standard name
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## StaticEJBFieldShouldBeFinal
-
-**Since:** PMD 4.1
-
-**Priority:** Medium (3)
-
-According to the J2EE specification, 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.
-
-```
-//ClassOrInterfaceDeclaration[
- (
- (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'SessionBean')])
- or
- (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'EJBHome')])
- or
- (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalObject')])
- or
- (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalHome')])
- or
- (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBObject')])
- )
- and
- (./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[
- (./FieldDeclaration[@Static = 'true'])
- and
- (./FieldDeclaration[@Final = 'false'])
- ])
-]
-```
-
-**Example(s):**
-
-``` java
-public class SomeEJB extends EJBObject implements EJBLocalHome {
-
- private static int CountA; // poor, field can be edited
-
- private static final int CountB; // preferred, read-only access
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseProperClassLoader
-
-**Since:** PMD 3.7
-
-**Priority:** Medium (3)
-
-In J2EE, the getClassLoader() method might not work as expected. Use
-Thread.currentThread().getContextClassLoader() instead.
-
-```
-//PrimarySuffix[@Image='getClassLoader']
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- ClassLoader cl = Bar.class.getClassLoader();
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/javabeans.md b/docs/pages/pmd/rules/java/javabeans.md
deleted file mode 100644
index 8a8a05afd6e..00000000000
--- a/docs/pages/pmd/rules/java/javabeans.md
+++ /dev/null
@@ -1,87 +0,0 @@
----
-title: JavaBeans
-summary: The JavaBeans Ruleset catches instances of bean rules not being followed.
-permalink: pmd_rules_java_javabeans.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/javabeans.xml
-keywords: JavaBeans, BeanMembersShouldSerialize, MissingSerialVersionUID
----
-## BeanMembersShouldSerialize
-
-**Since:** PMD 1.1
-
-**Priority:** Medium (3)
-
-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. for a variable named foo, getFoo() and setFoo() accessor methods should be provided.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.javabeans.BeanMembersShouldSerializeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/javabeans/BeanMembersShouldSerializeRule.java)
-
-**Example(s):**
-
-``` java
-private transient int someFoo; // good, it's transient
-private static int otherFoo; // also OK
-private int moreFoo; // OK, has proper accessors, see below
-private int badFoo; // bad, should be marked transient
-
-private void setMoreFoo(int moreFoo){
- this.moreFoo = moreFoo;
-}
-
-private int getMoreFoo(){
- return this.moreFoo;
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|prefix||A variable prefix to skip, i.e., m_|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MissingSerialVersionUID
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-Serializable classes should provide a serialVersionUID field.
-
-```
-//ClassOrInterfaceDeclaration
- [
- count(ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
- /FieldDeclaration/VariableDeclarator/VariableDeclaratorId[@Image='serialVersionUID']) = 0
-and
- count(ImplementsList
- [ClassOrInterfaceType/@Image='Serializable'
- or ClassOrInterfaceType/@Image='java.io.Serializable']) =1
-and
- @Abstract = 'false'
-]
-```
-
-**Example(s):**
-
-``` java
-public class Foo implements java.io.Serializable {
- String name;
- // Define serialization id to avoid serialization related bugs
- // i.e., public static final long serialVersionUID = 4328743;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/junit.md b/docs/pages/pmd/rules/java/junit.md
deleted file mode 100644
index b3d9bc0f408..00000000000
--- a/docs/pages/pmd/rules/java/junit.md
+++ /dev/null
@@ -1,442 +0,0 @@
----
-title: JUnit
-summary: These rules deal with different problems that can occur with JUnit tests.
-permalink: pmd_rules_java_junit.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/junit.xml
-keywords: JUnit, JUnitStaticSuite, JUnitSpelling, JUnitAssertionsShouldIncludeMessage, JUnitTestsShouldIncludeAssert, TestClassWithoutTestCases, UnnecessaryBooleanAssertion, UseAssertEqualsInsteadOfAssertTrue, UseAssertSameInsteadOfAssertTrue, UseAssertNullInsteadOfAssertTrue, SimplifyBooleanAssertion, JUnitTestContainsTooManyAsserts, UseAssertTrueInsteadOfAssertEquals
----
-## JUnitAssertionsShouldIncludeMessage
-
-**Since:** PMD 1.04
-
-**Priority:** Medium (3)
-
-JUnit assertions should include an informative message - i.e., use the three-argument version of
-assertEquals(), not the two-argument version.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.junit.JUnitAssertionsShouldIncludeMessageRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/junit/JUnitAssertionsShouldIncludeMessageRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo extends TestCase {
- public void testSomething() {
- assertEquals("foo", "bar");
- // Use the form:
- // assertEquals("Foo does not equals bar", "foo", "bar");
- // instead
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JUnitSpelling
-
-**Since:** PMD 1.0
-
-**Priority:** Medium (3)
-
-Some JUnit framework methods are easy to misspell.
-
-```
-//MethodDeclarator[(not(@Image = 'setUp')
- and translate(@Image, 'SETuP', 'setUp') = 'setUp')
- or (not(@Image = 'tearDown')
- and translate(@Image, 'TEARdOWN', 'tearDown') = 'tearDown')]
- [FormalParameters[count(*) = 0]]
-[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeof(@Image, 'junit.framework.TestCase','TestCase')] or //MarkerAnnotation/Name[pmd-java:typeof(@Image, 'org.junit.Test', 'Test')]]]
-```
-
-**Example(s):**
-
-``` java
-import junit.framework.*;
-
-public class Foo extends TestCase {
- public void setup() {} // oops, should be setUp
- public void TearDown() {} // oops, should be tearDown
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JUnitStaticSuite
-
-**Since:** PMD 1.0
-
-**Priority:** Medium (3)
-
-The suite() method in a JUnit test needs to be both public and static.
-
-```
-//MethodDeclaration[not(@Static='true') or not(@Public='true')]
-[MethodDeclarator/@Image='suite']
-[MethodDeclarator/FormalParameters/@ParameterCount=0]
-[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeof(@Image, 'junit.framework.TestCase','TestCase')] or //MarkerAnnotation/Name[pmd-java:typeof(@Image, 'org.junit.Test', 'Test')]]]
-```
-
-**Example(s):**
-
-``` java
-import junit.framework.*;
-
-public class Foo extends TestCase {
- public void suite() {} // oops, should be static
- private static void suite() {} // oops, should be public
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JUnitTestContainsTooManyAsserts
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-JUnit tests should not contain too many asserts. Many asserts are indicative of a complex test, for which
-it is harder to verify correctness. Consider breaking the test scenario into multiple, shorter test scenarios.
-Customize the maximum number of assertions used by this Rule to suit your needs.
-
-```
-//MethodDeclarator[(@Image[fn:matches(.,'^test')] or ../../Annotation/MarkerAnnotation/Name[@Image='Test']) and count(..//PrimaryPrefix/Name[@Image[fn:matches(.,'^assert')]]) > $maximumAsserts]
-```
-
-**Example(s):**
-
-``` java
-public class MyTestCase extends TestCase {
- // Ok
- public void testMyCaseWithOneAssert() {
- boolean myVar = false;
- assertFalse("should be false", myVar);
- }
-
- // Bad, too many asserts (assuming max=1)
- public void testMyCaseWithMoreAsserts() {
- boolean myVar = false;
- assertFalse("myVar should be false", myVar);
- assertEquals("should equals false", false, myVar);
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|maximumAsserts|1|Maximum number of Asserts in a test method|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JUnitTestsShouldIncludeAssert
-
-**Since:** PMD 2.0
-
-**Priority:** Medium (3)
-
-JUnit tests should include at least one assertion. This makes the tests more robust, and using assert
-with messages provide the developer a clearer idea of what the test does.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.junit.JUnitTestsShouldIncludeAssertRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/junit/JUnitTestsShouldIncludeAssertRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo extends TestCase {
- public void testSomething() {
- Bar b = findBar();
- // This is better than having a NullPointerException
- // assertNotNull("bar not found", b);
- b.work();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SimplifyBooleanAssertion
-
-**Since:** PMD 3.6
-
-**Priority:** Medium (3)
-
-Avoid negation in an assertTrue or assertFalse test.
-
-For example, rephrase:
-
- assertTrue(!expr);
-
-as:
-
- assertFalse(expr);
-
-```
-//StatementExpression
-[
-.//Name[@Image='assertTrue' or @Image='assertFalse']
-and
-PrimaryExpression/PrimarySuffix/Arguments/ArgumentList
- /Expression/UnaryExpressionNotPlusMinus[@Image='!']
-/PrimaryExpression/PrimaryPrefix
-]
-[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeof(@Image, 'junit.framework.TestCase','TestCase')] or //MarkerAnnotation/Name[pmd-java:typeof(@Image, 'org.junit.Test', 'Test')]]]
-```
-
-**Example(s):**
-
-``` java
-public class SimpleTest extends TestCase {
- public void testX() {
- assertTrue("not empty", !r.isEmpty()); // replace with assertFalse("not empty", r.isEmpty())
- assertFalse(!r.isEmpty()); // replace with assertTrue(r.isEmpty())
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TestClassWithoutTestCases
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-Test classes end with the suffix Test. Having a non-test class with that name is not a good practice,
-since most people will assume it is a test case. Test classes have test methods named testXXX.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.junit.TestClassWithoutTestCasesRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/junit/TestClassWithoutTestCasesRule.java)
-
-**Example(s):**
-
-``` java
-//Consider changing the name of the class if it is not a test
-//Consider adding test methods if it is a test
-public class CarTest {
- public static void main(String[] args) {
- // do something
- }
- // code
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryBooleanAssertion
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-A JUnit test assertion with a boolean literal is unnecessary since it always will evaluate to the same thing.
-Consider using flow control (in case of assertTrue(false) or similar) or simply removing
-statements like assertTrue(true) and assertFalse(false). If you just want a test to halt after finding
-an error, use the fail() method and provide an indication message of why it did.
-
-```
-//StatementExpression
-[
-PrimaryExpression/PrimaryPrefix/Name[@Image='assertTrue' or @Image='assertFalse']
-and
-PrimaryExpression/PrimarySuffix/Arguments/ArgumentList/Expression
-[PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral
-or
-UnaryExpressionNotPlusMinus[@Image='!']
-/PrimaryExpression/PrimaryPrefix[Literal/BooleanLiteral or Name[count(../../*)=1]]]
-]
-[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeof(@Image, 'junit.framework.TestCase','TestCase')] or //MarkerAnnotation/Name[pmd-java:typeof(@Image, 'org.junit.Test', 'Test')]]]
-```
-
-**Example(s):**
-
-``` java
-public class SimpleTest extends TestCase {
- public void testX() {
- assertTrue(true); // serves no real purpose
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseAssertEqualsInsteadOfAssertTrue
-
-**Since:** PMD 3.1
-
-**Priority:** Medium (3)
-
-This rule detects JUnit assertions in object equality. These assertions should be made by more specific methods, like assertEquals.
-
-```
-//PrimaryExpression[
- PrimaryPrefix/Name[@Image = 'assertTrue']
-][
- PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Name
- [ends-with(@Image, '.equals')]
-]
-[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeof(@Image, 'junit.framework.TestCase','TestCase')] or //MarkerAnnotation/Name[pmd-java:typeof(@Image, 'org.junit.Test', 'Test')]]]
-```
-
-**Example(s):**
-
-``` java
-public class FooTest extends TestCase {
- void testCode() {
- Object a, b;
- assertTrue(a.equals(b)); // bad usage
- assertEquals(?a should equals b?, a, b); // good usage
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseAssertNullInsteadOfAssertTrue
-
-**Since:** PMD 3.5
-
-**Priority:** Medium (3)
-
-This rule detects JUnit assertions in object references equality. These assertions should be made by
-more specific methods, like assertNull, assertNotNull.
-
-```
-//PrimaryExpression[
- PrimaryPrefix/Name[@Image = 'assertTrue' or @Image = 'assertFalse']
-][
- PrimarySuffix/Arguments/ArgumentList[
- Expression/EqualityExpression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral
- ]
-]
-[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeof(@Image, 'junit.framework.TestCase','TestCase')] or //MarkerAnnotation/Name[pmd-java:typeof(@Image, 'org.junit.Test', 'Test')]]]
-```
-
-**Example(s):**
-
-``` java
-public class FooTest extends TestCase {
- void testCode() {
- Object a = doSomething();
- assertTrue(a==null); // bad usage
- assertNull(a); // good usage
- assertTrue(a != null); // bad usage
- assertNotNull(a); // good usage
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseAssertSameInsteadOfAssertTrue
-
-**Since:** PMD 3.1
-
-**Priority:** Medium (3)
-
-This rule detects JUnit assertions in object references equality. These assertions should be made
-by more specific methods, like assertSame, assertNotSame.
-
-```
-//PrimaryExpression[
- PrimaryPrefix/Name
- [@Image = 'assertTrue' or @Image = 'assertFalse']
-]
-[PrimarySuffix/Arguments
- /ArgumentList/Expression
- /EqualityExpression[count(.//NullLiteral) = 0]]
-[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeof(@Image, 'junit.framework.TestCase','TestCase')] or //MarkerAnnotation/Name[pmd-java:typeof(@Image, 'org.junit.Test', 'Test')]]]
-```
-
-**Example(s):**
-
-``` java
-public class FooTest extends TestCase {
- void testCode() {
- Object a, b;
- assertTrue(a == b); // bad usage
- assertSame(a, b); // good usage
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseAssertTrueInsteadOfAssertEquals
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-When asserting a value is the same as a literal or Boxed boolean, use assertTrue/assertFalse, instead of assertEquals.
-
-```
-//PrimaryExpression[PrimaryPrefix/Name[@Image = 'assertEquals']]
-[
- PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral
- or
- PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix
- /Name[(@Image = 'Boolean.TRUE' or @Image = 'Boolean.FALSE')]
-]
-```
-
-**Example(s):**
-
-``` java
-public class MyTestCase extends TestCase {
- public void testMyCase() {
- boolean myVar = true;
- // Ok
- assertTrue("myVar is true", myVar);
- // Bad
- assertEquals("myVar is true", true, myVar);
- // Bad
- assertEquals("myVar is false", false, myVar);
- // Bad
- assertEquals("myVar is true", Boolean.TRUE, myVar);
- // Bad
- assertEquals("myVar is false", Boolean.FALSE, myVar);
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/logging-jakarta-commons.md b/docs/pages/pmd/rules/java/logging-jakarta-commons.md
deleted file mode 100644
index 6e3473fe19c..00000000000
--- a/docs/pages/pmd/rules/java/logging-jakarta-commons.md
+++ /dev/null
@@ -1,172 +0,0 @@
----
-title: Jakarta Commons Logging
-summary: The Jakarta Commons Logging ruleset contains a collection of rules that find questionable usages of that framework.
-permalink: pmd_rules_java_logging-jakarta-commons.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/logging-jakarta-commons.xml
-keywords: Jakarta Commons Logging, UseCorrectExceptionLogging, ProperLogger, GuardDebugLogging, GuardLogStatement
----
-## GuardDebugLogging
-
-**Since:** PMD 4.3
-
-**Priority:** Medium (3)
-
-When log messages are composed by concatenating strings, the whole section should be guarded
-by a isDebugEnabled() check to avoid performance and memory issues.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.logging.GuardDebugLoggingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/logging/GuardDebugLoggingRule.java)
-
-**Example(s):**
-
-``` java
-public class Test {
- private static final Log __log = LogFactory.getLog(Test.class);
- public void test() {
- // okay:
- __log.debug("log something");
-
- // okay:
- __log.debug("log something with exception", e);
-
- // bad:
- __log.debug("log something" + " and " + "concat strings");
-
- // bad:
- __log.debug("log something" + " and " + "concat strings", e);
-
- // good:
- if (__log.isDebugEnabled()) {
- __log.debug("bla" + "",e );
- }
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|guardsMethods|[]|method use to guard the log statement|
-|logLevels|[]|LogLevels to guard|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## GuardLogStatement
-
-**Since:** PMD 5.1.0
-
-**Priority:** Medium High (2)
-
-Whenever using a log level, one should check if the loglevel is actually enabled, or
-otherwise skip the associate String creation and manipulation.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.logging.GuardLogStatementRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/logging/GuardLogStatementRule.java)
-
-**Example(s):**
-
-``` java
-// Add this for performance
- if (log.isDebugEnabled() { ...
- log.debug("log something" + " and " + "concat strings");
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|guardsMethods|[]|method use to guard the log statement|
-|logLevels|[]|LogLevels to guard|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ProperLogger
-
-**Since:** PMD 3.3
-
-**Priority:** Medium (3)
-
-A logger should normally be defined private static final and be associated with the correct class.
-Private final Log log; is also allowed for rare cases where loggers need to be passed around,
-with the restriction that the logger needs to be passed into the constructor.
-
-```
-//ClassOrInterfaceBodyDeclaration[FieldDeclaration//ClassOrInterfaceType[@Image='Log']
- and
- not(FieldDeclaration[@Final='true'][@Static='true'][@Private='true'][.//VariableDeclaratorId[@Image=$staticLoggerName]]
- //ArgumentList//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration/@Image)
- and
- not(FieldDeclaration[@Final='true'][@Private='true'][.//VariableDeclaratorId[@Image='log']]
- [count(.//VariableInitializer)=0]
- [ancestor::ClassOrInterfaceBody//StatementExpression[.//PrimaryExpression/descendant::*[@Image='log']][count(.//AllocationExpression)=0]]
- )]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
-
- private static final Log LOG = LogFactory.getLog(Foo.class); // proper way
-
- protected Log LOG = LogFactory.getLog(Testclass.class); // wrong approach
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|staticLoggerName|LOG|Name of the static Logger variable|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseCorrectExceptionLogging
-
-**Since:** PMD 3.2
-
-**Priority:** Medium (3)
-
-To make sure the full stacktrace is printed out, use the logging statement with two arguments: a String and a Throwable.
-
-```
-//CatchStatement/Block/BlockStatement/Statement/StatementExpression
-/PrimaryExpression[PrimaryPrefix/Name[starts-with(@Image,
-concat(ancestor::ClassOrInterfaceDeclaration/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/FieldDeclaration
-[Type//ClassOrInterfaceType[@Image='Log']]
-/VariableDeclarator/VariableDeclaratorId/@Image, '.'))]]
-[PrimarySuffix/Arguments[@ArgumentCount='1']]
-[PrimarySuffix/Arguments//Name/@Image = ancestor::CatchStatement/FormalParameter/VariableDeclaratorId/@Image]
-```
-
-**Example(s):**
-
-``` java
-public class Main {
- private static final Log _LOG = LogFactory.getLog( Main.class );
- void bar() {
- try {
- } catch( Exception e ) {
- _LOG.error( e ); //Wrong!
- } catch( OtherException oe ) {
- _LOG.error( oe.getMessage(), oe ); //Correct
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/logging-java.md b/docs/pages/pmd/rules/java/logging-java.md
deleted file mode 100644
index 20d350c430a..00000000000
--- a/docs/pages/pmd/rules/java/logging-java.md
+++ /dev/null
@@ -1,192 +0,0 @@
----
-title: Java Logging
-summary: The Java Logging ruleset contains a collection of rules that find questionable usages of the logger.
-permalink: pmd_rules_java_logging-java.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/logging-java.xml
-keywords: Java Logging, MoreThanOneLogger, LoggerIsNotStaticFinal, SystemPrintln, AvoidPrintStackTrace, GuardLogStatementJavaUtil, InvalidSlf4jMessageFormat
----
-## AvoidPrintStackTrace
-
-**Since:** PMD 3.2
-
-**Priority:** Medium (3)
-
-Avoid printStackTrace(); use a logger call instead.
-
-```
-//PrimaryExpression
- [PrimaryPrefix/Name[contains(@Image,'printStackTrace')]]
- [PrimarySuffix[not(boolean(Arguments/ArgumentList/Expression))]]
-```
-
-**Example(s):**
-
-``` java
-class Foo {
- void bar() {
- try {
- // do something
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## GuardLogStatementJavaUtil
-
-**Since:** PMD 5.1.0
-
-**Priority:** Medium High (2)
-
-Whenever using a log level, one should check if the loglevel is actually enabled, or
-otherwise skip the associate String creation and manipulation.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.logging.GuardLogStatementJavaUtilRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/logging/GuardLogStatementJavaUtilRule.java)
-
-**Example(s):**
-
-``` java
-//...
-// Add this for performance
-if (log.isLoggable(Level.FINE)) {
- log.fine("log something" + " and " + "concat strings");
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|guardsMethods|[]|method use to guard the log statement|
-|logLevels|[]|LogLevels to guard|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## InvalidSlf4jMessageFormat
-
-**Since:** PMD 5.5.0
-
-**Priority:** Low (5)
-
-Check for messages in slf4j loggers with non matching number of arguments and placeholders.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.logging.InvalidSlf4jMessageFormatRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/logging/InvalidSlf4jMessageFormatRule.java)
-
-**Example(s):**
-
-``` java
-LOGGER.error("forget the arg {}");
-LOGGER.error("too many args {}", "arg1", "arg2");
-LOGGER.error("param {}", "arg1", new IllegalStateException("arg")); //The exception is shown separately, so is correct.
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## LoggerIsNotStaticFinal
-
-**Since:** PMD 2.0
-
-**Priority:** Medium High (2)
-
-In most cases, the Logger reference can be declared as static and final.
-
-```
-//VariableDeclarator
- [parent::FieldDeclaration]
- [../Type/ReferenceType
- /ClassOrInterfaceType[@Image='Logger']
- and
- (..[@Final='false'] or ..[@Static = 'false'] ) ]
-```
-
-**Example(s):**
-
-``` java
-public class Foo{
- Logger log = Logger.getLogger(Foo.class.getName()); // not recommended
-
- static final Logger log = Logger.getLogger(Foo.class.getName()); // preferred approach
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MoreThanOneLogger
-
-**Since:** PMD 2.0
-
-**Priority:** Medium High (2)
-
-Normally only one logger is used in each class.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.logging.MoreThanOneLoggerRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/logging/MoreThanOneLoggerRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- Logger log = Logger.getLogger(Foo.class.getName());
- // It is very rare to see two loggers on a class, normally
- // log information is multiplexed by levels
- Logger log2= Logger.getLogger(Foo.class.getName());
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SystemPrintln
-
-**Since:** PMD 2.1
-
-**Priority:** Medium High (2)
-
-References to System.(out|err).print are usually intended for debugging purposes and can remain in
-the codebase even in production code. By using a logger one can enable/disable this behaviour at
-will (and by priority) and avoid clogging the Standard out log.
-
-```
-//Name[
- starts-with(@Image, 'System.out.print')
- or
- starts-with(@Image, 'System.err.print')
- ]
-```
-
-**Example(s):**
-
-``` java
-class Foo{
- Logger log = Logger.getLogger(Foo.class.getName());
- public void testA () {
- System.out.println("Entering test");
- // Better use this
- log.fine("Entering test");
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/migrating.md b/docs/pages/pmd/rules/java/migrating.md
deleted file mode 100644
index ae8f19c8499..00000000000
--- a/docs/pages/pmd/rules/java/migrating.md
+++ /dev/null
@@ -1,478 +0,0 @@
----
-title: Migration
-summary: Contains rules about migrating from one JDK version to another. Don't use these rules directly, rather, use a wrapper ruleset such as migrating_to_13.xml.
-permalink: pmd_rules_java_migrating.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/migrating.xml
-keywords: Migration, ReplaceVectorWithList, ReplaceHashtableWithMap, ReplaceEnumerationWithIterator, AvoidEnumAsIdentifier, AvoidAssertAsIdentifier, IntegerInstantiation, ByteInstantiation, ShortInstantiation, LongInstantiation, JUnit4TestShouldUseBeforeAnnotation, JUnit4TestShouldUseAfterAnnotation, JUnit4TestShouldUseTestAnnotation, JUnit4SuitesShouldUseSuiteAnnotation, JUnitUseExpected, ForLoopCanBeForeach
----
-## AvoidAssertAsIdentifier
-
-**Since:** PMD 3.4
-
-**Priority:** Medium High (2)
-
-Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
-
-```
-//VariableDeclaratorId[@Image='assert']
-```
-
-**Example(s):**
-
-``` java
-public class A {
- public class Foo {
- String assert = "foo";
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidEnumAsIdentifier
-
-**Since:** PMD 3.4
-
-**Priority:** Medium High (2)
-
-Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
-
-```
-//VariableDeclaratorId[@Image='enum']
-```
-
-**Example(s):**
-
-``` java
-public class A {
- public class Foo {
- String enum = "foo";
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ByteInstantiation
-
-**Since:** PMD 4.0
-
-**Priority:** Medium High (2)
-
-Calling new Byte() causes memory allocation that can be avoided by the static Byte.valueOf().
-It makes use of an internal cache that recycles earlier instances making it more memory efficient.
-
-```
-//PrimaryPrefix/AllocationExpression
-[not (ArrayDimsAndInits)
-and (ClassOrInterfaceType/@Image='Byte'
-or ClassOrInterfaceType/@Image='java.lang.Byte')]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- private Byte i = new Byte(0); // change to Byte i = Byte.valueOf(0);
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ForLoopCanBeForeach
-
-**Since:** PMD 6.0
-
-**Priority:** Medium (3)
-
-**Minimum Language Version:** Java 1.5
-
-Reports loops that can be safely replaced with the foreach syntax. The rule considers loops over
- lists, arrays and iterators. A loop is safe to replace if it only uses the index variable to
- access an element of the list or array, only has one update statement, and loops through *every*
- element of the list or array left to right.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.migrating.ForLoopCanBeForeachRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/migrating/ForLoopCanBeForeachRule.java)
-
-**Example(s):**
-
-``` java
-public class MyClass {
- void loop(List l) {
- for (int i = 0; i < l.size(); i++) { // pre Java 1.5
- System.out.println(l.get(i));
- }
-
- for (String s : l) { // post Java 1.5
- System.out.println(s);
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## IntegerInstantiation
-
-**Since:** PMD 3.5
-
-**Priority:** Medium High (2)
-
-Calling new Integer() causes memory allocation that can be avoided by the static Integer.valueOf().
-It makes use of an internal cache that recycles earlier instances making it more memory efficient.
-
-```
-//PrimaryPrefix
- /AllocationExpression
- [not (ArrayDimsAndInits)
- and (ClassOrInterfaceType/@Image='Integer'
- or ClassOrInterfaceType/@Image='java.lang.Integer')]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- private Integer i = new Integer(0); // change to Integer i = Integer.valueOf(0);
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JUnit4SuitesShouldUseSuiteAnnotation
-
-**Since:** PMD 4.0
-
-**Priority:** Medium (3)
-
-In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicated
-through the @RunWith(Suite.class) annotation.
-
-```
-//ClassOrInterfaceBodyDeclaration[MethodDeclaration/MethodDeclarator[@Image='suite']]
-[MethodDeclaration/ResultType/Type/ReferenceType/ClassOrInterfaceType[@Image='Test' or @Image = 'junit.framework.Test']]
-[not(MethodDeclaration/Block//ClassOrInterfaceType[@Image='JUnit4TestAdapter'])]
-```
-
-**Example(s):**
-
-``` java
-public class BadExample extends TestCase{
-
- public static Test suite(){
- return new Suite();
- }
-}
-
-@RunWith(Suite.class)
-@SuiteClasses( { TestOne.class, TestTwo.class })
-public class GoodTest {
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JUnit4TestShouldUseAfterAnnotation
-
-**Since:** PMD 4.0
-
-**Priority:** Medium (3)
-
-In JUnit 3, the tearDown method was used to clean up all data entities required in running tests.
-JUnit 4 skips the tearDown method and executes all methods annotated with @After after running each test
-
-```
-//CompilationUnit[not(ImportDeclaration/Name[starts-with(@Image, "org.testng")])]
-//ClassOrInterfaceBodyDeclaration[MethodDeclaration/MethodDeclarator[@Image='tearDown']]
-[count(Annotation//Name[@Image='After'])=0]
-```
-
-**Example(s):**
-
-``` java
-public class MyTest {
- public void tearDown() {
- bad();
- }
-}
-public class MyTest2 {
- @After public void tearDown() {
- good();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JUnit4TestShouldUseBeforeAnnotation
-
-**Since:** PMD 4.0
-
-**Priority:** Medium (3)
-
-In JUnit 3, the setUp method was used to set up all data entities required in running tests.
-JUnit 4 skips the setUp method and executes all methods annotated with @Before before all tests
-
-```
-//CompilationUnit[not(ImportDeclaration/Name[starts-with(@Image, "org.testng")])]
-//ClassOrInterfaceBodyDeclaration[MethodDeclaration/MethodDeclarator[@Image='setUp']]
-[count(Annotation//Name[@Image='Before'])=0]
-```
-
-**Example(s):**
-
-``` java
-public class MyTest {
- public void setUp() {
- bad();
- }
-}
-public class MyTest2 {
- @Before public void setUp() {
- good();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JUnit4TestShouldUseTestAnnotation
-
-**Since:** PMD 4.0
-
-**Priority:** Medium (3)
-
-In JUnit 3, the framework executed all methods which started with the word test as a unit test.
-In JUnit 4, only methods annotated with the @Test annotation are executed.
-
-```
-//ClassOrInterfaceBodyDeclaration[MethodDeclaration[@Public='true']/MethodDeclarator[starts-with(@Image,'test')]]
-[count(Annotation//Name[@Image='Test'])=0]
-```
-
-**Example(s):**
-
-``` java
-public class MyTest {
- public void testBad() {
- doSomething();
- }
-
- @Test
- public void testGood() {
- doSomething();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JUnitUseExpected
-
-**Since:** PMD 4.0
-
-**Priority:** Medium (3)
-
-In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.migrating.JUnitUseExpectedRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/migrating/JUnitUseExpectedRule.java)
-
-**Example(s):**
-
-``` java
-public class MyTest {
- @Test
- public void testBad() {
- try {
- doSomething();
- fail("should have thrown an exception");
- } catch (Exception e) {
- }
- }
-
- @Test(expected=Exception.class)
- public void testGood() {
- doSomething();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## LongInstantiation
-
-**Since:** PMD 4.0
-
-**Priority:** Medium High (2)
-
-Calling new Long() causes memory allocation that can be avoided by the static Long.valueOf().
-It makes use of an internal cache that recycles earlier instances making it more memory efficient.
-
-```
-//PrimaryPrefix
-/AllocationExpression
-[not (ArrayDimsAndInits)
-and (ClassOrInterfaceType/@Image='Long'
-or ClassOrInterfaceType/@Image='java.lang.Long')]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- private Long i = new Long(0); // change to Long i = Long.valueOf(0);
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ReplaceEnumerationWithIterator
-
-**Since:** PMD 3.4
-
-**Priority:** Medium (3)
-
-Consider replacing Enumeration usages with the newer java.util.Iterator
-
-```
-//ImplementsList/ClassOrInterfaceType[@Image='Enumeration']
-```
-
-**Example(s):**
-
-``` java
-public class Foo implements Enumeration {
- private int x = 42;
- public boolean hasMoreElements() {
- return true;
- }
- public Object nextElement() {
- return String.valueOf(i++);
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ReplaceHashtableWithMap
-
-**Since:** PMD 3.4
-
-**Priority:** Medium (3)
-
-Consider replacing Hashtable usage with the newer java.util.Map if thread safety is not required.
-
-```
-//Type/ReferenceType/ClassOrInterfaceType[@Image='Hashtable']
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- void bar() {
- Hashtable h = new Hashtable();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ReplaceVectorWithList
-
-**Since:** PMD 3.4
-
-**Priority:** Medium (3)
-
-Consider replacing Vector usages with the newer java.util.ArrayList if expensive thread-safe operations are not required.
-
-```
-//Type/ReferenceType/ClassOrInterfaceType[@Image='Vector']
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- void bar() {
- Vector v = new Vector();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ShortInstantiation
-
-**Since:** PMD 4.0
-
-**Priority:** Medium High (2)
-
-Calling new Short() causes memory allocation that can be avoided by the static Short.valueOf().
-It makes use of an internal cache that recycles earlier instances making it more memory efficient.
-
-```
-//PrimaryPrefix
-/AllocationExpression
-[not (ArrayDimsAndInits)
-and (ClassOrInterfaceType/@Image='Short'
-or ClassOrInterfaceType/@Image='java.lang.Short')]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- private Short i = new Short(0); // change to Short i = Short.valueOf(0);
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/multithreading.md b/docs/pages/pmd/rules/java/multithreading.md
new file mode 100644
index 00000000000..6c673f40a80
--- /dev/null
+++ b/docs/pages/pmd/rules/java/multithreading.md
@@ -0,0 +1,379 @@
+---
+title: Multithreading
+summary: Rules that flag issues when dealing with multiple threads of execution.
+permalink: pmd_rules_java_multithreading.html
+folder: pmd/rules/java
+sidebaractiveurl: /pmd_rules_java.html
+editmepath: ../pmd-java/src/main/resources/category/java/multithreading.xml
+keywords: Multithreading, AvoidSynchronizedAtMethodLevel, AvoidThreadGroup, AvoidUsingVolatile, DoNotUseThreads, DontCallThreadRun, DoubleCheckedLocking, NonThreadSafeSingleton, UnsynchronizedStaticDateFormatter, UseConcurrentHashMap, UseNotifyAllInsteadOfNotify
+language: Java
+---
+## AvoidSynchronizedAtMethodLevel
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+Method-level synchronization can cause problems when new code is added to the method.
+Block-level synchronization helps to ensure that only the code that needs synchronization
+gets it.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//MethodDeclaration[@Synchronized='true']
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ // Try to avoid this:
+ synchronized void foo() {
+ }
+ // Prefer this:
+ void bar() {
+ synchronized(this) {
+ }
+ }
+
+ // Try to avoid this for static methods:
+ static synchronized void fooStatic() {
+ }
+
+ // Prefer this:
+ static void barStatic() {
+ synchronized(Foo.class) {
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidThreadGroup
+
+**Since:** PMD 3.6
+
+**Priority:** Medium (3)
+
+Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environment
+it contains methods that are not thread-safe.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AllocationExpression/ClassOrInterfaceType[pmd-java:typeIs('java.lang.ThreadGroup')]|
+//PrimarySuffix[contains(@Image, 'getThreadGroup')]
+```
+
+**Example(s):**
+
+``` java
+public class Bar {
+ void buz() {
+ ThreadGroup tg = new ThreadGroup("My threadgroup");
+ tg = new ThreadGroup(tg, "my thread group");
+ tg = Thread.currentThread().getThreadGroup();
+ tg = System.getSecurityManager().getThreadGroup();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidUsingVolatile
+
+**Since:** PMD 4.1
+
+**Priority:** Medium High (2)
+
+Use of the keyword 'volatile' is generally used to fine tune a Java application, and therefore, requires
+a good expertise of the Java Memory Model. Moreover, its range of action is somewhat misknown. Therefore,
+the volatile keyword should not be used for maintenance purpose and portability.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//FieldDeclaration[contains(@Volatile,'true')]
+```
+
+**Example(s):**
+
+``` java
+public class ThrDeux {
+ private volatile String var1; // not suggested
+ private String var2; // preferred
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DoNotUseThreads
+
+**Since:** PMD 4.1
+
+**Priority:** Medium (3)
+
+The J2EE specification explicitly forbids the use of threads.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ClassOrInterfaceType[@Image = 'Thread' or @Image = 'Runnable']
+```
+
+**Example(s):**
+
+``` java
+// This is not allowed
+public class UsingThread extends Thread {
+
+}
+
+// Neither this,
+public class OtherThread implements Runnable {
+ // Nor this ...
+ public void methode() {
+ Runnable thread = new Thread(); thread.run();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DontCallThreadRun
+
+**Since:** PMD 4.3
+
+**Priority:** Medium Low (4)
+
+Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//StatementExpression/PrimaryExpression
+[
+ PrimaryPrefix
+ [
+ ./Name[ends-with(@Image, '.run') or @Image = 'run']
+ and substring-before(Name/@Image, '.') =//VariableDeclarator/VariableDeclaratorId/@Image
+ [../../../Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('java.lang.Thread')]]
+ or (./AllocationExpression/ClassOrInterfaceType[pmd-java:typeIs('java.lang.Thread')]
+ and ../PrimarySuffix[@Image = 'run'])
+ ]
+]
+```
+
+**Example(s):**
+
+``` java
+Thread t = new Thread();
+t.run(); // use t.start() instead
+new Thread().run(); // same violation
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## DoubleCheckedLocking
+
+**Since:** PMD 1.04
+
+**Priority:** High (1)
+
+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 calls the constructor of the object the
+reference points to.
+
+Note: With Java 5, you can make Double checked locking work, if you declare the variable to be `volatile`.
+
+For more details refer to:
+or
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.multithreading.DoubleCheckedLockingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/multithreading/DoubleCheckedLockingRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ /*volatile */ Object baz = null; // fix for Java5 and later: volatile
+ Object bar() {
+ if (baz == null) { // baz may be non-null yet not fully created
+ synchronized(this) {
+ if (baz == null) {
+ baz = new Object();
+ }
+ }
+ }
+ return baz;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NonThreadSafeSingleton
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+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](https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom).
+
+Refrain from using the double-checked locking pattern. The Java Memory Model doesn't
+guarantee it to work unless the variable is declared as `volatile`, adding an uneeded
+performance penalty. [Reference](http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html)
+
+See Effective Java, item 48.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.multithreading.NonThreadSafeSingletonRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/multithreading/NonThreadSafeSingletonRule.java)
+
+**Example(s):**
+
+``` java
+private static Foo foo = null;
+
+//multiple simultaneous callers may see partially initialized objects
+public static Foo getFoo() {
+ if (foo==null) {
+ foo = new Foo();
+ }
+ return foo;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|checkNonStaticFields|false|Check for non-static fields. Do not set this to true and checkNonStaticMethods to false.|no|
+|checkNonStaticMethods|true|Check for non-static methods. Do not set this to false and checkNonStaticFields to true.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnsynchronizedStaticDateFormatter
+
+**Since:** PMD 3.6
+
+**Priority:** Medium (3)
+
+SimpleDateFormat instances are not synchronized. Sun recommends using 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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.multithreading.UnsynchronizedStaticDateFormatterRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/multithreading/UnsynchronizedStaticDateFormatterRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private static final SimpleDateFormat sdf = new SimpleDateFormat();
+ void bar() {
+ sdf.format(); // poor, no thread-safety
+ }
+ synchronized void foo() {
+ sdf.format(); // preferred
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseConcurrentHashMap
+
+**Since:** PMD 4.2.6
+
+**Priority:** Medium (3)
+
+**Minimum Language Version:** Java 1.5
+
+Since Java5 brought a new implementation of the Map designed for multi-threaded access, you can
+perform efficient map reads without blocking other threads.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Type[../VariableDeclarator/VariableInitializer//AllocationExpression/ClassOrInterfaceType[@Image != 'ConcurrentHashMap']]
+/ReferenceType/ClassOrInterfaceType[@Image = 'Map']
+```
+
+**Example(s):**
+
+``` java
+public class ConcurrentApp {
+ public void getMyInstance() {
+ Map map1 = new HashMap(); // fine for single-threaded access
+ Map map2 = new ConcurrentHashMap(); // preferred for use with multiple threads
+
+ // the following case will be ignored by this rule
+ Map map3 = someModule.methodThatReturnMap(); // might be OK, if the returned map is already thread-safe
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseNotifyAllInsteadOfNotify
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+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 its usually safer to call notifyAll() instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//StatementExpression/PrimaryExpression
+[PrimarySuffix/Arguments[@ArgumentCount = '0']]
+[
+ PrimaryPrefix[
+ ./Name[@Image='notify' or ends-with(@Image,'.notify')]
+ or ../PrimarySuffix/@Image='notify'
+ or (./AllocationExpression and ../PrimarySuffix[@Image='notify'])
+ ]
+]
+```
+
+**Example(s):**
+
+``` java
+void bar() {
+ x.notify();
+ // If many threads are monitoring x, only one (and you won't know which) will be notified.
+ // use instead:
+ x.notifyAll();
+ }
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/java/naming.md b/docs/pages/pmd/rules/java/naming.md
deleted file mode 100644
index db258a25ae2..00000000000
--- a/docs/pages/pmd/rules/java/naming.md
+++ /dev/null
@@ -1,653 +0,0 @@
----
-title: Naming
-summary: The Naming Ruleset contains rules regarding preferred usage of names and identifiers.
-permalink: pmd_rules_java_naming.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/naming.xml
-keywords: Naming, ShortVariable, LongVariable, ShortMethodName, VariableNamingConventions, MethodNamingConventions, ClassNamingConventions, AbstractNaming, AvoidDollarSigns, MethodWithSameNameAsEnclosingClass, SuspiciousHashcodeMethodName, SuspiciousConstantFieldName, SuspiciousEqualsMethodName, AvoidFieldNameMatchingTypeName, AvoidFieldNameMatchingMethodName, NoPackage, PackageCase, MisleadingVariableName, BooleanGetMethodName, ShortClassName, GenericsNaming
----
-## AbstractNaming
-
-**Since:** PMD 1.4
-
-**Priority:** Medium (3)
-
-Abstract classes should be named 'AbstractXXX'.
-
-```
-//ClassOrInterfaceDeclaration
- [@Abstract='true' and @Interface='false']
- [not (starts-with(@Image,'Abstract'))]
-|
-//ClassOrInterfaceDeclaration
- [@Abstract='false']
- [$strict='true']
- [starts-with(@Image, 'Abstract')]
-```
-
-**Example(s):**
-
-``` java
-public abstract class Foo { // should be AbstractFoo
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|strict|true|Also flag classes, that are named Abstract, but are not abstract.|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidDollarSigns
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-Avoid using dollar signs in variable/method/class/interface names.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.naming.AvoidDollarSignsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/naming/AvoidDollarSignsRule.java)
-
-**Example(s):**
-
-``` java
-public class Fo$o { // not a recommended name
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidFieldNameMatchingMethodName
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-It can be confusing to have a field name with the same name as a method. While this is permitted,
-having information (field) and actions (method) is not clear naming. Developers versed in
-Smalltalk often prefer this approach as the methods denote accessor methods.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.naming.AvoidFieldNameMatchingMethodNameRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/naming/AvoidFieldNameMatchingMethodNameRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- Object bar;
- // bar is data or an action or both?
- void bar() {
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidFieldNameMatchingTypeName
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-It is somewhat confusing to have a field name matching the declaring class name.
-This probably means that type and/or field names should be chosen more carefully.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.naming.AvoidFieldNameMatchingTypeNameRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/naming/AvoidFieldNameMatchingTypeNameRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo extends Bar {
- int foo; // There is probably a better name that can be used
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## BooleanGetMethodName
-
-**Since:** PMD 4.0
-
-**Priority:** Medium Low (4)
-
-Methods that return boolean results should be named as predicate statements to denote this.
-I.e, 'isReady()', 'hasValues()', 'canCommit()', 'willFail()', etc. Avoid the use of the 'get'
-prefix for these methods.
-
-```
-//MethodDeclaration[
-MethodDeclarator[count(FormalParameters/FormalParameter) = 0 or $checkParameterizedMethods = 'true']
- [starts-with(@Image, 'get')]
-and
-ResultType/Type/PrimitiveType[@Image = 'boolean']
-and not(../Annotation//Name[@Image = 'Override'])
-]
-```
-
-**Example(s):**
-
-``` java
-public boolean getFoo(); // bad
-public boolean isFoo(); // ok
-public boolean getFoo(boolean bar); // ok, unless checkParameterizedMethods=true
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|checkParameterizedMethods|false|Check parameterized methods|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ClassNamingConventions
-
-**Since:** PMD 1.2
-
-**Priority:** High (1)
-
-Class names should always begin with an upper case character.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.naming.ClassNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/naming/ClassNamingConventionsRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## GenericsNaming
-
-**Since:** PMD 4.2.6
-
-**Priority:** Medium Low (4)
-
-Names for references to generic values should be limited to a single uppercase letter.
-
-```
-//TypeDeclaration/ClassOrInterfaceDeclaration/TypeParameters/TypeParameter[
- string-length(@Image) > 1
- or
- string:upper-case(@Image) != @Image
-]
-```
-
-**Example(s):**
-
-``` java
-public interface GenericDao extends BaseDao {
- // This is ok...
-}
-
-public interface GenericDao {
- // Also this
-}
-
-public interface GenericDao {
- // 'e' should be an 'E'
-}
-
-public interface GenericDao {
- // 'EF' is not ok.
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## LongVariable
-
-**Since:** PMD 0.3
-
-**Priority:** Medium (3)
-
-Fields, formal arguments, or local variable names that are too long can make the code difficult to follow.
-
-```
-//VariableDeclaratorId[string-length(@Image) > $minimum]
-```
-
-**Example(s):**
-
-``` java
-public class Something {
- int reallyLongIntName = -3; // VIOLATION - Field
- public static void main( String argumentsList[] ) { // VIOLATION - Formal
- int otherReallyLongName = -5; // VIOLATION - Local
- for (int interestingIntIndex = 0; // VIOLATION - For
- interestingIntIndex < 10;
- interestingIntIndex ++ ) {
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|minimum|17|The variable length reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MethodNamingConventions
-
-**Since:** PMD 1.2
-
-**Priority:** High (1)
-
-Method names should always begin with a lower case character, and should not contain underscores.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.naming.MethodNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/naming/MethodNamingConventionsRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void fooStuff() {
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|checkNativeMethods|true|Check native methods|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MethodWithSameNameAsEnclosingClass
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-Non-constructor methods should not have the same name as the enclosing class.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.naming.MethodWithSameNameAsEnclosingClassRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/naming/MethodWithSameNameAsEnclosingClassRule.java)
-
-**Example(s):**
-
-``` java
-public class MyClass {
-
- public MyClass() {} // this is OK because it is a constructor
-
- public void MyClass() {} // this is bad because it is a method
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MisleadingVariableName
-
-**Since:** PMD 3.4
-
-**Priority:** Medium (3)
-
-Detects when a non-field has a name starting with 'm_'. This usually denotes a field and could be confusing.
-
-```
-//VariableDeclaratorId
-[starts-with(@Image, 'm_')]
-[not (../../../FieldDeclaration)]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- private int m_foo; // OK
- public void bar(String m_baz) { // Bad
- int m_boz = 42; // Bad
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoPackage
-
-**Since:** PMD 3.3
-
-**Priority:** Medium (3)
-
-Detects when a class or interface does not have a package definition.
-
-```
-//ClassOrInterfaceDeclaration[count(preceding::PackageDeclaration) = 0]
-```
-
-**Example(s):**
-
-``` java
-// no package declaration
-public class ClassInDefaultPackage {
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## PackageCase
-
-**Since:** PMD 3.3
-
-**Priority:** Medium (3)
-
-Detects when a package definition contains uppercase characters.
-
-```
-//PackageDeclaration/Name[lower-case(@Image)!=@Image]
-```
-
-**Example(s):**
-
-``` java
-package com.MyCompany; // should be lowercase name
-
-public class SomeClass {
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ShortClassName
-
-**Since:** PMD 5.0
-
-**Priority:** Medium Low (4)
-
-Short Classnames with fewer than e.g. five characters are not recommended.
-
-```
-//ClassOrInterfaceDeclaration[string-length(@Image) < $minimum]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|minimum|5|Number of characters that are required as a minimum for a class name.|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ShortMethodName
-
-**Since:** PMD 0.3
-
-**Priority:** Medium (3)
-
-Method names that are very short are not helpful to the reader.
-
-```
-//MethodDeclarator[string-length(@Image) < $minimum]
-```
-
-**Example(s):**
-
-``` java
-public class ShortMethod {
- public void a( int i ) { // Violation
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|minimum|3|Number of characters that are required as a minimum for a method name.|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ShortVariable
-
-**Since:** PMD 0.3
-
-**Priority:** Medium (3)
-
-Fields, local variables, or parameter names that are very short are not helpful to the reader.
-
-```
-//VariableDeclaratorId[string-length(@Image) < $minimum]
- [not(ancestor::ForInit)]
- [not(../../VariableDeclarator and ../../../LocalVariableDeclaration and ../../../../ForStatement)]
- [not((ancestor::FormalParameter) and (ancestor::TryStatement))]
-```
-
-**Example(s):**
-
-``` java
-public class Something {
- private int q = 15; // field - too short
- public static void main( String as[] ) { // formal arg - too short
- int r = 20 + q; // local var - too short
- for (int i = 0; i < 10; i++) { // not a violation (inside 'for' loop)
- r += q;
- }
- for (Integer i : numbers) { // not a violation (inside 'for-each' loop)
- r += q;
- }
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|minimum|3|Number of characters that are required as a minimum for a variable name.|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SuspiciousConstantFieldName
-
-**Since:** PMD 2.0
-
-**Priority:** Medium (3)
-
-Field names using all uppercase characters - Sun's Java naming conventions indicating constants - should
-be declared as final.
-
-```
-//ClassOrInterfaceDeclaration[@Interface='false']
- /ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/FieldDeclaration
- [@Final='false']
- [VariableDeclarator/VariableDeclaratorId[upper-case(@Image)=@Image]]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- // this is bad, since someone could accidentally
- // do PI = 2.71828; which is actually e
- // final double PI = 3.16; is ok
- double PI = 3.16;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SuspiciousEqualsMethodName
-
-**Since:** PMD 2.0
-
-**Priority:** Medium High (2)
-
-The method name and parameter number are suspiciously close to equals(Object), which can denote an
-intention to override the equals(Object) method.
-
-```
-//MethodDeclarator[@Image = 'equals']
-[
- (count(FormalParameters/*) = 1
- and not (FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
- [@Image = 'Object' or @Image = 'java.lang.Object'])
- or not (../ResultType/Type/PrimitiveType[@Image = 'boolean'])
- ) or (
- count(FormalParameters/*) = 2
- and ../ResultType/Type/PrimitiveType[@Image = 'boolean']
- and FormalParameters//ClassOrInterfaceType[@Image = 'Object' or @Image = 'java.lang.Object']
- and not(../../Annotation/MarkerAnnotation/Name[@Image='Override'])
- )
-]
-| //MethodDeclarator[@Image = 'equal']
-[
- count(FormalParameters/*) = 1
- and FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
- [@Image = 'Object' or @Image = 'java.lang.Object']
-]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public int equals(Object o) {
- // oops, this probably was supposed to be boolean equals
- }
- public boolean equals(String s) {
- // oops, this probably was supposed to be equals(Object)
- }
- public boolean equals(Object o1, Object o2) {
- // oops, this probably was supposed to be equals(Object)
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SuspiciousHashcodeMethodName
-
-**Since:** PMD 1.5
-
-**Priority:** Medium (3)
-
-The method name and return type are suspiciously close to hashCode(), which may denote an intention
-to override the hashCode() method.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.naming.SuspiciousHashcodeMethodNameRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/naming/SuspiciousHashcodeMethodNameRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public int hashcode() { // oops, this probably was supposed to be 'hashCode'
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## VariableNamingConventions
-
-**Since:** PMD 1.2
-
-**Priority:** High (1)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.naming.VariableNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/naming/VariableNamingConventionsRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public static final int MY_NUM = 0;
- public String myTest = "";
- DataModule dmTest = new DataModule();
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|parameterSuffix|[]|Method parameter variable suffixes|
-|parameterPrefix|[]|Method parameter variable prefixes|
-|localSuffix|[]|Local variable suffixes|
-|localPrefix|[]|Local variable prefixes|
-|memberSuffix|[]|Member variable suffixes|
-|memberPrefix|[]|Member variable prefixes|
-|staticSuffix|[]|Static variable suffixes|
-|checkParameters|true|Check constructor and method parameter variables|
-|checkNativeMethodParameters|true|Check method parameter of native methods|
-|staticPrefix|[]|Static variable prefixes|
-|checkLocals|true|Check local variables|
-|checkMembers|true|Check member variables|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/optimizations.md b/docs/pages/pmd/rules/java/optimizations.md
deleted file mode 100644
index a2670e8be45..00000000000
--- a/docs/pages/pmd/rules/java/optimizations.md
+++ /dev/null
@@ -1,441 +0,0 @@
----
-title: Optimization
-summary: These rules deal with different optimizations that generally apply to best practices.
-permalink: pmd_rules_java_optimizations.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/optimizations.xml
-keywords: Optimization, LocalVariableCouldBeFinal, MethodArgumentCouldBeFinal, AvoidInstantiatingObjectsInLoops, UseArrayListInsteadOfVector, SimplifyStartsWith, UseStringBufferForStringAppends, UseArraysAsList, AvoidArrayLoops, UnnecessaryWrapperObjectCreation, AddEmptyString, RedundantFieldInitializer, PrematureDeclaration
----
-## AddEmptyString
-
-**Since:** PMD 4.0
-
-**Priority:** Medium (3)
-
-The conversion of literals to strings by concatenating them with empty strings is inefficient.
-It is much better to use one of the type-specific toString() methods instead.
-
-```
-//AdditiveExpression/PrimaryExpression/PrimaryPrefix/Literal[@Image='""']
-```
-
-**Example(s):**
-
-``` java
-String s = "" + 123; // inefficient
-String t = Integer.toString(456); // preferred approach
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidArrayLoops
-
-**Since:** PMD 3.5
-
-**Priority:** Medium (3)
-
-Instead of manually copying data between two arrays, use the efficient System.arraycopy method instead.
-
-```
-//Statement[(ForStatement or WhileStatement) and
-count(*//AssignmentOperator[@Image = '='])=1
-and
-*/Statement
-[
-./Block/BlockStatement/Statement/StatementExpression/PrimaryExpression
-/PrimaryPrefix/Name/../../PrimarySuffix/Expression
-[(PrimaryExpression or AdditiveExpression) and count
-(.//PrimaryPrefix/Name)=1]//PrimaryPrefix/Name/@Image
-and
-./Block/BlockStatement/Statement/StatementExpression/Expression/PrimaryExpression
-/PrimaryPrefix/Name/../../PrimarySuffix[count
-(..//PrimarySuffix)=1]/Expression[(PrimaryExpression
-or AdditiveExpression) and count(.//PrimaryPrefix/Name)=1]
-//PrimaryPrefix/Name/@Image
-]]
-```
-
-**Example(s):**
-
-``` java
-public class Test {
- public void bar() {
- int[] a = new int[10];
- int[] b = new int[10];
- for (int i=0;i<10;i++) {
- b[i]=a[i];
- }
-
- int[] c = new int[10];
- // this will trigger the rule
- for (int i=0;i<10;i++) {
- b[i]=a[c[i]];
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidInstantiatingObjectsInLoops
-
-**Since:** PMD 2.2
-
-**Priority:** Medium (3)
-
-New objects created within loops should be checked to see if they can created outside them and reused.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.optimizations.AvoidInstantiatingObjectsInLoopsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/optimizations/AvoidInstantiatingObjectsInLoopsRule.java)
-
-**Example(s):**
-
-``` java
-public class Something {
- public static void main( String as[] ) {
- for (int i = 0; i < 10; i++) {
- Foo f = new Foo(); // Avoid this whenever you can it's really expensive
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## LocalVariableCouldBeFinal
-
-**Since:** PMD 2.2
-
-**Priority:** Medium (3)
-
-A local variable assigned only once can be declared final.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.optimizations.LocalVariableCouldBeFinalRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/optimizations/LocalVariableCouldBeFinalRule.java)
-
-**Example(s):**
-
-``` java
-public class Bar {
- public void foo () {
- String txtA = "a"; // if txtA will not be assigned again it is better to do this:
- final String txtB = "b";
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MethodArgumentCouldBeFinal
-
-**Since:** PMD 2.2
-
-**Priority:** Medium (3)
-
-A method argument that is never re-assigned within the method can be declared final.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.optimizations.MethodArgumentCouldBeFinalRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/optimizations/MethodArgumentCouldBeFinalRule.java)
-
-**Example(s):**
-
-``` java
-public void foo1 (String param) { // do stuff with param never assigning it
-
-}
-
-public void foo2 (final String param) { // better, do stuff with param never assigning it
-
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## PrematureDeclaration
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Checks for variables that are defined before they might be used. A reference is deemed to be premature if it is created right before a block of code that doesn't use it that also has the ability to return or throw an exception.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.optimizations.PrematureDeclarationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/optimizations/PrematureDeclarationRule.java)
-
-**Example(s):**
-
-``` java
-public int getLength(String[] strings) {
-
- int length = 0; // declared prematurely
-
- if (strings == null || strings.length == 0) return 0;
-
- for (String str : strings) {
- length += str.length();
- }
-
- return length;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## RedundantFieldInitializer
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Java will initialize fields with known default values so any explicit initialization of those same defaults
-is redundant and results in a larger class file (approximately three additional bytecode instructions per field).
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.optimizations.RedundantFieldInitializerRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/optimizations/RedundantFieldInitializerRule.java)
-
-**Example(s):**
-
-``` java
-public class C {
- boolean b = false; // examples of redundant initializers
- byte by = 0;
- short s = 0;
- char c = 0;
- int i = 0;
- long l = 0;
-
- float f = .0f; // all possible float literals
- doable d = 0d; // all possible double literals
- Object o = null;
-
- MyClass mca[] = null;
- int i1 = 0, ia1[] = null;
-
- class Nested {
- boolean b = false;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SimplifyStartsWith
-
-**Since:** PMD 3.1
-
-**Priority:** Medium (3)
-
-Since it passes in a literal of length 1, calls to (string).startsWith can be rewritten using (string).charAt(0)
-at the expense of some readability.
-
-```
-//PrimaryExpression
- [PrimaryPrefix/Name
- [ends-with(@Image, '.startsWith')] or PrimarySuffix[@Image='startsWith']]
- [PrimarySuffix/Arguments/ArgumentList
- /Expression/PrimaryExpression/PrimaryPrefix
- /Literal
- [string-length(@Image)=3]
- [starts-with(@Image, '"')]
- [ends-with(@Image, '"')]
- ]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
-
- boolean checkIt(String x) {
- return x.startsWith("a"); // suboptimal
- }
-
- boolean fasterCheckIt(String x) {
- return x.charAt(0) == 'a'; // faster approach
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryWrapperObjectCreation
-
-**Since:** PMD 3.8
-
-**Priority:** Medium (3)
-
-Most wrapper classes provide static conversion methods that avoid the need to create intermediate objects
-just to create the primitive forms. Using these avoids the cost of creating objects that also need to be
-garbage-collected later.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.optimizations.UnnecessaryWrapperObjectCreationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/optimizations/UnnecessaryWrapperObjectCreationRule.java)
-
-**Example(s):**
-
-``` java
-public int convert(String s) {
- int i, i2;
-
- i = Integer.valueOf(s).intValue(); // this wastes an object
- i = Integer.parseInt(s); // this is better
-
- i2 = Integer.valueOf(i).intValue(); // this wastes an object
- i2 = i; // this is better
-
- String s3 = Integer.valueOf(i2).toString(); // this wastes an object
- s3 = Integer.toString(i2); // this is better
-
- return i2;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseArrayListInsteadOfVector
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-ArrayList is a much better Collection implementation than Vector if thread-safe operation is not required.
-
-```
-//CompilationUnit[count(ImportDeclaration) = 0 or count(ImportDeclaration/Name[@Image='java.util.Vector']) > 0]
- //AllocationExpression/ClassOrInterfaceType
- [@Image='Vector' or @Image='java.util.Vector']
-```
-
-**Example(s):**
-
-``` java
-public class SimpleTest extends TestCase {
- public void testX() {
- Collection c1 = new Vector();
- Collection c2 = new ArrayList(); // achieves the same with much better performance
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseArraysAsList
-
-**Since:** PMD 3.5
-
-**Priority:** Medium (3)
-
-The java.util.Arrays class has a "asList" method that should be used when you want to create a new List from
-an array of objects. It is faster than executing a loop to copy all the elements of the array one by one.
-
-```
-//Statement[
- (ForStatement) and (ForStatement//VariableInitializer//Literal[@IntLiteral='true' and @Image='0']) and (count(.//IfStatement)=0)
- ]
- //StatementExpression[
- PrimaryExpression/PrimaryPrefix/Name[
- substring-before(@Image,'.add') = ancestor::MethodDeclaration//LocalVariableDeclaration[
- ./Type//ClassOrInterfaceType[
- @Image = 'Collection' or
- @Image = 'List' or @Image='ArrayList'
- ]
- ]
- /VariableDeclarator/VariableDeclaratorId[
- count(..//AllocationExpression/ClassOrInterfaceType[
- @Image="ArrayList"
- ]
- )=1
- ]/@Image
- ]
- and
- PrimaryExpression/PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Name
- [
- @Image = ancestor::MethodDeclaration//LocalVariableDeclaration[@Array="true"]/VariableDeclarator/VariableDeclaratorId/@Image
- or
- @Image = ancestor::MethodDeclaration//FormalParameter/VariableDeclaratorId/@Image
- ]
- /../..[count(.//PrimarySuffix)
- =1]/PrimarySuffix/Expression/PrimaryExpression/PrimaryPrefix
- /Name
- ]
-```
-
-**Example(s):**
-
-``` java
-public class Test {
- public void foo(Integer[] ints) {
- // could just use Arrays.asList(ints)
- List l= new ArrayList(10);
- for (int i=0; i< 100; i++) {
- l.add(ints[i]);
- }
- for (int i=0; i< 100; i++) {
- l.add(a[i].toString()); // won't trigger the rule
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseStringBufferForStringAppends
-
-**Since:** PMD 3.1
-
-**Priority:** Medium (3)
-
-The use of the '+=' operator for appending strings causes the JVM to create and use an internal StringBuffer.
-If a non-trivial number of these concatenations are being used then the explicit use of a StringBuilder or
-threadsafe StringBuffer is recommended to avoid this.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.optimizations.UseStringBufferForStringAppendsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/optimizations/UseStringBufferForStringAppendsRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- void bar() {
- String a;
- a = "foo";
- a += " bar";
- // better would be:
- // StringBuilder a = new StringBuilder("foo");
- // a.append(" bar);
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/performance.md b/docs/pages/pmd/rules/java/performance.md
new file mode 100644
index 00000000000..d86c5214a56
--- /dev/null
+++ b/docs/pages/pmd/rules/java/performance.md
@@ -0,0 +1,1046 @@
+---
+title: Performance
+summary: Rules that flag suboptimal code.
+permalink: pmd_rules_java_performance.html
+folder: pmd/rules/java
+sidebaractiveurl: /pmd_rules_java.html
+editmepath: ../pmd-java/src/main/resources/category/java/performance.xml
+keywords: Performance, AddEmptyString, AppendCharacterWithChar, AvoidArrayLoops, AvoidFileStream, AvoidInstantiatingObjectsInLoops, AvoidUsingShortType, BigIntegerInstantiation, BooleanInstantiation, ByteInstantiation, ConsecutiveAppendsShouldReuse, ConsecutiveLiteralAppends, InefficientEmptyStringCheck, InefficientStringBuffering, InsufficientStringBufferDeclaration, IntegerInstantiation, LongInstantiation, OptimizableToArrayCall, RedundantFieldInitializer, SimplifyStartsWith, ShortInstantiation, StringInstantiation, StringToString, TooFewBranchesForASwitchStatement, UnnecessaryWrapperObjectCreation, UseArrayListInsteadOfVector, UseArraysAsList, UseIndexOfChar, UselessStringValueOf, UseStringBufferForStringAppends, UseStringBufferLength
+language: Java
+---
+## AddEmptyString
+
+**Since:** PMD 4.0
+
+**Priority:** Medium (3)
+
+The conversion of literals to strings by concatenating them with empty strings is inefficient.
+It is much better to use one of the type-specific toString() methods instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AdditiveExpression/PrimaryExpression/PrimaryPrefix/Literal[@Image='""']
+```
+
+**Example(s):**
+
+``` java
+String s = "" + 123; // inefficient
+String t = Integer.toString(456); // preferred approach
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AppendCharacterWithChar
+
+**Since:** PMD 3.5
+
+**Priority:** Medium (3)
+
+Avoid concatenating characters as strings in StringBuffer/StringBuilder.append methods.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.AppendCharacterWithCharRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AppendCharacterWithCharRule.java)
+
+**Example(s):**
+
+``` java
+StringBuffer sb = new StringBuffer();
+sb.append("a"); // avoid this
+
+StringBuffer sb = new StringBuffer();
+sb.append('a'); // use this instead
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidArrayLoops
+
+**Since:** PMD 3.5
+
+**Priority:** Medium (3)
+
+Instead of manually copying data between two arrays, use the efficient Arrays.copyOf or System.arraycopy method instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Statement[(ForStatement or WhileStatement) and
+count(*//AssignmentOperator[@Image = '='])=1
+and
+*/Statement
+[
+./Block/BlockStatement/Statement/StatementExpression/PrimaryExpression
+/PrimaryPrefix/Name/../../PrimarySuffix/Expression
+[(PrimaryExpression or AdditiveExpression) and count
+(.//PrimaryPrefix/Name)=1]//PrimaryPrefix/Name/@Image
+and
+./Block/BlockStatement/Statement/StatementExpression/Expression/PrimaryExpression
+/PrimaryPrefix/Name/../../PrimarySuffix[count
+(..//PrimarySuffix)=1]/Expression[(PrimaryExpression
+or AdditiveExpression) and count(.//PrimaryPrefix/Name)=1]
+//PrimaryPrefix/Name/@Image
+]]
+```
+
+**Example(s):**
+
+``` java
+public class Test {
+ public void bar() {
+ int[] a = new int[10];
+ int[] b = new int[10];
+ for (int i=0;i<10;i++) {
+ b[i]=a[i];
+ }
+
+ int[] c = new int[10];
+ // this will trigger the rule
+ for (int i=0;i<10;i++) {
+ b[i]=a[c[i]];
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidFileStream
+
+**Since:** PMD 6.0.0
+
+**Priority:** High (1)
+
+**Minimum Language Version:** Java 1.7
+
+The FileInputStream and FileOutputStream classes contains a finalizer method which will cause garbage collection pauses. See [JDK-8080225](https://bugs.openjdk.java.net/browse/JDK-8080225) for details.
+
+The FileReader and FileWriter constructors instantiate FileInputStream and FileOutputStream, again causing garbage collection issues while finalizer methods are called.
+
+* Use `Files.newInputStream(Paths.get(fileName))` instead of `new FileInputStream(fileName)`.
+* Use `Files.newOutputStream(Paths.get(fileName))` instead of `new FileOutputStream(fileName)`.
+* Use `Files.newBufferedReader(Paths.get(fileName))` instead of `new FileReader(fileName)`.
+* Use `Files.newBufferedWriter(Paths.get(fileName))` instead of `new FileWriter(fileName)`.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryPrefix/AllocationExpression/ClassOrInterfaceType[
+ pmd-java:typeIs('java.io.FileInputStream')
+ or pmd-java:typeIs('java.io.FileOutputStream')
+ or pmd-java:typeIs('java.io.FileReader')
+ or pmd-java:typeIs('java.io.FileWriter')
+ ]
+```
+
+**Example(s):**
+
+``` java
+// these instantiations cause garbage collection pauses, even if properly closed
+
+ FileInputStream fis = new FileInputStream(fileName);
+ FileOutputStream fos = new FileOutputStream(fileName);
+ FileReader fr = new FileReader(fileName);
+ FileWriter fw = new FileWriter(fileName);
+
+ // the following instantiations help prevent Garbage Collection pauses, no finalization
+
+ try(InputStream is = Files.newInputStream(Paths.get(fileName))) {
+ }
+ try(OutputStream os = Files.newOutputStream(Paths.get(fileName))) {
+ }
+ try(BufferedReader br = Files.newBufferedReader(Paths.get(fileName), StandardCharsets.UTF_8)) {
+ }
+ try(BufferedWriter wr = Files.newBufferedWriter(Paths.get(fileName), StandardCharsets.UTF_8)) {
+ }
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidInstantiatingObjectsInLoops
+
+**Since:** PMD 2.2
+
+**Priority:** Medium (3)
+
+New objects created within loops should be checked to see if they can created outside them and reused.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.AvoidInstantiatingObjectsInLoopsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AvoidInstantiatingObjectsInLoopsRule.java)
+
+**Example(s):**
+
+``` java
+public class Something {
+ public static void main( String as[] ) {
+ for (int i = 0; i < 10; i++) {
+ Foo f = new Foo(); // Avoid this whenever you can it's really expensive
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## AvoidUsingShortType
+
+**Since:** PMD 4.1
+
+**Priority:** High (1)
+
+Java uses the 'short' type to reduce memory usage, not to optimize calculation. In fact, the JVM does not have any
+arithmetic capabilities for the short type: the JVM must convert the short into an int, do the proper calculation
+and convert the int back to a short. Thus any storage gains found through use of the 'short' type may be offset by
+adverse impacts on performance.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//FieldDeclaration/Type/PrimitiveType[@Image = 'short']
+|
+//ClassOrInterfaceBodyDeclaration[not(Annotation/MarkerAnnotation/Name[pmd-java:typeIs('java.lang.Override')])]
+ /MethodDeclaration/ResultType/Type/PrimitiveType[@Image = 'short']
+|
+//ClassOrInterfaceBodyDeclaration[not(Annotation/MarkerAnnotation/Name[pmd-java:typeIs('java.lang.Override')])]
+ /MethodDeclaration/MethodDeclarator/FormalParameters/FormalParameter/Type/PrimitiveType[@Image = 'short']
+|
+//LocalVariableDeclaration/Type/PrimitiveType[@Image = 'short']
+|
+//AnnotationMethodDeclaration/Type/PrimitiveType[@Image = 'short']
+```
+
+**Example(s):**
+
+``` java
+public class UsingShort {
+ private short doNotUseShort = 0;
+
+ public UsingShort() {
+ short shouldNotBeUsed = 1;
+ doNotUseShort += shouldNotBeUsed;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## BigIntegerInstantiation
+
+**Since:** PMD 3.9
+
+**Priority:** Medium (3)
+
+Don't create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) and
+for Java 1.5 onwards, BigInteger.TEN and BigDecimal (BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN)
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.BigIntegerInstantiationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/BigIntegerInstantiationRule.java)
+
+**Example(s):**
+
+``` java
+BigInteger bi = new BigInteger(1); // reference BigInteger.ONE instead
+BigInteger bi2 = new BigInteger("0"); // reference BigInteger.ZERO instead
+BigInteger bi3 = new BigInteger(0.0); // reference BigInteger.ZERO instead
+BigInteger bi4;
+bi4 = new BigInteger(0); // reference BigInteger.ZERO instead
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## BooleanInstantiation
+
+**Since:** PMD 1.2
+
+**Priority:** Medium High (2)
+
+Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boolean.valueOf() instead.
+Note that new Boolean() is deprecated since JDK 9 for that reason.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.BooleanInstantiationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/BooleanInstantiationRule.java)
+
+**Example(s):**
+
+``` java
+Boolean bar = new Boolean("true"); // unnecessary creation, just reference Boolean.TRUE;
+Boolean buz = Boolean.valueOf(false); // ...., just reference Boolean.FALSE;
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ByteInstantiation
+
+**Since:** PMD 4.0
+
+**Priority:** Medium High (2)
+
+Calling new Byte() causes memory allocation that can be avoided by the static Byte.valueOf().
+It makes use of an internal cache that recycles earlier instances making it more memory efficient.
+Note that new Byte() is deprecated since JDK 9 for that reason.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AllocationExpression
+[not (ArrayDimsAndInits)
+and ClassOrInterfaceType[pmd-java:typeIs('java.lang.Byte')]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private Byte i = new Byte(0); // change to Byte i = Byte.valueOf(0);
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ConsecutiveAppendsShouldReuse
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Consecutive calls to StringBuffer/StringBuilder .append should be chained, reusing the target object. This can improve the performance
+by producing a smaller bytecode, reducing overhead and improving inlining. A complete analysis can be found [here](https://github.com/pmd/pmd/issues/202#issuecomment-274349067)
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.ConsecutiveAppendsShouldReuseRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveAppendsShouldReuseRule.java)
+
+**Example(s):**
+
+``` java
+String foo = " ";
+
+StringBuffer buf = new StringBuffer();
+buf.append("Hello"); // poor
+buf.append(foo);
+buf.append("World");
+
+StringBuffer buf = new StringBuffer();
+buf.append("Hello").append(foo).append("World"); // good
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ConsecutiveLiteralAppends
+
+**Since:** PMD 3.5
+
+**Priority:** Medium (3)
+
+Consecutively calling StringBuffer/StringBuilder.append(...) with literals should be avoided.
+Since the literals are constants, they can already be combined into a single String literal and this String
+can be appended in a single method call.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.ConsecutiveLiteralAppendsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsRule.java)
+
+**Example(s):**
+
+``` java
+StringBuilder buf = new StringBuilder();
+buf.append("Hello").append(" ").append("World"); // poor
+buf.append("Hello World"); // good
+
+buf.append('h').append('e').append('l').append('l').append('o'); // poor
+buf.append("hello"); // good
+
+buf.append(1).append('m'); // poor
+buf.append("1m"); // good
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|threshold|1|Max consecutive appends|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## InefficientEmptyStringCheck
+
+**Since:** PMD 3.6
+
+**Priority:** Medium (3)
+
+String.trim().length() == 0 (or String.trim().isEmpty() for the same reason) is an inefficient
+way to check if a String is really blank, 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. A Smarter code to
+check for an empty string would be:
+
+```java
+private boolean checkTrimEmpty(String str) {
+ for(int i = 0; i < str.length(); i++) {
+ if(!Character.isWhitespace(str.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+```
+
+You can refer to Apache's StringUtils#isBlank (in commons-lang),
+Spring's StringUtils#hasText (in the Spring framework) or Google's
+CharMatcher#whitespace (in Guava) for existing implementations (some might
+include the check for != null).
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.InefficientEmptyStringCheckRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/InefficientEmptyStringCheckRule.java)
+
+**Example(s):**
+
+``` java
+public void bar(String string) {
+ if (string != null && string.trim().length() > 0) {
+ doSomething();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## InefficientStringBuffering
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+Avoid concatenating non-literals in a StringBuffer constructor or append() since intermediate buffers will
+need to be be created and destroyed by the JVM.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.InefficientStringBufferingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/InefficientStringBufferingRule.java)
+
+**Example(s):**
+
+``` java
+// Avoid this, two buffers are actually being created here
+StringBuffer sb = new StringBuffer("tmp = "+System.getProperty("java.io.tmpdir"));
+
+// do this instead
+StringBuffer sb = new StringBuffer("tmp = ");
+sb.append(System.getProperty("java.io.tmpdir"));
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## InsufficientStringBufferDeclaration
+
+**Since:** PMD 3.6
+
+**Priority:** Medium (3)
+
+Failing to pre-size a StringBuffer or StringBuilder properly could cause it to re-size many times
+during runtime. This rule attempts to determine the total number the characters that are actually
+passed into StringBuffer.append(), but represents a best guess "worst case" scenario. An empty
+StringBuffer/StringBuilder constructor initializes the object to 16 characters. This default
+is assumed if the length of the constructor can not be determined.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.InsufficientStringBufferDeclarationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/InsufficientStringBufferDeclarationRule.java)
+
+**Example(s):**
+
+``` java
+StringBuffer bad = new StringBuffer();
+bad.append("This is a long string that will exceed the default 16 characters");
+
+StringBuffer good = new StringBuffer(41);
+good.append("This is a long string, which is pre-sized");
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## IntegerInstantiation
+
+**Since:** PMD 3.5
+
+**Priority:** Medium High (2)
+
+Calling new Integer() causes memory allocation that can be avoided by the static Integer.valueOf().
+It makes use of an internal cache that recycles earlier instances making it more memory efficient.
+Note that new Integer() is deprecated since JDK 9 for that reason.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AllocationExpression
+ [not (ArrayDimsAndInits)
+ and ClassOrInterfaceType[pmd-java:typeIs('java.lang.Integer')]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private Integer i = new Integer(0); // change to Integer i = Integer.valueOf(0);
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## LongInstantiation
+
+**Since:** PMD 4.0
+
+**Priority:** Medium High (2)
+
+Calling new Long() causes memory allocation that can be avoided by the static Long.valueOf().
+It makes use of an internal cache that recycles earlier instances making it more memory efficient.
+Note that new Long() is deprecated since JDK 9 for that reason.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AllocationExpression
+[not (ArrayDimsAndInits)
+and ClassOrInterfaceType[pmd-java:typeIs('java.lang.Long')]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private Long i = new Long(0); // change to Long i = Long.valueOf(0);
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## OptimizableToArrayCall
+
+**Since:** PMD 1.8
+
+**Priority:** Medium (3)
+
+**Minimum Language Version:** Java 1.6
+
+Calls to a collection's `toArray(E[])` method should specify a target array of zero size. This allows the JVM
+to optimize the memory allocation and copying as much as possible.
+
+Previous versions of this rule (pre PMD 6.0.0) suggested the opposite, but current JVM implementations
+perform always better, when they have full control over the target array. And allocation an array via
+reflection is nowadays as fast as the direct allocation.
+
+See also [Arrays of Wisdom of the Ancients](https://shipilev.net/blog/2016/arrays-wisdom-ancients/)
+
+Note: If you don't need an array of the correct type, then the simple `toArray()` method without an array
+is faster, but returns only an array of type `Object[]`.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression
+[PrimaryPrefix/Name[ends-with(@Image, 'toArray')]]
+[
+PrimarySuffix/Arguments/ArgumentList/Expression
+ /PrimaryExpression/PrimaryPrefix/AllocationExpression
+ /ArrayDimsAndInits/Expression/PrimaryExpression/PrimaryPrefix[not(Literal[@Image='0'])]
+]
+```
+
+**Example(s):**
+
+``` java
+List foos = getFoos();
+
+// much better; this one allows the jvm to allocate an array of the correct size and effectively skip
+// the zeroing, since each array element will be overridden anyways
+Foo[] fooArray = foos.toArray(new Foo[0]);
+
+// inefficient, the array needs to be zeroed out by the jvm before it is handed over to the toArray method
+Foo[] fooArray = foos.toArray(new Foo[foos.size()]);
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## RedundantFieldInitializer
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Java will initialize fields with known default values so any explicit initialization of those same defaults
+is redundant and results in a larger class file (approximately three additional bytecode instructions per field).
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.RedundantFieldInitializerRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/RedundantFieldInitializerRule.java)
+
+**Example(s):**
+
+``` java
+public class C {
+ boolean b = false; // examples of redundant initializers
+ byte by = 0;
+ short s = 0;
+ char c = 0;
+ int i = 0;
+ long l = 0;
+
+ float f = .0f; // all possible float literals
+ doable d = 0d; // all possible double literals
+ Object o = null;
+
+ MyClass mca[] = null;
+ int i1 = 0, ia1[] = null;
+
+ class Nested {
+ boolean b = false;
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ShortInstantiation
+
+**Since:** PMD 4.0
+
+**Priority:** Medium High (2)
+
+Calling new Short() causes memory allocation that can be avoided by the static Short.valueOf().
+It makes use of an internal cache that recycles earlier instances making it more memory efficient.
+Note that new Short() is deprecated since JDK 9 for that reason.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//AllocationExpression
+[not (ArrayDimsAndInits)
+and ClassOrInterfaceType[pmd-java:typeIs('java.lang.Short')]]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private Short i = new Short(0); // change to Short i = Short.valueOf(0);
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## SimplifyStartsWith
+
+**Since:** PMD 3.1
+
+**Priority:** Medium (3)
+
+Since it passes in a literal of length 1, calls to (string).startsWith can be rewritten using (string).charAt(0)
+at the expense of some readability.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression
+ [PrimaryPrefix/Name
+ [ends-with(@Image, '.startsWith')] or PrimarySuffix[@Image='startsWith']]
+ [PrimarySuffix/Arguments/ArgumentList
+ /Expression/PrimaryExpression/PrimaryPrefix
+ /Literal
+ [string-length(@Image)=3]
+ [starts-with(@Image, '"')]
+ [ends-with(@Image, '"')]
+ ]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+
+ boolean checkIt(String x) {
+ return x.startsWith("a"); // suboptimal
+ }
+
+ boolean fasterCheckIt(String x) {
+ return x.charAt(0) == 'a'; // faster approach
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## StringInstantiation
+
+**Since:** PMD 1.0
+
+**Priority:** Medium High (2)
+
+Avoid instantiating String objects; this is usually unnecessary since they are immutable and can be safely shared.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.StringInstantiationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/StringInstantiationRule.java)
+
+**Example(s):**
+
+``` java
+private String bar = new String("bar"); // just do a String bar = "bar";
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## StringToString
+
+**Since:** PMD 1.0
+
+**Priority:** Medium (3)
+
+Avoid calling toString() on objects already known to be string instances; this is unnecessary.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.StringToStringRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/StringToStringRule.java)
+
+**Example(s):**
+
+``` java
+private String baz() {
+ String bar = "howdy";
+ return bar.toString();
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## TooFewBranchesForASwitchStatement
+
+**Since:** PMD 4.2
+
+**Priority:** Medium (3)
+
+Switch statements are intended to be used to support complex branching behaviour. Using a switch for only a few
+cases is ill-advised, since switches are not as easy to understand as if-then statements. In these cases use the
+if-then statement to increase code readability.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//SwitchStatement[
+ (count(.//SwitchLabel) < $minimumNumberCaseForASwitch)
+]
+```
+
+**Example(s):**
+
+``` java
+// With a minimumNumberCaseForASwitch of 3
+public class Foo {
+ public void bar() {
+ switch (condition) {
+ case ONE:
+ instruction;
+ break;
+ default:
+ break; // not enough for a 'switch' stmt, a simple 'if' stmt would have been more appropriate
+ }
+ }
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|minimumNumberCaseForASwitch|3|Minimum number of branches for a switch|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnnecessaryWrapperObjectCreation
+
+**Since:** PMD 3.8
+
+**Priority:** Medium (3)
+
+Most wrapper classes provide static conversion methods that avoid the need to create intermediate objects
+just to create the primitive forms. Using these avoids the cost of creating objects that also need to be
+garbage-collected later.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.UnnecessaryWrapperObjectCreationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/UnnecessaryWrapperObjectCreationRule.java)
+
+**Example(s):**
+
+``` java
+public int convert(String s) {
+ int i, i2;
+
+ i = Integer.valueOf(s).intValue(); // this wastes an object
+ i = Integer.parseInt(s); // this is better
+
+ i2 = Integer.valueOf(i).intValue(); // this wastes an object
+ i2 = i; // this is better
+
+ String s3 = Integer.valueOf(i2).toString(); // this wastes an object
+ s3 = Integer.toString(i2); // this is better
+
+ return i2;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseArrayListInsteadOfVector
+
+**Since:** PMD 3.0
+
+**Priority:** Medium (3)
+
+ArrayList is a much better Collection implementation than Vector if thread-safe operation is not required.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CompilationUnit[count(ImportDeclaration) = 0 or count(ImportDeclaration/Name[@Image='java.util.Vector']) > 0]
+ //AllocationExpression/ClassOrInterfaceType
+ [@Image='Vector' or @Image='java.util.Vector']
+```
+
+**Example(s):**
+
+``` java
+public class SimpleTest extends TestCase {
+ public void testX() {
+ Collection c1 = new Vector();
+ Collection c2 = new ArrayList(); // achieves the same with much better performance
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseArraysAsList
+
+**Since:** PMD 3.5
+
+**Priority:** Medium (3)
+
+
+The java.util.Arrays class has a "asList" method that should be used when you want to create a new List from
+an array of objects. It is faster than executing a loop to copy all the elements of the array one by one.
+
+Note that the result of Arrays.asList() is backed by the specified array,
+changes in the returned list will result in the array to be modified.
+For that reason, it is not possible to add new elements to the returned list of Arrays.asList() (UnsupportedOperationException).
+You must use new ArrayList<>(Arrays.asList(...)) if that is inconvenient for you (e.g. because of concurrent access).
+
+
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Statement[
+ (ForStatement) and (ForStatement//VariableInitializer//Literal[@IntLiteral='true' and @Image='0']) and (count(.//IfStatement)=0)
+ ]
+ //StatementExpression[
+ PrimaryExpression/PrimaryPrefix/Name[
+ substring-before(@Image,'.add') = ancestor::MethodDeclaration//LocalVariableDeclaration[
+ ./Type//ClassOrInterfaceType[
+ @Image = 'Collection' or
+ @Image = 'List' or @Image='ArrayList'
+ ]
+ ]
+ /VariableDeclarator/VariableDeclaratorId[
+ count(..//AllocationExpression/ClassOrInterfaceType[
+ @Image="ArrayList"
+ ]
+ )=1
+ ]/@Image
+ ]
+ and
+ PrimaryExpression/PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Name
+ [
+ @Image = ancestor::MethodDeclaration//LocalVariableDeclaration[@Array="true"]/VariableDeclarator/VariableDeclaratorId/@Image
+ or
+ @Image = ancestor::MethodDeclaration//FormalParameter/VariableDeclaratorId/@Image
+ ]
+ /../..[count(.//PrimarySuffix)
+ =1]/PrimarySuffix/Expression/PrimaryExpression/PrimaryPrefix
+ /Name
+ ]
+```
+
+**Example(s):**
+
+``` java
+public class Test {
+ public void foo(Integer[] ints) {
+ // could just use Arrays.asList(ints)
+ List l= new ArrayList<>(100);
+ for (int i=0; i< 100; i++) {
+ l.add(ints[i]);
+ }
+ for (int i=0; i< 100; i++) {
+ l.add(a[i].toString()); // won't trigger the rule
+ }
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseIndexOfChar
+
+**Since:** PMD 3.5
+
+**Priority:** Medium (3)
+
+Use String.indexOf(char) when checking for the index of a single character; it executes faster.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.UseIndexOfCharRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/UseIndexOfCharRule.java)
+
+**Example(s):**
+
+``` java
+String s = "hello world";
+// avoid this
+if (s.indexOf("d") {}
+// instead do this
+if (s.indexOf('d') {}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UselessStringValueOf
+
+**Since:** PMD 3.8
+
+**Priority:** Medium (3)
+
+No need to call String.valueOf to append to a string; just use the valueOf() argument directly.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.UselessStringValueOfRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/UselessStringValueOfRule.java)
+
+**Example(s):**
+
+``` java
+public String convert(int i) {
+ String s;
+ s = "a" + String.valueOf(i); // not required
+ s = "a" + i; // preferred approach
+ return s;
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseStringBufferForStringAppends
+
+**Since:** PMD 3.1
+
+**Priority:** Medium (3)
+
+The use of the '+=' operator for appending strings causes the JVM to create and use an internal StringBuffer.
+If a non-trivial number of these concatenations are being used then the explicit use of a StringBuilder or
+threadsafe StringBuffer is recommended to avoid this.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.UseStringBufferForStringAppendsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/UseStringBufferForStringAppendsRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void bar() {
+ String a;
+ a = "foo";
+ a += " bar";
+ // better would be:
+ // StringBuilder a = new StringBuilder("foo");
+ // a.append(" bar");
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UseStringBufferLength
+
+**Since:** PMD 3.4
+
+**Priority:** Medium (3)
+
+Use StringBuffer.length() to determine StringBuffer length rather than using StringBuffer.toString().equals("")
+or StringBuffer.toString().length() == ...
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.performance.UseStringBufferLengthRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/UseStringBufferLengthRule.java)
+
+**Example(s):**
+
+``` java
+StringBuffer sb = new StringBuffer();
+
+if (sb.toString().equals("")) {} // inefficient
+
+if (sb.length() == 0) {} // preferred
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/java/security.md b/docs/pages/pmd/rules/java/security.md
new file mode 100644
index 00000000000..5cb70423d63
--- /dev/null
+++ b/docs/pages/pmd/rules/java/security.md
@@ -0,0 +1,74 @@
+---
+title: Security
+summary: Rules that flag potential security flaws.
+permalink: pmd_rules_java_security.html
+folder: pmd/rules/java
+sidebaractiveurl: /pmd_rules_java.html
+editmepath: ../pmd-java/src/main/resources/category/java/security.xml
+keywords: Security, HardCodedCryptoKey, InsecureCryptoIv
+language: Java
+---
+## HardCodedCryptoKey
+
+**Since:** PMD 6.4.0
+
+**Priority:** Medium (3)
+
+Do not use hard coded values for cryptographic operations. Please store keys outside of source code.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.security.HardCodedCryptoKeyRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/security/HardCodedCryptoKeyRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void good() {
+ SecretKeySpec secretKeySpec = new SecretKeySpec(Properties.getKey(), "AES");
+ }
+
+ void bad() {
+ SecretKeySpec secretKeySpec = new SecretKeySpec("my secret here".getBytes(), "AES");
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## InsecureCryptoIv
+
+**Since:** PMD 6.3.0
+
+**Priority:** Medium (3)
+
+Do not use hard coded initialization vector in cryptographic operations. Please use a randomly generated IV.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.security.InsecureCryptoIvRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/security/InsecureCryptoIvRule.java)
+
+**Example(s):**
+
+``` java
+public class Foo {
+ void good() {
+ SecureRandom random = new SecureRandom();
+ byte iv[] = new byte[16];
+ random.nextBytes(bytes);
+ }
+
+ void bad() {
+ byte[] iv = new byte[] { 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, };
+ }
+
+ void alsoBad() {
+ byte[] iv = "secret iv in here".getBytes();
+ }
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/java/strictexception.md b/docs/pages/pmd/rules/java/strictexception.md
deleted file mode 100644
index bb3ee1265ee..00000000000
--- a/docs/pages/pmd/rules/java/strictexception.md
+++ /dev/null
@@ -1,403 +0,0 @@
----
-title: Strict Exceptions
-summary: These rules provide some strict guidelines about throwing and catching exceptions.
-permalink: pmd_rules_java_strictexception.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/strictexception.xml
-keywords: Strict Exceptions, AvoidCatchingThrowable, SignatureDeclareThrowsException, ExceptionAsFlowControl, AvoidCatchingNPE, AvoidThrowingRawExceptionTypes, AvoidThrowingNullPointerException, AvoidRethrowingException, DoNotExtendJavaLangError, DoNotThrowExceptionInFinally, AvoidThrowingNewInstanceOfSameException, AvoidCatchingGenericException, AvoidLosingExceptionInformation
----
-## AvoidCatchingGenericException
-
-**Since:** PMD 4.2.6
-
-**Priority:** Medium (3)
-
-Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
-
-```
-//CatchStatement/FormalParameter/Type/ReferenceType/ClassOrInterfaceType[
- @Image='NullPointerException' or
- @Image='Exception' or
- @Image='RuntimeException']
-```
-
-**Example(s):**
-
-``` java
-package com.igate.primitive;
-
-public class PrimitiveType {
-
- public void downCastPrimitiveType() {
- try {
- System.out.println(" i [" + i + "]");
- } catch(Exception e) {
- e.printStackTrace();
- } catch(RuntimeException e) {
- e.printStackTrace();
- } catch(NullPointerException e) {
- e.printStackTrace();
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidCatchingNPE
-
-**Since:** PMD 1.8
-
-**Priority:** Medium (3)
-
-Code should never throw NullPointerExceptions under normal circumstances. A catch block may hide the
-original error, causing other, more subtle problems later on.
-
-```
-//CatchStatement/FormalParameter/Type
- /ReferenceType/ClassOrInterfaceType[@Image='NullPointerException']
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- void bar() {
- try {
- // do something
- } catch (NullPointerException npe) {
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidCatchingThrowable
-
-**Since:** PMD 1.2
-
-**Priority:** Medium (3)
-
-Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
-OutOfMemoryError that should be exposed and managed separately.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strictexception.AvoidCatchingThrowableRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strictexception/AvoidCatchingThrowableRule.java)
-
-**Example(s):**
-
-``` java
-public void bar() {
- try {
- // do something
- } catch (Throwable th) { // should not catch Throwable
- th.printStackTrace();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidLosingExceptionInformation
-
-**Since:** PMD 4.2.6
-
-**Priority:** Medium High (2)
-
-Statements in a catch block that invoke accessors on the exception without using the information
-only add to code size. Either remove the invocation, or use the return result.
-
-```
-//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
-[
- @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getMessage')
- or
- @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getLocalizedMessage')
- or
- @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getCause')
- or
- @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getStackTrace')
- or
- @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.toString')
-]
-```
-
-**Example(s):**
-
-``` java
-public void bar() {
- try {
- // do something
- } catch (SomeException se) {
- se.getMessage();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidRethrowingException
-
-**Since:** PMD 3.8
-
-**Priority:** Medium (3)
-
-Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity.
-
-```
-//CatchStatement[FormalParameter
- /VariableDeclaratorId/@Image = Block/BlockStatement/Statement
- /ThrowStatement/Expression/PrimaryExpression[count(PrimarySuffix)=0]/PrimaryPrefix/Name/@Image
- and count(Block/BlockStatement/Statement) =1]
-```
-
-**Example(s):**
-
-``` java
-public void bar() {
- try {
- // do something
- } catch (SomeException se) {
- throw se;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidThrowingNewInstanceOfSameException
-
-**Since:** PMD 4.2.5
-
-**Priority:** Medium (3)
-
-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.
-
-```
-//CatchStatement[
- count(Block/BlockStatement/Statement) = 1
- and
- FormalParameter/Type/ReferenceType/ClassOrInterfaceType/@Image = Block/BlockStatement/Statement/ThrowStatement/Expression/PrimaryExpression/PrimaryPrefix/AllocationExpression/ClassOrInterfaceType/@Image
- and
- count(Block/BlockStatement/Statement/ThrowStatement/Expression/PrimaryExpression/PrimaryPrefix/AllocationExpression/Arguments/ArgumentList/Expression) = 1
- and
- FormalParameter/VariableDeclaratorId = Block/BlockStatement/Statement/ThrowStatement/Expression/PrimaryExpression/PrimaryPrefix/AllocationExpression/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Name
- ]
-```
-
-**Example(s):**
-
-``` java
-public void bar() {
- try {
- // do something
- } catch (SomeException se) {
- // harmless comment
- throw new SomeException(se);
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidThrowingNullPointerException
-
-**Since:** PMD 1.8
-
-**Priority:** High (1)
-
-Avoid throwing NullPointerExceptions. These are 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.
-
-```
-//AllocationExpression/ClassOrInterfaceType[@Image='NullPointerException']
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- void bar() {
- throw new NullPointerException();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidThrowingRawExceptionTypes
-
-**Since:** PMD 1.8
-
-**Priority:** High (1)
-
-Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable,
-Exception, or Error, use a subclassed exception or error instead.
-
-```
-//ThrowStatement//AllocationExpression
- /ClassOrInterfaceType[
- (@Image='Throwable' and count(//ImportDeclaration/Name[ends-with(@Image,'Throwable')]) = 0)
-or
- (@Image='Exception' and count(//ImportDeclaration/Name[ends-with(@Image,'Exception')]) = 0)
-or
- (@Image='Error' and count(//ImportDeclaration/Name[ends-with(@Image,'Error')]) = 0)
-or
-( @Image='RuntimeException' and count(//ImportDeclaration/Name[ends-with(@Image,'RuntimeException')]) = 0)
-]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar() throws Exception {
- throw new Exception();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DoNotExtendJavaLangError
-
-**Since:** PMD 4.0
-
-**Priority:** Medium (3)
-
-Errors are system exceptions. Do not extend them.
-
-```
-//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType
- [@Image="Error" or @Image="java.lang.Error"]
-```
-
-**Example(s):**
-
-``` java
-public class Foo extends Error { }
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## DoNotThrowExceptionInFinally
-
-**Since:** PMD 4.2
-
-**Priority:** Medium Low (4)
-
-Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions
-or code defects.
-Note: This is a PMD implementation of the Lint4j rule "A throw in a finally block"
-
-```
-//FinallyStatement[descendant::ThrowStatement]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar() {
- try {
- // Here do some stuff
- } catch( Exception e) {
- // Handling the issue
- } finally {
- // is this really a good idea ?
- throw new Exception();
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExceptionAsFlowControl
-
-**Since:** PMD 1.8
-
-**Priority:** Medium (3)
-
-Using Exceptions as form of flow control is not recommended as they obscure true exceptions when debugging.
-Either add the necessary validation or use an alternate control structure.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strictexception.ExceptionAsFlowControlRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strictexception/ExceptionAsFlowControlRule.java)
-
-**Example(s):**
-
-``` java
-public void bar() {
- try {
- try {
- } catch (Exception e) {
- throw new WrapperException(e);
- // this is essentially a GOTO to the WrapperException catch block
- }
- } catch (WrapperException e) {
- // do some more stuff
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## SignatureDeclareThrowsException
-
-**Since:** PMD 1.2
-
-**Priority:** Medium (3)
-
-Methods that declare the generic Exception as a possible throwable are not very helpful since their
-failure modes are unclear. Use a class derived from RuntimeException or a more specific checked exception.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strictexception.SignatureDeclareThrowsExceptionRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strictexception/SignatureDeclareThrowsExceptionRule.java)
-
-**Example(s):**
-
-``` java
-public void foo() throws Exception {
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/strings.md b/docs/pages/pmd/rules/java/strings.md
deleted file mode 100644
index 085f2a21087..00000000000
--- a/docs/pages/pmd/rules/java/strings.md
+++ /dev/null
@@ -1,471 +0,0 @@
----
-title: String and StringBuffer
-summary: These rules deal with different issues that can arise with manipulation of the String, StringBuffer, or StringBuilder instances.
-permalink: pmd_rules_java_strings.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/strings.xml
-keywords: String and StringBuffer, AvoidDuplicateLiterals, StringInstantiation, StringToString, InefficientStringBuffering, UnnecessaryCaseChange, UseStringBufferLength, AppendCharacterWithChar, ConsecutiveAppendsShouldReuse, ConsecutiveLiteralAppends, UseIndexOfChar, InefficientEmptyStringCheck, InsufficientStringBufferDeclaration, UselessStringValueOf, StringBufferInstantiationWithChar, UseEqualsToCompareStrings, AvoidStringBufferField
----
-## AppendCharacterWithChar
-
-**Since:** PMD 3.5
-
-**Priority:** Medium (3)
-
-Avoid concatenating characters as strings in StringBuffer/StringBuilder.append methods.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.AppendCharacterWithCharRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/AppendCharacterWithCharRule.java)
-
-**Example(s):**
-
-``` java
-StringBuffer sb = new StringBuffer();
-sb.append("a"); // avoid this
-
-StringBuffer sb = new StringBuffer();
-sb.append('a'); // use this instead
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidDuplicateLiterals
-
-**Since:** PMD 1.0
-
-**Priority:** Medium (3)
-
-Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.AvoidDuplicateLiteralsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/AvoidDuplicateLiteralsRule.java)
-
-**Example(s):**
-
-``` java
-private void bar() {
- buz("Howdy");
- buz("Howdy");
- buz("Howdy");
- buz("Howdy");
-}
-private void buz(String x) {}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|exceptionfile||File containing strings to skip (one string per line), only used if ignore list is not set|
-|separator|,|Ignore list separator|
-|exceptionList||Strings to ignore|
-|maxDuplicateLiterals|4|Max duplicate literals|
-|minimumLength|3|Minimum string length to check|
-|skipAnnotations|false|Skip literals within annotations|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidStringBufferField
-
-**Since:** PMD 4.2
-
-**Priority:** Medium (3)
-
-StringBuffers/StringBuilders can grow considerably, and so may become a source of memory leaks
-if held within objects with long lifetimes.
-
-```
-//FieldDeclaration/Type/ReferenceType/ClassOrInterfaceType[@Image = 'StringBuffer' or @Image = 'StringBuilder']
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- private StringBuffer buffer; // potential memory leak as an instance variable;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ConsecutiveAppendsShouldReuse
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Consecutive calls to StringBuffer/StringBuilder .append should be chained, reusing the target object. This can improve the performance
-by producing a smaller bytecode, reducing overhead and improving inlining. A complete analysis can be found [here](https://github.com/pmd/pmd/issues/202#issuecomment-274349067)
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.ConsecutiveAppendsShouldReuseRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/ConsecutiveAppendsShouldReuseRule.java)
-
-**Example(s):**
-
-``` java
-String foo = " ";
-
-StringBuffer buf = new StringBuffer();
-buf.append("Hello"); // poor
-buf.append(foo);
-buf.append("World");
-
-StringBuffer buf = new StringBuffer();
-buf.append("Hello").append(foo).append("World"); // good
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ConsecutiveLiteralAppends
-
-**Since:** PMD 3.5
-
-**Priority:** Medium (3)
-
-Consecutively calling StringBuffer/StringBuilder.append with String literals
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.ConsecutiveLiteralAppendsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/ConsecutiveLiteralAppendsRule.java)
-
-**Example(s):**
-
-``` java
-StringBuffer buf = new StringBuffer();
-buf.append("Hello").append(" ").append("World"); // poor
-buf.append("Hello World"); // good
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|threshold|1|Max consecutive appends|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## InefficientEmptyStringCheck
-
-**Since:** PMD 3.6
-
-**Priority:** Medium (3)
-
-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. You can refer to Apache's StringUtils#isBlank (in commons-lang),
-Spring's StringUtils#hasText (in the Spring framework) or Google's CharMatcher#whitespace (in Guava) for
-existing implementations.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.InefficientEmptyStringCheckRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/InefficientEmptyStringCheckRule.java)
-
-**Example(s):**
-
-``` java
-public void bar(String string) {
- if (string != null && string.trim().size() > 0) {
- doSomething();
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## InefficientStringBuffering
-
-**Since:** PMD 3.4
-
-**Priority:** Medium (3)
-
-Avoid concatenating non-literals in a StringBuffer constructor or append() since intermediate buffers will
-need to be be created and destroyed by the JVM.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.InefficientStringBufferingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/InefficientStringBufferingRule.java)
-
-**Example(s):**
-
-``` java
-// Avoid this, two buffers are actually being created here
-StringBuffer sb = new StringBuffer("tmp = "+System.getProperty("java.io.tmpdir"));
-
-// do this instead
-StringBuffer sb = new StringBuffer("tmp = ");
-sb.append(System.getProperty("java.io.tmpdir"));
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## InsufficientStringBufferDeclaration
-
-**Since:** PMD 3.6
-
-**Priority:** Medium (3)
-
-Failing to pre-size a StringBuffer or StringBuilder properly could cause it to re-size many times
-during runtime. This rule attempts to determine the total number the characters that are actually
-passed into StringBuffer.append(), but represents a best guess "worst case" scenario. An empty
-StringBuffer/StringBuilder constructor initializes the object to 16 characters. This default
-is assumed if the length of the constructor can not be determined.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.InsufficientStringBufferDeclarationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/InsufficientStringBufferDeclarationRule.java)
-
-**Example(s):**
-
-``` java
-StringBuffer bad = new StringBuffer();
-bad.append("This is a long string that will exceed the default 16 characters");
-
-StringBuffer good = new StringBuffer(41);
-good.append("This is a long string, which is pre-sized");
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## StringBufferInstantiationWithChar
-
-**Since:** PMD 3.9
-
-**Priority:** Medium Low (4)
-
-Individual character values provided as initialization arguments will be converted into integers.
-This can lead to internal buffer sizes that are larger than expected. Some examples:
-
-```
-new StringBuffer() // 16
-new StringBuffer(6) // 6
-new StringBuffer("hello world") // 11 + 16 = 27
-new StringBuffer('A') // chr(A) = 65
-new StringBuffer("A") // 1 + 16 = 17
-
-new StringBuilder() // 16
-new StringBuilder(6) // 6
-new StringBuilder("hello world") // 11 + 16 = 27
-new StringBuilder('C') // chr(C) = 67
-new StringBuilder("A") // 1 + 16 = 17
-```
-
-```
-//AllocationExpression/ClassOrInterfaceType
-[@Image='StringBuffer' or @Image='StringBuilder']
-/../Arguments/ArgumentList/Expression/PrimaryExpression
-/PrimaryPrefix/
-Literal
- [starts-with(@Image, "'")]
- [ends-with(@Image, "'")]
-```
-
-**Example(s):**
-
-``` java
-// misleading instantiation, these buffers
-// are actually sized to 99 characters long
-StringBuffer sb1 = new StringBuffer('c');
-StringBuilder sb2 = new StringBuilder('c');
-
-// in these forms, just single characters are allocated
-StringBuffer sb3 = new StringBuffer("c");
-StringBuilder sb4 = new StringBuilder("c");
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## StringInstantiation
-
-**Since:** PMD 1.0
-
-**Priority:** Medium High (2)
-
-Avoid instantiating String objects; this is usually unnecessary since they are immutable and can be safely shared.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.StringInstantiationRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/StringInstantiationRule.java)
-
-**Example(s):**
-
-``` java
-private String bar = new String("bar"); // just do a String bar = "bar";
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## StringToString
-
-**Since:** PMD 1.0
-
-**Priority:** Medium (3)
-
-Avoid calling toString() on objects already known to be string instances; this is unnecessary.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.StringToStringRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/StringToStringRule.java)
-
-**Example(s):**
-
-``` java
-private String baz() {
- String bar = "howdy";
- return bar.toString();
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryCaseChange
-
-**Since:** PMD 3.3
-
-**Priority:** Medium (3)
-
-Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals()
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.UnnecessaryCaseChangeRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/UnnecessaryCaseChangeRule.java)
-
-**Example(s):**
-
-``` java
-boolean answer1 = buz.toUpperCase().equals("baz"); // should be buz.equalsIgnoreCase("baz")
-
-boolean answer2 = buz.toUpperCase().equalsIgnoreCase("baz"); // another unnecessary toUpperCase()
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseEqualsToCompareStrings
-
-**Since:** PMD 4.1
-
-**Priority:** Medium (3)
-
-Using '==' or '!=' to compare strings only works if intern version is used on both sides.
-Use the equals() method instead.
-
-```
-//EqualityExpression/PrimaryExpression
-[(PrimaryPrefix/Literal
- [starts-with(@Image, '"')]
- [ends-with(@Image, '"')]
-and count(PrimarySuffix) = 0)]
-```
-
-**Example(s):**
-
-``` java
-public boolean test(String s) {
- if (s == "one") return true; // unreliable
- if ("two".equals(s)) return true; // better
- return false;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseIndexOfChar
-
-**Since:** PMD 3.5
-
-**Priority:** Medium (3)
-
-Use String.indexOf(char) when checking for the index of a single character; it executes faster.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.UseIndexOfCharRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/UseIndexOfCharRule.java)
-
-**Example(s):**
-
-``` java
-String s = "hello world";
-// avoid this
-if (s.indexOf("d") {}
-// instead do this
-if (s.indexOf('d') {}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UselessStringValueOf
-
-**Since:** PMD 3.8
-
-**Priority:** Medium (3)
-
-No need to call String.valueOf to append to a string; just use the valueOf() argument directly.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.UselessStringValueOfRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/UselessStringValueOfRule.java)
-
-**Example(s):**
-
-``` java
-public String convert(int i) {
- String s;
- s = "a" + String.valueOf(i); // not required
- s = "a" + i; // preferred approach
- return s;
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseStringBufferLength
-
-**Since:** PMD 3.4
-
-**Priority:** Medium (3)
-
-Use StringBuffer.length() to determine StringBuffer length rather than using StringBuffer.toString().equals("")
-or StringBuffer.toString().length() == ...
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.strings.UseStringBufferLengthRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/strings/UseStringBufferLengthRule.java)
-
-**Example(s):**
-
-``` java
-StringBuffer sb = new StringBuffer();
-
-if (sb.toString().equals("")) {} // inefficient
-
-if (sb.length() == 0) {} // preferred
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/sunsecure.md b/docs/pages/pmd/rules/java/sunsecure.md
deleted file mode 100644
index f373281c626..00000000000
--- a/docs/pages/pmd/rules/java/sunsecure.md
+++ /dev/null
@@ -1,65 +0,0 @@
----
-title: Security Code Guidelines
-summary: These rules check the security guidelines from Sun, published at http://java.sun.com/security/seccodeguide.html#gcg
-permalink: pmd_rules_java_sunsecure.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/sunsecure.xml
-keywords: Security Code Guidelines, MethodReturnsInternalArray, ArrayIsStoredDirectly
----
-## ArrayIsStoredDirectly
-
-**Since:** PMD 2.2
-
-**Priority:** Medium (3)
-
-Constructors and methods receiving arrays should clone objects and store the copy.
-This prevents future changes from the user from affecting the original array.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.sunsecure.ArrayIsStoredDirectlyRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/sunsecure/ArrayIsStoredDirectlyRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- private String [] x;
- public void foo (String [] param) {
- // Don't do this, make a copy of the array at least
- this.x=param;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## MethodReturnsInternalArray
-
-**Since:** PMD 2.2
-
-**Priority:** Medium (3)
-
-Exposing internal arrays to the caller violates object encapsulation since elements can be
-removed or replaced outside of the object that owns it. It is safer to return a copy of the array.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.sunsecure.MethodReturnsInternalArrayRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/sunsecure/MethodReturnsInternalArrayRule.java)
-
-**Example(s):**
-
-``` java
-public class SecureSystem {
- UserData [] ud;
- public UserData [] getUserData() {
- // Don't return directly the internal array, return a copy
- return ud;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/unnecessary.md b/docs/pages/pmd/rules/java/unnecessary.md
deleted file mode 100644
index 42f194a7efa..00000000000
--- a/docs/pages/pmd/rules/java/unnecessary.md
+++ /dev/null
@@ -1,408 +0,0 @@
----
-title: Unnecessary
-summary: The Unnecessary Ruleset contains a collection of rules for unnecessary code.
-permalink: pmd_rules_java_unnecessary.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/unnecessary.xml
-keywords: Unnecessary, UnnecessaryConversionTemporary, UnnecessaryReturn, UnnecessaryFinalModifier, UselessOverridingMethod, UselessOperationOnImmutable, UnusedNullCheckInEquals, UselessParentheses, UselessQualifiedThis, UnnecessaryModifier
----
-## UnnecessaryConversionTemporary
-
-**Since:** PMD 0.1
-
-**Priority:** Medium (3)
-
-Avoid the use temporary objects when converting primitives to Strings. Use the static conversion methods
-on the wrapper classes instead.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.unnecessary.UnnecessaryConversionTemporaryRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/unnecessary/UnnecessaryConversionTemporaryRule.java)
-
-**Example(s):**
-
-``` java
-public String convert(int x) {
- String foo = new Integer(x).toString(); // this wastes an object
-
- return Integer.toString(x); // preferred approach
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryFinalModifier
-
-**Since:** PMD 3.0
-
-**Priority:** Medium (3)
-
-When a class has the final modifier, all the methods are automatically final and do not need to be
-tagged as such. Similarly, methods that can't be overridden (private methods, methods of anonymous classes,
-methods of enum instance) do not need to be tagged either.
-
-```
-//ClassOrInterfaceDeclaration[@Final='true' and @Interface='false']
- /ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
- [count(./Annotation/MarkerAnnotation/Name[@Image='SafeVarargs' or @Image='java.lang.SafeVarargs']) = 0]
- /MethodDeclaration[@Final='true']
-| //MethodDeclaration[@Final='true' and @Private='true']
-| //EnumConstant/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/MethodDeclaration[@Final='true']
-| //AllocationExpression/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/MethodDeclaration[@Final='true']
-```
-
-**Example(s):**
-
-``` java
-public final class Foo {
- // This final modifier is not necessary, since the class is final
- // and thus, all methods are final
- private final void foo() {
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryModifier
-
-**Since:** PMD 1.02
-
-**Priority:** Medium (3)
-
-Fields in interfaces and annotations are automatically `public static final`, and methods are `public abstract`.
-Classes, interfaces or annotations nested in an interface or annotation are automatically `public static`
-(all nested interfaces and annotations are automatically static).
-Nested enums are automatically `static`.
-For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.unnecessary.UnnecessaryModifierRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/unnecessary/UnnecessaryModifierRule.java)
-
-**Example(s):**
-
-``` java
-public @interface Annotation {
- public abstract void bar(); // both abstract and public are ignored by the compiler
- public static final int X = 0; // public, static, and final all ignored
- public static class Bar {} // public, static ignored
- public static interface Baz {} // ditto
-}
-public interface Foo {
- public abstract void bar(); // both abstract and public are ignored by the compiler
- public static final int X = 0; // public, static, and final all ignored
- public static class Bar {} // public, static ignored
- public static interface Baz {} // ditto
-}
-public class Bar {
- public static interface Baz {} // static ignored
- public static enum FoorBar { // static ignored
- FOO;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnnecessaryReturn
-
-**Since:** PMD 1.3
-
-**Priority:** Medium (3)
-
-Avoid the use of unnecessary return statements.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.unnecessary.UnnecessaryReturnRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/unnecessary/UnnecessaryReturnRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void bar() {
- int x = 42;
- return;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnusedNullCheckInEquals
-
-**Since:** PMD 3.5
-
-**Priority:** Medium (3)
-
-After checking an object reference for null, you should invoke equals() on that object rather than passing it to another object's equals() method.
-
-```
-(//PrimaryPrefix[ends-with(Name/@Image, '.equals') and Name/@Image != 'Arrays.equals'] | //PrimarySuffix[@Image='equals' and not(../PrimaryPrefix/Literal)])
- /following-sibling::PrimarySuffix/Arguments/ArgumentList/Expression
- /PrimaryExpression[count(PrimarySuffix)=0]/PrimaryPrefix
- /Name[@Image = ./../../../../../../../../../../Expression/ConditionalAndExpression
- /EqualityExpression[@Image="!=" and count(./preceding-sibling::*)=0 and
- ./PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
- /PrimaryExpression/PrimaryPrefix/Name/@Image]
-```
-
-**Example(s):**
-
-``` java
-public class Test {
-
- public String method1() { return "ok";}
- public String method2() { return null;}
-
- public void method(String a) {
- String b;
- // I don't know it method1() can be "null"
- // but I know "a" is not null..
- // I'd better write a.equals(method1())
-
- if (a!=null && method1().equals(a)) { // will trigger the rule
- //whatever
- }
-
- if (method1().equals(a) && a != null) { // won't trigger the rule
- //whatever
- }
-
- if (a!=null && method1().equals(b)) { // won't trigger the rule
- //whatever
- }
-
- if (a!=null && "LITERAL".equals(a)) { // won't trigger the rule
- //whatever
- }
-
- if (a!=null && !a.equals("go")) { // won't trigger the rule
- a=method2();
- if (method1().equals(a)) {
- //whatever
- }
- }
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UselessOperationOnImmutable
-
-**Since:** PMD 3.5
-
-**Priority:** Medium (3)
-
-An operation on an Immutable object (String, BigDecimal or BigInteger) won't change the object itself
-since the result of the operation is a new object. Therefore, ignoring the operation result is an error.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.unnecessary.UselessOperationOnImmutableRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/unnecessary/UselessOperationOnImmutableRule.java)
-
-**Example(s):**
-
-``` java
-import java.math.*;
-
-class Test {
- void method1() {
- BigDecimal bd=new BigDecimal(10);
- bd.add(new BigDecimal(5)); // this will trigger the rule
- }
- void method2() {
- BigDecimal bd=new BigDecimal(10);
- bd = bd.add(new BigDecimal(5)); // this won't trigger the rule
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UselessOverridingMethod
-
-**Since:** PMD 3.3
-
-**Priority:** Medium (3)
-
-The overriding method merely calls the same method defined in a superclass.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.unnecessary.UselessOverridingMethodRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/unnecessary/UselessOverridingMethodRule.java)
-
-**Example(s):**
-
-``` java
-public void foo(String bar) {
- super.foo(bar); // why bother overriding?
-}
-
-public String foo() {
- return super.foo(); // why bother overriding?
-}
-
-@Id
-public Long getId() {
- return super.getId(); // OK if 'ignoreAnnotations' is false, which is the default behavior
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|ignoreAnnotations|false|Ignore annotations|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UselessParentheses
-
-**Since:** PMD 5.0
-
-**Priority:** Medium Low (4)
-
-Useless parentheses should be removed.
-
-```
-//Expression[not(parent::PrimaryPrefix)]/PrimaryExpression[count(*)>1]
- /PrimaryPrefix/Expression
- [not(./CastExpression)]
- [not(./ConditionalExpression[@Ternary='true'])]
- [not(./AdditiveExpression[//Literal[@StringLiteral='true']])]
-|
-//Expression[not(parent::PrimaryPrefix)]/PrimaryExpression[count(*)=1]
- /PrimaryPrefix/Expression
-|
-//Expression/ConditionalAndExpression/PrimaryExpression/PrimaryPrefix/Expression[
- count(*)=1 and
- count(./CastExpression)=0 and
- count(./EqualityExpression/MultiplicativeExpression)=0 and
- count(./ConditionalExpression[@Ternary='true'])=0 and
- count(./ConditionalOrExpression)=0]
-|
-//Expression/ConditionalOrExpression/PrimaryExpression/PrimaryPrefix/Expression[
- count(*)=1 and
- not(./CastExpression) and
- not(./ConditionalExpression[@Ternary='true']) and
- not(./EqualityExpression/MultiplicativeExpression)]
-|
-//Expression/ConditionalExpression/PrimaryExpression/PrimaryPrefix/Expression[
- count(*)=1 and
- not(./CastExpression) and
- not(./EqualityExpression)]
-|
-//Expression/AdditiveExpression[not(./PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true'])]
- /PrimaryExpression[1]/PrimaryPrefix/Expression[
- count(*)=1 and
- not(./CastExpression) and
- not(./AdditiveExpression[@Image = '-']) and
- not(./ShiftExpression) and
- not(./RelationalExpression) and
- not(./InstanceOfExpression) and
- not(./EqualityExpression) and
- not(./AndExpression) and
- not(./ExclusiveOrExpression) and
- not(./InclusiveOrExpression) and
- not(./ConditionalAndExpression) and
- not(./ConditionalOrExpression) and
- not(./ConditionalExpression)]
-|
-//Expression/EqualityExpression/PrimaryExpression/PrimaryPrefix/Expression[
- count(*)=1 and
- not(./CastExpression) and
- not(./AndExpression) and
- not(./InclusiveOrExpression) and
- not(./ExclusiveOrExpression) and
- not(./ConditionalExpression) and
- not(./ConditionalAndExpression) and
- not(./ConditionalOrExpression) and
- not(./EqualityExpression)]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
-
- private int _bar1;
- private Integer _bar2;
-
- public void setBar(int n) {
- _bar1 = Integer.valueOf((n)); // here
- _bar2 = (n); // and here
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UselessQualifiedThis
-
-**Since:** PMD 5.4.0
-
-**Priority:** Medium (3)
-
-Look for qualified this usages in the same class.
-
-```
-//PrimaryExpression
-[PrimaryPrefix/Name[@Image]]
-[PrimarySuffix[@Arguments='false']]
-[not(PrimarySuffix/MemberSelector)]
-[ancestor::ClassOrInterfaceBodyDeclaration[1][@AnonymousInnerClass='false']]
-/PrimaryPrefix/Name[@Image = ancestor::ClassOrInterfaceDeclaration[1]/@Image]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- final Foo otherFoo = Foo.this; // use "this" directly
-
- public void doSomething() {
- final Foo anotherFoo = Foo.this; // use "this" directly
- }
-
- private ActionListener returnListener() {
- return new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- doSomethingWithQualifiedThis(Foo.this); // This is fine
- }
- };
- }
-
- private class Foo3 {
- final Foo myFoo = Foo.this; // This is fine
- }
-
- private class Foo2 {
- final Foo2 myFoo2 = Foo2.this; // Use "this" direclty
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/java/unusedcode.md b/docs/pages/pmd/rules/java/unusedcode.md
deleted file mode 100644
index bb87f2152b3..00000000000
--- a/docs/pages/pmd/rules/java/unusedcode.md
+++ /dev/null
@@ -1,116 +0,0 @@
----
-title: Unused Code
-summary: The Unused Code ruleset contains rules that find unused or ineffective code.
-permalink: pmd_rules_java_unusedcode.html
-folder: pmd/rules/java
-sidebaractiveurl: /pmd_rules_java.html
-editmepath: ../pmd-java/src/main/resources/rulesets/java/unusedcode.xml
-keywords: Unused Code, UnusedPrivateField, UnusedLocalVariable, UnusedPrivateMethod, UnusedFormalParameter
----
-## UnusedFormalParameter
-
-**Since:** PMD 0.8
-
-**Priority:** Medium (3)
-
-Avoid passing parameters to methods or constructors without actually referencing them in the method body.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedFormalParameterRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/unusedcode/UnusedFormalParameterRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- private void bar(String howdy) {
- // howdy is not used
- }
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|checkAll|false|Check all methods, including non-private ones|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnusedLocalVariable
-
-**Since:** PMD 0.1
-
-**Priority:** Medium (3)
-
-Detects when a local variable is declared and/or assigned, but not used.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedLocalVariableRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/unusedcode/UnusedLocalVariableRule.java)
-
-**Example(s):**
-
-``` java
-public class Foo {
- public void doSomething() {
- int i = 5; // Unused
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnusedPrivateField
-
-**Since:** PMD 0.1
-
-**Priority:** Medium (3)
-
-Detects when a private field is declared and/or assigned a value, but not used.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedPrivateFieldRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/unusedcode/UnusedPrivateFieldRule.java)
-
-**Example(s):**
-
-``` java
-public class Something {
- private static int FOO = 2; // Unused
- private int i = 5; // Unused
- private int j = 6;
- public int addOne() {
- return j++;
- }
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnusedPrivateMethod
-
-**Since:** PMD 0.7
-
-**Priority:** Medium (3)
-
-Unused Private Method detects when a private method is declared but is unused.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedPrivateMethodRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/unusedcode/UnusedPrivateMethodRule.java)
-
-**Example(s):**
-
-``` java
-public class Something {
- private void foo() {} // unused
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/jsp.md b/docs/pages/pmd/rules/jsp.md
index 9951e6aa564..bad2ea4fb65 100644
--- a/docs/pages/pmd/rules/jsp.md
+++ b/docs/pages/pmd/rules/jsp.md
@@ -1,26 +1,56 @@
---
title: Java Server Pages Rules
+tags: [rule_references, jsp]
+summary: Index of all built-in rules available for Java Server Pages
+language_name: Java Server Pages
permalink: pmd_rules_jsp.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
-
-* [Basic JSF](pmd_rules_jsp_basic-jsf.html): Rules concerning basic JSF guidelines.
-* [Basic JSP](pmd_rules_jsp_basic.html): Rules concerning basic JSP guidelines.
-
-## Basic JSF
-* [DontNestJsfInJstlIteration](pmd_rules_jsp_basic-jsf.html#dontnestjsfinjstliteration): Do not nest JSF component custom actions inside a custom action that iterates over its body.
-
-## Basic JSP
-* [DuplicateJspImports](pmd_rules_jsp_basic.html#duplicatejspimports): Avoid duplicate import statements inside JSP's.
-* [IframeMissingSrcAttribute](pmd_rules_jsp_basic.html#iframemissingsrcattribute): IFrames which are missing a src element can cause security information popups in IE if you are ac...
-* [JspEncoding](pmd_rules_jsp_basic.html#jspencoding): A missing 'meta' tag or page directive will trigger this rule, as well as a non-UTF-8 charset.
-* [NoClassAttribute](pmd_rules_jsp_basic.html#noclassattribute): Do not use an attribute called 'class'. Use "styleclass" for CSS styles.
-* [NoHtmlComments](pmd_rules_jsp_basic.html#nohtmlcomments): In a production system, HTML comments increase the payloadbetween the application server to the c...
-* [NoInlineScript](pmd_rules_jsp_basic.html#noinlinescript): Avoid inlining HTML script content. Consider externalizing the HTML script using the 'src' attri...
-* [NoInlineStyleInformation](pmd_rules_jsp_basic.html#noinlinestyleinformation): Style information should be put in CSS files, not in JSPs. Therefore, don't use or tags...
-* [NoJspForward](pmd_rules_jsp_basic.html#nojspforward): Do not do a forward from within a JSP file.
-* [NoLongScripts](pmd_rules_jsp_basic.html#nolongscripts): Scripts should be part of Tag Libraries, rather than part of JSP pages.
-* [NoScriptlets](pmd_rules_jsp_basic.html#noscriptlets): Scriptlets should be factored into Tag Libraries or JSP declarations, rather than being part of J...
-* [NoUnsanitizedJSPExpression](pmd_rules_jsp_basic.html#nounsanitizedjspexpression): Avoid using expressions without escaping / sanitizing. This could lead to cross site scripting - ...
+## Best Practices
+
+{% include callout.html content="Rules which enforce generally accepted best practices." %}
+
+* [DontNestJsfInJstlIteration](pmd_rules_jsp_bestpractices.html#dontnestjsfinjstliteration): Do not nest JSF component custom actions inside a custom action that iterates over its body.
+* [NoClassAttribute](pmd_rules_jsp_bestpractices.html#noclassattribute): Do not use an attribute called 'class'. Use "styleclass" for CSS styles.
+* [NoHtmlComments](pmd_rules_jsp_bestpractices.html#nohtmlcomments): In a production system, HTML comments increase the payloadbetween the application server to the c...
+* [NoJspForward](pmd_rules_jsp_bestpractices.html#nojspforward): Do not do a forward from within a JSP file.
+
+## Code Style
+
+{% include callout.html content="Rules which enforce a specific coding style." %}
+
+* [DuplicateJspImports](pmd_rules_jsp_codestyle.html#duplicatejspimports): Avoid duplicate import statements inside JSP's.
+
+## Design
+
+{% include callout.html content="Rules that help you discover design issues." %}
+
+* [NoInlineScript](pmd_rules_jsp_design.html#noinlinescript): Avoid inlining HTML script content. Consider externalizing the HTML script using the 'src' attri...
+* [NoInlineStyleInformation](pmd_rules_jsp_design.html#noinlinestyleinformation): Style information should be put in CSS files, not in JSPs. Therefore, don't use or tags...
+* [NoLongScripts](pmd_rules_jsp_design.html#nolongscripts): Scripts should be part of Tag Libraries, rather than part of JSP pages.
+* [NoScriptlets](pmd_rules_jsp_design.html#noscriptlets): Scriptlets should be factored into Tag Libraries or JSP declarations, rather than being part of J...
+
+## Error Prone
+
+{% include callout.html content="Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors." %}
+
+* [JspEncoding](pmd_rules_jsp_errorprone.html#jspencoding): A missing 'meta' tag or page directive will trigger this rule, as well as a non-UTF-8 charset.
+
+## Security
+
+{% include callout.html content="Rules that flag potential security flaws." %}
+
+* [IframeMissingSrcAttribute](pmd_rules_jsp_security.html#iframemissingsrcattribute): IFrames which are missing a src element can cause security information popups in IE if you are ac...
+* [NoUnsanitizedJSPExpression](pmd_rules_jsp_security.html#nounsanitizedjspexpression): Avoid using expressions without escaping / sanitizing. This could lead to cross site scripting - ...
+
+## Additional rulesets
+
+* Basic JSP (`rulesets/jsp/basic.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [DuplicateJspImports](pmd_rules_jsp_codestyle.html#duplicatejspimports), [IframeMissingSrcAttribute](pmd_rules_jsp_security.html#iframemissingsrcattribute), [JspEncoding](pmd_rules_jsp_errorprone.html#jspencoding), [NoClassAttribute](pmd_rules_jsp_bestpractices.html#noclassattribute), [NoHtmlComments](pmd_rules_jsp_bestpractices.html#nohtmlcomments), [NoInlineScript](pmd_rules_jsp_design.html#noinlinescript), [NoInlineStyleInformation](pmd_rules_jsp_design.html#noinlinestyleinformation), [NoJspForward](pmd_rules_jsp_bestpractices.html#nojspforward), [NoLongScripts](pmd_rules_jsp_design.html#nolongscripts), [NoScriptlets](pmd_rules_jsp_design.html#noscriptlets), [NoUnsanitizedJSPExpression](pmd_rules_jsp_security.html#nounsanitizedjspexpression)
+
diff --git a/docs/pages/pmd/rules/jsp/basic-jsf.md b/docs/pages/pmd/rules/jsp/basic-jsf.md
deleted file mode 100644
index d8104dca9dd..00000000000
--- a/docs/pages/pmd/rules/jsp/basic-jsf.md
+++ /dev/null
@@ -1,40 +0,0 @@
----
-title: Basic JSF
-summary: Rules concerning basic JSF guidelines.
-permalink: pmd_rules_jsp_basic-jsf.html
-folder: pmd/rules/jsp
-sidebaractiveurl: /pmd_rules_jsp.html
-editmepath: ../pmd-jsp/src/main/resources/rulesets/jsp/basic-jsf.xml
-keywords: Basic JSF, DontNestJsfInJstlIteration
----
-## DontNestJsfInJstlIteration
-
-**Since:** PMD 3.6
-
-**Priority:** Medium (3)
-
-Do not nest JSF component custom actions inside a custom action that iterates over its body.
-
-```
-//Element[ @Name="c:forEach" ] // Element[ @NamespacePrefix="h" or @NamespacePrefix="f" ]
-```
-
-**Example(s):**
-
-``` jsp
-
-
-
-
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/jsp/basic.md b/docs/pages/pmd/rules/jsp/basic.md
deleted file mode 100644
index f1704787d95..00000000000
--- a/docs/pages/pmd/rules/jsp/basic.md
+++ /dev/null
@@ -1,325 +0,0 @@
----
-title: Basic JSP
-summary: Rules concerning basic JSP guidelines.
-permalink: pmd_rules_jsp_basic.html
-folder: pmd/rules/jsp
-sidebaractiveurl: /pmd_rules_jsp.html
-editmepath: ../pmd-jsp/src/main/resources/rulesets/jsp/basic.xml
-keywords: Basic JSP, NoLongScripts, NoScriptlets, NoInlineStyleInformation, NoClassAttribute, NoJspForward, IframeMissingSrcAttribute, NoHtmlComments, DuplicateJspImports, JspEncoding, NoInlineScript, NoUnsanitizedJSPExpression
----
-## DuplicateJspImports
-
-**Since:** PMD 3.7
-
-**Priority:** Medium (3)
-
-Avoid duplicate import statements inside JSP's.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.jsp.rule.basic.DuplicateJspImportsRule](https://github.com/pmd/pmd/blob/master/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/basic/DuplicateJspImportsRule.java)
-
-**Example(s):**
-
-``` jsp
-<%@ page import=\"com.foo.MyClass,com.foo.MyClass\"%> /foo\">xxtext
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## IframeMissingSrcAttribute
-
-**Since:** PMD 3.6
-
-**Priority:** Medium High (2)
-
-IFrames which are missing a src element can cause security information popups in IE if you are accessing the page
-through SSL. See http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q261188
-
-```
-//Element[upper-case(@Name)="IFRAME"][count(Attribute[upper-case(@Name)="SRC" ]) = 0]
-```
-
-**Example(s):**
-
-``` jsp
-bad example>
-
-
-
-good example>
-
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## JspEncoding
-
-**Since:** PMD 4.0
-
-**Priority:** Medium (3)
-
-A missing 'meta' tag or page directive will trigger this rule, as well as a non-UTF-8 charset.
-
-```
-//CompilationUnit/Content[
-not(Element[@Name="meta"][
- Attribute[@Name="content"]/AttributeValue[contains(lower-case(@Image),"charset=utf-8")]
-])
-and
- not(JspDirective[@Name='page']/JspDirectiveAttribute[@Name='contentType'][contains(lower-case(@Value),"charset=utf-8")])
-]
-```
-
-**Example(s):**
-
-``` jsp
-Most browsers should be able to interpret the following headers:
-
-<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
-
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoClassAttribute
-
-**Since:** PMD 3.6
-
-**Priority:** Medium High (2)
-
-Do not use an attribute called 'class'. Use "styleclass" for CSS styles.
-
-```
-//Attribute[ upper-case(@Name)="CLASS" ]
-```
-
-**Example(s):**
-
-``` jsp
-
-Some text
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoHtmlComments
-
-**Since:** PMD 3.6
-
-**Priority:** Medium High (2)
-
-In a production system, HTML comments increase the payload
-between the application server to the client, and serve
-little other purpose. Consider switching to JSP comments.
-
-```
-//CommentTag
-```
-
-**Example(s):**
-
-``` jsp
-bad example>
-
-
-
-good example>
-<%-- JSP comment --%>
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoInlineScript
-
-**Since:** PMD 4.0
-
-**Priority:** Medium (3)
-
-Avoid inlining HTML script content. Consider externalizing the HTML script using the 'src' attribute on the "script" element.
-Externalized script could be reused between pages. Browsers can also cache the script, reducing overall download bandwidth.
-
-```
-//HtmlScript[@Image != '']
-```
-
-**Example(s):**
-
-``` jsp
-Most browsers should be able to interpret the following headers:
-
-<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
-
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoInlineStyleInformation
-
-**Since:** PMD 3.6
-
-**Priority:** Medium (3)
-
-Style information should be put in CSS files, not in JSPs. Therefore, don't use or
-tags, or attributes like "align='center'".
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.jsp.rule.basic.NoInlineStyleInformationRule](https://github.com/pmd/pmd/blob/master/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/basic/NoInlineStyleInformationRule.java)
-
-**Example(s):**
-
-``` jsp
-text
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoJspForward
-
-**Since:** PMD 3.6
-
-**Priority:** Medium (3)
-
-Do not do a forward from within a JSP file.
-
-```
-//Element[ @Name="jsp:forward" ]
-```
-
-**Example(s):**
-
-``` jsp
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoLongScripts
-
-**Since:** PMD 3.6
-
-**Priority:** Medium High (2)
-
-Scripts should be part of Tag Libraries, rather than part of JSP pages.
-
-```
-//HtmlScript[(@EndLine - @BeginLine > 10)]
-```
-
-**Example(s):**
-
-``` jsp
-
-
-
-
-
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoScriptlets
-
-**Since:** PMD 3.6
-
-**Priority:** Medium (3)
-
-Scriptlets should be factored into Tag Libraries or JSP declarations, rather than being part of JSP pages.
-
-```
-//JspScriptlet
-|
-//Element[ upper-case(@Name)="JSP:SCRIPTLET" ]
-```
-
-**Example(s):**
-
-``` jsp
-
-
-<%
-response.setHeader("Pragma", "No-cache");
-%>
-
-
- String title = "Hello world!";
-
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoUnsanitizedJSPExpression
-
-**Since:** PMD 5.1.4
-
-**Priority:** Medium (3)
-
-Avoid using expressions without escaping / sanitizing. This could lead to cross site scripting - as the expression
-would be interpreted by the browser directly (e.g. "").
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.jsp.rule.basic.NoUnsanitizedJSPExpressionRule](https://github.com/pmd/pmd/blob/master/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/basic/NoUnsanitizedJSPExpressionRule.java)
-
-**Example(s):**
-
-``` jsp
-<%@ page contentType="text/html; charset=UTF-8" %>
-<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
-${expression}
-${fn:escapeXml(expression)}
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/jsp/bestpractices.md b/docs/pages/pmd/rules/jsp/bestpractices.md
new file mode 100644
index 00000000000..eb055fb6c99
--- /dev/null
+++ b/docs/pages/pmd/rules/jsp/bestpractices.md
@@ -0,0 +1,124 @@
+---
+title: Best Practices
+summary: Rules which enforce generally accepted best practices.
+permalink: pmd_rules_jsp_bestpractices.html
+folder: pmd/rules/jsp
+sidebaractiveurl: /pmd_rules_jsp.html
+editmepath: ../pmd-jsp/src/main/resources/category/jsp/bestpractices.xml
+keywords: Best Practices, DontNestJsfInJstlIteration, NoClassAttribute, NoHtmlComments, NoJspForward
+language: Java Server Pages
+---
+## DontNestJsfInJstlIteration
+
+**Since:** PMD 3.6
+
+**Priority:** Medium (3)
+
+Do not nest JSF component custom actions inside a custom action that iterates over its body.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Element[ @Name="c:forEach" ] // Element[ @NamespacePrefix="h" or @NamespacePrefix="f" ]
+```
+
+**Example(s):**
+
+``` jsp
+
+
+
+
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoClassAttribute
+
+**Since:** PMD 3.6
+
+**Priority:** Medium High (2)
+
+Do not use an attribute called 'class'. Use "styleclass" for CSS styles.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Attribute[ upper-case(@Name)="CLASS" ]
+```
+
+**Example(s):**
+
+``` jsp
+
+Some text
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoHtmlComments
+
+**Since:** PMD 3.6
+
+**Priority:** Medium High (2)
+
+In a production system, HTML comments increase the payload
+between the application server to the client, and serve
+little other purpose. Consider switching to JSP comments.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CommentTag
+```
+
+**Example(s):**
+
+``` jsp
+bad example>
+
+
+
+good example>
+<%-- JSP comment --%>
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoJspForward
+
+**Since:** PMD 3.6
+
+**Priority:** Medium (3)
+
+Do not do a forward from within a JSP file.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Element[ @Name="jsp:forward" ]
+```
+
+**Example(s):**
+
+``` jsp
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/jsp/codestyle.md b/docs/pages/pmd/rules/jsp/codestyle.md
new file mode 100644
index 00000000000..2654710a2d1
--- /dev/null
+++ b/docs/pages/pmd/rules/jsp/codestyle.md
@@ -0,0 +1,31 @@
+---
+title: Code Style
+summary: Rules which enforce a specific coding style.
+permalink: pmd_rules_jsp_codestyle.html
+folder: pmd/rules/jsp
+sidebaractiveurl: /pmd_rules_jsp.html
+editmepath: ../pmd-jsp/src/main/resources/category/jsp/codestyle.xml
+keywords: Code Style, DuplicateJspImports
+language: Java Server Pages
+---
+## DuplicateJspImports
+
+**Since:** PMD 3.7
+
+**Priority:** Medium (3)
+
+Avoid duplicate import statements inside JSP's.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.jsp.rule.codestyle.DuplicateJspImportsRule](https://github.com/pmd/pmd/blob/master/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/codestyle/DuplicateJspImportsRule.java)
+
+**Example(s):**
+
+``` jsp
+<%@ page import=\"com.foo.MyClass,com.foo.MyClass\"%> /foo\">xxtext
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/jsp/design.md b/docs/pages/pmd/rules/jsp/design.md
new file mode 100644
index 00000000000..b4b1733fe42
--- /dev/null
+++ b/docs/pages/pmd/rules/jsp/design.md
@@ -0,0 +1,130 @@
+---
+title: Design
+summary: Rules that help you discover design issues.
+permalink: pmd_rules_jsp_design.html
+folder: pmd/rules/jsp
+sidebaractiveurl: /pmd_rules_jsp.html
+editmepath: ../pmd-jsp/src/main/resources/category/jsp/design.xml
+keywords: Design, NoInlineScript, NoInlineStyleInformation, NoLongScripts, NoScriptlets
+language: Java Server Pages
+---
+## NoInlineScript
+
+**Since:** PMD 4.0
+
+**Priority:** Medium (3)
+
+Avoid inlining HTML script content. Consider externalizing the HTML script using the 'src' attribute on the "script" element.
+Externalized script could be reused between pages. Browsers can also cache the script, reducing overall download bandwidth.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//HtmlScript[@Image != '']
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoInlineStyleInformation
+
+**Since:** PMD 3.6
+
+**Priority:** Medium (3)
+
+Style information should be put in CSS files, not in JSPs. Therefore, don't use or
+tags, or attributes like "align='center'".
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.jsp.rule.design.NoInlineStyleInformationRule](https://github.com/pmd/pmd/blob/master/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/design/NoInlineStyleInformationRule.java)
+
+**Example(s):**
+
+``` jsp
+text
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoLongScripts
+
+**Since:** PMD 3.6
+
+**Priority:** Medium High (2)
+
+Scripts should be part of Tag Libraries, rather than part of JSP pages.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//HtmlScript[(@EndLine - @BeginLine > 10)]
+```
+
+**Example(s):**
+
+``` jsp
+
+
+
+
+
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoScriptlets
+
+**Since:** PMD 3.6
+
+**Priority:** Medium (3)
+
+Scriptlets should be factored into Tag Libraries or JSP declarations, rather than being part of JSP pages.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//JspScriptlet
+|
+//Element[ upper-case(@Name)="JSP:SCRIPTLET" ]
+```
+
+**Example(s):**
+
+``` jsp
+
+
+<%
+response.setHeader("Pragma", "No-cache");
+%>
+
+
+ String title = "Hello world!";
+
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/jsp/errorprone.md b/docs/pages/pmd/rules/jsp/errorprone.md
new file mode 100644
index 00000000000..b351d9a844d
--- /dev/null
+++ b/docs/pages/pmd/rules/jsp/errorprone.md
@@ -0,0 +1,44 @@
+---
+title: Error Prone
+summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+permalink: pmd_rules_jsp_errorprone.html
+folder: pmd/rules/jsp
+sidebaractiveurl: /pmd_rules_jsp.html
+editmepath: ../pmd-jsp/src/main/resources/category/jsp/errorprone.xml
+keywords: Error Prone, JspEncoding
+language: Java Server Pages
+---
+## JspEncoding
+
+**Since:** PMD 4.0
+
+**Priority:** Medium (3)
+
+A missing 'meta' tag or page directive will trigger this rule, as well as a non-UTF-8 charset.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CompilationUnit/Content[
+not(Element[@Name="meta"][
+ Attribute[@Name="content"]/AttributeValue[contains(lower-case(@Image),"charset=utf-8")]
+])
+and
+ not(JspDirective[@Name='page']/JspDirectiveAttribute[@Name='contentType'][contains(lower-case(@Value),"charset=utf-8")])
+]
+```
+
+**Example(s):**
+
+``` jsp
+Most browsers should be able to interpret the following headers:
+
+<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/jsp/security.md b/docs/pages/pmd/rules/jsp/security.md
new file mode 100644
index 00000000000..0cc3cc60e58
--- /dev/null
+++ b/docs/pages/pmd/rules/jsp/security.md
@@ -0,0 +1,67 @@
+---
+title: Security
+summary: Rules that flag potential security flaws.
+permalink: pmd_rules_jsp_security.html
+folder: pmd/rules/jsp
+sidebaractiveurl: /pmd_rules_jsp.html
+editmepath: ../pmd-jsp/src/main/resources/category/jsp/security.xml
+keywords: Security, IframeMissingSrcAttribute, NoUnsanitizedJSPExpression
+language: Java Server Pages
+---
+## IframeMissingSrcAttribute
+
+**Since:** PMD 3.6
+
+**Priority:** Medium High (2)
+
+IFrames which are missing a src element can cause security information popups in IE if you are accessing the page
+through SSL. See http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q261188
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Element[upper-case(@Name)="IFRAME"][count(Attribute[upper-case(@Name)="SRC" ]) = 0]
+```
+
+**Example(s):**
+
+``` jsp
+bad example>
+
+
+
+good example>
+
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoUnsanitizedJSPExpression
+
+**Since:** PMD 5.1.4
+
+**Priority:** Medium (3)
+
+Avoid using expressions without escaping / sanitizing. This could lead to cross site scripting - as the expression
+would be interpreted by the browser directly (e.g. "").
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.jsp.rule.security.NoUnsanitizedJSPExpressionRule](https://github.com/pmd/pmd/blob/master/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/security/NoUnsanitizedJSPExpressionRule.java)
+
+**Example(s):**
+
+``` jsp
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
+${expression}
+${fn:escapeXml(expression)}
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/plsql.md b/docs/pages/pmd/rules/plsql.md
index 8263aac1d85..7dfe05bca82 100644
--- a/docs/pages/pmd/rules/plsql.md
+++ b/docs/pages/pmd/rules/plsql.md
@@ -1,37 +1,82 @@
---
title: PLSQL Rules
+tags: [rule_references, plsql]
+summary: Index of all built-in rules available for PLSQL
+language_name: PLSQL
permalink: pmd_rules_plsql.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
-
-* [Code Size](pmd_rules_plsql_codesize.html): The Code Size ruleset contains rules that find problems related to code size or complexity.
-* [PLSQL DATETIME](pmd_rules_plsql_dates.html): The Dates ruleset deals with PLSQL DATETIME usages.
-* [Strict Syntax](pmd_rules_plsql_strictsyntax.html): The Strict Syntax ruleset contains rules that highlight invalid plsql syntax, which works, but should be avoided.
-* [Tom Kyte's Despair](pmd_rules_plsql_TomKytesDespair.html): Rules based on Thomas Kyte's recommendations on http://asktom.oracle.com/ and http://tkyte.blogspot.com/.
-
-## Code Size
-* [CyclomaticComplexity](pmd_rules_plsql_codesize.html#cyclomaticcomplexity): Complexity directly affects maintenance costs is determined by the number of decision points in a...
-* [ExcessiveMethodLength](pmd_rules_plsql_codesize.html#excessivemethodlength): When methods are excessively long this usually indicates that the method is doing more than itsna...
-* [ExcessiveObjectLength](pmd_rules_plsql_codesize.html#excessiveobjectlength): Excessive object line lengths are usually indications that the object may be burdened with excess...
-* [ExcessivePackageBodyLength](pmd_rules_plsql_codesize.html#excessivepackagebodylength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
-* [ExcessivePackageSpecificationLength](pmd_rules_plsql_codesize.html#excessivepackagespecificationlength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
-* [ExcessiveParameterList](pmd_rules_plsql_codesize.html#excessiveparameterlist): Methods with numerous parameters are a challenge to maintain, especially if most of them share th...
-* [ExcessiveTypeLength](pmd_rules_plsql_codesize.html#excessivetypelength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
-* [NcssMethodCount](pmd_rules_plsql_codesize.html#ncssmethodcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
-* [NcssObjectCount](pmd_rules_plsql_codesize.html#ncssobjectcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
-* [NPathComplexity](pmd_rules_plsql_codesize.html#npathcomplexity): The NPath complexity of a method is the number of acyclic execution paths through that method.A t...
-* [TooManyFields](pmd_rules_plsql_codesize.html#toomanyfields): Classes that have too many fields can become unwieldy and could be redesigned to have fewer field...
-* [TooManyMethods](pmd_rules_plsql_codesize.html#toomanymethods): A package or type with too many methods is probably a good suspect for refactoring, in order to r...
-
-## PLSQL DATETIME
-* [TO_DATE_TO_CHAR](pmd_rules_plsql_dates.html#to_date_to_char): TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
-* [TO_DATEWithoutDateFormat](pmd_rules_plsql_dates.html#to_datewithoutdateformat): TO_DATE without date format- use TO_DATE(expression, date-format)
-* [TO_TIMESTAMPWithoutDateFormat](pmd_rules_plsql_dates.html#to_timestampwithoutdateformat): TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
-
-## Strict Syntax
-* [MisplacedPragma](pmd_rules_plsql_strictsyntax.html#misplacedpragma): Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,but the cod...
-
-## Tom Kyte's Despair
-* [TomKytesDespair](pmd_rules_plsql_TomKytesDespair.html#tomkytesdespair): "WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
+## Best Practices
+
+{% include callout.html content="Rules which enforce generally accepted best practices." %}
+
+* [TomKytesDespair](pmd_rules_plsql_bestpractices.html#tomkytesdespair): "WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
+
+## Code Style
+
+{% include callout.html content="Rules which enforce a specific coding style." %}
+
+* [CodeFormat](pmd_rules_plsql_codestyle.html#codeformat): This rule verifies that the PLSQL code is properly formatted. The following checks are executed:S...
+* [ForLoopNaming](pmd_rules_plsql_codestyle.html#forloopnaming): In case you have loops please name the loop variables more meaningful.
+* [MisplacedPragma](pmd_rules_plsql_codestyle.html#misplacedpragma): Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,but the cod...
+
+## Design
+
+{% include callout.html content="Rules that help you discover design issues." %}
+
+* [CyclomaticComplexity](pmd_rules_plsql_design.html#cyclomaticcomplexity): Complexity directly affects maintenance costs is determined by the number of decision points in a...
+* [ExcessiveMethodLength](pmd_rules_plsql_design.html#excessivemethodlength): When methods are excessively long this usually indicates that the method is doing more than itsna...
+* [ExcessiveObjectLength](pmd_rules_plsql_design.html#excessiveobjectlength): Excessive object line lengths are usually indications that the object may be burdened with excess...
+* [ExcessivePackageBodyLength](pmd_rules_plsql_design.html#excessivepackagebodylength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
+* [ExcessivePackageSpecificationLength](pmd_rules_plsql_design.html#excessivepackagespecificationlength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
+* [ExcessiveParameterList](pmd_rules_plsql_design.html#excessiveparameterlist): Methods with numerous parameters are a challenge to maintain, especially if most of them share th...
+* [ExcessiveTypeLength](pmd_rules_plsql_design.html#excessivetypelength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
+* [NcssMethodCount](pmd_rules_plsql_design.html#ncssmethodcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
+* [NcssObjectCount](pmd_rules_plsql_design.html#ncssobjectcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
+* [NPathComplexity](pmd_rules_plsql_design.html#npathcomplexity): The NPath complexity of a method is the number of acyclic execution paths through that method.A t...
+* [TooManyFields](pmd_rules_plsql_design.html#toomanyfields): Classes that have too many fields can become unwieldy and could be redesigned to have fewer field...
+* [TooManyMethods](pmd_rules_plsql_design.html#toomanymethods): A package or type with too many methods is probably a good suspect for refactoring, in order to r...
+
+## Error Prone
+
+{% include callout.html content="Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors." %}
+
+* [TO_DATE_TO_CHAR](pmd_rules_plsql_errorprone.html#to_date_to_char): TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-variable)
+* [TO_DATEWithoutDateFormat](pmd_rules_plsql_errorprone.html#to_datewithoutdateformat): TO_DATE without date format- use TO_DATE(expression, date-format)
+* [TO_TIMESTAMPWithoutDateFormat](pmd_rules_plsql_errorprone.html#to_timestampwithoutdateformat): TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
+
+## Additional rulesets
+
+* Code Size (`rulesets/plsql/codesize.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [CyclomaticComplexity](pmd_rules_plsql_design.html#cyclomaticcomplexity), [ExcessiveMethodLength](pmd_rules_plsql_design.html#excessivemethodlength), [ExcessiveObjectLength](pmd_rules_plsql_design.html#excessiveobjectlength), [ExcessivePackageBodyLength](pmd_rules_plsql_design.html#excessivepackagebodylength), [ExcessivePackageSpecificationLength](pmd_rules_plsql_design.html#excessivepackagespecificationlength), [ExcessiveParameterList](pmd_rules_plsql_design.html#excessiveparameterlist), [ExcessiveTypeLength](pmd_rules_plsql_design.html#excessivetypelength), [NcssMethodCount](pmd_rules_plsql_design.html#ncssmethodcount), [NcssObjectCount](pmd_rules_plsql_design.html#ncssobjectcount), [NPathComplexity](pmd_rules_plsql_design.html#npathcomplexity), [TooManyFields](pmd_rules_plsql_design.html#toomanyfields), [TooManyMethods](pmd_rules_plsql_design.html#toomanymethods)
+
+* PLSQL DATETIME (`rulesets/plsql/dates.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [TO_DATE_TO_CHAR](pmd_rules_plsql_errorprone.html#to_date_to_char), [TO_DATEWithoutDateFormat](pmd_rules_plsql_errorprone.html#to_datewithoutdateformat), [TO_TIMESTAMPWithoutDateFormat](pmd_rules_plsql_errorprone.html#to_timestampwithoutdateformat)
+
+* Strict Syntax (`rulesets/plsql/strictsyntax.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [MisplacedPragma](pmd_rules_plsql_codestyle.html#misplacedpragma)
+
+* Tom Kyte's Despair (`rulesets/plsql/TomKytesDespair.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [TomKytesDespair](pmd_rules_plsql_bestpractices.html#tomkytesdespair)
+
diff --git a/docs/pages/pmd/rules/plsql/TomKytesDespair.md b/docs/pages/pmd/rules/plsql/TomKytesDespair.md
deleted file mode 100644
index d6f2bbdf6bf..00000000000
--- a/docs/pages/pmd/rules/plsql/TomKytesDespair.md
+++ /dev/null
@@ -1,71 +0,0 @@
----
-title: Tom Kyte's Despair
-summary: Rules based on Thomas Kyte's recommendations on http://asktom.oracle.com/ and http://tkyte.blogspot.com/.
-permalink: pmd_rules_plsql_TomKytesDespair.html
-folder: pmd/rules/plsql
-sidebaractiveurl: /pmd_rules_plsql.html
-editmepath: ../pmd-plsql/src/main/resources/rulesets/plsql/TomKytesDespair.xml
-keywords: Tom Kyte's Despair, TomKytesDespair
----
-## TomKytesDespair
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
-
-```
-//ExceptionHandler[QualifiedName/@Image='OTHERS' and upper-case(Statement/UnlabelledStatement/Expression/@Image)='NULL']
-```
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE PACKAGE BODY update_planned_hrs
-IS
-
-PROCEDURE set_new_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER, p_hours IN NUMBER)
-IS
-BEGIN
- UPDATE employee_on_activity ea
- SET ea.ea_planned_hours = p_hours
- WHERE
- ea.ea_emp_id = p_emp_id
- AND ea.ea_proj_id = p_project_id;
-
-EXCEPTION
- WHEN NO_DATA_FOUND THEN
- RAISE_APPLICATION_ERROR (-20100, 'No such employee or project');
-
-END set_new_planned;
-
-FUNCTION existing_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER) RETURN NUMBER
-
-IS
-
-existing_hours NUMBER(4);
-
-BEGIN
- SELECT ea.ea_planned_hours INTO existing_hours
- FROM employee_on_activity ea
- WHERE
- ea.ea_emp_id = p_emp_id
- AND ea.ea_proj_id = p_project_id;
-
- RETURN (existing_hours);
-
- EXCEPTION
- WHEN OTHERS THEN NULL;
-
- END existing_planned;
-
-END update_planned_hrs;
-/
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/plsql/bestpractices.md b/docs/pages/pmd/rules/plsql/bestpractices.md
new file mode 100644
index 00000000000..498922eab21
--- /dev/null
+++ b/docs/pages/pmd/rules/plsql/bestpractices.md
@@ -0,0 +1,73 @@
+---
+title: Best Practices
+summary: Rules which enforce generally accepted best practices.
+permalink: pmd_rules_plsql_bestpractices.html
+folder: pmd/rules/plsql
+sidebaractiveurl: /pmd_rules_plsql.html
+editmepath: ../pmd-plsql/src/main/resources/category/plsql/bestpractices.xml
+keywords: Best Practices, TomKytesDespair
+language: PLSQL
+---
+## TomKytesDespair
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ExceptionHandler[QualifiedName/@Image='OTHERS' and upper-case(Statement/UnlabelledStatement/Expression/@Image)='NULL']
+```
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE PACKAGE BODY update_planned_hrs
+IS
+
+PROCEDURE set_new_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER, p_hours IN NUMBER)
+IS
+BEGIN
+ UPDATE employee_on_activity ea
+ SET ea.ea_planned_hours = p_hours
+ WHERE
+ ea.ea_emp_id = p_emp_id
+ AND ea.ea_proj_id = p_project_id;
+
+EXCEPTION
+ WHEN NO_DATA_FOUND THEN
+ RAISE_APPLICATION_ERROR (-20100, 'No such employee or project');
+
+END set_new_planned;
+
+FUNCTION existing_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER) RETURN NUMBER
+
+IS
+
+existing_hours NUMBER(4);
+
+BEGIN
+ SELECT ea.ea_planned_hours INTO existing_hours
+ FROM employee_on_activity ea
+ WHERE
+ ea.ea_emp_id = p_emp_id
+ AND ea.ea_proj_id = p_project_id;
+
+ RETURN (existing_hours);
+
+ EXCEPTION
+ WHEN OTHERS THEN NULL;
+
+ END existing_planned;
+
+END update_planned_hrs;
+/
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/plsql/codesize.md b/docs/pages/pmd/rules/plsql/codesize.md
deleted file mode 100644
index 60c525d2e5d..00000000000
--- a/docs/pages/pmd/rules/plsql/codesize.md
+++ /dev/null
@@ -1,638 +0,0 @@
----
-title: Code Size
-summary: The Code Size ruleset contains rules that find problems related to code size or complexity.
-permalink: pmd_rules_plsql_codesize.html
-folder: pmd/rules/plsql
-sidebaractiveurl: /pmd_rules_plsql.html
-editmepath: ../pmd-plsql/src/main/resources/rulesets/plsql/codesize.xml
-keywords: Code Size, NPathComplexity, ExcessiveMethodLength, ExcessiveParameterList, ExcessiveObjectLength, ExcessiveTypeLength, ExcessivePackageBodyLength, ExcessivePackageSpecificationLength, CyclomaticComplexity, TooManyFields, NcssMethodCount, NcssObjectCount, TooManyMethods
----
-## CyclomaticComplexity
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Complexity directly affects maintenance costs is determined by the number of decision points in a method
-plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
-Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
-high complexity, and 11+ is very high complexity.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.CyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/CyclomaticComplexityRule.java)
-
-**Example(s):**
-
-``` sql
--- Cyclomatic Complexity of 25
-CREATE OR REPLACE PACKAGE BODY pkg_pmd_working_sequence AS
-1 PROCEDURE ty_logger IS BEGIN
-2 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-3 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-4 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-5 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- END IF;
-6 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
-7 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-8 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- END IF;
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
-9 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-10 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- END IF;
- END IF;
-11 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
-12 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-13 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-14 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- END IF;
-15 ELSIF false
- THEN
-16 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-17 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- END IF;
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- END IF;
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
-18 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-19 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-20 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- END IF;
-21 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
-22 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-23 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- END IF;
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
-24 IF true
- THEN
- DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
-25 ELSIF false
- THEN
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- ELSE
- DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
- END IF;
- END IF;
- END IF;
-END;
-
-END;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|showMethodsComplexity|true|Add method average violations to the report|
-|showClassesComplexity|true|Add class average violations to the report|
-|reportLevel|10|Cyclomatic Complexity reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveMethodLength
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-When methods are excessively long this usually indicates that the method is doing more than its
-name/signature might suggest. They also become challenging for others to digest since excessive
-scrolling causes readers to lose focus.
-Try to reduce the method length by creating helper methods and removing any copy/pasted code.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessiveMethodLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessiveMethodLengthRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE
-PROCEDURE doSomething BEGIN
- DBMS_OUTPUT.PUT_LINE("Hello world!");
- DBMS_OUTPUT.PUT_LINE("Hello world!");
- -- 98 copies omitted for brevity.
-END;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveObjectLength
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Excessive object line lengths are usually indications that the object may be burdened with excessive
-responsibilities that could be provided by other objects. In breaking these methods
-apart the code becomes more managable and ripe for reuse.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessiveObjectLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessiveObjectLengthRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE
-PACKAGE BODY Foo AS
- PROCEDURE bar1 IS BEGIN
- -- 1000 lines of code
- END bar1;
- PROCEDURE bar2 IS BEGIN
- -- 1000 lines of code
- END bar2;
- PROCEDURE bar3 IS BEGIN
- -- 1000 lines of code
- END bar3;
-
-
- PROCEDURE barN IS BEGIN
- -- 1000 lines of code
- END barn;
-END;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessivePackageBodyLength
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Excessive class file lengths are usually indications that the class may be burdened with excessive
-responsibilities that could be provided by external classes or functions. In breaking these methods
-apart the code becomes more managable and ripe for reuse.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessivePackageBodyLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessivePackageBodyLengthRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE
-PACKAGE BODY Foo AS
- PROCEDURE bar1 IS BEGIN
- -- 1000 lines of code
- END bar1;
- PROCEDURE bar2 IS BEGIN
- -- 1000 lines of code
- END bar2;
- PROCEDURE bar3 IS BEGIN
- -- 1000 lines of code
- END bar3;
-
-
- PROCEDURE barN IS BEGIN
- -- 1000 lines of code
- END barn;
-END;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessivePackageSpecificationLength
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Excessive class file lengths are usually indications that the class may be burdened with excessive
-responsibilities that could be provided by external classes or functions. In breaking these methods
-apart the code becomes more managable and ripe for reuse.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessivePackageSpecificationLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessivePackageSpecificationLengthRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE
-PACKAGE Foo AS
- PROCEDURE bar1;
- PROCEDURE bar2;
- PROCEDURE bar3;
-
- ...
-
- PROCEDURE barN;
-END;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveParameterList
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Methods with numerous parameters are a challenge to maintain, especially if most of them share the
-same datatype. These situations usually denote the need for new objects to wrap the numerous parameters.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessiveParameterListRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessiveParameterListRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE
-PROCEDURE addPerson( -- too many arguments liable to be mixed up
- birthYear pls_integer, birthMonth pls_integer, birthDate pls_integer, height pls_integer, weight pls_integer, ssn pls_integer) {
-
- . . . .
-END ADDPERSON;
-
-CREATE OR REPLACE
-PROCEDURE addPerson( -- preferred approach
- birthdate DATE, measurements BodyMeasurements , ssn INTEGER) BEGIN
-
- . . . .
-END;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveTypeLength
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Excessive class file lengths are usually indications that the class may be burdened with excessive
-responsibilities that could be provided by external classes or functions. In breaking these methods
-apart the code becomes more managable and ripe for reuse.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessiveTypeLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessiveTypeLengthRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE
-TYPE BODY Foo AS
- MEMBER PROCEDURE bar1 IS BEGIN
- -- 1000 lines of code
- END bar1;
- MEMBER PROCEDURE bar2 IS BEGIN
- -- 1000 lines of code
- END bar2;
- MEMBER PROCEDURE bar3 IS BEGIN
- -- 1000 lines of code
- END bar3;
-
-
- MEMBER PROCEDURE barN IS BEGIN
- -- 1000 lines of code
- END barn;
-END;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NcssMethodCount
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-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.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.NcssMethodCountRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/NcssMethodCountRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE PACKAGE BODY AS
- FUNCTION methd RETURN INTEGER IS
- BEGIN
- RETURN 1;;
- END;
-END;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NcssObjectCount
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of lines
-of code for a given Oracle object. NCSS ignores comments, and counts actual statements. Using this algorithm,
-lines of code that are split are counted as one.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.NcssObjectCountRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/NcssObjectCountRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE PACKAGE pkg_
- PROCEDURE Foo IS
- BEGIN
- --this class only has 6 NCSS lines
- super();
- super();
- END;
-}
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NPathComplexity
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-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 and increase readability.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.NPathComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/NPathComplexityRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE
-PROCEDURE bar AS BEGIN -- this is something more complex than it needs to be,
- if (y) THEN -- it should be broken down into smaller methods or functions
- for j IN 0 .. j-1 LOOP
- if (j > r) THEN
- doSomething;
- while (f < 5 ) LOOP
- anotherThing;
- f := f - 27;
- END LOOP;
- else
- tryThis();
- END IF;
- END LOOP;
- END IF;
- if ( r - n > 45) THEN
- while (doMagic) LOOP
- findRabbits;
- END LOOP;
- END IF;
- BEGIN
- doSomethingDangerous();
- EXCEPTION WHEN FooException THEN
- makeAmends;
- BEGIN
- dontDoItAgain;
- EXCEPTION
- WHEN OTHERS THEN
- log_problem;
- END;
- END;
-END;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TooManyFields
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields,
-possibly through grouping related fields in new objects. For example, a class with individual
-city/state/zip fields could park them within a single Address field.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.TooManyFieldsRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/TooManyFieldsRule.java)
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE PACKAGE pkg_too_many_fields AS
- C_CHAR_A CONSTANT CHAR(1 CHAR) := 'A';
- C_CHAR_B CONSTANT CHAR(1 CHAR) := 'B';
- ...
- C_CHAR_Z CONSTANT CHAR(1 CHAR) := 'Z';
-END pkg_too_many_fields;
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|maxfields|15|Max allowable fields|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TooManyMethods
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-A package or type 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.
-
-```
-//node()
- [ (
- local-name(.) = 'PackageSpecification'
- or
- local-name(.) = 'TypeSpecification'
- )
- and
- (
- count(/descendant::ProgramUnit[
- not (
- starts-with(@Image,'get')
- or
- starts-with(@Image,'set')
- or
- starts-with(@Image,'is')
- )
- ]
- )
- +
- count(/descendant::TypeMethod[
- not (
- starts-with(@Image,'get')
- or
- starts-with(@Image,'set')
- or
- starts-with(@Image,'is')
- )
- ]
- )
- ) > $maxmethods
- ]
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|maxmethods|1|The method count reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/plsql/codestyle.md b/docs/pages/pmd/rules/plsql/codestyle.md
new file mode 100644
index 00000000000..eeecd344a33
--- /dev/null
+++ b/docs/pages/pmd/rules/plsql/codestyle.md
@@ -0,0 +1,192 @@
+---
+title: Code Style
+summary: Rules which enforce a specific coding style.
+permalink: pmd_rules_plsql_codestyle.html
+folder: pmd/rules/plsql
+sidebaractiveurl: /pmd_rules_plsql.html
+editmepath: ../pmd-plsql/src/main/resources/category/plsql/codestyle.xml
+keywords: Code Style, CodeFormat, MisplacedPragma, ForLoopNaming
+language: PLSQL
+---
+## CodeFormat
+
+**Since:** PMD 6.9.0
+
+**Priority:** Medium (3)
+
+This rule verifies that the PLSQL code is properly formatted. The following checks are executed:
+
+SQL Queries:
+
+* The selected columns must be each on a new line
+* The keywords (BULK COLLECT INTO, FROM) start on a new line and are indented by one level
+* UNION should be on the same indentation level as SELECT
+* Each JOIN is on a new line. If there are more than one JOIN conditions, then each condition should be
+ on a separate line.
+
+Parameter definitions for procedures:
+
+* Each parameter should be on a new line
+* Variable names as well as their types should be aligned
+
+Variable declarations:
+
+* Each variable should be on a new line
+* Variable names as well as their types should be aligned
+
+Calling a procedure:
+
+* If there are more than 3 parameters
+ * then named parameters should be used
+ * and each parameter should be on a new line
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codestyle.CodeFormatRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codestyle/CodeFormatRule.java)
+
+**Example(s):**
+
+``` sql
+BEGIN
+ -- select columns each on a separate line
+ SELECT cmer_id
+ ,version
+ ,cmp_id
+ BULK COLLECT INTO v_cmer_ids
+ ,v_versions
+ ,v_cmp_ids
+ FROM cmer;
+
+ -- each parameter on a new line
+ PROCEDURE create_prospect(
+ company_info_in IN prospects.company_info%TYPE -- Organization
+ ,firstname_in IN persons.firstname%TYPE -- FirstName
+ ,lastname_in IN persons.lastname%TYPE -- LastName
+ );
+
+ -- more than three parameters, each parameter on a separate line
+ webcrm_marketing.prospect_ins(
+ cmp_id_in => NULL
+ ,company_info_in => company_info_in
+ ,firstname_in => firstname_in
+ ,lastname_in => lastname_in
+ ,slt_code_in => NULL
+ );
+
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|indentation|2|Indentation to be used for blocks|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ForLoopNaming
+
+**Since:** PMD 6.7.0
+
+**Priority:** Medium (3)
+
+In case you have loops please name the loop variables more meaningful.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//CursorForLoopStatement[
+ $allowSimpleLoops = 'false' or
+ (Statement//CursorForLoopStatement or ancestor::CursorForLoopStatement)
+]
+/ForIndex[not(matches(@Image, $cursorPattern))]
+|
+//ForStatement[
+ $allowSimpleLoops = 'false' or
+ (Statement//ForStatement or ancestor::ForStatement)
+]
+/ForIndex[not(matches(@Image, $indexPattern))]
+```
+
+**Example(s):**
+
+``` sql
+-- good example
+BEGIN
+FOR company IN (SELECT * FROM companies) LOOP
+ FOR contact IN (SELECT * FROM contacts) LOOP
+ FOR party IN (SELECT * FROM parties) LOOP
+ NULL;
+ END LOOP;
+ END LOOP;
+END LOOP;
+END;
+/
+
+-- bad example
+BEGIN
+FOR c1 IN (SELECT * FROM companies) LOOP
+ FOR c2 IN (SELECT * FROM contacts) LOOP
+ FOR c3 IN (SELECT * FROM parties) LOOP
+ NULL;
+ END LOOP;
+ END LOOP;
+END LOOP;
+END;
+/
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|allowSimpleLoops|false|Ignore simple loops, that are not nested|no|
+|cursorPattern|\[a-zA-Z\_0-9\]{5,}|The pattern used for the curosr loop variable|no|
+|indexPattern|\[a-zA-Z\_0-9\]{5,}|The pattern used for the index loop variable|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## MisplacedPragma
+
+**Since:** PMD 5.5.2
+
+**Priority:** Medium (3)
+
+Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,
+but the code does not complain, when being compiled on the 11g DB.
+https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/static.htm#BABIIHBJ
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//ProgramUnit/Pragma
+```
+
+**Example(s):**
+
+``` sql
+create or replace package inline_pragma_error is
+
+end;
+/
+
+create or replace package body inline_pragma_error is
+ procedure do_transaction(p_input_token in varchar(200)) is
+ PRAGMA AUTONOMOUS_TRANSACTION; /* this is correct place for PRAGMA */
+ begin
+ PRAGMA AUTONOMOUS_TRANSACTION; /* this is the wrong place for PRAGMA -> violation */
+ /* do something */
+ COMMIT;
+ end do_transaction;
+
+end inline_pragma_error;
+/
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/plsql/dates.md b/docs/pages/pmd/rules/plsql/dates.md
deleted file mode 100644
index 63e581f4aee..00000000000
--- a/docs/pages/pmd/rules/plsql/dates.md
+++ /dev/null
@@ -1,146 +0,0 @@
----
-title: PLSQL DATETIME
-summary: The Dates ruleset deals with PLSQL DATETIME usages.
-permalink: pmd_rules_plsql_dates.html
-folder: pmd/rules/plsql
-sidebaractiveurl: /pmd_rules_plsql.html
-editmepath: ../pmd-plsql/src/main/resources/rulesets/plsql/dates.xml
-keywords: PLSQL DATETIME, TO_DATEWithoutDateFormat, TO_DATE_TO_CHAR, TO_TIMESTAMPWithoutDateFormat
----
-## TO_DATE_TO_CHAR
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
-
-```
-//PrimaryExpression
- [PrimaryPrefix/Name/@Image='TO_DATE']
- [count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
- [.//PrimaryExpression
- [PrimaryPrefix/Name/@Image='TO_CHAR']
- [count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
- ]
-```
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE PACKAGE BODY date_utilities
-IS
-
--- Take single parameter, relyimg on current default NLS date format
-FUNCTION strip_time (p_date IN DATE) RETURN DATE
-IS
-BEGIN
- RETURN TO_DATE(TO_CHAR(p_date));
-END strip_time;
-
-
-END date_utilities;
-/
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TO_DATEWithoutDateFormat
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-TO_DATE without date format- use TO_DATE(expression, date-format)
-
-```
-//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_DATE' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
-```
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE PACKAGE BODY date_utilities
-IS
-
--- Take single parameter, relyimg on current default NLS date format
-FUNCTION to_date_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
-IS
-BEGIN
- RETURN TO_DATE(p_date_string);
-END to_date_single_parameter ;
-
--- Take 2 parameters, using an explicit date format string
-FUNCTION to_date_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
-IS
-BEGIN
- TO_DATE(p_date_string, p_date_format);
-END to_date_two_parameters;
-
--- Take 3 parameters, using an explicit date format string and an explicit language
-FUNCTION to_date_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
-IS
-BEGIN
- TO_DATE(p_date_string, p_format_mask, p_nls_language);
-END to_date_three_parameters;
-
-END date_utilities;
-/
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## TO_TIMESTAMPWithoutDateFormat
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
-
-```
-//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_TIMESTAMP' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
-```
-
-**Example(s):**
-
-``` sql
-CREATE OR REPLACE PACKAGE BODY date_utilities
-IS
-
--- Take single parameter, relyimg on current default NLS date format
-FUNCTION to_timestamp_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
-IS
-BEGIN
- RETURN TO_TIMESTAMP(p_date_string);
-END to_timestamp_single_parameter;
-
--- Take 2 parameters, using an explicit date format string
-FUNCTION to_timestamp_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
-IS
-BEGIN
- TO_TIMESTAMP(p_date_string, p_date_format);
-END to_timestamp_two_parameters;
-
--- Take 3 parameters, using an explicit date format string and an explicit language
-FUNCTION to_timestamp_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
-IS
-BEGIN
- TO_TIMESTAMP(p_date_string, p_format_mask, p_nls_language);
-END to_timestamp_three_parameters;
-
-END date_utilities;
-/
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/plsql/design.md b/docs/pages/pmd/rules/plsql/design.md
new file mode 100644
index 00000000000..68e2fb29b71
--- /dev/null
+++ b/docs/pages/pmd/rules/plsql/design.md
@@ -0,0 +1,640 @@
+---
+title: Design
+summary: Rules that help you discover design issues.
+permalink: pmd_rules_plsql_design.html
+folder: pmd/rules/plsql
+sidebaractiveurl: /pmd_rules_plsql.html
+editmepath: ../pmd-plsql/src/main/resources/category/plsql/design.xml
+keywords: Design, CyclomaticComplexity, ExcessiveMethodLength, ExcessiveObjectLength, ExcessivePackageBodyLength, ExcessivePackageSpecificationLength, ExcessiveParameterList, ExcessiveTypeLength, NcssMethodCount, NcssObjectCount, NPathComplexity, TooManyFields, TooManyMethods
+language: PLSQL
+---
+## CyclomaticComplexity
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Complexity directly affects maintenance costs is determined by the number of decision points in a method
+plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
+Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
+high complexity, and 11+ is very high complexity.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.CyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/CyclomaticComplexityRule.java)
+
+**Example(s):**
+
+``` sql
+-- Cyclomatic Complexity of 25
+CREATE OR REPLACE PACKAGE BODY pkg_pmd_working_sequence AS
+1 PROCEDURE ty_logger IS BEGIN
+2 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+3 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+4 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+5 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ END IF;
+6 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+7 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+8 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ END IF;
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+9 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+10 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ END IF;
+ END IF;
+11 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+12 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+13 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+14 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ END IF;
+15 ELSIF false
+ THEN
+16 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+17 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ END IF;
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ END IF;
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+18 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+19 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+20 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ END IF;
+21 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+22 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+23 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ END IF;
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+24 IF true
+ THEN
+ DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
+25 ELSIF false
+ THEN
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ ELSE
+ DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
+ END IF;
+ END IF;
+ END IF;
+END;
+
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|showMethodsComplexity|true|Add method average violations to the report|no|
+|showClassesComplexity|true|Add class average violations to the report|no|
+|reportLevel|10|Cyclomatic Complexity reporting threshold|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessiveMethodLength
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+When methods are excessively long this usually indicates that the method is doing more than its
+name/signature might suggest. They also become challenging for others to digest since excessive
+scrolling causes readers to lose focus.
+Try to reduce the method length by creating helper methods and removing any copy/pasted code.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveMethodLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessiveMethodLengthRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE
+PROCEDURE doSomething BEGIN
+ DBMS_OUTPUT.PUT_LINE("Hello world!");
+ DBMS_OUTPUT.PUT_LINE("Hello world!");
+ -- 98 copies omitted for brevity.
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessiveObjectLength
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Excessive object line lengths are usually indications that the object may be burdened with excessive
+responsibilities that could be provided by other objects. In breaking these methods
+apart the code becomes more managable and ripe for reuse.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveObjectLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessiveObjectLengthRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE
+PACKAGE BODY Foo AS
+ PROCEDURE bar1 IS BEGIN
+ -- 1000 lines of code
+ END bar1;
+ PROCEDURE bar2 IS BEGIN
+ -- 1000 lines of code
+ END bar2;
+ PROCEDURE bar3 IS BEGIN
+ -- 1000 lines of code
+ END bar3;
+
+
+ PROCEDURE barN IS BEGIN
+ -- 1000 lines of code
+ END barn;
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessivePackageBodyLength
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Excessive class file lengths are usually indications that the class may be burdened with excessive
+responsibilities that could be provided by external classes or functions. In breaking these methods
+apart the code becomes more managable and ripe for reuse.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessivePackageBodyLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessivePackageBodyLengthRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE
+PACKAGE BODY Foo AS
+ PROCEDURE bar1 IS BEGIN
+ -- 1000 lines of code
+ END bar1;
+ PROCEDURE bar2 IS BEGIN
+ -- 1000 lines of code
+ END bar2;
+ PROCEDURE bar3 IS BEGIN
+ -- 1000 lines of code
+ END bar3;
+
+
+ PROCEDURE barN IS BEGIN
+ -- 1000 lines of code
+ END barn;
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessivePackageSpecificationLength
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Excessive class file lengths are usually indications that the class may be burdened with excessive
+responsibilities that could be provided by external classes or functions. In breaking these methods
+apart the code becomes more managable and ripe for reuse.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessivePackageSpecificationLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessivePackageSpecificationLengthRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE
+PACKAGE Foo AS
+ PROCEDURE bar1;
+ PROCEDURE bar2;
+ PROCEDURE bar3;
+
+ ...
+
+ PROCEDURE barN;
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessiveParameterList
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Methods with numerous parameters are a challenge to maintain, especially if most of them share the
+same datatype. These situations usually denote the need for new objects to wrap the numerous parameters.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveParameterListRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessiveParameterListRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE
+PROCEDURE addPerson( -- too many arguments liable to be mixed up
+ birthYear pls_integer, birthMonth pls_integer, birthDate pls_integer, height pls_integer, weight pls_integer, ssn pls_integer) {
+
+ . . . .
+END ADDPERSON;
+
+CREATE OR REPLACE
+PROCEDURE addPerson( -- preferred approach
+ birthdate DATE, measurements BodyMeasurements , ssn INTEGER) BEGIN
+
+ . . . .
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessiveTypeLength
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Excessive class file lengths are usually indications that the class may be burdened with excessive
+responsibilities that could be provided by external classes or functions. In breaking these methods
+apart the code becomes more managable and ripe for reuse.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveTypeLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessiveTypeLengthRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE
+TYPE BODY Foo AS
+ MEMBER PROCEDURE bar1 IS BEGIN
+ -- 1000 lines of code
+ END bar1;
+ MEMBER PROCEDURE bar2 IS BEGIN
+ -- 1000 lines of code
+ END bar2;
+ MEMBER PROCEDURE bar3 IS BEGIN
+ -- 1000 lines of code
+ END bar3;
+
+
+ MEMBER PROCEDURE barN IS BEGIN
+ -- 1000 lines of code
+ END barn;
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NcssMethodCount
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+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.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.NcssMethodCountRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/NcssMethodCountRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE PACKAGE BODY AS
+ FUNCTION methd RETURN INTEGER IS
+ BEGIN
+ RETURN 1;;
+ END;
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NcssObjectCount
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of lines
+of code for a given Oracle object. NCSS ignores comments, and counts actual statements. Using this algorithm,
+lines of code that are split are counted as one.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.NcssObjectCountRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/NcssObjectCountRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE PACKAGE pkg_
+ PROCEDURE Foo IS
+ BEGIN
+ --this class only has 6 NCSS lines
+ super();
+ super();
+ END;
+}
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NPathComplexity
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+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 and increase readability.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.NPathComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/NPathComplexityRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE
+PROCEDURE bar AS BEGIN -- this is something more complex than it needs to be,
+ if (y) THEN -- it should be broken down into smaller methods or functions
+ for j IN 0 .. j-1 LOOP
+ if (j > r) THEN
+ doSomething;
+ while (f < 5 ) LOOP
+ anotherThing;
+ f := f - 27;
+ END LOOP;
+ else
+ tryThis();
+ END IF;
+ END LOOP;
+ END IF;
+ if ( r - n > 45) THEN
+ while (doMagic) LOOP
+ findRabbits;
+ END LOOP;
+ END IF;
+ BEGIN
+ doSomethingDangerous();
+ EXCEPTION WHEN FooException THEN
+ makeAmends;
+ BEGIN
+ dontDoItAgain;
+ EXCEPTION
+ WHEN OTHERS THEN
+ log_problem;
+ END;
+ END;
+END;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## TooManyFields
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields,
+possibly through grouping related fields in new objects. For example, a class with individual
+city/state/zip fields could park them within a single Address field.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.TooManyFieldsRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/TooManyFieldsRule.java)
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE PACKAGE pkg_too_many_fields AS
+ C_CHAR_A CONSTANT CHAR(1 CHAR) := 'A';
+ C_CHAR_B CONSTANT CHAR(1 CHAR) := 'B';
+ ...
+ C_CHAR_Z CONSTANT CHAR(1 CHAR) := 'Z';
+END pkg_too_many_fields;
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|maxfields|15|Max allowable fields|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## TooManyMethods
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+A package or type 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.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//node()
+ [ (
+ local-name(.) = 'PackageSpecification'
+ or
+ local-name(.) = 'TypeSpecification'
+ )
+ and
+ (
+ count(/descendant::ProgramUnit[
+ not (
+ starts-with(@Image,'get')
+ or
+ starts-with(@Image,'set')
+ or
+ starts-with(@Image,'is')
+ )
+ ]
+ )
+ +
+ count(/descendant::TypeMethod[
+ not (
+ starts-with(@Image,'get')
+ or
+ starts-with(@Image,'set')
+ or
+ starts-with(@Image,'is')
+ )
+ ]
+ )
+ ) > $maxmethods
+ ]
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|maxmethods|1|The method count reporting threshold|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/plsql/errorprone.md b/docs/pages/pmd/rules/plsql/errorprone.md
new file mode 100644
index 00000000000..17b048571b6
--- /dev/null
+++ b/docs/pages/pmd/rules/plsql/errorprone.md
@@ -0,0 +1,150 @@
+---
+title: Error Prone
+summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+permalink: pmd_rules_plsql_errorprone.html
+folder: pmd/rules/plsql
+sidebaractiveurl: /pmd_rules_plsql.html
+editmepath: ../pmd-plsql/src/main/resources/category/plsql/errorprone.xml
+keywords: Error Prone, TO_DATE_TO_CHAR, TO_DATEWithoutDateFormat, TO_TIMESTAMPWithoutDateFormat
+language: PLSQL
+---
+## TO_DATE_TO_CHAR
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-variable)
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression
+ [PrimaryPrefix/Name/@Image='TO_DATE']
+ [count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
+ [.//PrimaryExpression
+ [PrimaryPrefix/Name/@Image='TO_CHAR']
+ [count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
+ ]
+```
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE PACKAGE BODY date_utilities
+IS
+
+-- Take single parameter, relying on current default NLS date format
+FUNCTION strip_time (p_date IN DATE) RETURN DATE
+IS
+BEGIN
+ RETURN TO_DATE(TO_CHAR(p_date));
+END strip_time;
+
+
+END date_utilities;
+/
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## TO_DATEWithoutDateFormat
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+TO_DATE without date format- use TO_DATE(expression, date-format)
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_DATE' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
+```
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE PACKAGE BODY date_utilities
+IS
+
+-- Take single parameter, relying on current default NLS date format
+FUNCTION to_date_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
+IS
+BEGIN
+ RETURN TO_DATE(p_date_string);
+END to_date_single_parameter ;
+
+-- Take 2 parameters, using an explicit date format string
+FUNCTION to_date_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
+IS
+BEGIN
+ TO_DATE(p_date_string, p_date_format);
+END to_date_two_parameters;
+
+-- Take 3 parameters, using an explicit date format string and an explicit language
+FUNCTION to_date_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
+IS
+BEGIN
+ TO_DATE(p_date_string, p_format_mask, p_nls_language);
+END to_date_three_parameters;
+
+END date_utilities;
+/
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## TO_TIMESTAMPWithoutDateFormat
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_TIMESTAMP' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
+```
+
+**Example(s):**
+
+``` sql
+CREATE OR REPLACE PACKAGE BODY date_utilities
+IS
+
+-- Take single parameter, relying on current default NLS date format
+FUNCTION to_timestamp_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
+IS
+BEGIN
+ RETURN TO_TIMESTAMP(p_date_string);
+END to_timestamp_single_parameter;
+
+-- Take 2 parameters, using an explicit date format string
+FUNCTION to_timestamp_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
+IS
+BEGIN
+ TO_TIMESTAMP(p_date_string, p_date_format);
+END to_timestamp_two_parameters;
+
+-- Take 3 parameters, using an explicit date format string and an explicit language
+FUNCTION to_timestamp_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
+IS
+BEGIN
+ TO_TIMESTAMP(p_date_string, p_format_mask, p_nls_language);
+END to_timestamp_three_parameters;
+
+END date_utilities;
+/
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/plsql/strictsyntax.md b/docs/pages/pmd/rules/plsql/strictsyntax.md
deleted file mode 100644
index 6e33ee8efa1..00000000000
--- a/docs/pages/pmd/rules/plsql/strictsyntax.md
+++ /dev/null
@@ -1,49 +0,0 @@
----
-title: Strict Syntax
-summary: The Strict Syntax ruleset contains rules that highlight invalid plsql syntax, which works, but should be avoided.
-permalink: pmd_rules_plsql_strictsyntax.html
-folder: pmd/rules/plsql
-sidebaractiveurl: /pmd_rules_plsql.html
-editmepath: ../pmd-plsql/src/main/resources/rulesets/plsql/strictsyntax.xml
-keywords: Strict Syntax, MisplacedPragma
----
-## MisplacedPragma
-
-**Since:** PMD 5.5.2
-
-**Priority:** Medium (3)
-
-Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,
-but the code does not complain, when being compiled on the 11g DB.
-https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/static.htm#BABIIHBJ
-
-```
-//ProgramUnit/Pragma
-```
-
-**Example(s):**
-
-``` sql
-create or replace package inline_pragma_error is
-
-end;
-/
-
-create or replace package body inline_pragma_error is
- procedure do_transaction(p_input_token in varchar(200)) is
- PRAGMA AUTONOMOUS_TRANSACTION; /* this is correct place for PRAGMA */
- begin
- PRAGMA AUTONOMOUS_TRANSACTION; /* this is the wrong place for PRAGMA -> violation */
- /* do something */
- COMMIT;
- end do_transaction;
-
-end inline_pragma_error;
-/
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/pom.md b/docs/pages/pmd/rules/pom.md
index acd194c3abf..0b5e8f692fc 100644
--- a/docs/pages/pmd/rules/pom.md
+++ b/docs/pages/pmd/rules/pom.md
@@ -1,13 +1,26 @@
---
title: Maven POM Rules
+tags: [rule_references, pom]
+summary: Index of all built-in rules available for Maven POM
+language_name: Maven POM
permalink: pmd_rules_pom.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
+## Error Prone
-* [Basic POM](pmd_rules_pom_basic.html): The Basic POM Ruleset contains a collection of good practices regarding Maven's POM files.
+{% include callout.html content="Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors." %}
+
+* [InvalidDependencyTypes](pmd_rules_pom_errorprone.html#invaliddependencytypes): If you use an invalid dependency type in the dependency management section, Maven doesn't fail. I...
+* [ProjectVersionAsDependencyVersion](pmd_rules_pom_errorprone.html#projectversionasdependencyversion): Using that expression in dependency declarations seems like a shortcut, but it can go wrong.By fa...
+
+## Additional rulesets
+
+* Basic POM (`rulesets/pom/basic.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [InvalidDependencyTypes](pmd_rules_pom_errorprone.html#invaliddependencytypes), [ProjectVersionAsDependencyVersion](pmd_rules_pom_errorprone.html#projectversionasdependencyversion)
-## Basic POM
-* [InvalidDependencyTypes](pmd_rules_pom_basic.html#invaliddependencytypes): While Maven will not failed if you use an invalid type for a dependency in thedependency manageme...
-* [ProjectVersionAsDependencyVersion](pmd_rules_pom_basic.html#projectversionasdependencyversion): Using that expression in dependency declarations seems like a shortcut, but it can go wrong.By fa...
diff --git a/docs/pages/pmd/rules/pom/basic.md b/docs/pages/pmd/rules/pom/basic.md
deleted file mode 100644
index c00904d2de3..00000000000
--- a/docs/pages/pmd/rules/pom/basic.md
+++ /dev/null
@@ -1,76 +0,0 @@
----
-title: Basic POM
-summary: The Basic POM Ruleset contains a collection of good practices regarding Maven's POM files.
-permalink: pmd_rules_pom_basic.html
-folder: pmd/rules/pom
-sidebaractiveurl: /pmd_rules_pom.html
-editmepath: ../pmd-xml/src/main/resources/rulesets/pom/basic.xml
-keywords: Basic POM, ProjectVersionAsDependencyVersion, InvalidDependencyTypes
----
-## InvalidDependencyTypes
-
-**Since:** PMD 5.4
-
-**Priority:** Medium (3)
-
-While Maven will not failed if you use an invalid type for a dependency in the
-dependency management section, it will not also uses the dependency.
-
-```
-//dependencyManagement/dependency/type/text[not(contains('pom, jar, maven-plugin, ejb, war, ear, rar, par',@Image))]
-```
-
-**Example(s):**
-
-``` xml
-
- ...
-
- ...
-
- org.jboss.arquillian
- arquillian-bom
- ${arquillian.version}
- bom
- import
-
- ...
-
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ProjectVersionAsDependencyVersion
-
-**Since:** PMD 5.4
-
-**Priority:** Medium (3)
-
-Using that expression in dependency declarations seems like a shortcut, but it can go wrong.
-By far the most common problem is the use of 6.0.0-SNAPSHOT in a BOM or parent POM.
-
-```
-//dependency/version/text[contains(@Image,'{project.version}')]
-```
-
-**Example(s):**
-
-``` xml
-
- ...
-
- ...
- ${project.dependency}
-
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/pom/errorprone.md b/docs/pages/pmd/rules/pom/errorprone.md
new file mode 100644
index 00000000000..7dff1d6ec5e
--- /dev/null
+++ b/docs/pages/pmd/rules/pom/errorprone.md
@@ -0,0 +1,93 @@
+---
+title: Error Prone
+summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+permalink: pmd_rules_pom_errorprone.html
+folder: pmd/rules/pom
+sidebaractiveurl: /pmd_rules_pom.html
+editmepath: ../pmd-xml/src/main/resources/category/pom/errorprone.xml
+keywords: Error Prone, InvalidDependencyTypes, ProjectVersionAsDependencyVersion
+language: Maven POM
+---
+## InvalidDependencyTypes
+
+**Since:** PMD 5.4
+
+**Priority:** Medium (3)
+
+If you use an invalid dependency type in the dependency management section, Maven doesn't fail. Instead,
+the entry is just ignored, which might have the effect, that the wrong version of the dependency is used.
+
+The following types are considered valid: pom, jar, maven-plugin, ejb, war, ear, rar, par.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//dependencyManagement/dependency/type/text[not(@Image = $validTypes)]
+```
+
+**Example(s):**
+
+``` xml
+
+ ...
+
+ ...
+
+ org.jboss.arquillian
+ arquillian-bom
+ ${arquillian.version}
+ bom
+ import
+
+ ...
+
+
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|validTypes|pom , jar , maven-plugin , ejb , war , ear , rar , par|Set of valid types.|yes. Delimiter is ','.|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ProjectVersionAsDependencyVersion
+
+**Since:** PMD 5.4
+
+**Priority:** Medium (3)
+
+Using that expression in dependency declarations seems like a shortcut, but it can go wrong.
+By far the most common problem is the use of ${project.version} in a BOM or parent POM.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//dependencies/dependency
+ [contains(version/text/@Image,'{project.version}')]
+ [
+ (/project/parent/groupId and groupId/text/@Image != /project/parent/groupId/text/@Image)
+ or
+ (/project/groupId and groupId/text/@Image != /project/groupId/text/@Image)
+ ]/version
+```
+
+**Example(s):**
+
+``` xml
+
+ ...
+
+ ...
+ ${project.dependency}
+
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/vf.md b/docs/pages/pmd/rules/vf.md
index 95b6f091563..0e0ad6a889e 100644
--- a/docs/pages/pmd/rules/vf.md
+++ b/docs/pages/pmd/rules/vf.md
@@ -1,13 +1,26 @@
---
title: Salesforce VisualForce Rules
+tags: [rule_references, vf]
+summary: Index of all built-in rules available for Salesforce VisualForce
+language_name: Salesforce VisualForce
permalink: pmd_rules_vf.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
+## Security
-* [Basic VF](pmd_rules_vf_security.html): Rules concerning basic VF guidelines.
+{% include callout.html content="Rules that flag potential security flaws." %}
-## Basic VF
* [VfCsrf](pmd_rules_vf_security.html#vfcsrf): Avoid calling VF action upon page load as the action becomes vulnerable to CSRF.
* [VfUnescapeEl](pmd_rules_vf_security.html#vfunescapeel): Avoid unescaped user controlled content in EL as it results in XSS.
+## Additional rulesets
+
+* Basic VF (`rulesets/vf/security.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [VfCsrf](pmd_rules_vf_security.html#vfcsrf), [VfUnescapeEl](pmd_rules_vf_security.html#vfunescapeel)
+
+
diff --git a/docs/pages/pmd/rules/vf/security.md b/docs/pages/pmd/rules/vf/security.md
index 1ed3b4febd2..28a4b5a6bfa 100644
--- a/docs/pages/pmd/rules/vf/security.md
+++ b/docs/pages/pmd/rules/vf/security.md
@@ -1,11 +1,12 @@
---
-title: Basic VF
-summary: Rules concerning basic VF guidelines.
+title: Security
+summary: Rules that flag potential security flaws.
permalink: pmd_rules_vf_security.html
folder: pmd/rules/vf
sidebaractiveurl: /pmd_rules_vf.html
-editmepath: ../pmd-visualforce/src/main/resources/rulesets/vf/security.xml
-keywords: Basic VF, VfUnescapeEl, VfCsrf
+editmepath: ../pmd-visualforce/src/main/resources/category/vf/security.xml
+keywords: Security, VfCsrf, VfUnescapeEl
+language: Salesforce VisualForce
---
## VfCsrf
@@ -25,7 +26,7 @@ Avoid calling VF action upon page load as the action becomes vulnerable to CSRF.
**Use this rule by referencing it:**
``` xml
-
+
```
## VfUnescapeEl
@@ -46,6 +47,6 @@ Avoid unescaped user controlled content in EL as it results in XSS.
**Use this rule by referencing it:**
``` xml
-
+
```
diff --git a/docs/pages/pmd/rules/vm.md b/docs/pages/pmd/rules/vm.md
index 88f95f9bee7..10be2fe45be 100644
--- a/docs/pages/pmd/rules/vm.md
+++ b/docs/pages/pmd/rules/vm.md
@@ -1,20 +1,43 @@
---
title: VM Rules
+tags: [rule_references, vm]
+summary: Index of all built-in rules available for VM
+language_name: VM
permalink: pmd_rules_vm.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
-
-* [Basic Velocity](pmd_rules_vm_basic.html): The Basic Velocity ruleset contains basic rules for Apache Velocity pages.
-
-## Basic Velocity
-* [AvoidDeeplyNestedIfStmts](pmd_rules_vm_basic.html#avoiddeeplynestedifstmts): Avoid creating deeply nested if-then statements since they are harder to read and error-prone to ...
-* [AvoidReassigningParameters](pmd_rules_vm_basic.html#avoidreassigningparameters): Reassigning values to incoming parameters is not recommended. Use temporary local variables inst...
-* [CollapsibleIfStatements](pmd_rules_vm_basic.html#collapsibleifstatements): Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with...
-* [EmptyForeachStmt](pmd_rules_vm_basic.html#emptyforeachstmt): Empty foreach statements should be deleted.
-* [EmptyIfStmt](pmd_rules_vm_basic.html#emptyifstmt): Empty if statements should be deleted.
-* [ExcessiveTemplateLength](pmd_rules_vm_basic.html#excessivetemplatelength): The template is too long. It should be broken up into smaller pieces.
-* [NoInlineJavaScript](pmd_rules_vm_basic.html#noinlinejavascript): Avoid inline JavaScript. Import .js files instead.
-* [NoInlineStyles](pmd_rules_vm_basic.html#noinlinestyles): Avoid inline styles. Use css classes instead.
-* [UnusedMacroParameter](pmd_rules_vm_basic.html#unusedmacroparameter): Avoid unused macro parameters. They should be deleted.
+## Best Practices
+
+{% include callout.html content="Rules which enforce generally accepted best practices." %}
+
+* [AvoidReassigningParameters](pmd_rules_vm_bestpractices.html#avoidreassigningparameters): Reassigning values to incoming parameters is not recommended. Use temporary local variables inst...
+* [UnusedMacroParameter](pmd_rules_vm_bestpractices.html#unusedmacroparameter): Avoid unused macro parameters. They should be deleted.
+
+## Design
+
+{% include callout.html content="Rules that help you discover design issues." %}
+
+* [AvoidDeeplyNestedIfStmts](pmd_rules_vm_design.html#avoiddeeplynestedifstmts): Avoid creating deeply nested if-then statements since they are harder to read and error-prone to ...
+* [CollapsibleIfStatements](pmd_rules_vm_design.html#collapsibleifstatements): Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with...
+* [ExcessiveTemplateLength](pmd_rules_vm_design.html#excessivetemplatelength): The template is too long. It should be broken up into smaller pieces.
+* [NoInlineJavaScript](pmd_rules_vm_design.html#noinlinejavascript): Avoid inline JavaScript. Import .js files instead.
+* [NoInlineStyles](pmd_rules_vm_design.html#noinlinestyles): Avoid inline styles. Use css classes instead.
+
+## Error Prone
+
+{% include callout.html content="Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors." %}
+
+* [EmptyForeachStmt](pmd_rules_vm_errorprone.html#emptyforeachstmt): Empty foreach statements should be deleted.
+* [EmptyIfStmt](pmd_rules_vm_errorprone.html#emptyifstmt): Empty if statements should be deleted.
+
+## Additional rulesets
+
+* Basic Velocity (`rulesets/vm/basic.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [AvoidDeeplyNestedIfStmts](pmd_rules_vm_design.html#avoiddeeplynestedifstmts), [AvoidReassigningParameters](pmd_rules_vm_bestpractices.html#avoidreassigningparameters), [CollapsibleIfStatements](pmd_rules_vm_design.html#collapsibleifstatements), [EmptyForeachStmt](pmd_rules_vm_errorprone.html#emptyforeachstmt), [EmptyIfStmt](pmd_rules_vm_errorprone.html#emptyifstmt), [ExcessiveTemplateLength](pmd_rules_vm_design.html#excessivetemplatelength), [NoInlineJavaScript](pmd_rules_vm_design.html#noinlinejavascript), [NoInlineStyles](pmd_rules_vm_design.html#noinlinestyles), [UnusedMacroParameter](pmd_rules_vm_bestpractices.html#unusedmacroparameter)
+
diff --git a/docs/pages/pmd/rules/vm/basic.md b/docs/pages/pmd/rules/vm/basic.md
deleted file mode 100644
index 2cdf621585e..00000000000
--- a/docs/pages/pmd/rules/vm/basic.md
+++ /dev/null
@@ -1,160 +0,0 @@
----
-title: Basic Velocity
-summary: The Basic Velocity ruleset contains basic rules for Apache Velocity pages.
-permalink: pmd_rules_vm_basic.html
-folder: pmd/rules/vm
-sidebaractiveurl: /pmd_rules_vm.html
-editmepath: ../pmd-vm/src/main/resources/rulesets/vm/basic.xml
-keywords: Basic Velocity, AvoidDeeplyNestedIfStmts, CollapsibleIfStatements, ExcessiveTemplateLength, AvoidReassigningParameters, EmptyIfStmt, EmptyForeachStmt, UnusedMacroParameter, NoInlineJavaScript, NoInlineStyles
----
-## AvoidDeeplyNestedIfStmts
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Avoid creating deeply nested if-then statements since they are harder to read and error-prone to maintain.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.basic.AvoidDeeplyNestedIfStmtsRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/basic/AvoidDeeplyNestedIfStmtsRule.java)
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|problemDepth|3|The if statement depth reporting threshold|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## AvoidReassigningParameters
-
-**Since:** PMD 5.1
-
-**Priority:** Medium High (2)
-
-Reassigning values to incoming parameters is not recommended. Use temporary local variables instead.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.basic.AvoidReassigningParametersRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/basic/AvoidReassigningParametersRule.java)
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## CollapsibleIfStatements
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.basic.CollapsibleIfStatementsRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/basic/CollapsibleIfStatementsRule.java)
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyForeachStmt
-
-**Since:** PMD 5.1
-
-**Priority:** Medium High (2)
-
-Empty foreach statements should be deleted.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.basic.EmptyForeachStmtRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/basic/EmptyForeachStmtRule.java)
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## EmptyIfStmt
-
-**Since:** PMD 5.1
-
-**Priority:** Medium High (2)
-
-Empty if statements should be deleted.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.basic.EmptyIfStmtRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/basic/EmptyIfStmtRule.java)
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## ExcessiveTemplateLength
-
-**Since:** PMD 5.1
-
-**Priority:** Medium (3)
-
-The template is too long. It should be broken up into smaller pieces.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.basic.ExcessiveTemplateLengthRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/basic/ExcessiveTemplateLengthRule.java)
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|topscore||Top score value|
-|minimum||Minimum reporting threshold|
-|sigma||Sigma value|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoInlineJavaScript
-
-**Since:** PMD 5.1
-
-**Priority:** Medium High (2)
-
-Avoid inline JavaScript. Import .js files instead.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.basic.NoInlineJavaScriptRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/basic/NoInlineJavaScriptRule.java)
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## NoInlineStyles
-
-**Since:** PMD 5.1
-
-**Priority:** Medium High (2)
-
-Avoid inline styles. Use css classes instead.
-
-```
-//Text[matches(@literal, "<[^>]+\s[sS][tT][yY][lL][eE]\s*=")]
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UnusedMacroParameter
-
-**Since:** PMD 5.1
-
-**Priority:** Medium High (2)
-
-Avoid unused macro parameters. They should be deleted.
-
-**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.basic.UnusedMacroParameterRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/basic/UnusedMacroParameterRule.java)
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/vm/bestpractices.md b/docs/pages/pmd/rules/vm/bestpractices.md
new file mode 100644
index 00000000000..6823e639a4e
--- /dev/null
+++ b/docs/pages/pmd/rules/vm/bestpractices.md
@@ -0,0 +1,40 @@
+---
+title: Best Practices
+summary: Rules which enforce generally accepted best practices.
+permalink: pmd_rules_vm_bestpractices.html
+folder: pmd/rules/vm
+sidebaractiveurl: /pmd_rules_vm.html
+editmepath: ../pmd-vm/src/main/resources/category/vm/bestpractices.xml
+keywords: Best Practices, AvoidReassigningParameters, UnusedMacroParameter
+language: VM
+---
+## AvoidReassigningParameters
+
+**Since:** PMD 5.1
+
+**Priority:** Medium High (2)
+
+Reassigning values to incoming parameters is not recommended. Use temporary local variables instead.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.bestpractices.AvoidReassigningParametersRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/bestpractices/AvoidReassigningParametersRule.java)
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## UnusedMacroParameter
+
+**Since:** PMD 5.1
+
+**Priority:** Medium High (2)
+
+Avoid unused macro parameters. They should be deleted.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.bestpractices.UnusedMacroParameterRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/bestpractices/UnusedMacroParameterRule.java)
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/vm/design.md b/docs/pages/pmd/rules/vm/design.md
new file mode 100644
index 00000000000..089de4f9267
--- /dev/null
+++ b/docs/pages/pmd/rules/vm/design.md
@@ -0,0 +1,102 @@
+---
+title: Design
+summary: Rules that help you discover design issues.
+permalink: pmd_rules_vm_design.html
+folder: pmd/rules/vm
+sidebaractiveurl: /pmd_rules_vm.html
+editmepath: ../pmd-vm/src/main/resources/category/vm/design.xml
+keywords: Design, AvoidDeeplyNestedIfStmts, CollapsibleIfStatements, ExcessiveTemplateLength, NoInlineJavaScript, NoInlineStyles
+language: VM
+---
+## AvoidDeeplyNestedIfStmts
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Avoid creating deeply nested if-then statements since they are harder to read and error-prone to maintain.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.design.AvoidDeeplyNestedIfStmtsRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/design/AvoidDeeplyNestedIfStmtsRule.java)
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|problemDepth|3|The if statement depth reporting threshold|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## CollapsibleIfStatements
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.design.CollapsibleIfStatementsRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/design/CollapsibleIfStatementsRule.java)
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## ExcessiveTemplateLength
+
+**Since:** PMD 5.1
+
+**Priority:** Medium (3)
+
+The template is too long. It should be broken up into smaller pieces.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.design.ExcessiveTemplateLengthRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/design/ExcessiveTemplateLengthRule.java)
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|topscore||Top score value|no|
+|minimum||Minimum reporting threshold|no|
+|sigma||Sigma value|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoInlineJavaScript
+
+**Since:** PMD 5.1
+
+**Priority:** Medium High (2)
+
+Avoid inline JavaScript. Import .js files instead.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.design.NoInlineJavaScriptRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/design/NoInlineJavaScriptRule.java)
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## NoInlineStyles
+
+**Since:** PMD 5.1
+
+**Priority:** Medium High (2)
+
+Avoid inline styles. Use css classes instead.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Text[matches(@literal, "<[^>]+\s[sS][tT][yY][lL][eE]\s*=")]
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/vm/errorprone.md b/docs/pages/pmd/rules/vm/errorprone.md
new file mode 100644
index 00000000000..8fdce71143e
--- /dev/null
+++ b/docs/pages/pmd/rules/vm/errorprone.md
@@ -0,0 +1,40 @@
+---
+title: Error Prone
+summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+permalink: pmd_rules_vm_errorprone.html
+folder: pmd/rules/vm
+sidebaractiveurl: /pmd_rules_vm.html
+editmepath: ../pmd-vm/src/main/resources/category/vm/errorprone.xml
+keywords: Error Prone, EmptyForeachStmt, EmptyIfStmt
+language: VM
+---
+## EmptyForeachStmt
+
+**Since:** PMD 5.1
+
+**Priority:** Medium High (2)
+
+Empty foreach statements should be deleted.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.errorprone.EmptyForeachStmtRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/errorprone/EmptyForeachStmtRule.java)
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
+## EmptyIfStmt
+
+**Since:** PMD 5.1
+
+**Priority:** Medium High (2)
+
+Empty if statements should be deleted.
+
+**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.vm.rule.errorprone.EmptyIfStmtRule](https://github.com/pmd/pmd/blob/master/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/errorprone/EmptyIfStmtRule.java)
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/xml.md b/docs/pages/pmd/rules/xml.md
index 104b0bbf0c1..4c3ca2ec0a9 100644
--- a/docs/pages/pmd/rules/xml.md
+++ b/docs/pages/pmd/rules/xml.md
@@ -1,12 +1,25 @@
---
title: XML Rules
+tags: [rule_references, xml]
+summary: Index of all built-in rules available for XML
+language_name: XML
permalink: pmd_rules_xml.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
+## Error Prone
-* [Basic XML](pmd_rules_xml_basic.html): The Basic XML Ruleset contains a collection of good practices which everyone should follow.
+{% include callout.html content="Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors." %}
+
+* [MistypedCDATASection](pmd_rules_xml_errorprone.html#mistypedcdatasection): An XML CDATA section begins with a mar...
+
+## Additional rulesets
+
+* Basic XML (`rulesets/xml/basic.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [MistypedCDATASection](pmd_rules_xml_errorprone.html#mistypedcdatasection)
-## Basic XML
-* [MistypedCDATASection](pmd_rules_xml_basic.html#mistypedcdatasection): An XML CDATA section begins with a mar...
diff --git a/docs/pages/pmd/rules/xml/basic.md b/docs/pages/pmd/rules/xml/basic.md
deleted file mode 100644
index f1537675594..00000000000
--- a/docs/pages/pmd/rules/xml/basic.md
+++ /dev/null
@@ -1,32 +0,0 @@
----
-title: Basic XML
-summary: The Basic XML Ruleset contains a collection of good practices which everyone should follow.
-permalink: pmd_rules_xml_basic.html
-folder: pmd/rules/xml
-sidebaractiveurl: /pmd_rules_xml.html
-editmepath: ../pmd-xml/src/main/resources/rulesets/xml/basic.xml
-keywords: Basic XML, MistypedCDATASection
----
-## MistypedCDATASection
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-An XML CDATA section begins with a marker, which has only two ].
-
-```
-//cdata-section[starts-with(@Image,'[') or ends-with(@Image,']')]
-```
-
-**Example(s):**
-
-``` xml
-An extra [ looks like <!CDATA[[]]>, and an extra ] looks like <!CDATA[]]]>.
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/rules/xml/errorprone.md b/docs/pages/pmd/rules/xml/errorprone.md
new file mode 100644
index 00000000000..01e61d95392
--- /dev/null
+++ b/docs/pages/pmd/rules/xml/errorprone.md
@@ -0,0 +1,34 @@
+---
+title: Error Prone
+summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+permalink: pmd_rules_xml_errorprone.html
+folder: pmd/rules/xml
+sidebaractiveurl: /pmd_rules_xml.html
+editmepath: ../pmd-xml/src/main/resources/category/xml/errorprone.xml
+keywords: Error Prone, MistypedCDATASection
+language: XML
+---
+## MistypedCDATASection
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+An XML CDATA section begins with a marker, which has only two ].
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//cdata-section[starts-with(@Image,'[') or ends-with(@Image,']')]
+```
+
+**Example(s):**
+
+``` xml
+An extra [ looks like <!CDATA[[]]>, and an extra ] looks like <!CDATA[]]]>.
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/xsl.md b/docs/pages/pmd/rules/xsl.md
index ebd281d09b4..ffaf5e0b2d5 100644
--- a/docs/pages/pmd/rules/xsl.md
+++ b/docs/pages/pmd/rules/xsl.md
@@ -1,13 +1,31 @@
---
title: XSL Rules
+tags: [rule_references, xsl]
+summary: Index of all built-in rules available for XSL
+language_name: XSL
permalink: pmd_rules_xsl.html
folder: pmd/rules
---
-List of rulesets and rules contained in each ruleset.
+## Code Style
-* [XPath in XSL](pmd_rules_xsl_xpath.html): This ruleset regroups a collection of good practices regarding XPath querying and functions inside an XSL.
+{% include callout.html content="Rules which enforce a specific coding style." %}
+
+* [UseConcatOnce](pmd_rules_xsl_codestyle.html#useconcatonce): The XPath concat() functions accepts as many arguments as required so you can have"concat($a,'b',...
+
+## Performance
+
+{% include callout.html content="Rules that flag suboptimal code." %}
+
+* [AvoidAxisNavigation](pmd_rules_xsl_performance.html#avoidaxisnavigation): Avoid using the 'following' or 'preceeding' axes whenever possible, as these can cutthrough 100% ...
+
+## Additional rulesets
+
+* XPath in XSL (`rulesets/xsl/xpath.xml`):
+
+ Deprecated This ruleset is for backwards compatibility.
+
+ It contains the following rules:
+
+ [AvoidAxisNavigation](pmd_rules_xsl_performance.html#avoidaxisnavigation), [UseConcatOnce](pmd_rules_xsl_codestyle.html#useconcatonce)
-## XPath in XSL
-* [AvoidAxisNavigation](pmd_rules_xsl_xpath.html#avoidaxisnavigation): Avoid using the 'following' or 'preceeding' axes whenever possible, as these can cutthrough 100% ...
-* [UseConcatOnce](pmd_rules_xsl_xpath.html#useconcatonce): The XPath concat() functions accepts as many arguments as required so you can have"concat($a,'b',...
diff --git a/docs/pages/pmd/rules/xsl/codestyle.md b/docs/pages/pmd/rules/xsl/codestyle.md
new file mode 100644
index 00000000000..8e66e2fabf1
--- /dev/null
+++ b/docs/pages/pmd/rules/xsl/codestyle.md
@@ -0,0 +1,36 @@
+---
+title: Code Style
+summary: Rules which enforce a specific coding style.
+permalink: pmd_rules_xsl_codestyle.html
+folder: pmd/rules/xsl
+sidebaractiveurl: /pmd_rules_xsl.html
+editmepath: ../pmd-xml/src/main/resources/category/xsl/codestyle.xml
+keywords: Code Style, UseConcatOnce
+language: XSL
+---
+## UseConcatOnce
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+The XPath concat() functions accepts as many arguments as required so you can have
+"concat($a,'b',$c)" rather than "concat($a,concat('b',$c)".
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//node()[contains(substring-after(@select,'concat'),'concat')]
+```
+
+**Example(s):**
+
+``` xsl
+
+
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/xsl/performance.md b/docs/pages/pmd/rules/xsl/performance.md
new file mode 100644
index 00000000000..24adc757e8c
--- /dev/null
+++ b/docs/pages/pmd/rules/xsl/performance.md
@@ -0,0 +1,56 @@
+---
+title: Performance
+summary: Rules that flag suboptimal code.
+permalink: pmd_rules_xsl_performance.html
+folder: pmd/rules/xsl
+sidebaractiveurl: /pmd_rules_xsl.html
+editmepath: ../pmd-xml/src/main/resources/category/xsl/performance.xml
+keywords: Performance, AvoidAxisNavigation
+language: XSL
+---
+## AvoidAxisNavigation
+
+**Since:** PMD 5.0
+
+**Priority:** Medium (3)
+
+Avoid using the 'following' or 'preceeding' axes whenever possible, as these can cut
+through 100% of the document in the worst case. Also, try to avoid using 'descendant'
+or 'descendant-self' axes, as if you're at the top of the Document, it necessarily means
+cutting through 100% of the document.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//node()[
+ contains(@select,'preceeding::')
+ or
+ contains(@select,'following::')
+ or
+ contains(@select,'descendant::')
+ or
+ contains(@select,'descendant-self::')
+ or (
+ ($checkSelfDescendantAbreviation = 'true' )
+ and
+ contains(@select,'//')
+ )
+]
+```
+
+**Example(s):**
+
+``` xsl
+
+```
+
+**This rule has the following properties:**
+
+|Name|Default Value|Description|Multivalued|
+|----|-------------|-----------|-----------|
+|checkSelfDescendantAbreviation|false|descendant::self abreviation, '//', will also trigger this rule.|no|
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
diff --git a/docs/pages/pmd/rules/xsl/xpath.md b/docs/pages/pmd/rules/xsl/xpath.md
deleted file mode 100644
index eda6752a0ea..00000000000
--- a/docs/pages/pmd/rules/xsl/xpath.md
+++ /dev/null
@@ -1,79 +0,0 @@
----
-title: XPath in XSL
-summary: This ruleset regroups a collection of good practices regarding XPath querying and functions inside an XSL.
-permalink: pmd_rules_xsl_xpath.html
-folder: pmd/rules/xsl
-sidebaractiveurl: /pmd_rules_xsl.html
-editmepath: ../pmd-xml/src/main/resources/rulesets/xsl/xpath.xml
-keywords: XPath in XSL, UseConcatOnce, AvoidAxisNavigation
----
-## AvoidAxisNavigation
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-Avoid using the 'following' or 'preceeding' axes whenever possible, as these can cut
-through 100% of the document in the worst case. Also, try to avoid using 'descendant'
-or 'descendant-self' axes, as if you're at the top of the Document, it necessarily means
-cutting through 100% of the document.
-
-```
-//node()[
- contains(@select,'preceeding::')
- or
- contains(@select,'following::')
- or
- contains(@select,'descendant::')
- or
- contains(@select,'descendant-self::')
- or (
- ($checkSelfDescendantAbreviation = 'true' )
- and
- contains(@select,'//')
- )
-]
-```
-
-**Example(s):**
-
-``` xsl
-
-```
-
-**This rule has the following properties:**
-
-|Name|Default Value|Description|
-|----|-------------|-----------|
-|checkSelfDescendantAbreviation|false|descendant::self abreviation, '//', will also trigger this rule.|
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
-## UseConcatOnce
-
-**Since:** PMD 5.0
-
-**Priority:** Medium (3)
-
-The XPath concat() functions accepts as many arguments as required so you can have
-"concat($a,'b',$c)" rather than "concat($a,concat('b',$c)".
-
-```
-//node()[contains(substring-after(@select,'concat'),'concat')]
-```
-
-**Example(s):**
-
-``` xsl
-
-
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
diff --git a/docs/pages/pmd/userdocs/best_practices.md b/docs/pages/pmd/userdocs/best_practices.md
index 6e59d9391ac..5c6aad01586 100644
--- a/docs/pages/pmd/userdocs/best_practices.md
+++ b/docs/pages/pmd/userdocs/best_practices.md
@@ -1,24 +1,32 @@
---
title: Best Practices
+tags: [userdocs]
permalink: pmd_userdocs_best_practices.html
author: Tom Copeland
+last_updated: November 2017
---
## Choose the rules that are right for you
-Running every ruleset will result in a huge number of rule violations, most of which will be unimportant.
+Running every existing rule will result in a huge number of rule violations, most of which will be unimportant.
Having to sort through a thousand line report to find the few you're really interested in takes
all the fun out of things.
-Instead, start with some of the obvious rulesets - just run [unusedcode](/pmd_rules_java.html#unused-code) and fix any unused locals and fields.
-Then, run [empty](/pmd_rules_java.html#empty-code) and fix all the empty `if` statements and such-like. After that, take [unnecessary](/pmd_rules_java.html#unnecessary)
-and fix these violations. Then, run [basic](/pmd_rules_java.html#basic) and fix the remaining violations.
-Then peruse the [design](/pmd_rules_java.html#design) and [controversial](/pmd_rules_java.html#controversial) rulesets and use the ones
-you like [via a custom ruleset](/pmd_userdocs_understanding_rulesets.html).
+Instead, start with some selected specific rules, e.g. the rules that detect unused code from
+the category [Best Practices](pmd_rules_java_bestpractices.html) and fix any unused locals and fields.
+
+Then, run rules, that detect empty `if` statements and such-like. You can find these rules in the category
+[Error Prone](pmd_rules_java_errorprone.html).
+
+After that, look at all the categories and select the rules, that are useful for your project.
+You can find an overview of the rules on the [Rule Index](pmd_rules_java.html).
+
+Use the rules you like [via a custom ruleset](pmd_userdocs_understanding_rulesets.html).
## PMD rules are not set in stone
-Generally, pick the ones you like, and ignore or [suppress](/pmd_userdocs_suppressing.html) the warnings you don't like. It's just a tool.
+Generally, pick the ones you like, and ignore or [suppress](pmd_userdocs_suppressing.html)
+the warnings you don't like. It's just a tool.
## PMD IDE plugins are nice
diff --git a/docs/pages/pmd/userdocs/cli_reference.md b/docs/pages/pmd/userdocs/cli_reference.md
new file mode 100644
index 00000000000..3a6b2df8e22
--- /dev/null
+++ b/docs/pages/pmd/userdocs/cli_reference.md
@@ -0,0 +1,252 @@
+---
+title: PMD CLI reference
+summary: "Full reference for PMD's command-line interface, including options, output formats and supported languages"
+tags: [userdocs]
+keywords: [command, line, options, help, formats, renderers]
+permalink: pmd_userdocs_cli_reference.html
+author: Tom Copeland , Xavier Le Vourch , Juan MartÃn Sotuyo Dodero
+---
+
+
+## Options
+
+The tool comes with a rather extensive help text, simply running with `-help`!
+
+
+
+ Option
+ Description
+ Default value
+ Applies to
+
+
+ {% include custom/cli_option_row.html options="-rulesets,-R"
+ option_arg="refs"
+ description="Comma-separated list of ruleset or rule references."
+ required="yes"
+ %}
+ {% include custom/cli_option_row.html options="-dir,-d"
+ option_arg="path"
+ description="Root directory for the analyzed sources."
+ required="yes"
+ %}
+ {% include custom/cli_option_row.html options="-format,-f"
+ option_arg="format"
+ description="Output format of the analysis report. The available formats
+ are described [here](#available-report-formats)."
+ default="text"
+ %}
+
+ {% include custom/cli_option_row.html options="-auxclasspath"
+ option_arg="cp"
+ description="Specifies the classpath for libraries used by the source code.
+ This is used to resolve types in source files. Alternatively, a `file://` URL
+ to a text file containing path elements on consecutive lines can be specified."
+ languages="Java"
+ %}
+ {% include custom/cli_option_row.html options="-benchmark,-b"
+ description="Enables benchmark mode, which outputs a benchmark report upon completion.
+ The report is sent to standard error."
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="-cache"
+ option_arg="filepath"
+ description="Specify the location of the cache file for incremental analysis.
+ This should be the full path to the file, including the desired file name (not just the parent directory).
+ If the file doesn't exist, it will be created on the first run. The file will be overwritten on each run
+ with the most up-to-date rule violations.
+ This can greatly improve analysis performance and is **highly recommended**."
+ %}
+ {% include custom/cli_option_row.html options="-debug,-verbose,-D,-V"
+ description="Debug mode. Prints more log output."
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="-encoding,-e"
+ option_arg="charset"
+ description="Specifies the character set encoding of the source code files PMD is reading.
+ The valid values are the standard character sets of `java.nio.charset.Charset`."
+ default="UTF-8"
+ %}
+ {% include custom/cli_option_row.html options="-failOnViolation,--failOnViolation"
+ option_arg="bool"
+ description="Specifies whether PMD exits with non-zero status if violations are found.
+ By default PMD exits with status 4 if violations are found.
+ Disable this feature with `-failOnViolation false` to exit with 0 instead and just output the report."
+ default="true"
+ %}
+ {% include custom/cli_option_row.html options="-filelist"
+ option_arg="filepath"
+ description="Path to file containing a comma delimited list of files to analyze.
+ If this is given, then you don't need to provide `-dir`."
+ %}
+ {% include custom/cli_option_row.html options="-ignorelist"
+ option_arg="filepath"
+ description="Path to file containing a comma delimited list of files to ignore.
+ This option can be combined with `-dir` and `-filelist`.
+ This ignore list takes precedence over any files in the filelist."
+ %}
+ {% include custom/cli_option_row.html options="-help,-h,-H"
+ description="Display help on usage."
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="-language,-l"
+ option_arg="lang"
+ description="Specify the language PMD should use."
+ %}
+ {% include custom/cli_option_row.html options="-minimumpriority,-min"
+ option_arg="num"
+ description="Rule priority threshold; rules with lower priority than configured here won't be used."
+ default="5"
+ %}
+ {% include custom/cli_option_row.html options="-norulesetcompatibility"
+ description='Disables the ruleset compatibility filter. The filter is active by default and tries to automatically "fix" old ruleset files with old rule names'
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="-no-cache"
+ description="Explicitly disables incremental analysis. This switch turns off suggestions to use Incremental Analysis,
+ and causes the `-cache` option to be discarded if it is provided."
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="-property,-P"
+ option_arg="name>=
+
+## Exit Status
+
+Please note that if PMD detects any violations, it will exit with status 4 (since 5.3).
+This behavior has been introduced to ease PMD integration into scripts or hooks, such as SVN hooks.
+
+
+0 Everything is fine, no violations found
+1 Couldn't understand command-line parameters or PMD exited with an exception
+4 At least one violation has been detected, unless -failOnViolation false
is set.
+
+
+
+## Supported Languages
+
+* [apex](pmd_rules_apex.html) (Salesforce Apex)
+* [java](pmd_rules_java.html)
+* [ecmascript](pmd_rules_javascript.html) (JavaScript)
+* [jsp](pmd_rules_jsp.html)
+* [plsql](pmd_rules_plsql.html)
+* [vf](pmd_rules_vf.html) (Salesforce VisualForce)
+* [vm](pmd_rules_vm.html) (Apache Velocity)
+* [xml and xsl](/pmd_rules_xml.html)
+
+
+## Available Report Formats
+
+PMD comes with many different renderers.
+The mnemonics in bold are used to select them on the command line, as
+arguments to the `-format` option. Some formats accept *properties*,
+which can be specified with the `-property` option on the command-line.
+
+* **codeclimate**: Renderer for Code Climate JSON format.
+
+* **csv**: Comma-separated values tabular format.
+
+ Properties:
+
+ * problem: Include problem column. Default: true.
+ * package: Include package column. Default: true.
+ * file: Include file column. Default: true.
+ * priority: Include priority column. Default: true.
+ * line: Include line column. Default: true.
+ * desc: Include description column. Default: true.
+ * ruleSet: Include Rule set column. Default: true.
+ * rule: Include Rule column. Default: true.
+
+* **emacs**: GNU Emacs integration.
+
+* **html**: HTML format.
+
+ Properties:
+
+ * linePrefix: Prefix for line number anchor in the source file.
+ * linkPrefix: Path to HTML source.
+
+* **ideaj**: IntelliJ IDEA integration.
+
+ Properties:
+
+ * classAndMethodName: Class and method name, pass `.method` when processing a directory.
+ * sourcePath:
+ * fileName:
+
+* **summaryhtml**: Summary HTML format.
+
+ Properties:
+
+ * linePrefix: Prefix for line number anchor in the source file.
+ * linkPrefix: Path to HTML source.
+
+* **text**: Text format.
+
+* **textcolor**: Text format, with color support (requires ANSI console support, e.g. xterm, rxvt, etc.).
+
+ Properties:
+
+ * color: Enables colors with anything other than `false` or `0`. Default: yes.
+
+* **textpad**: TextPad integration.
+
+* **vbhtml**: Vladimir Bossicard HTML format.
+
+* **xml**: XML format.
+
+ Properties:
+
+ * encoding: XML encoding format, defaults to UTF-8.
+
+* **xslt**: XML with a XSL transformation applied.
+
+ Properties:
+
+ * encoding: XML encoding format, defaults to UTF-8.
+ * xsltFilename: The XSLT file name.
+
+* **yahtml**: Yet Another HTML format.
+
+ Properties:
+
+ * outputDir: Output directory.
diff --git a/docs/pages/pmd/userdocs/configuring_rules.md b/docs/pages/pmd/userdocs/configuring_rules.md
new file mode 100644
index 00000000000..8db986cf1cf
--- /dev/null
+++ b/docs/pages/pmd/userdocs/configuring_rules.md
@@ -0,0 +1,65 @@
+---
+title: Configuring rules
+short_title: Configuring rules
+keywords: [property, properties, message, priority]
+tags: [userdocs, getting_started]
+summary: "Learn how to configure your rules directly from the ruleset XML."
+last_updated: May 2018 (6.4.0)
+permalink: pmd_userdocs_configuring_rules.html
+author: Hooper Bloob , Romain Pelisse , Clément Fournier
+---
+
+## Message and priority overriding
+
+You can change a rule's **message** by specifying a `message`
+attribute on the rule element. This will override the previous
+value and change the message the rule will print on the report.
+
+Similarly, the **priority** of a rule can be changed via a nested
+element. Using priority, you can deactivate some rules based on a
+minimum priority threshold (set using the `-min` CLI option).
+Priority is an integer ranging from 1 to 5, with 1 being the highest
+priority.
+
+
+Putting things together, the following rule reference lowers the priority
+of EmptyCatchBlock to 5, such that e.g. using the `-min 4` CLI parameters
+will cause the rule to be ignored.
+
+```xml
+
+ 5
+
+```
+
+
+## Rule properties
+
+Properties make it easy to customise the behaviour of a rule directly from the xml. They come in several types, which correspond to the type of their values. For example, NPathComplexity declares a property "reportLevel", with an integer value type, and which corresponds to the threshold above which a method will be reported. If you believe that its default value of 200 is too high, you could lower it to e.g. 150 in the following way:
+
+```xml
+
+
+ 150
+
+
+```
+
+Properties are assigned a value with a `property` element, which should mention the name of a property as an attribute. The value of the property can be specified either in the content of the element, like above, or in the `value` attribute, e.g.
+
+```xml
+
+```
+
+All property assignements must be enclosed in a `properties` element, which is itself inside a `rule` element.
+
+{%include tip.html content="The properties of a rule are documented with the rule, e.g. [here](pmd_rules_java_design.html#npathcomplexity) for NPathComplexity. Note that **assigning a value to a property that does not exist throws an error!**" %}
+
+Some properties take multiple values (a list), in which case you can provide them all by delimiting them with a delimiter character. It is usually a pipe ('\|'), or a comma (',') for numeric properties, e.g.
+```xml
+
+```
+
+These properties are referred to as **multivalued properties** in this documentation.
diff --git a/docs/pages/pmd/userdocs/cpd.md b/docs/pages/pmd/userdocs/cpd.md
index e75b3e42721..41ed9e6bb8d 100644
--- a/docs/pages/pmd/userdocs/cpd.md
+++ b/docs/pages/pmd/userdocs/cpd.md
@@ -1,6 +1,7 @@
---
-title: Finding duplicated code
-summary: Or how to find copied and pasted code
+title: Finding duplicated code with CPD
+tags: [cpd, userdocs]
+summary: "Learn how to use CPD, the copy-paste detector shipped with PMD."
permalink: pmd_userdocs_cpd.html
author: Tom Copeland
---
@@ -8,178 +9,137 @@ author: Tom Copeland
## Overview
Duplicate code can be hard to find, especially in a large project.
-But PMD's Copy/Paste Detector (CPD) can find it for you!
-CPD has been through three major incarnations:
+But PMD's **Copy/Paste Detector (CPD)** can find it for you!
-* First we wrote it using a variant of Michael Wise's Greedy String Tiling algorithm (our variant is described
- [here](http://www.onjava.com/pub/a/onjava/2003/03/12/pmd_cpd.html)).
-
-* Then it was completely rewritten by Brian Ewins using the
- [Burrows-Wheeler transform](http://dogma.net/markn/articles/bwt/bwt.htm).
-
-* Finally, it was rewritten by Steve Hawkins to use the
- [Karp-Rabin](http://www.nist.gov/dads/HTML/karpRabin.html) string matching algorithm.
+CPD works with Java, JSP, C, C++, C#, Fortran and PHP code and [some more languages](#supported-languages).
+It can be used via [command-line](#cli-usage), or via an [Ant task](#ant-task).
+It can also be run with Maven by using the `cpd-check` goal on the [Maven PMD Plugin](pmd_userdocs_tools_maven.html).
-Each rewrite made it much faster, and now it can process the JDK 1.4 java.* packages in about 4 seconds
-(on my workstation, at least).
-
-Note that CPD works with Java, JSP, C, C++, C#, Fortran and PHP code and some more languages. For the
-full list, see below [Supported Languages](#supported-languages).
Your own language is missing?
See how to add it [here](/pmd_devdocs_adding_new_cpd_language.html).
-CPD is included with PMD, which you can download [here](http://sourceforge.net/projects/pmd/files/pmd/).
-## Command line usage
+### Why should you care about duplicates?
+
+It's certainly important to know where to get CPD, and how to call it, but it's worth stepping back for a moment and asking yourself why you should care about this, being the occurrence of duplicate code blocks.
-### Windows
+Assuming duplicated blocks of code are supposed to do the same thing, any refactoring, even simple, must be duplicated too -- which is unrewarding grunt work, and puts pressure on the developer to find every place in which to perform the refactoring. Automated tools like CPD can help with that to some extent.
-CPD comes with its own starter batch file: `cpd.bat`. It's located in the `bin` subdirectory in the PMD
-binary distribution zip-file. Let's assume, you are in this directory, then you can start CPD this way:
+However, failure to keep the code in sync may mean automated tools will no longer recognise these blocks as duplicates. This means the task of finding duplicates to keep them in sync when doing subsequent refactorings can no longer be entrusted to an automated tool -- adding more burden on the maintainer. Segments of code initially supposed to do the same thing may grow apart undetected upon further refactoring.
- cpd.bat --minimum-tokens 100 --files c:\temp\src\java
+Now, if the code may never change in the future, then this is not a problem.
-The options "minimum-tokens" and "files" are the two required options; there are more options, see below.
+Otherwise, the most viable solution is to not duplicate. If the duplicates are already there, then they should be refactored out. We thus advise developers to use CPD to **help remove duplicates**, not to help keep duplicates in sync.
+### Refactoring duplicates
-### Linux
+Once you have located some duplicates, several refactoring strategies may apply depending of the scope and extent of the duplication. Here's a quick summary:
-For Linux, there is since PMD 5.0 a combined start script for all command line tools. This includes CPD.
-The start script is called `run.sh` and is located in the `bin` subdirectory in the PMD binary distribution
-zip-file. Let's assume, you are in this directory, then you can start CPD this way:
+* If the duplication is local to a method or single class:
+ * Extract a local variable if the duplicated logic is not prohibitively long
+ * Extract the duplicated logic into a private method
+* If the duplication occurs in siblings within a class hierarchy:
+ * Extract a method and pull it up in the class hierarchy, along with common fields
+ * Use the [Template Method](https://sourcemaking.com/design_patterns/template_method) design pattern
+* If the duplication occurs consistently in unrelated hierarchies:
+ * Introduce a common ancestor to those class hierarchies
- ./run.sh cpd --minimum-tokens 100 --files /tmp/src/java
+Novice as much as advanced readers may want to [read on on Refactoring Guru](https://refactoring.guru/smells/duplicate-code) for more in-depth strategies, use cases and explanations.
-The options "minimum-tokens" and "files" are the two required options; there are more options, see below.
+## CLI Usage
-### Options
+### CLI options reference
Option
Description
- Required
- Applies for language
-
-
- --minimum-tokens
- The minimum token length which should be reported as a duplicate.
- yes
-
-
-
- --files
- List of files and directories to process
- yes
-
-
-
- --filelist
- Path to file containing a comma delimited list of files to analyze. If this is given, then you don't need to provide `--files`.
- no
-
-
-
- --language
- Sources code language. Default value is `java`
- no
-
-
-
- --encoding
- Character encoding to use when processing files
- no
-
-
-
- --skip-duplicate-files
- Ignore multiple copies of files of the same name and length in comparison.
- no
-
-
-
- --exclude
- Files to be excluded from CPD check
- no
-
-
-
- --non-recursive
- Don't scan subdirectiories
- no
-
-
-
- --skip-lexical-errors
- Skip files which can't be tokenized due to invalid characters instead of aborting CPD
- no
-
-
-
- --format
- Report format. Default value is `text`.
- no
-
-
-
- --failOnViolation {true|false}
- By default CPD exits with status 4 if code duplications are found.
- Disable this option with '--failOnViolation false' to exit with 0 instead and just write the report.
- no
-
-
-
- --ignore-literals
- Ignore number values and string contents when comparing text
- no
- java
-
-
- --ignore-identifiers
- Ignore constant and variable names when comparing text
- no
- java
-
-
- --ignore-annotations
- Ignore language annotations when comparing text
- no
- java
-
-
- --ignore-usings
- Ignore using directives in C# when comparing text
- no
- C#
-
-
- --no-skip-blocks
- Do not skip code blocks marked with --skip-blocks-pattern (e.g. #if 0 until #endif)
- no
- cpp
-
-
- --skip-blocks-pattern
-
- Pattern to find the blocks to skip. Start and End pattern separated by |.
- Default is `#if 0|#endif`.
-
- no
- cpp
-
-
- --uri
- URI to process
- no
- plsql
-
-
- --help / -h
- Print help text
- no
-
+ Default
+ Applies to
+ {% include custom/cli_option_row.html options="--minimum-tokens"
+ description="The minimum token length which should be reported as a duplicate."
+ required="yes"
+ %}
+ {% include custom/cli_option_row.html options="--files"
+ description="List of files and directories to process"
+ required="yes"
+ %}
+ {% include custom/cli_option_row.html options="--filelist"
+ description="Path to file containing a comma delimited list of files to analyze. If this is given, then you don't need to provide `--files`."
+ %}
+ {% include custom/cli_option_row.html options="--language"
+ description="Sources code language."
+ default="java"
+ %}
+ {% include custom/cli_option_row.html options="--encoding"
+ description="Character encoding to use when processing files. If not specified, CPD uses the system default encoding."
+ %}
+ {% include custom/cli_option_row.html options="--skip-duplicate-files"
+ description="Ignore multiple copies of files of the same name and length in comparison."
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="--exclude"
+ description="Files to be excluded from CPD check"
+ %}
+ {% include custom/cli_option_row.html options="--non-recursive"
+ description="Don't scan subdirectories"
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="--skip-lexical-errors"
+ description="Skip files which can't be tokenized due to invalid characters instead of aborting CPD"
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="--format"
+ description="Report format."
+ default="text"
+ %}
+ {% include custom/cli_option_row.html options="--failOnViolation"
+ option_arg="bool"
+ description="By default CPD exits with status 4 if code duplications are found.
+ Disable this option with `--failOnViolation false` to exit with 0 instead and just write the report."
+ default="true"
+ %}
+ {% include custom/cli_option_row.html options="--ignore-literals"
+ description="Ignore number values and string contents when comparing text"
+ default="false"
+ languages="Java"
+ %}
+ {% include custom/cli_option_row.html options="--ignore-identifiers"
+ description="Ignore constant and variable names when comparing text"
+ default="false"
+ languages="Java"
+ %}
+ {% include custom/cli_option_row.html options="--ignore-annotations"
+ description="Ignore language annotations when comparing text"
+ default="false"
+ languages="Java"
+ %}
+ {% include custom/cli_option_row.html options="--ignore-usings"
+ description="Ignore `using` directives in C# when comparing text"
+ default="false"
+ languages="C#"
+ %}
+ {% include custom/cli_option_row.html options="--no-skip-blocks"
+ description="Do not skip code blocks matched by `--skip-blocks-pattern`"
+ default="false"
+ languages="C++"
+ %}
+ {% include custom/cli_option_row.html options="--skip-blocks-pattern"
+ description="Pattern to find the blocks to skip. It is a string property and contains of two parts,
+ separated by `|`. The first part is the start pattern, the second part is the ending pattern."
+ default="#if 0|#endif"
+ languages="C++"
+ %}
+ {% include custom/cli_option_row.html options="--uri"
+ description="URI to process"
+ languages="PLSQL"
+ %}
+ {% include custom/cli_option_row.html options="--help,-h"
+ default="false"
+ description="Print help text"
+ %}
### Examples
@@ -241,26 +201,30 @@ This behavior has been introduced to ease CPD integration into scripts or hooks,
-### Supported Languages
+## Supported Languages
-* cs
-* cpp
-* ecmascript (JavaScript)
-* fortran
-* go
-* java
-* jsp
-* matlab
-* objectivec
-* php
-* plsql
-* python
-* ruby
-* scala
-* swift
+* Apex
+* C#
+* C/C++
+* EcmaScript (JavaScript)
+* Fortran
+* Go
+* Groovy
+* Java
+* Jsp
+* Matlab
+* Objective-C
+* Perl
+* PHP
+* PL/SQL
+* Python
+* Ruby
+* Scala
+* Swift
+* Visualforce
-### Available formats
+## Available report formats
* text : Default format
* xml
@@ -273,6 +237,7 @@ This behavior has been introduced to ease CPD integration into scripts or hooks,
Andy Glover wrote an Ant task for CPD; here's how to use it:
+```xml
@@ -281,128 +246,87 @@ Andy Glover wrote an Ant task for CPD; here's how to use it:
+```
+
+
+
+### Attribute reference
-
-
- Attribute
- Description
- Applies for language
- Required
-
-
- encoding
-
- The character set encoding (e.g., UTF-8) to use when reading the source code files, but also when
- producing the report. A piece of warning, even if you set properly the encoding value,
- let's say to UTF-8, but you are running CPD encoded with CP1252, you may end up with not UTF-8 file.
- Indeed, CPD copy piece of source code in its report directly, therefore, the source files
- keep their encoding.
- If not specified, CPD uses the system default encoding.
-
-
- No
-
-
- format
- The format of the report (e.g. `csv`, `text`, `xml`); defaults to `text`.
-
- No
-
-
- ignoreLiterals
-
- if `true`, CPD ignores literal
- value differences when evaluating a duplicate block. This means that `foo=42;` and `foo=43;`
- will be seen as equivalent. You may want to run PMD with this option off to start with and
- then switch it on to see what it turns up; defaults to `false`.
-
- java
- No
-
-
- ignoreIdentifiers
-
- Similar to `ignoreLiterals` but for identifiers; i.e., variable names, methods names,
- and so forth; defaults to `false`.
-
- java
- No
-
-
- ignoreAnnotations
-
- Ignore annotations. More and more modern frameworks use annotations on classes and methods,
- which can be very redundant and trigger CPD matches. With J2EE (CDI, Transaction Handling, etc)
- and Spring (everything) annotations become very redundant. Often classes or methods have the
- same 5-6 lines of annotations. This causes false positives; defaults to `false`.
-
- java
- No
-
-
- ignoreUsings
-
- Ignore using directives in C#.
-
- C#
- No
-
-
- skipDuplicateFiles
-
- Ignore multiple copies of files of the same name and length in comparison; defaults to `false`.
-
-
- No
-
-
- skipLexicalErrors
-
- Skip files which can't be tokenized due to invalid characters instead of aborting CPD; defaults to `false`.
-
-
- No
-
-
- skipBlocks
-
- Enables or disabled skipping of blocks like a pre-processor; defaults to `true`.
- See also option skipBlocksPattern.
-
- cpp
- No
-
-
- skipBlocksPattern
-
- Configures the pattern, to find the blocks to skip. It is a string property and contains of two parts,
- separated by `|`. The first part is the start pattern, the second part is the ending pattern.
- The default value is `#if 0|#endif`.
-
- cpp
- no
-
-
- language
-
- Flag to select the appropriate language (e.g. `c`, `cpp`, `cs`, `java`, `jsp`, `php`, `ruby`, `fortran`
- `ecmascript`, and `plsql`); defaults to `java`.
-
-
- No
-
-
- minimumtokencount
- A positive integer indicating the minimum duplicate size.
-
- Yes
-
-
- outputfile
- The destination file for the report. If not specified the console will be used instead.
-
- No
-
+
+
+ Attribute
+ Description
+ Default
+ Applies to
+
+ {% include custom/cli_option_row.html options="minimumtokencount"
+ description="A positive integer indicating the minimum duplicate size."
+ required="yes"
+ %}
+ {% include custom/cli_option_row.html options="encoding"
+ description="The character set encoding (e.g., UTF-8) to use when reading the source code files, but also when
+ producing the report. A piece of warning, even if you set properly the encoding value,
+ let's say to UTF-8, but you are running CPD encoded with CP1252, you may end up with not UTF-8 file.
+ Indeed, CPD copy piece of source code in its report directly, therefore, the source files
+ keep their encoding.
+ If not specified, CPD uses the system default encoding."
+ %}
+ {% include custom/cli_option_row.html options="format"
+ description="The format of the report (e.g. `csv`, `text`, `xml`)."
+ default="text"
+ %}
+ {% include custom/cli_option_row.html options="ignoreLiterals"
+ description="if `true`, CPD ignores literal value differences when evaluating a duplicate
+ block. This means that `foo=42;` and `foo=43;` will be seen as equivalent. You may want
+ to run PMD with this option off to start with and then switch it on to see what it turns up."
+ default="false"
+ languages="Java"
+ %}
+ {% include custom/cli_option_row.html options="ignoreIdentifiers"
+ description="Similar to `ignoreLiterals` but for identifiers; i.e., variable names, methods names, and so forth."
+ default="false"
+ languages="Java"
+ %}
+ {% include custom/cli_option_row.html options="ignoreAnnotations"
+ description="Ignore annotations. More and more modern frameworks use annotations on classes and methods,
+ which can be very redundant and trigger CPD matches. With J2EE (CDI, Transaction Handling, etc)
+ and Spring (everything) annotations become very redundant. Often classes or methods have the
+ same 5-6 lines of annotations. This causes false positives."
+ default="false"
+ languages="Java"
+ %}
+ {% include custom/cli_option_row.html options="ignoreUsings"
+ description="Ignore using directives in C#."
+ default="false"
+ languages="C#"
+ %}
+ {% include custom/cli_option_row.html options="skipDuplicateFiles"
+ description="Ignore multiple copies of files of the same name and length in comparison."
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="skipLexicalErrors"
+ description="Skip files which can't be tokenized due to invalid characters instead of aborting CPD."
+ default="false"
+ %}
+ {% include custom/cli_option_row.html options="skipBlocks"
+ description="Enables or disabled skipping of blocks like a pre-processor. See also option skipBlocksPattern."
+ default="true"
+ languages="C++"
+ %}
+ {% include custom/cli_option_row.html options="skipBlocksPattern"
+ description="Configures the pattern, to find the blocks to skip. It is a string property and contains of two parts,
+ separated by `|`. The first part is the start pattern, the second part is the ending pattern."
+ default="#if 0|#endif"
+ languages="C++"
+ %}
+ {% include custom/cli_option_row.html options="language"
+ description="Flag to select the appropriate language (e.g. `c`, `cpp`, `cs`, `java`, `jsp`, `php`, `ruby`, `fortran`
+ `ecmascript`, and `plsql`)."
+ default="java"
+ %}
+ {% include custom/cli_option_row.html options="outputfile"
+ description="The destination file for the report. If not specified the console will be used instead."
+ %}
Also, you can get verbose output from this task by running ant with the `-v` flag; i.e.:
@@ -412,7 +336,9 @@ Also, you can get verbose output from this task by running ant with the `-v` fla
Also, you can get an HTML report from CPD by using the XSLT script in pmd/etc/xslt/cpdhtml.xslt. Just run
the CPD task as usual and right after it invoke the Ant XSLT script like this:
+```xml
+```
## GUI
@@ -433,8 +359,10 @@ Here's a screenshot of CPD after running on the JDK 8 java.lang package:
## Suppression
-Arbitrary blocks of code can be ignored through comments on **Java** by including the keywords `CPD-OFF` and `CPD-ON`.
+Arbitrary blocks of code can be ignored through comments on **Java**, **C/C++**, **Javascript**, **Matlab**,
+**Objective-C**, **PL/SQL** and **Python** by including the keywords `CPD-OFF` and `CPD-ON`.
+```java
public Object someParameterizedFactoryMethod(int x) throws Exception {
// some unignored code
@@ -452,7 +380,7 @@ Arbitrary blocks of code can be ignored through comments on **Java** by includin
// further code will *not* be ignored
}
-
+```
Additionally, **Java** allows to toggle suppression by adding the annotations
**`@SuppressWarnings("CPD-START")`** and **`@SuppressWarnings("CPD-END")`**
@@ -461,6 +389,7 @@ all code within will be ignored by CPD.
This approach however, is limited to the locations were `@SuppressWarnings` is accepted.
It's legacy and the new comment's based approch should be favored.
+```java
//enable suppression
@SuppressWarnings("CPD-START")
public Object someParameterizedFactoryMethod(int x) throws Exception {
@@ -470,7 +399,19 @@ It's legacy and the new comment's based approch should be favored.
@SuppressWarnings("CPD-END)
public void nextMethod() {
}
-
+```
Other languages currently have no support to suppress CPD reports. In the future,
the comment based approach will be extended to those of them that can support it.
+
+## Credits
+CPD has been through three major incarnations:
+
+* First we wrote it using a variant of Michael Wise's Greedy String Tiling algorithm (our variant is described
+ [here](http://www.onjava.com/pub/a/onjava/2003/03/12/pmd_cpd.html)).
+
+* Then it was completely rewritten by Brian Ewins using the
+ [Burrows-Wheeler transform](http://dogma.net/markn/articles/bwt/bwt.htm).
+
+* Finally, it was rewritten by Steve Hawkins to use the
+ [Karp-Rabin](http://www.nist.gov/dads/HTML/karpRabin.html) string matching algorithm.
diff --git a/docs/pages/pmd/userdocs/extending/defining_properties.md b/docs/pages/pmd/userdocs/extending/defining_properties.md
new file mode 100644
index 00000000000..dfa69e98c04
--- /dev/null
+++ b/docs/pages/pmd/userdocs/extending/defining_properties.md
@@ -0,0 +1,173 @@
+---
+title: Defining rule properties
+short_title: Defining rule properties
+tags: [extending, userdocs]
+summary: "Learn how to define your own properties both for Java and XPath rules."
+last_updated: December 2017 (6.0.0)
+permalink: pmd_userdocs_extending_defining_properties.html
+author: Hooper Bloob , Romain Pelisse , Clément Fournier
+---
+
+
+## Defining properties
+
+If you're a rule developer, you may want to think about what would be useful for a user of your rule to parameterise. It could be a numeric report level, a boolean flag changing the behaviour of your rule... PMD ships with many types of properties ready to use!
+
+### Overview of properties
+
+The basic thing you need to do as a developer is to define a **property descriptor** and declare that your rule uses it. A property descriptor defines a number of attributes for your property:
+* Its *name*, with which the user will refer to your property;
+* Its *description*, for documentation purposes;
+* Its *default value*
+
+Don't worry, all of these attributes can be specified in a single Java statement (or xml element for XPath rules).
+
+Without further ado, here is the list of available (single-value) properties:
+
+|Class name|Value type|
+|----------|----------|
+|IntegerProperty | int
+|DoubleProperty | double
+|FloatProperty | float
+|LongProperty | long
+|EnumeratedProperty\<*E*\>| *E*
+|StringProperty|String
+|BooleanProperty|boolean
+|CharacterProperty|char
+|FileProperty|java.io.File
+|MethodProperty|java.lang.reflect.Method
+|TypeProperty|java.lang.Class\\>
+|RegexProperty|java.util.regex.Pattern
+
+Each of these is complemented by a multivalued variant, whose name ends with "MultiProperty", and which returns a list of values, e.g.
+
+|Class name|Value type|
+|----------|----------|
+|LongMultiProperty | List\
+|EnumeratedMultiProperty\<*E*\>| List\<*E*\>
+
+Note that RegexProperty doesn't have a multivalued variant, since the delimiters could be part of a specific value.
+
+### For Java rules
+
+The procedure to define a property is quite straightforward:
+* Create a property descriptor of the type you want, using its builder;
+* Call `definePropertyDescriptor()` in the rule's noarg constructor.
+
+You can then retrieve the value of the property at any time using `getProperty()`.
+
+#### Creating a descriptor
+
+From version 6.0.0 on, properties can be built using specific **builders**. For example, to build a string property, you'd call
+```java
+StringProperty.named("myProperty")
+ .desc("This is my property")
+ .defaultValue("foo")
+ .build();
+```
+
+This is fairly more readable than a constructor call, but keep in mind the description and the default value are not optional.
+
+{%include note.html content="The constructors may be deprecated in a future release, so please use the builders instead." %}
+
+For **numeric properties**, you'd add a call to `range` to define the range of acceptable values, e.g.
+```java
+IntegerProperty.named("myIntProperty")
+ .desc("This is my property")
+ .defaultValue(3)
+ .range(0, 100)
+ .build();
+```
+
+**Enumerated properties** are a bit less straightforward to define, though they are arguably more powerful. These properties don't have a specific value type, instead, you can choose any type of value, provided the values are from a closed set. To make that actionable, you give string labels to each of the acceptable values, and the user will provide one of those labels as a value in the XML. The property will give you back the associated value, not the label. Here's an example:
+```java
+static Map map = new HashMap<>();
+
+static {
+ map.put("easyMode", new EasyStrategy());
+ map.put("hardMode", new HardStrategy());
+}
+
+static EnumeratedProperty modeProperty
+ = EnumeratedProperty.named("modeProperty")
+ .desc("This is my property")
+ .defaultValue(new EasyStrategy())
+ .mappings(map)
+ .type(ModeStrategy.class)
+ .build();
+```
+
+Note that you're required to fill in the type of the values too, using `type()`.
+
+#### Example
+
+You can see an example of properties used in a PMD rule [here](https://github.com/pmd/pmd/blob/ac2ff0f6af8d16f739584ba8d00b7ea1a6311ccc/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/complexity/AvoidDeeplyNestedIfStmtsRule.java#L17).
+There are several things to notice here:
+* The property descriptor is declared `static final`, which should generally be the case, as descriptors are immutable and can be shared between instances of the same rule;
+* The property is declared using `definePropertyDescriptor` *in the constructor*, which ensures the property gets recognised by PMD;
+* The value of the property is *not retrieved in the constructor*, but in one of the `visit` methods (typically on the highest node in the tree, since the property doesn't change).
+
+
+
+### For XPath rules
+
+XPath rules can also define their own properties. To do so, you must add a `property` element in the `properties` element of your rule, which **declares the `type` attribute**. This attribute conditions what type the underlying property has, and can have the following values:
+
+| `type` attribute | Property type|
+|----------|----------|
+|Integer|IntegerProperty
+|Double | DoubleProperty
+|Float|FloatProperty
+|Long| LongProperty
+|String|StringProperty
+|Character|CharacterProperty
+|Boolean|BooleanProperty
+|Class|TypeProperty
+|Regex|RegexProperty
+
+Note that enumerated properties are not available in XPath rules (yet?).
+
+Properties defined in XPath also *must* declare the `description` attribute. Numeric properties also expect the `min` and `max` attributes. Here are a few examples to sum it up:
+
+```xml
+
+
+```
+
+You can then use the property in XPath with the syntax `$propertyName`, for example:
+
+```xml
+
+
+
+
+ $maxStatements]
+ ]]>
+
+
+```
+
+#### Multivalued properties
+
+Multivalued properties are also allowed and their `type` attribute has the form `List[Boolean]` or `List[Character]`, with every above type allowed. These properties **require XPath 2.0** to work properly, and make use of the **sequence datatype** provided by that language. You thus need to set the `version` property to `2.0` to use them. Properties can also declare the `delimiter` attribute.
+
+
+
+```xml
+
+
+
+
+
+
+
+
+
+```
+
+Notice that in the example above, `@Image = $reportedIdentifiers` doesn't test `@Image` for equality with the whole sequence `('foo', 'bar')`, it tests whether the sequence *contains* `@Image`. That is, the above rule will report all variables named `foo` or `bar`. All other XPath 2.0 [functions operating on sequences](https://www.w3.org/TR/xpath-functions/#sequence-functions) are supported.
diff --git a/docs/pages/pmd/devdocs/metrics_howto.md b/docs/pages/pmd/userdocs/extending/metrics_howto.md
similarity index 90%
rename from docs/pages/pmd/devdocs/metrics_howto.md
rename to docs/pages/pmd/userdocs/extending/metrics_howto.md
index 8c7045e062a..5ccabe03cdb 100644
--- a/docs/pages/pmd/devdocs/metrics_howto.md
+++ b/docs/pages/pmd/userdocs/extending/metrics_howto.md
@@ -1,24 +1,17 @@
---
-title: Using code metrics in custom rules
-tags: [customizing]
-summary: "PMD was recently enhanced with the ability to compute code metrics on Java and Apex source (the so-called
+title: Using and defining code metrics for custom rules
+tags: [extending, userdocs, metrics]
+summary: "Since version 6.0.0, PMD is enhanced with the ability to compute code metrics on Java and Apex source (the so-called
Metrics Framework). This framework provides developers with a straightforward interface to use code metrics in their
rules, and to extend the framework with their own custom metrics."
-last_updated: July 20, 2017
-permalink: pmd_devdocs_metrics_howto.html
+last_updated: December 18, 2017
+permalink: pmd_userdocs_extending_metrics_howto.html
author: Clément Fournier
---
-# Using code metrics in custom rules
## Using the metrics framework
-{%include note.html content="Using the metrics framework is for now restricted to Java rules (with plans to support
-XPath rules later)." %}
-
-To use the metrics framework in a custom rule, the first thing to do would be to **enable metrics by adding the
-`metrics="true"` attribute** to your rule's XML element.
-
-{%include note.html content="The following explains how to use the Java metrics framework. The Apex framework
+{%include note.html content="The following explains how to use the Java metrics framework. The Apex framework
differs only by the name of its classes." %}
In PMD's Metrics framework, a metric is an operation that can be carried out on nodes of a certain type and produces
@@ -57,8 +50,6 @@ or `ConstructorDeclaration`.
## For Java Rules
-First, similarly to XPath rules, you should add the `metrics="true"` attribute to your rule's XML element.
-
The static façade class `JavaMetrics` is the single entry point to compute metrics in the Java framework.
This class provides the method `get` and its overloads. The following sections describes the interface of this class.
@@ -107,7 +98,7 @@ public Object visit(ASTMethodDeclaration method, Object data) {
### Metric options
Some metrics define options that can be used to slightly modify the computation. You'll typically see these options
-gathered inside an enum in the implementation class of the metric, for example `CycloMetric.CycloOptions`. They're
+gathered inside an enum in the implementation class of the metric, for example `CycloMetric.CycloOption`. They're
also documented on the [index of metrics](pmd_java_metrics_index.html).
To use options with a metric, you must first bundle them into a `MetricOptions` object. `MetricOptions` provides the
@@ -126,7 +117,7 @@ public Object visit(ASTMethodDeclaration method, Object data) {
The version of `MetricOptions.ofOptions` using a collection is useful when you're building a `MetricOptions` from eg
the value of an `EnumeratedMultiProperty`, which gives users control of the options they use. See
-[CyclomaticComplexityRule]( https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/rule/CyclomaticComplexityRule.java)
+[CyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CyclomaticComplexityRule.java#L35)
for an example usage.
### Result options
@@ -153,17 +144,18 @@ option too.
The following is a sample code for a rule reporting methods with a cyclomatic
complexity over 10 and classes with a total cyclo over 50. A metric option can be
user-configured with a rule property. More complete examples can be found in
-[CyclomaticComplexityRule]( https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/rule/CyclomaticComplexityRule.java),
-[NcssCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/rule/NcssCountRule.java),
-or [GodClassRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/GodClassRule.java).
+[CyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CyclomaticComplexityRule.java#L35),
+[NcssCountRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java#L30),
+or [GodClassRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/GodClassRule.java#L24).
```java
public class CycloRule extends AbstractJavaMetricsRule {
public static final BooleanProperty COUNT_BOOLEAN_PATHS
- = new BooleanProperty("countBooleanPaths", "Count boolean paths",
- true, 0f);
+ = BooleanProperty.named("countBooleanPaths")
+ .desc("Count boolean paths")
+ .defaultValue(true).build();
private static final MetricOptions options;
@@ -275,9 +267,10 @@ concrete node types you can target with class and operation metrics, by language
Language | Java | Apex |
-----------|------|------|
-Operation declaration|`ASTMethodOrConstructorDeclaration` >: `ASTMethodDeclaration`, `ASTConstructorDeclaration`| `ASTMethod`
+Operation declaration|`ASTMethodOrConstructorDeclaration` >: `ASTMethodDeclaration`, `ASTConstructorDeclaration`| `ASTMethod`*
Type declaration|`ASTAnyTypeDeclaration` >: `ASTEnumDeclaration`, `ASTAnnotationDeclaration`, `ASTClassOrInterfaceDeclaration`| `ASTUserClassOrInterface` >: `ASTUserClass`, `ASTUserInterface`
+*Apex method metrics are also applied to triggers by default (see [#771](https://github.com/pmd/pmd/pull/771)). Finer capability checking is not available out of the box for now.
What if you don't want such a generalisation? The `supports` method lets you
define a predicate to check that the node is supported by your metric. For example,
@@ -300,5 +293,5 @@ classes. Here's the default behaviour by language and type of metric:
Language | Java | Apex |
-----------|------|------|
-Operation metrics| supports constructors and non abstract methods| supports any non abstract method except ``, ``, and `clone`
+Operation metrics| supports constructors and non abstract methods| supports any non abstract method (including triggers), except ``, ``, and `clone`
Type declaration|supports classes and enums|supports classes
diff --git a/docs/pages/pmd/devdocs/rule_guidelines.md b/docs/pages/pmd/userdocs/extending/rule_guidelines.md
similarity index 93%
rename from docs/pages/pmd/devdocs/rule_guidelines.md
rename to docs/pages/pmd/userdocs/extending/rule_guidelines.md
index 791830bcc37..91f03f6dba9 100644
--- a/docs/pages/pmd/devdocs/rule_guidelines.md
+++ b/docs/pages/pmd/userdocs/extending/rule_guidelines.md
@@ -1,9 +1,9 @@
---
-title: PMD Rule Guidelines
-tags: [customizing]
+title: Rule guidelines
+tags: [extending, userdocs]
summary: Rule Guidelines
last_updated: July 3, 2016
-permalink: pmd_devdocs_rule_guidelines.html
+permalink: pmd_userdocs_extending_rule_guidelines.html
author: Xavier Le Vourch, Ryan Gustafson, Romain Pelisse
---
@@ -51,8 +51,8 @@ See [Test Framework](pmd_devdocs_testing.html) for the general documentation
### … for a rule I want to submit (in a patch)
-Figure out the ruleset to which you want to the rule. Then add your rule to the appropriate test class for
-the ruleset and add the XML test data in the correct xml subpackage.
+Figure out the category to which you want to the rule. Then add your rule to the appropriate test class for
+the category and add the XML test data in the correct xml subpackage.
### … for something too specific, that I won’t be able to submit
diff --git a/docs/pages/pmd/userdocs/extending/testing.md b/docs/pages/pmd/userdocs/extending/testing.md
new file mode 100644
index 00000000000..d7ac79032c8
--- /dev/null
+++ b/docs/pages/pmd/userdocs/extending/testing.md
@@ -0,0 +1,280 @@
+---
+title: Testing your rules
+tags: [extending, userdocs]
+summary: "Learn how to use PMD's simple test framework for unit testing rules."
+permalink: pmd_userdocs_extending_testing.html
+last_updated: November 2018
+author: Andreas Dangel
+---
+
+## Introduction
+
+Good rules have tests. At least a positive test case - a code example, that triggers the rule and reports
+a violation - and a negative test case - a code example, that doesn't trigger the rule - should be created.
+Of course, the more tests, the better the rule is verified. If the rule is more complex or defines properties,
+with which the behavior can be modified, then these different cases can also be tested.
+
+And if there is a bug fix for a rule, be it a false positive or a false negative case, it should be accompanied
+with an additional test case, so that the bug is not accidentally reintroduced later on.
+
+## How it works
+
+PMD's built-in rules are organized in rulesets, where all rules belonging to the same category are placed
+in a single ruleset, such as "category/java/bestpractices.xml".
+Each category-ruleset has a single abstract base test class, from which the individual test classes inherit.
+We have one test class per rule, which executes all test cases for a single rule. The actual test cases are
+stored in separate XML files, for each rule a separate file is used.
+
+All the test classes inherit from `net.sourceforge.pmd.testframework.PmdRuleTst`,
+which provides the seamless integration with JUnit. This base class determines the language, the category name
+and the rule name from the concrete test class. It then searches the test code on its own.
+E.g. the individual rule test class
+`net.sourceforge.pmd.lang.java.rule.bestpractices.AbstractClassWithoutAbstractMethodTest` tests the
+rule with the name "AbstractClassWithoutAbstractMethod", which is in the category "bestpractices" for the
+language "java".
+
+The test code (see below [Test XML Reference](#test-xml-reference)) describes the test case completely with
+the expected behavior like number of expected rule violations, where the violations are expected, and so on.
+
+When you are running the test class in your IDE (e.g. Eclipse or IntelliJ IDEA) you can also select a single
+test case and just execute this one.
+
+## Where to place the test code
+
+The `PmdRuleTst` class searches the XML file, that describes the test cases for a certain rule
+using the following convention:
+The XML file is a test resource, so it is searched in the tree under `src/test/resources`.
+
+The sub package `xml` of the test class's package should contain a file with the same name as the rule's name
+which is under test.
+
+For example, to test the rule "AbstractClassWithoutAbstractMethod", the fully qualified test class is:
+
+ net.sourceforge.pmd.lang.java.rule.bestpractices.AbstractClassWithoutAbstractMethodTest
+
+The test code for the rule can be found in the file:
+
+ src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/AbstractClassWithoutAbstractMethod.xml
+
+In general, the class name and file name pattern for the test class and data is this:
+
+ net.sourceforge.pmd.lang..rule..Test
+ src/test/resources/net/sourceforge/pmd/lang//rule//xml/.xml
+
+{%include tip.html content="This convention allows you to quickly find the test cases for a given rule:
+Just search in the project for a file `.xml`. Search for a class `Test` to find the
+unit test class for the given rule." %}
+
+{%include note.html content="If you want to use the test framework with a different package structure,
+see [Using the test framework externally](#using-the-test-framework-externally)." %}
+
+## Simple example
+
+### Test Class: AbstractClassWithoutAbstractMethodTest
+
+This class inherits from `PmdRuleTst` and is located in the package "bestpractices", since the rule
+belongs to the category "Best Practices":
+
+``` java
+package net.sourceforge.pmd.lang.java.rule.bestpractices;
+
+import net.sourceforge.pmd.testframework.PmdRuleTst;
+
+public class AbstractClassWithoutAbstractMethodTest extends PmdRuleTst {
+ // no additional unit tests
+}
+```
+
+{%include note.html content="You can also add additionally standard JUnit test methods annotated with `@Test` to
+this test class." %}
+
+### Test Data: AvoidBranchingStatementAsLastInLoop.xml
+
+This is a stripped down example which just contains two test cases.
+
+``` xml
+
+
+
+ concrete class
+ 0
+
+
+
+ failure case
+ 1
+ 1
+
+
+
+```
+
+Each test case is in an own `` element. The first defines 0 expected problems, means this code doesn't
+trigger the rule. The second test case expects 1 problem. Since the rule violations also report the exact AST node,
+you can verify the line number, too.
+
+## Test XML Reference
+
+The root element is ``. It can contain one or more `` and `` elements.
+Each `` element defines a single test case. `` elements are used to share code snippets
+between different test cases.
+
+{%include note.html content="The XML schema is available at [rule-tests.xsd](https://github.com/pmd/pmd/blob/master/pmd-test/src/main/resources/rule-tests_1_0_0.xsd)." %}
+
+### `` attributes
+
+The `` elements understands three optional attributes:
+
+* **reinitializeRule**: By default, it's `true`, so each test case starts with a fresh instantiated rule. Set it
+ to `false` to reproduce cases, where the previous run has influences.
+
+* **regressionTest**: By default, it's `true`. Set it to `false`, to ignore and skip a test case.
+
+* **useAuxClasspath**: By default, it's `true`. Set it to `false` to reproduce issues which only
+ appear without type resolution.
+
+### `` children
+
+* **``**: Short description of the test case. This will be the JUnit test name in the report.
+ If applicable, this description should contain a reference to the bug number, this test case reproduces.
+
+* **``**: Optional rule properties, if the rule is configurable. Just add multiple elements, to
+ set multiple properties for one test case. For an example, see below.
+
+* **``**: The the raw number of expected rule violations, that this rule is expected to report.
+ For false-positive test cases, this is always "0". For false-negative test cases, it can be any positive number.
+
+* **``**: Optional element. It's a comma separated list of line numbers.
+ If there are rule violations reported, then this allows you to
+ assert the line numbers. Useful if multiple violations should be detected and to be sure that
+ false positives and negatives don't erase each other.
+
+* **``**: Optional element, with `` elements as children.
+ Can be used to validate the correct error message, e.g. if the error message references a variable name.
+
+* **``**: Either the `` element or the `` element is required. It provides the actual code
+ snippet on which the rule is executed. The code itself is usually wrapped in a "CDATA" section, so that no
+ further XML escapes (entity references such as <) are necessary.
+
+* **``**: Alternative to ``. References a `` defined earlier in the file.
+ This allows you to share the same code snippet with several test cases. The attribute `id` must match the
+ id of the references code fragment.
+
+* **``**: Optional element that specifies the source code language. This defines the parser that
+ is used for parsing the code snippet. If not given, **java** is used as default.
+
+### ``
+
+The code fragment has just one required attribute: **id**. This is used to reference it via a `` element
+inside a ``. Similar like the `` element, the content of `` is usually wrapped
+in a "CDATA" section, so that no further XML escapes (entity references such as <) are necessary.
+
+### Complete XML example
+
+``` xml
+
+
+
+
+ Just a description, will be used as the test name for JUnit in the reports
+ propValue
+ 2
+ 5,14
+
+ Violation message 1
+ Violation message 2
+
+
+ apex
+
+
+
+
+ test case using a code fragment
+ 0
+
+
+
+```
+
+## Using the test framework externally
+
+It is also possible to use the test framework for custom rules developed outside the PMD source base.
+Therefore you just need to reference the dependency `net.sourceforge.pmd:pmd-test`.
+
+For maven, you can use this snippet:
+
+
+ net.sourceforge.pmd
+ pmd-test
+ {{site.pmd.version}}
+ test
+
+
+Then proceed as described earlier: create your test class, create your test cases and run the unit test.
+
+There is one difference however: Since your package structure is probably different, you'll need to register
+the rule test manually, as SimpleAggregatorTst will fail to determine it correctly from the package and class names:
+
+``` java
+package com.example.pmd.rules;
+
+import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
+
+public class CustomRuleTest extends SimpleAggregatorTst {
+ @Override
+ public void setUp() {
+ addRule("com/example/pmd/ruleset.xml", "CustomRule");
+ }
+}
+```
+
+This will then search for a rule named "CustomRule" in the ruleset, that is located in "src/main/resources" under
+the path "com/example/pmd/ruleset.xml".
+
+The test data should be placed in an xml file located in "src/test/resources" under the path
+"com/example/pmd/rules/xml/CustomRule.xml".
+
+## How the test framework is implemented
+
+The framework uses a custom JUnit test runner under the hood, among a couple of utility classes:
+
+* `PmdRuleTst`: This is the base class for tests in PMD's code base. It is a subclass of `RuleTst` and just
+ contains the logic to determine the test resources based on the test class name.
+
+* `SimpleAggregatorTst`: This is a more generic base class for the test classes and defines
+ the custom JUnit test runner. It doesn't register any test cases on its own.
+ It itself is a subclass of `RuleTst`.
+
+* `RuleTst`: contains the logic to parse the XML files and provide a list of `TestDescriptor`s. Each test descriptor
+ describes a single test case. It also contains the logic to execute such a test descriptor and assert the results.
+
+* `PMDTestRunner`: A custom JUnit test runner, that combines two separate test runners: The custom `RuleTestRunner`
+ and the standard `JUnit4` test runner. This combination allows you to add additional standard unit test methods
+ annotated with `@Test` to your test class.
+
+ *Note:* Since the test class is executed through two test runners, it is actually instantiated twice. Be aware
+ of this, if you do any initialization in the constructor. Also, the static hooks `@BeforeClass` and `@AfterClass`
+ will be executed twice.
+
+* `RuleTestRunner`: This test runner executes the test descriptors with the help of `RuleTst`.
diff --git a/docs/pages/pmd/devdocs/writing_pmd_rules.md b/docs/pages/pmd/userdocs/extending/writing_pmd_rules.md
similarity index 76%
rename from docs/pages/pmd/devdocs/writing_pmd_rules.md
rename to docs/pages/pmd/userdocs/extending/writing_pmd_rules.md
index a6ec0ea8937..f19dec13bd3 100644
--- a/docs/pages/pmd/devdocs/writing_pmd_rules.md
+++ b/docs/pages/pmd/userdocs/extending/writing_pmd_rules.md
@@ -1,9 +1,9 @@
---
-title: PMD Writing a Custom Rule
-tags: [customizing]
-summary: Writing a Custom Rule for PMD
+title: Writing a custom rule
+tags: [extending, userdocs]
+summary: "Learn how to write a custom rule for PMD"
last_updated: July 3, 2016
-permalink: pmd_devdocs_writing_pmd_rules.html
+permalink: pmd_userdocs_extending_writing_pmd_rules.html
author: Tom Copeland
---
@@ -72,7 +72,7 @@ CompilationUnit
You can generate this yourself by:
-* Run the batch file bin/designer.bat
+* Run the batch file `bin/designer.bat`
* Paste the code into the left text area and click the “Go†button
* Note that there’s another panel and a textfield to test out XPath expressions; more on that later.
* Here’s a screenshot: {% include image.html file="devdocs/designer_screenshot.png" alt="Designer Screenshot" %}
@@ -154,7 +154,7 @@ We stuck a `println()` in there for now so we can see when our rule gets hit.
## Put the WhileLoopsMustUseBracesRule rule in a ruleset file
-Now our rule is written - at least, the shell of it is - and now we need to tell PMD about it. We need to add it to a ruleset XML file. Look at `pmd-java/src/main/resources/rulesets/java/basic.xml`; it’s got lots of rule definitions in it. Copy and paste one of these rules into a new ruleset - call it `mycustomrules.xml` or something. Then fill in the elements and attributes:
+Now our rule is written - at least, the shell of it is - and now we need to tell PMD about it. We need to add it to a ruleset XML file. Look at `pmd-java/src/main/resources/category/java/bestpractices.xml`; it’s got lots of rule definitions in it. Copy and paste one of these rules into a new ruleset - call it `mycustomrules.xml` or something. Then fill in the elements and attributes:
* name - WhileLoopsMustUseBracesRule
* message - Use braces for while loops
@@ -169,7 +169,7 @@ The whole ruleset file should look something like this:
+ xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
@@ -250,71 +250,23 @@ Note that access modifiers are held as attributes, so, for example,
finds all private fields. You can see the code that determines all the attributes [here](pmd-core/xref/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.html)
-Thanks to Miguel Griffa for writing a longer [XPath tutorial](xpathruletutorial.html).
-
-## I want to implement a rule that analyze more than the class!
-
-An obvious limitation of the previous mechanism is the “class-centric†focus of the rule. How can you implement a rule that checks stuff across the all source code? Let’s take a dummy example. Let’s say you want to implement a rule that count how many Expression Node you have in your source code (told you, it was a dummy example :) ).
-
-You realize quite simply. You just have to add static field to the RulesContext, as an attribute, and uses Rule.start() and Rule.end() hook to initialized and finalize your rule’s implementation:
-
-```java
-package net.sourceforge.pmd.rules;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-import net.sourceforge.pmd.RuleContext;
-import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
-import net.sourceforge.pmd.lang.java.ast.ASTExpression;
-
-public class CountRule extends AbstractJavaRule {
-
- private static final String COUNT = "count";
-
- @Override
- public void start(RuleContext ctx) {
- ctx.setAttribute(COUNT, new AtomicLong());
- super.start(ctx);
- }
-
- @Override
- public Object visit(ASTExpression node, Object data) {
- // How many Expression nodes are there in all files parsed! I must know!
- RuleContext ctx = (RuleContext)data;
- AtomicLong total = (AtomicLong)ctx.getAttribute(COUNT);
- total.incrementAndGet();
- return super.visit(node, data);
- }
-
- @Override
- public void end(RuleContext ctx) {
- AtomicLong total = (AtomicLong)ctx.getAttribute(COUNT);
- addViolation(ctx, null, new Object[] { total });
- ctx.removeAttribute(COUNT);
- super.end(ctx);
- }
-}
-```
-
-As you can see in this example, the method start will be call the first time the rule is going to be used, so you can initialize properly your rule here. Once the rule will have finished to parses the source code, the method end() will be invoke you can assert there if, or not, your rule has been violated.
-
->Note that the example logs a violation **without** a proper classname. This is not really a good idea. Indeed, a lot of aggregating tools that PMD (Such as [XRadar](http://xradar.sourceforge.net), or [Sonar](http://www.sonarsource.com/)) probably uses this kind of meta data on their aggregation processes. So, when implements such a rule, always try to find a way to add classname to the violation report.
+More information about writing XPath rules is [available here](pmd_userdocs_extending_writing_xpath_rules.html).
## I need some kind of Type Resolution for my rule!
### Inside an XPath query
-PMD XPath syntax includes now a new function called `typeof` which determines if a node (ClassOrInterfaceType only right now) is of the provided type. It also scans the type’s hierarchy, so if you extend a class it will also find this out.
+PMD's XPath extensions include two functions called `typeIs` and `typeIsExactly`,
+which determine if a node is of a specific type (either any subtype or exactly,
+respectively).
-Here a an example of use, inside an XPath Query:
+Here a an example of use, inside an XPath query:
-```xpath
-//ClassOrInterfaceDeclaration[
- //ClassOrInterfaceType[typeof(@Image, 'junit.framework.TestCase','TestCase')]
-]
+```ruby
+//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType[typeIs('junit.framework.TestCase')]
```
-This query will match on such source code:
+This query will for instance match the following class declaration:
```java
import junit.framework.TestCase;
@@ -322,6 +274,16 @@ import junit.framework.TestCase;
public class Foo extends TestCase { }
```
+It will also match against classes which extend a *subtype* of `junit.framework.TestCase`,
+i.e. a base class itself extending `TestCase` transitively. If you don't want this behaviour,
+then use `typeIsExactly` instead of `typeIs`.
+
+Checking against an array type is possible with the double bracket syntax.
+An array type is denoted by just appending `[]` to the fully qualified class name
+of the component type. These can be repeated for arrays of arrays
+(e.g. `byte[][]` or `java.lang.String[]`).
+
+
### With Java code
Below an other sample of use of type resolution inside a java code:
diff --git a/docs/pages/pmd/devdocs/writing_xpath_rules.md b/docs/pages/pmd/userdocs/extending/writing_xpath_rules.md
similarity index 96%
rename from docs/pages/pmd/devdocs/writing_xpath_rules.md
rename to docs/pages/pmd/userdocs/extending/writing_xpath_rules.md
index ccbc1982c18..39d8bdb802e 100644
--- a/docs/pages/pmd/devdocs/writing_xpath_rules.md
+++ b/docs/pages/pmd/userdocs/extending/writing_xpath_rules.md
@@ -1,9 +1,9 @@
---
-title: Writing XPath Rules
-tags: [customizing]
+title: Writing XPath rules
+tags: [extending, userdocs]
summary: "Writing XPath rules for PMD"
last_updated: July 3, 2016
-permalink: pmd_devdocs_writing_xpath_rules.html
+permalink: pmd_userdocs_extending_writing_xpath_rules.html
author: Miguel Griffa
---
@@ -160,9 +160,9 @@ the example code and give your rule a useful name and message.
+ xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
Custom rules
diff --git a/docs/pages/pmd/userdocs/getting_started.md b/docs/pages/pmd/userdocs/getting_started.md
deleted file mode 100644
index 21398decad6..00000000000
--- a/docs/pages/pmd/userdocs/getting_started.md
+++ /dev/null
@@ -1,345 +0,0 @@
----
-title: Getting Started
-permalink: pmd_userdocs_getting_started.html
-author: Tom Copeland , Xavier Le Vourch
----
-
-## How to install PMD and CPD
-
-### Windows
-
-Requirements:
-
-* [Java JRE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 1.7 or higher
-* [Winzip](http://winzip.com) or the free [7-zip](http://www.7-zip.org/)
-
-Download the latest binary distribution from [the github releases page](https://github.com/pmd/pmd/releases).
-
-Unzip it into any directory, i.e., c:\pmd\
-
-### Linux / Unix
-
-Requirements:
-
-* [Java JRE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 1.7 or higher
-* The Unix "zip" utility [InfoZip](http://www.info-zip.org/pub/infozip/)
-
-Download the latest binary distribution from [the github releases page](https://github.com/pmd/pmd/releases).
-
-Unzip it into any directory:
-
- [tom@hal tmp]$ unzip -q pmd-bin-{{site.pmd.version}}.zip
- [tom@hal tmp]$ ls -l
- total 4640
- drwxrwxr-x 5 tom tom 4096 Apr 17 16:38 pmd-bin-{{site.pmd.version}}
- -rw-rw-r-- 1 tom tom 4733312 Jun 9 15:44 pmd-bin-{{site.pmd.version}}.zip
- [tom@hal tmp]$
-
-
-Note that the PMD binary distribution file contains both [PMD](#running-pmd-via-command-line) and [CPD](/pmd_userdocs_cpd.html).
-
-
-## Running PMD via command line
-
-### On Linux and other UNIX based operating system...
-
-PMD comes with several command line utilities. Previously, each of them had its own start up script, but this has been
-greatly simplified since PMD 5.0. ... at least for Unix systems. There is now only one script, called "run.sh", inside
-the `bin/` directory of PMD distribution.
-
-The first argument is the name of the utility you want to execute ('pmd', 'designer', ...) and the other arguments are
-specific to the utility used.
-
- $ ./bin/run.sh pmd -d ../../../src/main/java/ -f text -R rulesets/java/basic.xml -version 1.7 -language java
- .../src/main/java/net/sourceforge/pmd/RuleSet.java:123 These nested if statements could be combined
- .../src/main/java/net/sourceforge/pmd/RuleSet.java:231 Useless parentheses.
- .../src/main/java/net/sourceforge/pmd/RuleSet.java:232 Useless parentheses.
- .../src/main/java/net/sourceforge/pmd/RuleSet.java:357 These nested if statements could be combined
- .../src/main/java/net/sourceforge/pmd/RuleSetWriter.java:66 Avoid empty catch blocks
- .../src/main/java/net/sourceforge/pmd/RuleSetWriter.java:269 Useless parentheses.
-
-Type "./run.sh pmd -d \[filename\|jar or zip file containing source code\|directory] -f \[report format] -R \[ruleset file]", i.e:
-
- /home/user/tmp/pmd-bin-{{site.pmd.version}}/pmd/bin>./run.sh pmd -d /home/user/data/pmd/pmd/test-data/Unused1.java -f xml -R rulesets/java/unusedcode.xml
-
-
-
- Avoid unused local variables such as 'fr'
-
-
-
- /home/user/tmp/pmd-bin-{{site.pmd.version}}/pmd/bin>
-
-
-### Basic usage for Windows
-
-You can find PMD's starter batch file `pmd.bat` in the `bin` subdirectory.
-
-Type "pmd -d \[filename\|jar or zip file containing source code\|directory] -f \[report format] -R \[ruleset file]", i.e:
-
- C:\tmp\pmd-bin-{{site.pmd.version}}<\pmd\bin>pmd -d c:\data\pmd\pmd\test-data\Unused1.java -f xml -R rulesets/java/unusedcode.xml
-
-
-
- Avoid unused local variables such as 'fr'
-
-
-
- C:\tmp\pmd-bin-{{site.pmd.version}}\pmd\bin>
-
-You can pass a file name, a directory name, or a jar or zip file name containing Java source code to PMD.
-
-Also, the PMD binary distribution includes the ruleset files
-inside the jar file - even though the "rulesets/java/unusedcode.xml" parameter
-above looks like a filesystem reference, it's really being used by a getResourceAsStream() call
-to load it out of the PMD jar file.
-
-### Options
-
-The tool comes with a rather extensive help text, simply running with `-help`!
-
-
-
- Option
- Description
- Required
- Applies for language
-
-
- -rulesets / -R
- Comma separated list of ruleset names to use
- yes
-
-
-
- -dir / -d
- Root directory for sources
- yes
-
-
-
- -format / -f
- Report format type. Default format is `text`.
- no
-
-
-
- -auxclasspath
-
- Specifies the classpath for libraries used by the source code. This is used by the type resolution.
- Alternatively a `file://` URL to a text file containing path elements on consecutive lines can be
- specified.
-
- no
-
-
-
- -uri / -u
- Database URI for sources. If this is given, then you don't need to provide `-dir`.
- no
- plsql
-
-
- -filelist
- Path to file containing a comma delimited list of files to analyze. If this is given, then you don't need to provide `-dir`.
- no
-
-
-
- -debug / -verbose / -D / -V
- Debug mode. Prints more log output.
- no
-
-
-
- -help / -h / -H
- Display help on usage.
- no
-
-
-
- -encoding / -e
- Specifies the character set encoding of the source code files PMD is reading (i.e. UTF-8). Default is `UTF-8`.
- no
-
-
-
- -threads / -t
- Sets the number of threads used by PMD. Default is `1`. Set threads to '0' to disable multi-threading processing.
- no
-
-
-
- -benchmark / -b
- Benchmark mode - output a benchmark report upon completion; defaults to System.err
- no
-
-
-
- -stress / -S
- Performs a stress test.
- no
-
-
-
- -shortnames
- Prints shortened filenames in the report.
- no
-
-
-
- -showsuppressed
- Report should show suppressed rule violations.
- no
-
-
-
- -suppressmarker
- Specifies the string that marks the line which PMD should ignore; default is `NOPMD`.
- no
-
-
-
- -minimumpriority / -min
- Rule priority threshold; rules with lower priority than configured here won't be used. Default is `5` - which is the lowest priority.
- no
-
-
-
- -property / -P
- `{name}={value}`: Define a property for a report format.
- no
-
-
-
- -reportfile / -r
- Send report output to a file; default to System.out
- no
-
-
-
- -version / -v
- Specify version of a language PMD should use.
- no
-
-
-
- -language / -l
- Specify a language PMD should use.
- no
-
-
-
- -failOnViolation {true|false}
- By default PMD exits with status 4 if violations are found.
- Disable this option with '-failOnViolation false' to exit with 0 instead and just write the report.
-
- no
-
-
-
- -cache
- Specify a location for the analysis cache file to use.
- This can greatly improve analysis performance and is highly recommended .
- no
-
-
-
-
-
-### Exit Status
-
-Please note that if PMD detects any violations, it will exit with status 4 (since 5.3).
-This behavior has been introduced to ease PMD integration into scripts or hooks, such as SVN hooks.
-
-
-0 Everything is fine, now violations found
-1 Couldn't understand command line parameters or PMD exited with an exception
-4 At least one violation has been detected unless '-failOnViolation false' is set.
-
-
-
-### Supported Languages
-
-* [apex](/pmd_rules_apex.html)
-* [java](/pmd_rules_java.html)
-* [ecmascript](/pmd_rules_javascript.html) (JavaScript)
-* [jsp](/pmd_rules_jsp.html)
-* [plsql](/pmd_rules_plsql.html)
-* [vm](/pmd_rules_vm.html) (Apache Velocity)
-* [xml and xsl](/pmd_rules_xml.html)
-
-
-### Available Report Formats / Renderers
-
-PMD comes with many different renderer types:
-
-* **codeclimate**: Renderer for Code Climate JSON format.
-
-* **csv**: Comma-separated values tabular format.
-
- Properties:
-
- * problem: Include problem column. Default: true.
- * package: Include package column. Default: true.
- * file: Include file column. Default: true.
- * priority: Include priority column. Default: true.
- * line: Include line column. Default: true.
- * desc: Include description column. Default: true.
- * ruleSet: Include Rule set column. Default: true.
- * rule: Include Rule column. Default: true.
-
-* **emacs**: GNU Emacs integration.
-
-* **html**: HTML format.
-
- Properties:
-
- * linePrefix: Prefix for line number anchor in the source file.
- * linkPrefix: Path to HTML source.
-
-* **ideaj**: IntelliJ IDEA integration.
-
- Properties:
-
- * classAndMethodName: Class and method name, pass '.method' when processing a directory.
- * sourcePath:
- * fileName:
-
-* **summaryhtml**: Summary HTML format.
-
- Properties:
-
- * linePrefix: Prefix for line number anchor in the source file.
- * linkPrefix: Path to HTML source.
-
-* **text**: Text format.
-
-* **textcolor**: Text format, with color support (requires ANSI console support, e.g. xterm, rxvt, etc.).
-
- Properties:
-
- * color: Enables colors with anything other than 'false' or '0'. Default: yes.
-
-* **textpad**: TextPad integration.
-
-* **vbhtml**: Vladimir Bossicard HTML format.
-
-* **xml**: XML format.
-
- Properties:
-
- * encoding: XML encoding format, defaults to UTF-8.
-
-* **xslt**: XML with a XSL transformation applied.
-
- Properties:
-
- * encoding: XML encoding format, defaults to UTF-8.
- * xsltFilename: The XSLT file name.
-
-* **yahtml**: Yet Another HTML format.
-
- Properties:
-
- * outputDir: Output directory.
diff --git a/docs/pages/pmd/userdocs/help.md b/docs/pages/pmd/userdocs/help.md
deleted file mode 100644
index 8ef0a175033..00000000000
--- a/docs/pages/pmd/userdocs/help.md
+++ /dev/null
@@ -1,8 +0,0 @@
----
-title: Getting Help
-sidebar: pmd_sidebar
-permalink: pmd_userdocs_help.html
-folder: pmd/userdocs
----
-
-Asking questions, reporting bugs, ...
diff --git a/docs/pages/pmd/userdocs/incremental_analysis.md b/docs/pages/pmd/userdocs/incremental_analysis.md
new file mode 100644
index 00000000000..8aa117b5a2f
--- /dev/null
+++ b/docs/pages/pmd/userdocs/incremental_analysis.md
@@ -0,0 +1,34 @@
+---
+title: Incremental Analysis
+keywords: [pmd, options, command, incremental, analysis, performance]
+tags: [userdocs]
+summary: "Explains how to use incremental analysis to speed up analysis"
+permalink: pmd_userdocs_incremental_analysis.html
+sidebar: pmd_sidebar
+---
+
+Ever since PMD 5.6.0, PMD has been able to perform Incremental Analysis.
+
+When performing Incremental Analysis for the first time, PMD will cache analysis data and results.
+This allows subsequent analysis to only look into those files that are new / have changed. For
+a typical development environment, where you only change a few files at a time, this can reduce
+analysis time dramatically.
+
+The generated report will be *exactly the same* as it would if running without incremental analysis.
+Files included in the final report will reflect exactly those files in your filesystem. Even if
+untouched, files with violations will be listed with full detail. Therefore, its usage is higly recommended.
+
+
+### Enabling incremental analysis
+
+Incremental analysis is enabled automatically once a location to store the cache has been defined.
+From command-line that is done through the [`-cache`](pmd_userdocs_cli_reference.html#cache) argument, but support for the feature is
+available for tools integrating PMD such as [Ant](pmd_userdocs_tools_ant.html),
+[Maven](pmd_userdocs_tools_maven.html), and Gradle.
+
+
+### Disabling incremental analysis
+
+By default, PMD will suggest to use an analysis cache by logging a warning.
+If you'd like to disable this warning, or ignore the analysis cache for a
+few runs, you can use the [`-no-cache`](pmd_userdocs_cli_reference.html#no-cache) switch.
diff --git a/docs/pages/pmd/userdocs/installation.md b/docs/pages/pmd/userdocs/installation.md
new file mode 100644
index 00000000000..44715742661
--- /dev/null
+++ b/docs/pages/pmd/userdocs/installation.md
@@ -0,0 +1,166 @@
+---
+title: Installation and basic CLI usage
+keywords: [pmd, cpd, options, command, auxclasspath]
+tags: [getting_started, userdocs]
+summary: "Sums up the first steps to set up a CLI installation and get started using PMD"
+permalink: pmd_userdocs_installation.html
+sidebar: pmd_sidebar
+---
+
+## How to install PMD and CPD
+
+### Requirements
+
+* [Java JRE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 1.7 or higher
+* A zip archiver, e.g.:
+
+ * For Windows: [Winzip](http://winzip.com) or the free [7-zip](http://www.7-zip.org/)
+ * For Linux / Unix: [InfoZip](http://www.info-zip.org/pub/infozip/)
+
+{% include note.html content="For executing the Designer (./run.sh designer) using [OpenJDK](http://jdk.java.net) or Java 11, you need additionally [OpenJFX](http://jdk.java.net). Download it, extract it and set the environment variable JAVAFX_HOME." %}
+
+
+### Installation
+
+PMD is distributed as a zip archive, which includes both [PMD](#running-pmd-via-command-line) and [CPD](/pmd_userdocs_cpd.html).
+You can download the latest binary distribution from [the github releases page](https://github.com/pmd/pmd/releases).
+
+Unzip it into any directory, optionally add the `bin` subdirectory in your `PATH`, and you're good to go!
+
+
+
+## Running PMD via command line
+
+{% include callout.html type="primary"
+ content="PMD comes with several command line utilities, like CPD, the rule designer or PMD itself.
+ On Unix, you can run any of them using the script `run.sh`, located inside the `bin/`
+ directory of the PMD distribution. The first argument is the name of the utility you want
+ to execute ('pmd', 'designer', ...), e.g. PMD is launched via `run.sh pmd`. The rest of
+ the arguments are specific to the utility used.
+ On Windows, each utility has its own startup script, e.g. `pmd.bat`, `cpd.bat`." %}
+
+The PMD command (`pmd.bat` or `run.sh pmd`) requires two options:
+
+* `-d `: path to the sources to analyse. This can be a file name, a directory, or a jar or zip file containing the
+sources.
+* `-R `: the ruleset file you want to use. PMD uses xml configuration files, called *rulesets*, which specify
+which rules to execute on your sources. You can also run a single rule by referencing it using its *category* and
+name (more details [here](pmd_userdocs_making_rulesets.html#referencing-a-single-rule)). For example, you can check for unnecessary
+modifiers on Java sources with `-R category/java/codestyle.xml/UnnecessaryModifier`.
+
+{% include note.html
+ content="At the moment the formerly provided rulesets (eg `rulesets/java/basic.xml`) are deprecated,
+ though you can still use them. PMD includes a quickstart ruleset for some languages (currently, Java)
+ as base configurations, which you can reference as e.g. `rulesets/java/quickstart.xml`. You're strongly
+ encouraged to [create your own ruleset](pmd_userdocs_making_rulesets.html) from the start though." %}
+
+Additionally, the following options, are specified most of the time even though they're not required:
+* `-f `: report format. PMD supports many report formats out of the box. You may want to start with the basic
+`text` format (default) or `xml` format. The supported formats are [documented here](pmd_userdocs_cli_reference.html#available-report-formats).
+* `-auxclasspath `: class path containing the compiled class files of the analysed Java sources, if any.
+ Setting this up correctly allows PMD to do much deeper analysis using reflection. Some rules, such as [MissingOverride](pmd_rules_java_bestpractices.html#missingoverride),
+ require it to function properly.
+
+{%include tip.html content="A full CLI reference, including report formats, is available under [PMD CLI Reference](pmd_userdocs_cli_reference.html)" %}
+
+
+
+### Sample usage
+
+ The following shows a sample run of PMD with the `text` format:
+
+
+
+
+
+
+
+
~ $ cd ~/bin/pmd-bin-{{site.pmd.version}}/bin
+~/.../bin $ ./run.sh pmd -d ../../../src/main/java/ -f text -R rulesets/java/basic.xml
+
+ .../src/main/java/com/me/RuleSet.java:123 These nested if statements could be combined
+ .../src/main/java/com/me/RuleSet.java:231 Useless parentheses.
+ .../src/main/java/com/me/RuleSet.java:232 Useless parentheses.
+ .../src/main/java/com/me/RuleSet.java:357 These nested if statements could be combined
+ .../src/main/java/com/me/RuleSetWriter.java:66 Avoid empty catch blocks
+
+
+
C:\ > cd C:\pmd-bin-{{site.pmd.version}}\bin
+C:\...\bin > .\pmd.bat -d ..\..\src\main\java\ -f text -R rulesets/java/basic.xml
+
+ .../src/main/java/com/me/RuleSet.java:123 These nested if statements could be combined
+ .../src/main/java/com/me/RuleSet.java:231 Useless parentheses.
+ .../src/main/java/com/me/RuleSet.java:232 Useless parentheses.
+ .../src/main/java/com/me/RuleSet.java:357 These nested if statements could be combined
+ .../src/main/java/com/me/RuleSetWriter.java:66 Avoid empty catch blocks
+
+
+
+
+
+## Running CPD via command line
+
+{% include note.html
+ content="CPD supports Java, JSP, C, C++, C#, Fortran and PHP source code, among other languages.
+ For the full list, see [Supported Languages](pmd_userdocs_cpd#supported-languages)." %}
+
+Like for PMD, CPD is started on Unix by `run.sh cpd` and on Windows by `cpd.bat`.
+
+There are two required parameters:
+* `--files `: path to the sources to analyse. This can be a file name, a
+ directory or a jar or zip file containing the sources.
+* `--minimum-tokens `: the minimum token length which should be reported as a duplicate.
+
+{% include tip.html
+ content="CPD's command-line reference, Ant task usage, and many examples are documented in the
+ [CPD documentation page](pmd_userdocs_cpd.html)" %}
+
+### Sample usage
+
+ The following shows a sample run of CPD with the `text` format:
+
+
+
+
+
+
+
+
~ $ cd ~/bin/pmd-bin-{{site.pmd.version}}/bin
+~/.../bin $ ./run.sh cpd --minimum-tokens 100 --files /home/me/src
+
+ Found a 7 line (110 tokens) duplication in the following files:
+ Starting at line 579 of /home/me/src/test/java/foo/FooTypeTest.java
+ Starting at line 586 of /home/me/src/test/java/foo/FooTypeTest.java
+
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+
+
+
C:\ > cd C:\pmd-bin-{{site.pmd.version}}\bin
+C:\...\bin > .\cpd.bat --minimum-tokens 100 --files c:\temp\src
+
+ Found a 7 line (110 tokens) duplication in the following files:
+ Starting at line 579 of c:\temp\src\test\java\foo\FooTypeTest.java
+ Starting at line 586 of c:\temp\src\test\java\foo\FooTypeTest.java
+
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+ assertEquals(Boolean.TYPE, expressions.get(index++).getType());
+
+
+
diff --git a/docs/pages/pmd/userdocs/making_rulesets.md b/docs/pages/pmd/userdocs/making_rulesets.md
new file mode 100644
index 00000000000..272ce53ebc3
--- /dev/null
+++ b/docs/pages/pmd/userdocs/making_rulesets.md
@@ -0,0 +1,110 @@
+---
+title: Making rulesets
+keywords: [rulesets, reference, rule, exclude, include, pattern, filter]
+tags: [getting_started, userdocs]
+summary: Making Custom Rulesets for PMD
+last_updated: November 2017
+summary: "A ruleset is an XML configuration file, which describes a collection of rules to be executed
+ in a PMD run. PMD includes built-in rulesets to run quick analyses with a default configuration, but
+ users are encouraged to make their own rulesets from the start, because they allow for so much
+ configurability. This page walk you through the creation of a ruleset and the multiple configuration
+ features offered by rulesets."
+last_updated: May 2018 (6.4.0)
+permalink: pmd_userdocs_making_rulesets.html
+author: Tom Copeland , Clément Fournier
+---
+
+## Creating a ruleset
+
+The first step is to create a new empty ruleset. You can use the following template:
+
+``` xml
+
+
+
+
+
+ My custom rules
+
+
+
+
+
+
+```
+
+### Referencing a single rule
+
+
+
+To use the built-in rules PMD provides, you need to add some *references* to them. Here's a
+basic rule reference:
+
+```xml
+
+```
+
+Adding that element into the `ruleset` element adds the rule [EmptyCatchBlock](pmd_rules_java_errorprone.html#emptycatchblock)
+to your ruleset. This is a Java rule, so it will be executed on every Java file PMD encounters in
+its search space.
+
+How to read the `ref` attribute?
+
+* `category/java/errorprone.xml` is a reference to the Java category `errorprone`. Since PMD 6.0.0,
+ all PMD built-in rules are sorted in one of eight categories, which are consistent across languages:
+
+ 1. **Best Practices**: These are rules which enforce generally accepted best practices.
+ 2. **Code Style**: These rules enforce a specific coding style.
+ 3. **Design**: Rules that help you discover design issues.
+ 4. **Documentation**: These rules are related to code documentation.
+ 5. **Error Prone**: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+ 6. **Multithreading**: These are rules that flag issues when dealing with multiple threads of execution.
+ 7. **Performance**: Rules that flag suboptimal code.
+ 8. **Security**: Rules that flag potential security flaws."
+
+{% include tip.html content="You can discover the available rules by language and category [from this page](tag_rule_references.html)" %}
+
+
+* `EmptyCatchBlock` is simply the name of the rule. If there were no rule with that name within the specified
+ category, then PMD would fail before starting the analysis.
+
+#### [Configuring individual rules](pmd_userdocs_configuring_rules.html)
+
+### Bulk-adding rules
+
+You can also reference rules in bulk by referencing a complete category or ruleset, possibly excluding certain rules, like in the following:
+
+```xml
+
+
+
+
+```
+
+Here, the `ref` attribute references a whole category. You can also use a file system path or classpath relative path. In any case, the path must address an accessible ruleset XML file.
+
+{% include note.html content="Path separators in the source file path are normalized to be the `/` character within PMD, so the same ruleset can be used on multiple platforms transparently." %}
+
+### Filtering the processed files
+
+You can exclude some files from being processed by a ruleset using **exclude patterns**, with an optional overridding **include pattern**. A file will be excluded from processing *when there is a matching exclude pattern, but no matching include pattern*. This exclude/include technique works regardless of how PMD is used (e.g. command line, IDE, Ant), making it easier to keep application of your PMD rules consistent throughout your environment. Here is an example:
+
+```xml
+
+
+ My ruleset
+
+ .*/some/package/.*
+ .*/some/other/package/FunkyClassNamePrefix.*
+ .*/some/package/ButNotThisClass.*
+
+
+
+
+```
diff --git a/docs/pages/pmd/userdocs/suppressing.md b/docs/pages/pmd/userdocs/suppressing.md
deleted file mode 100644
index d9de8589c7b..00000000000
--- a/docs/pages/pmd/userdocs/suppressing.md
+++ /dev/null
@@ -1,165 +0,0 @@
----
-title: Suppressing warnings
-permalink: pmd_userdocs_suppressing.html
-author: Tom Copeland
----
-
-PMD provides several methods by which Rule violations can be suppressed.
-Follow these steps to help you determine which expression method works best
-for you:
-
-1. Is the thing you need to suppress universally appealing to other
- users of PMD, or is it a false positive? Can you modify the Rule to
- support this specific suppression via a configuration property, or to
- fix the false positive? If you can do this, then please do so, and
- submit a patch back to the PMD project. Since PMD is built by users
- for users, your help would be greatly appreciated by everyone. If you
- cannot...
-
-2. Can you use Annotations or the NOPMD marker to work around your
- particular issue on a case by case basis? If not...
-
-3. Can a regular expression matching the violation message work
- around your particular issue? If not...
-
-4. Can a XPath query on the violation node work around your particular
- issue? If not...
-
-5. Your last and final option is to see the first point about
- changing the Rule, but you do not need to submit a patch back to the
- PMD project.
-
-If you need to modify the Rule, see [How to write a rule](/pmd_devdocs_writing_pmd_rules.html).
-Otherwise, the other suppression methods are explained in the following sections.
-
-## Annotations
-
-You can use a JDK 1.5 annotation to suppress PMD warnings, like this:
-
- // This will suppress all the PMD warnings in this class
- @SuppressWarnings("PMD")
- public class Bar {
- void bar() {
- int foo;
- }
- }
-
-Or you can suppress one rule with an annotation like this:
-
- // This will suppress UnusedLocalVariable warnings in this class
- @SuppressWarnings("PMD.UnusedLocalVariable")
- public class Bar {
- void bar() {
- int foo;
- }
- }
-
-PMD also obeys the JDK annotation @SuppressWarnings("unused"), which will apply to all rules in the unused ruleset.
-
- // This will suppress UnusedLocalVariable and UnusedPrivateMethod warnings in this class
- @SuppressWarnings("unused")
- public class Bar {
- void bar() {
- int foo;
- }
- private void foobar(){}
- }
-
-
-## NOPMD
-
-Alternatively, you can tell PMD to ignore a specific line by using the "NOPMD" marker, like this:
-
- public class Bar {
- // 'bar' is accessed by a native method, so we want to suppress warnings for it
- private int bar; //NOPMD
- }
-
-You can use whatever text string you want to suppress warnings, for example, here's
-how to use TURN\_OFF\_WARNINGS as the suppressor:
-
- $ cat Foo.java
- public class Foo {
- void bar() {
- int x = 2; // TURN_OFF_WARNINGS
- }
- }
-
- $ ./run.sh pmd -d Foo.java -f text -R java-unusedcode -suppressmarker TURN_OFF_WARNINGS
- No problems found!
- UnusedLocalVariable rule violation suppressed by //NOPMD in /home/tom/pmd/pmd/bin/Foo.java
-
-Note that PMD expects the //NOPMD marker to be on the same line as the violation. So, for
-example, if you want to suppress an "empty if statement" warning, you'll need to place it on
-the line containing the "if" keyword, e.g.:
-
- $ cat ~/tmp/Foo.java
- public class Foo {
- void bar() {
- int x = 42;
- if (x > 5) { // NOPMD
- }
- }
- }
- $ java net.sourceforge.pmd.PMD -d ~/tmp/Foo.java -f text -R java-basic
- No problems found!
- $
-
-A message placed after the NOPMD marker will get placed in the report, e.g.:
-
- public class Foo {
- void bar() {
- try {
- bar();
- } catch (FileNotFoundException e) {} // NOPMD - this surely will never happen
- }
- }
-
-## Violation Suppress Regex
-
-If a particular Rule does not provide a property to customize behavior
-sufficiently, you can fall back to using the global 'violationSuppressRegex'
-property. This property defines a regular expression to match against the
-message of the violation. If the regular expression matches,
-then the violation will be suppressed.
-
-When using a Rule reference in a RuleSet XML, you can customize the
-Rule by adding the 'violationSuppressRegex' property. For example, to
-suppress reporting specifically named parameters which are unused:
-
-
-
-
-
-
-
-
-Note for message based suppression to work, you must know who to write
-a regular expression that matches the message of violations you wish to
-suppress. Regular expressions are explained in the JavaDoc for standard
-Java class java.util.regex.Pattern.
-
-## Violation Suppress XPath
-
-If a particular Rule does not provide a property to customize behavior
-sufficiently, you can fall back to using the global 'violationSuppressXPath'
-property. This property defines an XPath query to be executed using the
-violation node as the starting point. If the XPath query matches anything,
-then the violation will be suppressed.
-
-When using a Rule reference in a RuleSet XML, you can customize the
-Rule by adding the 'violationSuppressXPath' property. For example, to
-suppress reporting specifically typed parameters which are unused:
-
-
-
-
-
-
-
-Note for XPath based suppression to work, you must know how to write
-an XPath query that matches the AST structure of the nodes of the
-violations you wish to suppress. XPath queries are explained in
-[XPath Rule tutorial](/pmd_devdocs_writing_xpath_rules.html).
-
-Suggestions? Comments? Post them [here](https://github.com/pmd/pmd/issues). Thanks!
diff --git a/docs/pages/pmd/userdocs/suppressing_warnings.md b/docs/pages/pmd/userdocs/suppressing_warnings.md
new file mode 100644
index 00000000000..5b19ccab1ca
--- /dev/null
+++ b/docs/pages/pmd/userdocs/suppressing_warnings.md
@@ -0,0 +1,206 @@
+---
+title: Suppressing warnings
+keywords: [suppressing, warnings, suppresswarnings, nopmd, violationSuppressXPath, violationSuppressRegex]
+tags: [userdocs]
+summary: "Learn how to suppress some rule violations, from the source code using annotations or comments, or globally from the ruleset"
+permalink: pmd_userdocs_suppressing_warnings.html
+author: Tom Copeland
+---
+
+PMD provides several methods by which Rule violations can be suppressed.
+Follow these steps to help you determine which expression method works best
+for you:
+
+1. Is the thing you need to suppress universally appealing to other
+ users of PMD, or is it a false positive? Can you modify the Rule to
+ support this specific suppression via a configuration property, or to
+ fix the false positive? If you can do this, then please do so, and
+ submit a patch back to the PMD project. Since PMD is built by users
+ for users, your help would be greatly appreciated by everyone. If you
+ cannot...
+
+2. Can you use Annotations or the NOPMD marker to work around your
+ particular issue on a case by case basis? If not...
+
+3. Can a regular expression matching the violation message work
+ around your particular issue? If not...
+
+4. Can a XPath query on the violation node work around your particular
+ issue? If not...
+
+5. Your last and final option is to see the first point about
+ changing the Rule, but you do not need to submit a patch back to the
+ PMD project.
+
+If you need to modify the Rule, see [How to write a rule](pmd_devdocs_writing_pmd_rules.html).
+Otherwise, the other suppression methods are explained in the following sections.
+
+## Annotations
+
+When using Java 1.5 or later, you can use annotations to suppress PMD warnings, like this:
+
+```java
+// This will suppress all the PMD warnings in this class
+@SuppressWarnings("PMD")
+public class Bar {
+ void bar() {
+ int foo;
+ }
+}
+```
+
+When using Apex make sure to use single quotes instead of double quotes
+
+```java
+// This will suppress all the PMD warnings in this class
+@SuppressWarnings('PMD')
+```
+
+
+Or you can suppress one rule with an annotation like this:
+
+```java
+// This will suppress UnusedLocalVariable warnings in this class
+@SuppressWarnings("PMD.UnusedLocalVariable")
+public class Bar {
+ void bar() {
+ int foo;
+ }
+}
+```
+
+Multiple rules can be suppressed by providing multiple values, ie:
+
+```java
+@SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.UnusedPrivateMethod"})
+```
+
+For Apex, the syntax for this is slightly different:
+
+```java
+@SuppressWarnings('PMD.UnusedLocalVariable, PMD.UnusedPrivateMethod')
+```
+
+PMD Java also obeys the JDK annotation @SuppressWarnings("unused"), which will apply to all rules in the unused ruleset.
+
+```java
+// This will suppress UnusedLocalVariable and UnusedPrivateMethod warnings in this class
+@SuppressWarnings("unused")
+public class Bar {
+ void bar() {
+ int foo;
+ }
+ private void foobar(){}
+}
+```
+
+## NOPMD comment
+
+Alternatively, you can tell PMD to ignore a specific line by using the "NOPMD" marker in a comment, like this:
+
+```java
+public class Bar {
+ // 'bar' is accessed by a native method, so we want to suppress warnings for it
+ private int bar; //NOPMD
+}
+```
+
+You can use whatever text string you want to suppress warnings, by using the `-suppressmarker` CLI option.
+For example, here's how to use `TURN_OFF_WARNINGS` as the suppressor:
+
+```java
+$ cat Foo.java
+public class Foo {
+ void bar() {
+ int x = 2; // TURN_OFF_WARNINGS
+ }
+}
+
+$ ./run.sh pmd -d Foo.java -f text -R java-unusedcode -suppressmarker TURN_OFF_WARNINGS
+No problems found!
+UnusedLocalVariable rule violation suppressed by //NOPMD in /home/tom/pmd/pmd/bin/Foo.java
+```
+Note that PMD expects the //NOPMD marker to be on the same line as the violation. So, for
+example, if you want to suppress an "empty `if` statement" warning, you'll need to place it on
+the line containing the `if` keyword, e.g.:
+
+```java
+$ cat ~/tmp/Foo.java
+public class Foo {
+ void bar() {
+ int x = 42;
+ if (x > 5) { // NOPMD
+ }
+ }
+}
+$ java net.sourceforge.pmd.PMD -d ~/tmp/Foo.java -f text -R java-basic
+No problems found!
+```
+
+A message placed after the NOPMD marker will get placed in the report, e.g.:
+
+```java
+public class Foo {
+ void bar() {
+ try {
+ bar();
+ } catch (FileNotFoundException e) {} // NOPMD - this surely will never happen
+ }
+}
+```
+
+## XPath and Regex message suppression
+
+If a particular rule consistently reports a warning in a particular context, you can fall
+back to disabling the rule for all these contexts using one of two rule properties
+that are defined on every rule. Depending on what you're after, you can suppress
+violations for **specific messages** using regular expressions, or **specific nodes**
+using an XPath expression.
+
+
+### The property `violationSuppressRegex`
+
+This property defines a regular expression to match against the
+message of the violation. If the regular expression matches,
+then the violation will be suppressed.
+
+For example, to suppress reporting specifically named parameters which
+are unused:
+
+```xml
+
+
+
+
+
+```
+
+Note for message based suppression to work, you must know how to write
+a regular expression that matches the message of violations you wish to
+suppress. Regular expressions are explained in the JavaDoc for standard
+Java class java.util.regex.Pattern.
+
+This technique of course relies on how the rule's message is implemented.
+Some rules always report the same message, in which case this property is
+of no use.
+
+### The property `violationSuppressXPath`
+
+This property defines an XPath query to be executed *using the
+violation node as the starting point*. If the XPath query matches anything,
+then the violation will be suppressed.
+
+For example, to suppress reporting specifically typed parameters which are unused:
+
+```xml
+
+
+
+
+
+```
+
+Note for XPath based suppression to work, you must know how to write
+an XPath query that matches the AST structure of the nodes of the
+violations you wish to suppress. XPath queries are explained in
+[XPath Rule tutorial](pmd_userdocs_extending_writing_xpath_rules.html).
diff --git a/docs/pages/pmd/userdocs/tools/ant.md b/docs/pages/pmd/userdocs/tools/ant.md
index eb2ff5f42e7..d85c588782b 100644
--- a/docs/pages/pmd/userdocs/tools/ant.md
+++ b/docs/pages/pmd/userdocs/tools/ant.md
@@ -1,5 +1,6 @@
---
title: Ant Task Usage
+tags: [userdocs, tools]
permalink: pmd_userdocs_tools_ant.html
author: >
David Dixon-Peugh ,
@@ -76,8 +77,16 @@ Runs a set of static code analysis rules on some source code files and generates
cacheLocation
The location of the analysis cache file to be used.
- The cache can greatly improve analysis time without loosing analysis quality.
- It's use is strongly recommended.
+ Setting this property enables Incremental Analysis, which can greatly improve analysis time without loosing analysis quality.
+ Its use is strongly recommended.
+
+ No
+
+
+ noCache
+
+ Setting this property to true disables Incremental Analysis, even if cacheLocation is provided.
+ You can use this to explicitly turn off suggestions to use incremental analysis, or for testing purposes.
No
@@ -151,8 +160,7 @@ and the associated version (1.5, 1.6,...)
The specific version of a language to be used for parsing is selected via the `sourceLanguage`
nested element. Possible values are:
-
-
+
@@ -160,12 +168,13 @@ nested element. Possible values are:
+
-
-
+
+
### Postprocessing the report file with XSLT
diff --git a/docs/pages/pmd/userdocs/ci.md b/docs/pages/pmd/userdocs/tools/ci.md
similarity index 91%
rename from docs/pages/pmd/userdocs/ci.md
rename to docs/pages/pmd/userdocs/tools/ci.md
index c84cff056af..5f2c6ea616b 100644
--- a/docs/pages/pmd/userdocs/ci.md
+++ b/docs/pages/pmd/userdocs/tools/ci.md
@@ -1,6 +1,7 @@
---
title: Continuous Integrations plugins
-permalink: pmd_userdocs_ci.html
+tags: [userdocs, tools]
+permalink: pmd_userdocs_tools_ci.html
author: Romain PELISSE
---
diff --git a/docs/pages/pmd/userdocs/tools/maven.md b/docs/pages/pmd/userdocs/tools/maven.md
index 06057b1b2d0..1e184ba2046 100644
--- a/docs/pages/pmd/userdocs/tools/maven.md
+++ b/docs/pages/pmd/userdocs/tools/maven.md
@@ -1,5 +1,6 @@
---
title: Maven PMD Plugin
+tags: [userdocs, tools]
permalink: /pmd_userdocs_tools_maven.html
last_updated: August 2017
author: >
@@ -112,6 +113,20 @@ writing a ruleset can be found [here](pmd_userdocs_understanding_rulesets.html).
Note that if you include other rulesets in your own rulesets, you have to be sure that the plugin
will be able to resolve those other ruleset references.
+#### Enabling Incremental Analysis
+
+When using the Maven PMD plugin 3.8 or later along with PMD 5.6.0 or later, you can enable incremental analysis to
+speed up PMD's execution while retaining the quality of the analysis. You can additionally customize where the cache is stored::
+
+
+ org.apache.maven.plugins
+ maven-pmd-plugin
+
+ true
+ ${project.build.directory}/pmd/pmd.cache
+
+
+
#### Other configurations
The Maven PMD plugin allows you to configure CPD, targetJDK, and the use of XRef to link
@@ -139,7 +154,7 @@ Maven plugin will use and benefit from the latest bugfixes and enhancements:
``` xml
- ...choose your version...
+ ...choose your version...
...
diff --git a/docs/pages/pmd/userdocs/tools.md b/docs/pages/pmd/userdocs/tools/tools.md
similarity index 95%
rename from docs/pages/pmd/userdocs/tools.md
rename to docs/pages/pmd/userdocs/tools/tools.md
index c76c5be90b3..37b9e32943f 100644
--- a/docs/pages/pmd/userdocs/tools.md
+++ b/docs/pages/pmd/userdocs/tools/tools.md
@@ -1,14 +1,24 @@
---
title: Tools / Integrations
+tags: [userdocs, tools]
+
permalink: pmd_userdocs_tools.html
author: David Dixon-Peugh
---
-* IDE plugins
-* [Continuous Integrations plugins](/pmd_userdocs_ci.html)
-* GUIs
+## Automated Code Review
+
+### Codacy
+
+[Codacy](https://www.codacy.com/) automates code reviews and monitors code quality on every commit and pull request.
+It gives visibility into the technical debt and it can track code style and security issues, code coverage, code duplication, cyclomatic complexity and enforce best practices.
+Codacy is static analysis without the hassle.
+With Codacy you have PMDJava analysis out-of-the-box, and it is free for open source projects.
+* Homepage: [https://www.codacy.com/](https://www.codacy.com/)
+* Source code: [https://github.com/codacy/codacy-pmdjava](https://github.com/codacy/codacy-pmdjava)
+* Maintainer: Codacy
## IDE Integrations
@@ -29,13 +39,6 @@ author: David Dixon-Peugh
Tom Copeland
-
- Codacy
-
- github: codacy/codacy-pmdjava
- Codacy
-
-
CodeGuide
@@ -49,6 +52,13 @@ author: David Dixon-Peugh
github: pmd/pmd-eclipse
Philippe Herlin
+
+
+ qa-Eclipse
+
+ qa-Eclipse
+ Christian Wulf
+
eclipse-pmd
@@ -158,12 +168,6 @@ the [PMDExtension jar file](http://sourceforge.net/projects/pmd/files/pmd-bluej/
and place it in your `bluej/lib/extensions/` directory.
-### Codacy
-
-Although it is not an IDE, with [Codacy](https://www.codacy.com/) you have PMDJava analysis out-of-the-box,
-and it is free for open source projects.
-
-
### Code Guide
Here's how to set up PMD with Omnicore's CodeGuide:
diff --git a/docs/pages/pmd/userdocs/understanding_rulesets.md b/docs/pages/pmd/userdocs/understanding_rulesets.md
deleted file mode 100644
index cf9ea363c6e..00000000000
--- a/docs/pages/pmd/userdocs/understanding_rulesets.md
+++ /dev/null
@@ -1,69 +0,0 @@
----
-title: Understanding Rulesets
-permalink: pmd_userdocs_understanding_rulesets.html
-summary: Rulesets are collections of rules
-last_updated: September 2017
----
-
-There are two major use cases:
-
-1. When defining a new rule, the rule needs to be defined in a ruleset. PMD's built-in rules
- are defined in specific rulesets from which the rule reference documentation is generated,
- see [Java Rules](pmd_rules_java.html) for an example.
-
- Similar rules are grouped together into the same ruleset, like the [Java Braces Ruleset](pmd_rules_java_braces.html)
- which contains rules that all deal with missing braces.
-
-2. When executing PMD you need to tell, which rules should be executed. You could directly point to the
- built-in rulesets, but then you might be overwhelmed by the found violations. As described
- in [Best Practices](pmd_userdocs_best_practices.html), it's better to define an own custom ruleset.
-
- With an own custom ruleset, you can:
-
- * Select the rules, that should be executed
- * Adjust the rule properties to exactly meet your needs
-
-## Create a custom ruleset
-
-You start by creating a new XML file with the following contents:
-
-``` xml
-
-
-
-
-Custom rules
-
-
-
-```
-
-Now start to add rule by **referencing** them. Let's say, you want to start with finding
-[Empty Catch Blocks](pmd_rules_java_empty.html#emptycatchblock). Then you'd add the following
-rule reference inside the `ruleset` elements:
-
-```xml
-
-```
-
-## Adjusting rule properties
-
-If you want to be less strict with empty catch blocks, you could define that an exception variable name
-of `ignored` will not raise a violation. Therefore you would reference the rule **and** define
-the appropriate property value:
-
-```xml
-
-
-
- ^ignored$
-
-
-
-```
-
-
-{% include note.html content="More information about rulesets can be found on [Making Rulesets](pmd_devdocs_making_rulesets.html)." %}
diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index c5dbb293eca..5baf27eb744 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -4,299 +4,46 @@ permalink: pmd_release_notes.html
keywords: changelog, release notes
---
-## ????? - 6.0.0-SNAPSHOT
+## {{ site.pmd.date }} - {{ site.pmd.version }}
-The PMD team is pleased to announce PMD 6.0.0.
+The PMD team is pleased to announce PMD {{ site.pmd.version }}.
-This is a major release.
+This is a {{ site.pmd.release_type }} release.
-### Table Of Contents
-
-* [New and noteworthy](#new-and-noteworthy)
- * [Revamped Apex CPD](#revamped-apex-cpd)
- * [Java Type Resolution](#java-type-resolution)
- * [Metrics Framework](#metrics-framework)
- * [Error Reporting](#error-reporting)
- * [Java Symbol Table](#java-symbol-table)
- * [Apex Parser Update](#apex-parser-update)
- * [New Rules](#new-rules)
- * [Modified Rules](#modified-rules)
- * [Deprecated Rules](#deprecated-rules)
- * [Removed Rules](#removed-rules)
-* [Fixed Issues](#fixed-issues)
-* [API Changes](#api-changes)
-* [External Contributions](#external-contributions)
+{% tocmaker is_release_notes_processor %}
### New and noteworthy
-#### Revamped Apex CPD
-
-We are now using the Apex Jorje Lexer to tokenize Apex code for CPD. This change means:
-
-* All comments are now ignored for CPD. This is consistent with how other languages such as Java and Groovy work.
-* Tokenization honors the language specification, which improves accuracy.
-
-CPD will therefore have less false positives and false negatives.
-
-#### Java Type Resolution
-
-As part of Google Summer of Code 2017, [Bendegúz Nagy](https://github.com/WinterGrascph)'s work on type resolution for Java continues.
-For this release he has extended support for method calls for both instance and static methods.
-
-Method shadowing and overloading are supported, as are varargs. However, the selection of the target method upon the presence
-of generics and type inference is still work in progress. Expect it in forecoming releases.
-
-As for fields, the basic support was in place for release 5.8.0, but has now been expanded to support static fields.
-
-#### Metrics Framework
-
-As part of Google Summer of Code 2017, [Clément Fournier](https://github.com/oowekyala) is continuing his work
-on the new metrics framework for object-oriented metrics.
-
-There are already a couple of metrics (e.g. ATFD, WMC, Cyclo, LoC) implemented. More metrics are planned.
-Based on those metrics, rules like "GodClass" detection can be implemented more easily.
-
-The Metrics framework has been abstracted and is available in `pmd-core` for other languages. With this
-PMD release, the metrics framework is supported for both Java and Apex.
-
-#### Error Reporting
-
-A number of improvements on error reporting have taken place, meaning changes to some of the report formats.
-
-Also of note, the xml report now provides a XML Schema definition, allowing easier parsing and validation.
-
-##### Processing Errors
-
-Processing errors can now provide not only the message previously included on some reports, but also a full stacktrace.
-This will allow better error reports when providing feedback to the PMD team and help in debugging issues.
-
-The report formats providing full stacktrace of errors are:
-
-* html
-* summaryhtml
-* textcolor
-* vbhtml
-* xml
-
-#####Â Configuration Errors
-
-For a long time reports have been notified of configuration errors on rules, but they have remained hidden.
-On a push to make these more evident to users, and help them get the best results out of PMD, we have started
-to include them on the reports.
-
-So far, only reports that include processing errors are showing configuration errors. In other words, the report formats
-providing configuration error reporting are:
-
-* csv
-* html
-* summaryhtml
-* text
-* textcolor
-* vbhtml
-* xml
-
-As we move forward we will be able to detect and report more configuration errors (ie: incomplete `auxclasspath`)
-and include them to such reports.
-
#### New Rules
-* The rule `NcssCount` (ruleset `java-codesize`) replaces the three rules "NcssConstructorCount", "NcssMethodCount",
- and "NcssTypeCount". The new rule uses the metrics framework to achieve the same. It has two properties, to
- define the report level for method and class sizes separately. Constructors and methods are considered the same.
-
-* The new rule `ForLoopCanBeForeach` (ruleset `java-migration`) helps to identify those for-loops that can
- be safely refactored into for-each-loops available since java 1.5.
-
-#### Modified Rules
-
-* The rule `UnnecessaryFinalModifier` (ruleset `java-unnecessarycode`) has been revamped to detect more cases.
- It will now flag anonymous class' methods marked as final (can't be overridden, so it's pointless), along with
- final methods overridden / defined within enum instances.
-
-* The rule `UnnecessaryParentheses` (ruleset `java-controversial`) has been merged into `UselessParentheses`
- (ruleset `java-unnecessary`). The rule covers all scenarios previously covered by either rule.
-
-* The rule `UncommentedEmptyConstructor` (ruleset `java-design`) will now ignore empty constructors annotated with
- `javax.inject.Inject`.
-
-* The rule `AbstractClassWithoutAnyMethod` (ruleset `java-design`) will now ignore classes annotated with
- `com.google.auto.value.AutoValue`.
-
-* The rule `GodClass` (ruleset `java-design`) has been revamped to use the new metrics framework.
-
-#### Deprecated Rules
-
-* The rules `NcssConstructorCount`, `NcssMethodCount`, and `NcssTypeCount` (ruleset `java-codesize`) have been
- deprecated. They will be replaced by the new rule `NcssCount` in the same ruleset.
-
-#### Removed Rules
-
-* The deprecated rule `UseSingleton` has been removed from the ruleset `java-design`. The rule has been renamed
- long time ago to `UseUtilityClass`.
-
-#### Java Symbol Table
-
-A [bug in symbol table](https://github.com/pmd/pmd/pull/549/commits/0958621ca884a8002012fc7738308c8dfc24b97c) prevented
-the symbol table analysis to properly match primitive arrays types. The issue [affected the `java-unsedcode/UnusedPrivateMethod`](https://github.com/pmd/pmd/issues/521)
-rule, but other rules may now produce improved results as consequence of this fix.
-
-#### Apex Parser Update
-
-The Apex parser version was bumped, from `1.0-sfdc-187` to `1.0-sfdc-224`. This update let us take full advantage
-of the latest improvements from Salesforce, but introduces some breaking changes:
-
-* `BlockStatements` are now created for all control structures, even if no brace is used. We have therefore added
- a `hasCurlyBrace` method to differentiate between both scenarios.
-* New AST node types are available. In particular `CastExpression`, `ConstructorPreamble`, `IllegalStoreExpression`,
- `MethodBlockStatement`, `Modifier`, `MultiStatement`, `NestedExpression`, `NestedStoreExpression`,
- `NewKeyValueObjectExpression` and `StatementExecuted`
-* Some nodes have been removed. Such is the case of `TestNode`, `DottedExpression` and `NewNameValueObjectExpression`
- (replaced by `NewKeyValueObjectExpression`)
-
-All existing rules have been updated to reflect these changes. If you have custom rules, be sure to update them.
+* The new Java rule {% rule "java/codestyle/UseUnderscoresInNumericLiterals" %} (`java-codestyle`)
+ verifies that numeric literals over a given length (4 chars by default, but configurable) are using
+ underscores every 3 digits for readability. The rule only applies to Java 7+ codebases.
### Fixed Issues
+* all
+ * [#1284](https://github.com/pmd/pmd/issues/1284): \[doc] Keep record of every currently deprecated API
* all
- * [#532](https://github.com/pmd/pmd/issues/532): \[core] security concerns on URL-based rulesets
- * [#538](https://github.com/pmd/pmd/issues/538): \[core] Provide an XML Schema for XML reports
- * [#600](https://github.com/pmd/pmd/issues/600): \[core] Nullpointer while creating cache File
-* apex
- * [#488](https://github.com/pmd/pmd/pull/488): \[apex] Use Apex lexer for CPD
- * [#489](https://github.com/pmd/pmd/pull/489): \[apex] Update Apex compiler
- * [#500](https://github.com/pmd/pmd/issues/500): \[apex] Running through CLI shows jorje optimization messages
-* cpp
- * [#448](https://github.com/pmd/pmd/issues/448): \[cpp] Write custom CharStream to handle continuation characters
-* java
- * [#1513](https://sourceforge.net/p/pmd/bugs/1513/): \[java] Remove deprecated rule UseSingleton
- * [#487](https://github.com/pmd/pmd/pull/487): \[java] Fix typeresolution for anonymous extending object
- * [#496](https://github.com/pmd/pmd/issues/496): \[java] processing error on generics inherited from enclosing class
- * [#527](https://github.com/pmd/pmd/issues/527): \[java] Lombok getter annotation on enum is not recognized correctly
-* java-basic
- * [#565](https://github.com/pmd/pmd/pull/565): \[java] False negative on DontCallThreadRun when extending Thread
-* java-comments
- * [#536](https://github.com/pmd/pmd/issues/536): \[java] CommentDefaultAccessModifierRule ignores constructors
-* java-controversial
- * [#388](https://github.com/pmd/pmd/issues/388): \[java] controversial.AvoidLiteralsInIfCondition 0.0 false positive
- * [#408](https://github.com/pmd/pmd/issues/408): \[java] DFA not analyzing asserts
- * [#537](https://github.com/pmd/pmd/issues/537): \[java] UnnecessaryParentheses fails to detect obvious scenario
-* java-design
- * [#357](https://github.com/pmd/pmd/issues/357): \[java] UncommentedEmptyConstructor consider annotations on Constructor
- * [#438](https://github.com/pmd/pmd/issues/438): \[java] Relax AbstractClassWithoutAnyMethod when class is annotated by @AutoValue
- * [#590](https://github.com/pmd/pmd/issues/590): \[java] False positive on MissingStaticMethodInNonInstantiatableClass
-* java-sunsecure
- * [#468](https://github.com/pmd/pmd/issues/468): \[java] ArrayIsStoredDirectly false positive
-* java-unusedcode
- * [#521](https://github.com/pmd/pmd/issues/521): \[java] UnusedPrivateMethod returns false positives with primitive data type in map argument
-* java-unnecessarycode
- * [#412](https://github.com/pmd/pmd/issues/412): \[java] java-unnecessarycode/UnnecessaryFinalModifier missing cases
+ * [#1318](https://github.com/pmd/pmd/issues/1318): \[test] Kotlin DSL to ease test writing
+ * [#1341](https://github.com/pmd/pmd/issues/1341): \[doc] Documentation Error with Regex Properties
+* java-codestyle
+ * [#1232](https://github.com/pmd/pmd/issues/1232): \[java] Detector for large numbers not separated by _
+ * [#1372](https://github.com/pmd/pmd/issues/1372): \[java] false positive for UselessQualifiedThis
### API Changes
-* The class `net.sourceforge.pmd.lang.dfa.NodeType` has been converted to an enum.
- All node types are enum members now instead of int constants. The names for node types are retained.
-
-* The properties API (rule and report properties) have been revamped to be fully typesafe. This is everything
- around `net.sourceforge.pmd.PropertyDescriptor`.
-
-* The rule classes `net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestClassShouldHaveAsserts`
- and `net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestShouldNotUseSeeAllDataTrue` have been
- renamed to `ApexUnitTestClassShouldHaveAssertsRule` and `ApexUnitTestShouldNotUseSeeAllDataTrueRule`,
- respectively. This is to comply with the naming convention, that each rule class should be suffixed with "Rule".
- This change has no impact on custom rulesets, since the rule names themselves didn't change.
-
-* The never implemented method `PMD.processFiles(PMDConfiguration, RuleSetFactory, Collection, RuleContext, ProgressMonitor)` along with the interface `ProgressMonitor` has been removed.
-
-* All APIs deprecated in older versions are now removed. This includes:
- * `Renderer.getPropertyDefinitions`
- * `AbstractRenderer.defineProperty(String, String)`
- * `AbstractRenderer.propertyDefinitions`
- * `ReportListener`
- * `Report.addListener(ReportListener)`
- * `SynchronizedReportListener`
- * `CPDConfiguration.CPDConfiguration(int, Language, String)`
- * `CPDConfiguration.getRendererFromString(String)`
- * `StreamUtil`
- * `StringUtil.appendXmlEscaped(StringBuilder, String)`
- * `StringUtil.htmlEncode(String)`
-
-
-* Several methods in `net.sourceforge.pmd.util.CollectionUtil` have been deprecated and will be removed in PMD 7.0.0. In particular:
- * `CollectionUtil.addWithoutDuplicates(T[], T)`
- * `CollectionUtil.addWithoutDuplicates(T[], T[])`
- * `CollectionUtil.areSemanticEquals(T[], T[])`
- * `CollectionUtil.areEqual(Object, Object)`
- * `CollectionUtil.arraysAreEqual(Object, Object)`
- * `CollectionUtil.valuesAreTransitivelyEqual(Object[], Object[])`
+* The implementation of the adapters for the XPath engines Saxon and Jaxen (package `net.sourceforge.pmd.lang.ast.xpath`)
+ are now deprecated. They'll be moved to an internal package come 7.0.0. Only `Attribute` remains public API.
+### External Contributions
-* Several methods in `net.sourceforge.pmd.util.StringUtil` have been deprecated and will be removed in PMD 7.0.0. In particular:
- * `StringUtil.startsWithAny(String, String[])`
- * `StringUtil.isNotEmpty(String)`
- * `StringUtil.isEmpty(String)`
- * `StringUtil.isMissing(String)`
- * `StringUtil.areSemanticEquals(String, String)`
- * `StringUtil.replaceString(String, String, String)`
- * `StringUtil.replaceString(String, char, String)`
- * `StringUtil.substringsOf(String, char)`
- * `StringUtil.substringsOf(String, String)`
- * `StringUtil.asStringOn(StringBuffer, Iterator, String)`
- * `StringUtil.asStringOn(StringBuilder, Object[], String)`
- * `StringUtil.lpad(String, int)`
+* [#1384](https://github.com/pmd/pmd/pull/1384): \[java] New Rule - UseUnderscoresInNumericLiterals - [RajeshR](https://github.com/rajeshggwp)
+* [#1424](https://github.com/pmd/pmd/pull/1424): \[doc] #1341 Updating Regex Values in default Value Property - [avishvat](https://github.com/vishva007)
+* [#1428](https://github.com/pmd/pmd/pull/1428): \[core] Upgrading JCommander from 1.48 to 1.72 - [Thunderforge](https://github.com/Thunderforge)
+* [#1430](https://github.com/pmd/pmd/pull/1430): \[doc] Who really knows regex? - [Dem Pilafian](https://github.com/dpilafian)
-* The class `net.sourceforge.pmd.lang.java.typeresolution.typedefinition.JavaTypeDefinition` is now abstract, and has been enhanced
- to provide several new methods.
+{% endtocmaker %}
-### External Contributions
+{% include note.html content="The release notes of previous versions are available [here](pmd_release_notes_old.html)" %}
-* [#420](https://github.com/pmd/pmd/pull/420): \[java] Fix UR anomaly in assert statements - [Clément Fournier](https://github.com/oowekyala)
-* [#482](https://github.com/pmd/pmd/pull/482): \[java] Metrics testing framework + improved capabilities for metrics - [Clément Fournier](https://github.com/oowekyala)
-* [#484](https://github.com/pmd/pmd/pull/484): \[core] Changed linux usage to a more unix like path - [patriksevallius](https://github.com/patriksevallius)
-* [#486](https://github.com/pmd/pmd/pull/486): \[java] Add basic method typeresolution - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#492](https://github.com/pmd/pmd/pull/492): \[java] Typeresolution for overloaded methods - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#495](https://github.com/pmd/pmd/pull/495): \[core] Custom rule reinitialization code - [Clément Fournier](https://github.com/oowekyala)
-* [#479](https://github.com/pmd/pmd/pull/479): \[core] Typesafe and immutable properties - [Clément Fournier](https://github.com/oowekyala)
-* [#499](https://github.com/pmd/pmd/pull/499): \[java] Metrics memoization tests - [Clément Fournier](https://github.com/oowekyala)
-* [#501](https://github.com/pmd/pmd/pull/501): \[java] Add support for most specific vararg method type resolution - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#502](https://github.com/pmd/pmd/pull/502): \[java] Add support for static field type resolution - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#505](https://github.com/pmd/pmd/pull/505): \[java] Followup on metrics - [Clément Fournier](https://github.com/oowekyala)
-* [#506](https://github.com/pmd/pmd/pull/506): \[java] Add reduction rules to type inference - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#511](https://github.com/pmd/pmd/pull/511): \[core] Prepare abstraction of the metrics framework - [Clément Fournier](https://github.com/oowekyala)
-* [#512](https://github.com/pmd/pmd/pull/512): \[java] Add incorporation to type inference - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#513](https://github.com/pmd/pmd/pull/513): \[java] Fix for maximally specific method selection - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#514](https://github.com/pmd/pmd/pull/514): \[java] Add static method type resolution - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#517](https://github.com/pmd/pmd/pull/517): \[doc] Metrics documentation - [Clément Fournier](https://github.com/oowekyala)
-* [#518](https://github.com/pmd/pmd/pull/518): \[core] Properties refactoring: factorized enumerated property - [Clément Fournier](https://github.com/oowekyala)
-* [#523](https://github.com/pmd/pmd/pull/523): \[java] Npath complexity metric and rule - [Clément Fournier](https://github.com/oowekyala)
-* [#524](https://github.com/pmd/pmd/pull/524): \[java] Add support for explicit type arguments with method invocation - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#525](https://github.com/pmd/pmd/pull/525): \[core] Fix line ending and not ignored files issues - [Matias Comercio](https://github.com/MatiasComercio)
-* [#528](https://github.com/pmd/pmd/pull/528): \[core] Fix typo - [Ayoub Kaanich](https://github.com/kayoub5)
-* [#529](https://github.com/pmd/pmd/pull/529): \[java] Abstracted the Java metrics framework - [Clément Fournier](https://github.com/oowekyala)
-* [#530](https://github.com/pmd/pmd/pull/530): \[java] Fix issue #527: Lombok getter annotation on enum is not recognized correctly - [Clément Fournier](https://github.com/oowekyala)
-* [#533](https://github.com/pmd/pmd/pull/533): \[core] improve error message - [Dennis Kieselhorst](https://github.com/deki)
-* [#535](https://github.com/pmd/pmd/pull/535): \[apex] Fix broken Apex visitor adapter - [Clément Fournier](https://github.com/oowekyala)
-* [#542](https://github.com/pmd/pmd/pull/542): \[java] Metrics abstraction - [Clément Fournier](https://github.com/oowekyala)
-* [#545](https://github.com/pmd/pmd/pull/545): \[apex] Apex metrics framework - [Clément Fournier](https://github.com/oowekyala)
-* [#548](https://github.com/pmd/pmd/pull/548): \[java] Metrics documentation - [Clément Fournier](https://github.com/oowekyala)
-* [#550](https://github.com/pmd/pmd/pull/550): \[java] Add basic resolution to type inference - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#553](https://github.com/pmd/pmd/pull/553): \[java] Refactored ParserTst into a static utility class + add getSourceFromClass - [Clément Fournier](https://github.com/oowekyala)
-* [#554](https://github.com/pmd/pmd/pull/554): \[java] Fix #537: UnnecessaryParentheses fails to detect obvious scenario - [Clément Fournier](https://github.com/oowekyala)
-* [#555](https://github.com/pmd/pmd/pull/555): \[java] Changed metrics/CyclomaticComplexityRule to use WMC when reporting classes - [Clément Fournier](https://github.com/oowekyala)
-* [#556](https://github.com/pmd/pmd/pull/556): \[java] Fix #357: UncommentedEmptyConstructor consider annotations on Constructor - [Clément Fournier](https://github.com/oowekyala)
-* [#557](https://github.com/pmd/pmd/pull/557): \[java] Fix NPath metric not counting ternaries correctly - [Clément Fournier](https://github.com/oowekyala)
-* [#563](https://github.com/pmd/pmd/pull/563): \[java] Add support for basic method type inference for strict invocation - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#566](https://github.com/pmd/pmd/pull/566): \[java] New rule in migrating ruleset: ForLoopCanBeForeach - [Clément Fournier](https://github.com/oowekyala)
-* [#567](https://github.com/pmd/pmd/pull/567): \[java] Last API change for metrics (metric options) - [Clément Fournier](https://github.com/oowekyala)
-* [#570](https://github.com/pmd/pmd/pull/570): \[java] Model lower, upper and intersection types - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#573](https://github.com/pmd/pmd/pull/573): \[java] Data class rule - [Clément Fournier](https://github.com/oowekyala)
-* [#576](https://github.com/pmd/pmd/pull/576): \[doc]\[java] Add hint for Guava users in InefficientEmptyStringCheck - [mmoehring](https://github.com/mmoehring)
-* [#578](https://github.com/pmd/pmd/pull/578): \[java] Refactored god class rule - [Clément Fournier](https://github.com/oowekyala)
-* [#579](https://github.com/pmd/pmd/pull/579): \[java] Update parsing to produce upper and lower bounds - [Bendegúz Nagy](https://github.com/WinterGrascph)
-* [#580](https://github.com/pmd/pmd/pull/580): \[core] Add AbstractMetric to topple the class hierarchy of metrics - [Clément Fournier](https://github.com/oowekyala)
-* [#581](https://github.com/pmd/pmd/pull/581): \[java] Relax AbstractClassWithoutAnyMethod when class is annotated by @AutoValue - [Niklas Baudy](https://github.com/vanniktech)
-* [#583](https://github.com/pmd/pmd/pull/583): \[java] Documentation about writing metrics - [Clément Fournier](https://github.com/oowekyala)
-* [#585](https://github.com/pmd/pmd/pull/585): \[java] Moved NcssCountRule to codesize.xml - [Clément Fournier](https://github.com/oowekyala)
-* [#587](https://github.com/pmd/pmd/pull/587): \[core] Properties refactoring: Move static constants of ValueParser to class ValueParserConstants - [Clément Fournier](https://github.com/oowekyala)
-* [#588](https://github.com/pmd/pmd/pull/588): \[java] XPath function to compute metrics - [Clément Fournier](https://github.com/oowekyala)
-* [#598](https://github.com/pmd/pmd/pull/598): \[java] Fix #388: controversial.AvoidLiteralsInIfCondition 0.0 false positive - [Clément Fournier](https://github.com/oowekyala)
-* [#620](https://github.com/pmd/pmd/pull/620): \[core] Moved properties to n.s.pmd.properties - [Clément Fournier](https://github.com/oowekyala)
diff --git a/docs/pages/release_notes_old.md b/docs/pages/release_notes_old.md
index 4278cd080db..d7110b64736 100644
--- a/docs/pages/release_notes_old.md
+++ b/docs/pages/release_notes_old.md
@@ -3,8 +3,1743 @@ title: Old Release Notes
permalink: pmd_release_notes_old.html
---
-Previous versions of PMD can be downloaded here:
-http://sourceforge.net/projects/pmd/files/pmd/
+Previous versions of PMD can be downloaded here: https://github.com/pmd/pmd/releases
+
+## 28-October-2018 - 6.9.0
+
+The PMD team is pleased to announce PMD 6.9.0.
+
+This is a minor release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [Improved Golang CPD Support](#improved-golang-cpd-support)
+ * [New Rules](#new-rules)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### Improved Golang CPD Support
+
+Thanks to the work of [ITBA](https://www.itba.edu.ar/) students [MatÃas Fraga](https://github.com/matifraga),
+[Tomi De Lucca](https://github.com/tomidelucca) and [Lucas Soncini](https://github.com/lsoncini),
+Golang is now backed by a proper Antlr Grammar. This means CPD is now better at detecting duplicates,
+as comments are recognized as such and ignored.
+
+#### New Rules
+
+* The new PLSQL rule [`CodeFormat`](https://pmd.github.io/pmd-6.9.0/pmd_rules_plsql_codestyle.html#codeformat) (`plsql-codestyle`) verifies that
+ PLSQL code is properly formatted. It checks e.g. for correct indentation in select statements and verifies
+ that each parameter is defined on a separate line.
+
+### Fixed Issues
+
+* all
+ * [#649](https://github.com/pmd/pmd/issues/649): \[core] Exclude specific files from command line
+ * [#1272](https://github.com/pmd/pmd/issues/1272): \[core] Could not find or load main class when using symlinked run.sh
+ * [#1377](https://github.com/pmd/pmd/issues/1377): \[core] LanguageRegistry uses default class loader when invoking ServiceLocator
+ * [#1394](https://github.com/pmd/pmd/issues/1394): \[doc] How to configure "-cache "
+ * [#1412](https://github.com/pmd/pmd/issues/1412): \[doc] Broken link to adding new cpd language documentation
+* apex
+ * [#1396](https://github.com/pmd/pmd/issues/1396): \[apex] ClassCastException caused by Javadoc
+* java
+ * [#1330](https://github.com/pmd/pmd/issues/1330): \[java] PMD crashes with java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/xml/ws/Service
+* java-bestpractices
+ * [#1202](https://github.com/pmd/pmd/issues/1202): \[java] GuardLogStatement: "There is log block not surrounded by if" doesn't sound right
+ * [#1209](https://github.com/pmd/pmd/issues/1209): \[java] UnusedImports false positive for static import with package-private method usage
+ * [#1343](https://github.com/pmd/pmd/issues/1343): \[java] Update CommentDefaultAccessModifierRule to extend AbstractIgnoredAnnotationRule
+ * [#1365](https://github.com/pmd/pmd/issues/1365): \[java] JUnitTestsShouldIncludeAssert false positive
+ * [#1404](https://github.com/pmd/pmd/issues/1404): \[java] UnusedImports false positive with static ondemand import with method call
+* java-codestyle
+ * [#1199](https://github.com/pmd/pmd/issues/1199): \[java] UnnecessaryFullyQualifiedName doesn't flag same package FQCNs
+ * [#1356](https://github.com/pmd/pmd/issues/1356): \[java] UnnecessaryModifier wrong message public-\>static
+* java-design
+ * [#1369](https://github.com/pmd/pmd/issues/1369): \[java] Processing error (ClassCastException) if a TYPE\_USE annotation is used on a base class in the "extends" clause
+* jsp
+ * [#1402](https://github.com/pmd/pmd/issues/1402): \[jsp] JspTokenManager has a problem about jsp scriptlet
+* documentation
+ * [#1349](https://github.com/pmd/pmd/pull/1349): \[doc] Provide some explanation for WHY duplicate code is bad, like mutations
+
+### API Changes
+
+* PMD has a new CLI option `-ignorelist`. With that, you can provide a file containing a comma-delimit list of files,
+ that should be excluded during analysis. The ignorelist is applied after the files have been selected
+ via `-dir` or `-filelist`, which means, if the file is in both lists, then it will be ignored.
+ Note: there is no corresponding option for the Ant task, since the feature is already available via
+ Ant's FileSet include/exclude filters.
+
+### External Contributions
+
+* [#1338](https://github.com/pmd/pmd/pull/1338): \[core] \[cpd] Generalize ANTLR tokens preparing support for ANTLR token filter - [MatÃas Fraga](https://github.com/matifraga) and [Tomi De Lucca](https://github.com/tomidelucca)
+* [#1361](https://github.com/pmd/pmd/pull/1361): \[doc] Update cpd.md with information about risks - [David M. Karr](https://github.com/davidmichaelkarr)
+* [#1366](https://github.com/pmd/pmd/pull/1366): \[java] Static Modifier on Internal Interface pmd #1356 - [avishvat](https://github.com/vishva007)
+* [#1368](https://github.com/pmd/pmd/pull/1368): \[doc] Updated outdated note in the building documentation. - [Maikel Steneker](https://github.com/maikelsteneker)
+* [#1374](https://github.com/pmd/pmd/pull/1374): \[java] Simplify check for 'Test' annotation in JUnitTestsShouldIncludeAssertRule. - [Will Winder](https://github.com/winder)
+* [#1375](https://github.com/pmd/pmd/pull/1375): \[java] Add missing null check AbstractJavaAnnotatableNode - [Will Winder](https://github.com/winder)
+* [#1376](https://github.com/pmd/pmd/pull/1376): \[all] Upgrading Apache Commons IO from 2.4 to 2.6 - [Thunderforge](https://github.com/Thunderforge)
+* [#1378](https://github.com/pmd/pmd/pull/1378): \[all] Upgrading Apache Commons Lang 3 from 3.7 to 3.8.1 - [Thunderforge](https://github.com/Thunderforge)
+* [#1382](https://github.com/pmd/pmd/pull/1382): \[all] Replacing deprecated IO methods with ones that specify a charset - [Thunderforge](https://github.com/Thunderforge)
+* [#1383](https://github.com/pmd/pmd/pull/1383): \[java] Improved message for GuardLogStatement rule - [Felix Lampe](https://github.com/fblampe)
+* [#1386](https://github.com/pmd/pmd/pull/1386): \[go] \[cpd] Add CPD support for Antlr based grammar on Golang - [MatÃas Fraga](https://github.com/matifraga)
+* [#1398](https://github.com/pmd/pmd/pull/1398): \[all] Upgrading SLF4J from 1.7.12 to 1.7.25 - [Thunderforge](https://github.com/Thunderforge)
+* [#1400](https://github.com/pmd/pmd/pull/1400): \[java] Fix Issue 1343: Update CommentDefaultAccessModifierRule - [CrazyUnderdog](https://github.com/CrazyUnderdog)
+* [#1401](https://github.com/pmd/pmd/pull/1401): \[all] Replacing IOUtils.closeQuietly(foo) with try-with-resources statements - [Thunderforge](https://github.com/Thunderforge)
+* [#1406](https://github.com/pmd/pmd/pull/1406): \[jsp] Fix issue 1402: JspTokenManager has a problem about jsp scriptlet - [JustPRV](https://github.com/JustPRV)
+* [#1411](https://github.com/pmd/pmd/pull/1411): \[core] Add ignore file path functionality - [Jon Moroney](https://github.com/darakian)
+* [#1414](https://github.com/pmd/pmd/pull/1414): \[doc] Fix broken link. Fixes #1412 - [Johan Hammar](https://github.com/johanhammar)
+
+
+## 30-September-2018 - 6.8.0
+
+The PMD team is pleased to announce PMD 6.8.0.
+
+This is a minor release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [Drawing a line between private and public API](#drawing-a-line-between-private-and-public-api)
+ * [`.internal` packages and `@InternalApi` annotation](#`.internal`-packages-and-`@internalapi`-annotation)
+ * [`@ReservedSubclassing`](#`@reservedsubclassing`)
+ * [`@Experimental`](#`@experimental`)
+ * [`@Deprecated`](#`@deprecated`)
+ * [The transition](#the-transition)
+ * [Quickstart Ruleset](#quickstart-ruleset)
+ * [New Rules](#new-rules)
+ * [Modified Rules](#modified-rules)
+ * [PLSQL](#plsql)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### Drawing a line between private and public API
+
+Until now, all released public members and types were implicitly considered part
+of PMD's public API, including inheritance-specific members (protected members, abstract methods).
+We have maintained those APIs with the goal to preserve full binary compatibility between minor releases,
+only breaking those APIs infrequently, for major releases.
+
+In order to allow PMD to move forward at a faster pace, this implicit contract will
+be invalidated with PMD 7.0.0. We now introduce more fine-grained distinctions between
+the type of compatibility support we guarantee for our libraries, and ways to make
+them explicit to clients of PMD.
+
+###### `.internal` packages and `@InternalApi` annotation
+
+*Internal API* is meant for use *only* by the main PMD codebase. Internal types and methods
+may be modified in any way, or even removed, at any time.
+
+Any API in a package that contains an `.internal` segment is considered internal.
+The `@InternalApi` annotation will be used for APIs that have to live outside of
+these packages, e.g. methods of a public type that shouldn't be used outside of PMD (again,
+these can be removed anytime).
+
+###### `@ReservedSubclassing`
+
+Types marked with the `@ReservedSubclassing` annotation are only meant to be subclassed
+by classes within PMD. As such, we may add new abstract methods, or remove protected methods,
+at any time. All published public members remain supported. The annotation is *not* inherited, which
+means a reserved interface doesn't prevent its implementors to be subclassed.
+
+###### `@Experimental`
+
+APIs marked with the `@Experimental` annotation at the class or method level are subject to change.
+They can be modified in any way, or even removed, at any time. You should not use or rely
+ on them in any production code. They are purely to allow broad testing and feedback.
+
+###### `@Deprecated`
+
+APIs marked with the `@Deprecated` annotation at the class or method level will remain supported
+until the next major release but it is recommended to stop using them.
+
+###### The transition
+
+*All currently supported APIs will remain so until 7.0.0*. All APIs that are to be moved to
+`.internal` packages or hidden will be tagged `@InternalApi` before that major release, and
+the breaking API changes will be performed in 7.0.0.
+
+
+#### Quickstart Ruleset
+
+PMD 6.8.0 provides a first quickstart ruleset for Java, which you can use as a base ruleset to get your
+custom ruleset started. You can reference it with `rulesets/java/quickstart.xml`.
+You are strongly encouraged to [create your own ruleset](https://pmd.github.io/pmd-6.7.0/pmd_userdocs_making_rulesets.html)
+though.
+
+The quickstart ruleset has the intention, to be useful out-of-the-box for many projects. Therefore it
+references only rules, that are most likely to apply everywhere.
+
+Any feedback would be greatly appreciated.
+
+
+#### New Rules
+
+* The new Apex rule [`ApexDoc`](https://pmd.github.io/pmd-6.8.0/pmd_rules_apex_documentation.html#apexdoc) (`apex-documentation`)
+ enforces the inclusion of ApexDoc on classes, interfaces, properties and methods; as well as some
+ sanity rules for such docs (no missing parameters, parameters' order, and return value). By default,
+ method overrides and test classes are allowed to not include ApexDoc.
+
+
+#### Modified Rules
+
+* The rule [`MissingSerialVersionUID`](https://pmd.github.io/pmd-6.8.0/pmd_rules_java_errorprone.html#missingserialversionuid) (`java-errorprone`) has been modified
+ in order to recognize also missing `serialVersionUID` fields in abstract classes, if they are serializable.
+ Each individual class in the inheritance chain needs an own serialVersionUID field. See also [Should an abstract class have a serialVersionUID](https://stackoverflow.com/questions/893259/should-an-abstract-class-have-a-serialversionuid).
+ This change might lead to additional violations in existing code bases.
+
+
+#### PLSQL
+
+The grammar for PLSQL has been revamped in order to fully parse `SELECT INTO`, `UPDATE`, and `DELETE`
+statements. Previously such statements have been simply skipped ahead, now PMD is parsing them, giving access
+to the individual parts of a SELECT-statement, such as the Where-Clause. This might produce new parsing errors
+where PMD previously could successfully parse PLSQL code. If this happens, please report a new [issue](https://github.com/pmd/pmd/issues/new) to get this problem fixed.
+
+
+### Fixed Issues
+
+* apex-bestpractices
+ * [#1348](https://github.com/pmd/pmd/issues/1348): \[apex] AvoidGlobalModifierRule gives warning even when its a webservice - false positive
+* java-codestyle
+ * [#1329](https://github.com/pmd/pmd/issues/1329): \[java] FieldNamingConventions: false positive in serializable class with serialVersionUID
+ * [#1334](https://github.com/pmd/pmd/issues/1334): \[java] LinguisticNaming should support AtomicBooleans
+* java-errorprone
+ * [#1350](https://github.com/pmd/pmd/issues/1350): \[java] MissingSerialVersionUID false-positive on interfaces
+ * [#1352](https://github.com/pmd/pmd/issues/1352): \[java] MissingSerialVersionUID false-negative with abstract classes
+* java-performance
+ * [#1325](https://github.com/pmd/pmd/issues/1325): \[java] False positive in ConsecutiveLiteralAppends
+* plsql
+ * [#1279](https://github.com/pmd/pmd/pull/1279): \[plsql] Support for SELECT INTO
+
+
+### API Changes
+
+* A couple of methods and fields in `net.sourceforge.pmd.properties.AbstractPropertySource` have been
+ deprecated, as they are replaced by already existing functionality or expose internal implementation
+ details: `propertyDescriptors`, `propertyValuesByDescriptor`,
+ `copyPropertyDescriptors()`, `copyPropertyValues()`, `ignoredProperties()`, `usesDefaultValues()`,
+ `useDefaultValueFor()`.
+
+* Some methods in `net.sourceforge.pmd.properties.PropertySource` have been deprecated as well:
+ `usesDefaultValues()`, `useDefaultValueFor()`, `ignoredProperties()`.
+
+* The class `net.sourceforge.pmd.lang.rule.AbstractDelegateRule` has been deprecated and will
+ be removed with PMD 7.0.0. It is internally only in use by RuleReference.
+
+* The default constructor of `net.sourceforge.pmd.lang.rule.RuleReference` has been deprecated
+ and will be removed with PMD 7.0.0. RuleReferences should only be created by providing a Rule and
+ a RuleSetReference. Furthermore the following methods are deprecated: `setRuleReference()`,
+ `hasOverriddenProperty()`, `usesDefaultValues()`, `useDefaultValueFor()`.
+
+
+### External Contributions
+
+* [#1309](https://github.com/pmd/pmd/pull/1309): \[core] \[CPD] Decouple Antlr Tokenizer implementation from any CPD language supported with Antlr - [MatÃas Fraga](https://github.com/matifraga)
+* [#1314](https://github.com/pmd/pmd/pull/1314): \[apex] Add validation of ApexDoc comments - [Jeff Hube](https://github.com/jeffhube)
+* [#1339](https://github.com/pmd/pmd/pull/1339): \[ci] Improve danger message - [BBG](https://github.com/djydewang)
+* [#1340](https://github.com/pmd/pmd/pull/1340): \[java] Derive correct classname for non-public non-classes - [kris-scheibe](https://github.com/kris-scheibe)
+* [#1357](https://github.com/pmd/pmd/pull/1357): \[doc] Improve Codacy description - [Daniel Reigada](https://github.com/DReigada)
+
+
+## 02-September-2018 - 6.7.0
+
+The PMD team is pleased to announce PMD 6.7.0.
+
+This is a minor release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [Modified Rules](#modified-rules)
+ * [New Rules](#new-rules)
+ * [Deprecated Rules](#deprecated-rules)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### Modified Rules
+
+* The Java rule {% rule java/bestpractices/OneDeclarationPerLine %} (`java-bestpractices`) has been revamped to
+ consider not only local variable declarations, but field declarations too.
+
+#### New Rules
+
+* The new Java rule {% rule java/codestyle/LinguisticNaming %} (`java-codestyle`)
+ detects cases, when a method name indicates it returns a boolean (such as `isSmall()`) but it doesn't.
+ Besides method names, the rule also checks field and variable names. It also checks, that getters return
+ something but setters won't. The rule has several properties with which it can be customized.
+
+* The new PL/SQL rule {% rule plsql/codestyle/ForLoopNaming %} (`plsql-codestyle`)
+ enforces a naming convention for "for loops". Both "cursor for loops" and "index for loops" are covered.
+ The rule can be customized via patterns. By default, short variable names are reported.
+
+* The new Java rule {% rule java/codestyle/FieldNamingConventions %} (`java-codestyle`)
+ detects field names that don't comply to a given convention. It defaults to standard Java convention of using camelCase,
+ but can be configured with ease for e.g. constants or static fields.
+
+* The new Apex rule {% rule apex/codestyle/OneDeclarationPerLine %} (`apex-codestyle`) enforces declaring a
+ single field / variable per line; or per statement if the `strictMode` property is set.
+ It's an Apex equivalent of the already existing Java rule of the same name.
+
+#### Deprecated Rules
+
+* The Java rules {% rule java/codestyle/VariableNamingConventions %}, {% rule java/codestyle/MIsLeadingVariableName %},
+ {% rule java/codestyle/SuspiciousConstantFieldName %}, and {% rule java/codestyle/AvoidPrefixingMethodParameters %} are
+ now deprecated, and will be removed with version 7.0.0. They are replaced by the more general
+ {% rule java/codestyle/FieldNamingConventions %}, {% rule java/codestyle/FormalParameterNamingConventions %}, and
+ {% rule java/codestyle/LocalVariableNamingConventions %}.
+
+### Fixed Issues
+
+* core
+ * [#1191](https://github.com/pmd/pmd/issues/1191): \[core] Test Framework: Sort violations by line/column
+ * [#1283](https://github.com/pmd/pmd/issues/1283): \[core] Deprecate ReportTree
+ * [#1288](https://github.com/pmd/pmd/issues/1288): \[core] No supported build listeners found with Gradle
+ * [#1300](https://github.com/pmd/pmd/issues/1300): \[core] PMD stops processing file completely, if one rule in a rule chain fails
+ * [#1317](https://github.com/pmd/pmd/issues/1317): \[ci] Coveralls hasn't built the project since June 25th
+* java-bestpractices
+ * [#940](https://github.com/pmd/pmd/issues/940): \[java] JUnit 4 false positives for JUnit 5 tests
+ * [#1267](https://github.com/pmd/pmd/pull/1267): \[java] MissingOverrideRule: Avoid NoClassDefFoundError with incomplete classpath
+ * [#1323](https://github.com/pmd/pmd/issues/1323): \[java] AvoidUsingHardCodedIP ignores match pattern
+ * [#1327](https://github.com/pmd/pmd/pull/1327): \[java] AvoidUsingHardCodedIP false positive for ":bee"
+* java-codestyle
+ * [#1255](https://github.com/pmd/pmd/issues/1255): \[java] UnnecessaryFullyQualifiedName false positive: static method on shadowed implicitly imported class
+ * [#1258](https://github.com/pmd/pmd/issues/1285): \[java] False positive "UselessParentheses" for parentheses that contain assignment
+* java-errorprone
+ * [#1078](https://github.com/pmd/pmd/issues/1078): \[java] MissingSerialVersionUID rule does not seem to catch inherited classes
+* java-performance
+ * [#1291](https://github.com/pmd/pmd/issues/1291): \[java] InvalidSlf4jMessageFormat false positive: too many arguments with string concatenation operator
+ * [#1298](https://github.com/pmd/pmd/issues/1298): \[java] RedundantFieldInitializer - NumberFormatException with Long
+* jsp
+ * [#1274](https://github.com/pmd/pmd/issues/1274): \[jsp] Support EL in tag attributes
+ * [#1276](https://github.com/pmd/pmd/issues/1276): \[jsp] add support for jspf and tag extensions
+* plsql
+ * [#681](https://github.com/pmd/pmd/issues/681): \[plsql] Parse error with Cursor For Loop
+
+### API Changes
+
+* All classes in the package `net.sourceforge.pmd.lang.dfa.report` have been deprecated and will be removed
+ with PMD 7.0.0. This includes the class `net.sourceforge.pmd.lang.dfa.report.ReportTree`. The reason is,
+ that this class is very specific to Java and not suitable for other languages. It has only been used for
+ `YAHTMLRenderer`, which has been rewritten to work without these classes.
+
+* The nodes RUNSIGNEDSHIFT and RSIGNEDSHIFT are deprecated and will be removed from the AST with PMD 7.0.0.
+ These represented the operator of ShiftExpression in two cases out of three, but they're not needed and
+ make ShiftExpression inconsistent. The operator of a ShiftExpression is now accessible through
+ ShiftExpression#getOperator.
+
+### External Contributions
+
+* [#109](https://github.com/pmd/pmd/pull/109): \[java] Add two linguistics rules under naming - [Arda Aslan](https://github.com/ardaasln)
+* [#1254](https://github.com/pmd/pmd/pull/1254): \[ci] \[GSoC] Integrating the danger and pmdtester to travis CI - [BBG](https://github.com/djydewang)
+* [#1258](https://github.com/pmd/pmd/pull/1258): \[java] Use typeof in MissingSerialVersionUID - [krichter722](https://github.com/krichter722)
+* [#1264](https://github.com/pmd/pmd/pull/1264): \[cpp] Fix NullPointerException in CPPTokenizer:99 - [Rafael Cortês](https://github.com/mrfyda)
+* [#1277](https://github.com/pmd/pmd/pull/1277): \[jsp] #1276 add support for jspf and tag extensions - [Jordi Llach](https://github.com/jordillachmrf)
+* [#1275](https://github.com/pmd/pmd/pull/1275): \[jsp] Issue #1274 - Support EL in tag attributes - [Jordi Llach](https://github.com/jordillachmrf)
+* [#1278](https://github.com/pmd/pmd/pull/1278): \[ci] \[GSoC] Use pmdtester 1.0.0.pre.beta3 - [BBG](https://github.com/djydewang)
+* [#1289](https://github.com/pmd/pmd/pull/1289): \[java] UselessParentheses: Fix false positive with assignments - [cobratbq](https://github.com/cobratbq)
+* [#1290](https://github.com/pmd/pmd/pull/1290): \[docs] \[GSoC] Create the documentation about pmdtester - [BBG](https://github.com/djydewang)
+* [#1256](https://github.com/pmd/pmd/pull/1256): \[java] #940 Avoid JUnit 4 false positives for JUnit 5 tests - [Alex Shesterov](https://github.com/vovkss)
+* [#1315](https://github.com/pmd/pmd/pull/1315): \[apex] Add OneDeclarationPerStatement rule - [Jeff Hube](https://github.com/jeffhube)
+
+
+## 29-July-2018 - 6.6.0
+
+The PMD team is pleased to announce PMD 6.6.0.
+
+This is a minor release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [Java 11 Support](#java-11-support)
+ * [New Rules](#new-rules)
+ * [Modified Rules](#modified-rules)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### Java 11 Support
+
+PMD is now able to parse the local-variable declaration syntax `var xxx`, that has been
+extended for lambda parameters with Java 11 via
+[JEP 323: Local-Variable Syntax for Lambda Parameters](http://openjdk.java.net/jeps/323).
+
+#### New Rules
+
+* The new Java rule [`LocalVariableNamingConventions`](pmd_rules_java_codestyle.html#localvariablenamingconventions)
+ (`java-codestyle`) detects local variable names that don't comply to a given convention. It defaults to standard
+ Java convention of using camelCase, but can be configured. Special cases can be configured for final variables
+ and caught exceptions' names.
+
+* The new Java rule [`FormalParameterNamingConventions`](pmd_rules_java_codestyle.html#formalparameternamingconventions)
+ (`java-codestyle`) detects formal parameter names that don't comply to a given convention. It defaults to
+ standard Java convention of using camelCase, but can be configured. Special cases can be configured for final
+ parameters and lambda parameters (considering whether they are explicitly typed or not).
+
+#### Modified Rules
+
+* The Java rules [`AccessorClassGeneration`](pmd_rules_java_bestpracices.html#accessorclassgeneration) and
+ [`AccessorMethodGeneration`](pmd_rules_java_bestpracices.html#accessormethodgeneration) (both in category
+ `java-bestpractices`) have been modified to be only valid up until Java 10. Java 11 adds support for
+ [JEP 181: Nest-Based Access Control](http://openjdk.java.net/jeps/181) which avoids the generation of
+ accessor classes / methods altogether.
+
+### Fixed Issues
+
+* core
+ * [#1178](https://github.com/pmd/pmd/issues/1178): \[core] "Unsupported build listener" in gradle build
+ * [#1225](https://github.com/pmd/pmd/issues/1225): \[core] Error in sed expression on line 82 of run.sh while detecting installed version of Java
+* doc
+ * [#1215](https://github.com/pmd/pmd/issues/1215): \[doc] TOC links don't work?
+* java-codestyle
+ * [#1211](https://github.com/pmd/pmd/issues/1211): \[java] CommentDefaultAccessModifier false positive with nested interfaces (regression from 6.4.0)
+ * [#1216](https://github.com/pmd/pmd/issues/1216): \[java] UnnecessaryFullyQualifiedName false positive for the same name method
+* java-design
+ * [#1217](https://github.com/pmd/pmd/issues/1217): \[java] CyclomaticComplexityRule counts ?-operator twice
+ * [#1226](https://github.com/pmd/pmd/issues/1226): \[java] NPath complexity false negative due to overflow
+* plsql
+ * [#980](https://github.com/pmd/pmd/issues/980): \[plsql] ParseException for CREATE TABLE
+ * [#981](https://github.com/pmd/pmd/issues/981): \[plsql] ParseException when parsing VIEW
+ * [#1047](https://github.com/pmd/pmd/issues/1047): \[plsql] ParseException when parsing EXECUTE IMMEDIATE
+* ui
+ * [#1233](https://github.com/pmd/pmd/issues/1233): \[ui] XPath autocomplete arrows on first and last items
+
+### API Changes
+
+* The `findDescendantsOfType` methods in `net.sourceforge.pmd.lang.ast.AbstractNode` no longer search for
+ exact type matches, but will match subclasses, too. That means, it's now possible to look for abstract node
+ types such as `AbstractJavaTypeNode` and not only for it's concrete subtypes.
+
+### External Contributions
+
+* [#1182](https://github.com/pmd/pmd/pull/1182): \[ui] XPath AutoComplete - [Akshat Bahety](https://github.com/akshatbahety)
+* [#1231](https://github.com/pmd/pmd/pull/1231): \[doc] Minor typo fix in installation.md - [Ashish Rana](https://github.com/ashishrana160796)
+* [#1250](https://github.com/pmd/pmd/pull/1250): \[ci] \[GSoC] Upload baseline of pmdtester automatically - [BBG](https://github.com/djydewang)
+
+
+## 26-June-2018 - 6.5.0
+
+The PMD team is pleased to announce PMD 6.5.0.
+
+This is a minor release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [New Rules](#new-rules)
+ * [Modified Rules](#modified-rules)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### New Rules
+
+* The new Apex rule [`AvoidNonExistentAnnotations`](pmd_rules_apex_errorprone.html#avoidnonexistentannotations) (`apex-errorprone`)
+ detects usages non-officially supported annotations. Apex supported non existent annotations for legacy reasons.
+ In the future, use of such non-existent annotations could result in broken Apex code that will not compile.
+ A full list of supported annotations can be found [here](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation.htm)
+
+#### Modified Rules
+
+* The Java rule [UnnecessaryModifier](pmd_rules_java_codestyle.html#unnecessarymodifier) (`java-codestyle`)
+ now detects enum constrcutors with explicit `private` modifier. The rule now produces better error messages
+ letting you know exactly which modifiers are redundant at each declaration.
+
+### Fixed Issues
+* all
+ * [#1119](https://github.com/pmd/pmd/issues/1119): \[doc] Make the landing page of the documentation website more useful
+ * [#1168](https://github.com/pmd/pmd/issues/1168): \[core] xml renderer schema definitions (#538) break included xslt files
+ * [#1173](https://github.com/pmd/pmd/issues/1173): \[core] Some characters in CPD are not shown correctly.
+ * [#1193](https://github.com/pmd/pmd/issues/1193): \[core] Designer doesn't start with run.sh
+* ecmascript
+ * [#861](https://github.com/pmd/pmd/issues/861): \[ecmascript] InnaccurateNumericLiteral false positive with hex literals
+* java
+ * [#1074](https://github.com/pmd/pmd/issues/1074): \[java] MissingOverrideRule exception when analyzing PMD under Java 9
+ * [#1174](https://github.com/pmd/pmd/issues/1174): \[java] CommentUtil.multiLinesIn() could lead to StringIndexOutOfBoundsException
+* java-bestpractices
+ * [#651](https://github.com/pmd/pmd/issues/651): \[java] SwitchStmtsShouldHaveDefault should be aware of enum types
+ * [#869](https://github.com/pmd/pmd/issues/869): \[java] GuardLogStatement false positive on return statements and Math.log
+* java-codestyle
+ * [#667](https://github.com/pmd/pmd/issues/667): \[java] Make AtLeastOneConstructor Lombok-aware
+ * [#1154](https://github.com/pmd/pmd/pull/1154): \[java] CommentDefaultAccessModifierRule FP with nested enums
+ * [#1158](https://github.com/pmd/pmd/issues/1158): \[java] Fix IdenticalCatchBranches false positive
+ * [#1186](https://github.com/pmd/pmd/issues/1186): \[java] UnnecessaryFullyQualifiedName doesn't detect java.lang FQ names as violations
+* java-design
+ * [#1200](https://github.com/pmd/pmd/issues/1200): \[java] New default NcssCount method report level is drastically reduced from values of deprecated NcssMethodCount and NcssTypeCount
+* xml
+ * [#715](https://github.com/pmd/pmd/issues/715): \[xml] ProjectVersionAsDependencyVersion false positive
+
+### API Changes
+
+* The utility class `net.sourceforge.pmd.lang.java.ast.CommentUtil` has been deprecated and will be removed
+ with PMD 7.0.0. Its methods have been intended to parse javadoc tags. A more useful solution will be added
+ around the AST node `FormalComment`, which contains as children `JavadocElement` nodes, which in
+ turn provide access to the `JavadocTag`.
+
+ All comment AST nodes (`FormalComment`, `MultiLineComment`, `SingleLineComment`) have a new method
+ `getFilteredComment()` which provide access to the comment text without the leading `/*` markers.
+
+* The method `AbstractCommentRule.tagsIndicesIn()` has been deprecated and will be removed with
+ PMD 7.0.0. It is not very useful, since it doesn't extract the information
+ in a useful way. You would still need check, which tags have been found, and with which
+ data they might be accompanied.
+
+### External Contributions
+
+* [#836](https://github.com/pmd/pmd/pull/836): \[apex] Add a rule to prevent use of non-existent annotations - [anand13s](https://github.com/anand13s)
+* [#1159](https://github.com/pmd/pmd/pull/1159): \[ui] Allow to setup the auxclasspath in the designer - [Akshat Bahety](https://github.com/akshatbahety)
+* [#1169](https://github.com/pmd/pmd/pull/1169): \[core] Update stylesheets with a default namespace - [Matthew Duggan](https://github.com/mduggan)
+* [#1183](https://github.com/pmd/pmd/pull/1183): \[java] fixed typos in rule remediation - [Jake Hemmerle](https://github.com/jakehemmerle)
+* [#1206](https://github.com/pmd/pmd/pull/1206): \[java] Recommend StringBuilder next to StringBuffer - [krichter722](https://github.com/krichter722)
+
+
+## 29-May-2018 - 6.4.0
+
+The PMD team is pleased to announce PMD 6.4.0.
+
+This is a minor release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [Java 10 Support](#java-10-support)
+ * [XPath Type Resolution Functions](#xpath-type-resolution-functions)
+ * [New Rules](#new-rules)
+ * [Modified Rules](#modified-rules)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### Java 10 Support
+
+PMD is now able to understand local-variable type inference as introduced by Java 10.
+Simple type resolution features are available, e.g. the type of the variable `s` is inferred
+correctly as `String`:
+
+ var s = "Java 10";
+
+#### XPath Type Resolution Functions
+
+For some time now PMD has supported Type Resolution, and exposed this functionality to XPath rules for the Java language
+with the `typeof` function. This function however had a number of shortcomings:
+
+* It would take a first arg with the name to match if types couldn't be resolved. In all cases this was `@Image`
+ but was still required.
+* It required 2 separate arguments for the Fully Qualified Class Name and the simple name of the class against
+ which to test.
+* If only the Fully Qualified Class Name was provided, no simple name check was performed (not documented,
+ but abused on some rules to "fix" some false positives).
+
+In this release we are deprecating `typeof` in favor of a simpler `typeIs` function, which behaves exactly as the
+old `typeof` when given all 3 arguments.
+
+`typeIs` receives a single parameter, which is the fully qualified name of the class to test against.
+
+So, calls such as:
+
+```ruby
+//ClassOrInterfaceType[typeof(@Image, 'junit.framework.TestCase', 'TestCase')]
+```
+
+can now we expressed much more concisely as:
+
+```ruby
+//ClassOrInterfaceType[typeIs('junit.framework.TestCase')]
+```
+
+With this change, we also allow to check against array types by just appending `[]` to the fully qualified class name.
+These can be repeated for arrays of arrays (e.g. `byte[][]` or `java.lang.String[]`).
+
+Additionally, we introduce the companion function `typeIsExactly`, that receives the same parameters as `typeIs`,
+but checks for exact type matches, without considering the type hierarchy. That is, the test
+`typeIsExactly('junit.framework.TestCase')` will match only if the context node is an instance of `TestCase`, but
+not if it's an instance of a subclass of `TestCase`. Be aware then, that using that method with abstract types will
+never match.
+
+#### New Rules
+
+* The new Java rule [`HardCodedCryptoKey`](pmd_rules_java_security.html#hardcodedcryptokey) (`java-security`)
+ detects hard coded keys used for encryption. It is recommended to store keys outside of the source code.
+
+* The new Java rule [`IdenticalCatchBranches`](pmd_rules_java_codestyle.html#identicalcatchbranches) (`java-codestyle`)
+ finds catch blocks,
+ that catch different exception but perform the same exception handling and thus can be collapsed into a
+ multi-catch try statement.
+
+#### Modified Rules
+
+* The Java rule [JUnit4TestShouldUseTestAnnotation](pmd_rules_java_bestpractices.html#junit4testshouldusetestannotation) (`java-bestpractices`)
+ has a new parameter "testClassPattern". It is used to distinguish test classes from other classes and
+ avoid false positives. By default, any class, that has "Test" in its name, is considered a test class.
+
+* The Java rule [CommentDefaultAccessModifier](pmd_rules_java_codestyle.html#commentdefaultaccessmodifier) (`java-codestyle`)
+ allows now by default the comment "`/* package */` in addition to "`/* default */`. This behavior can
+ still be adjusted by setting the property `regex`.
+
+### Fixed Issues
+
+* all
+ * [#1018](https://github.com/pmd/pmd/issues/1018): \[java] Performance degradation of 250% between 6.1.0 and 6.2.0
+ * [#1145](https://github.com/pmd/pmd/issues/1145): \[core] JCommander's help text for option -min is wrong
+* java
+ * [#672](https://github.com/pmd/pmd/issues/672): \[java] Support exact type matches for type resolution from XPath
+ * [#743](https://github.com/pmd/pmd/issues/743): \[java] Prepare for Java 10
+ * [#1077](https://github.com/pmd/pmd/issues/1077): \[java] Analyzing enum with lambda passed in constructor fails with "The enclosing scope must exist."
+ * [#1115](https://github.com/pmd/pmd/issues/1115): \[java] Simplify xpath typeof syntax
+ * [#1131](https://github.com/pmd/pmd/issues/1131): \[java] java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/application/FacesMessage$Severity
+* java-bestpractices
+ * [#527](https://github.com/pmd/pmd/issues/572): \[java] False Alarm of JUnit4TestShouldUseTestAnnotation on Predicates
+ * [#1063](https://github.com/pmd/pmd/issues/1063): \[java] MissingOverride is triggered in illegal places
+* java-codestyle
+ * [#720](https://github.com/pmd/pmd/issues/720): \[java] ShortVariable should whitelist lambdas
+ * [#955](https://github.com/pmd/pmd/issues/955): \[java] Detect identical catch statements
+ * [#1114](https://github.com/pmd/pmd/issues/1114): \[java] Star import overwritten by explicit import is not correctly handled
+ * [#1064](https://github.com/pmd/pmd/issues/1064): \[java] ClassNamingConventions suggests to add Util suffix for simple exception wrappers
+ * [#1065](https://github.com/pmd/pmd/issues/1065): \[java] ClassNamingConventions shouldn't prohibit numbers in class names
+ * [#1067](https://github.com/pmd/pmd/issues/1067): \[java] \[6.3.0] PrematureDeclaration false-positive
+ * [#1096](https://github.com/pmd/pmd/issues/1096): \[java] ClassNamingConventions is too ambitious on finding utility classes
+* java-design
+ * [#824](https://github.com/pmd/pmd/issues/824): \[java] UseUtilityClass false positive when extending
+ * [#1021](https://github.com/pmd/pmd/issues/1021): \[java] False positive for `DoNotExtendJavaLangError`
+ * [#1097](https://github.com/pmd/pmd/pull/1097): \[java] False negative in AvoidThrowingRawExceptionTypes
+* java-performance
+ * [#1051](https://github.com/pmd/pmd/issues/1051): \[java] ConsecutiveAppendsShouldReuse false-negative
+ * [#1098](https://github.com/pmd/pmd/pull/1098): \[java] Simplify LongInstantiation, IntegerInstantiation, ByteInstantiation, and ShortInstantiation using type resolution
+ * [#1125](https://github.com/pmd/pmd/issues/1125): \[java] Improve message of InefficientEmptyStringCheck for String.trim().isEmpty()
+* doc
+ * [#999](https://github.com/pmd/pmd/issues/999): \[doc] Add a header before the XPath expression in rules
+ * [#1082](https://github.com/pmd/pmd/issues/1082): \[doc] Multifile analysis doc is invalid
+* vf-security
+ * [#1100](https://github.com/pmd/pmd/issues/1100): \[vf] URLENCODE is ignored as valid escape method
+
+### API Changes
+
+* The following classes in package `net.sourceforge.pmd.benchmark` have been deprecated: `Benchmark`, `Benchmarker`,
+ `BenchmarkReport`, `BenchmarkResult`, `RuleDuration`, `StringBuilderCR` and `TextReport`. Their API is not supported anymore
+ and is disconnected from the internals of PMD. Use the newer API based around `TimeTracker` instead, which can be found
+ in the same package.
+* The class `net.sourceforge.pmd.lang.java.xpath.TypeOfFunction` has been deprecated. Use the newer `TypeIsFunction` in the same package.
+* The `typeof` methdos in `net.sourceforge.pmd.lang.java.xpath.JavaFunctions` have been deprecated.
+ Use the newer `typeIs` method in the same class instead..
+* The methods `isA`, `isEither` and `isNeither` of `net.sourceforge.pmd.lang.java.typeresolution.TypeHelper`.
+ Use the new `isExactlyAny` and `isExactlyNone` methods in the same class instead.
+
+
+### External Contributions
+
+* [#966](https://github.com/pmd/pmd/pull/966): \[java] Issue #955: add new rule to detect identical catch statement - [Clément Fournier](https://github.com/oowekyala) and [BBG](https://github.com/djydewang)
+* [#1046](https://github.com/pmd/pmd/pull/1046): \[java] New security rule for finding hard-coded keys used for cryptographic operations - [Sergey Gorbaty](https://github.com/sgorbaty)
+* [#1101](https://github.com/pmd/pmd/pull/1101): \[java] Fixes false positive for `DoNotExtendJavaLangError` - [Akshat Bahety](https://github.com/akshatbahety)
+* [#1106](https://github.com/pmd/pmd/pull/1106): \[vf] URLENCODE is ignored as valid escape method - [Robert Sösemann](https://github.com/rsoesemann)
+* [#1126](https://github.com/pmd/pmd/pull/1126): \[java] Improve implementation hint in InefficientEmptyStringCheck - [krichter722](https://github.com/krichter722)
+* [#1129](https://github.com/pmd/pmd/pull/1129): \[java] Adjust InefficientEmptyStringCheck documentation - [krichter722](https://github.com/krichter722)
+* [#1137](https://github.com/pmd/pmd/pull/1137): \[ui] Removes the need for RefreshAST - [Akshat Bahety](https://github.com/akshatbahety)
+
+
+
+## 29-April-2018 - 6.3.0
+
+The PMD team is pleased to announce PMD 6.3.0.
+
+This is a minor release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [Tree Traversal Revision](#tree-traversal-revision)
+ * [Naming Rules Enhancements](#naming-rules-enhancements)
+ * [CPD Suppression](#cpd-suppression)
+ * [Swift 4.1 Support](#swift-41-support)
+ * [New Rules](#new-rules)
+ * [Modified Rules](#modified-rules)
+ * [Deprecated Rules](#deprecated-rules)
+* [Fixed Issues](#fixed-issues)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### Tree Traversal Revision
+
+As described in [#904](https://github.com/pmd/pmd/issues/904), when searching for child nodes of the AST methods
+such as `hasDescendantOfType`, `getFirstDescendantOfType` and `findDescendantsOfType` were found to behave inconsistently,
+not all of them honoring find boundaries; that is, nodes that define a self-contained entity which should be considered separately
+(think of lambdas, nested classes, anonymous classes, etc.). We have modified these methods to ensure all of them honor
+find boundaries.
+
+This change implies several false positives / unexpected results
+(ie: `ASTBlockStatement` falsely returning `true` to `isAllocation()`)
+have been fixed; and lots of searches are now restricted to smaller search areas, which improves performance
+(depending on the project, we have measured up to 10% improvements during Type Resolution, Symbol Table analysis,
+and some rules' application).
+
+#### Naming Rules Enhancements
+
+* [ClassNamingConventions](pmd_rules_java_codestyle.html#classnamingconventions) (`java-codestyle`)
+ has been enhanced to allow granular configuration of naming
+ conventions for different kinds of type declarations (eg enum or abstract
+ class). Each kind of declaration can use its own naming convention
+ using a regex property. See the rule's documentation for more info about
+ configuration and default conventions.
+
+* [MethodNamingConventions](pmd_rules_java_codestyle.html#methodnamingconventions) (`java-codestyle`)
+ has been enhanced in the same way.
+
+#### CPD Suppression
+
+Back in PMD 5.6.0 we introduced the ability to suppress CPD warnings in Java using comments, by
+including `CPD-OFF` (to start ignoring code), or `CPD-ON` (to resume analysis) during CPD execution.
+This has proved to be much more flexible and versatile than the old annotation-based approach,
+and has since been the preferred way to suppress CPD warnings.
+
+On this occasion, we are extending support for comment-based suppressions to many other languages:
+
+* C/C++
+* Ecmascript / Javascript
+* Matlab
+* Objective-C
+* PL/SQL
+* Python
+
+So for instance, in Python we could now do:
+
+```python
+class BaseHandler(object):
+ def __init__(self):
+ # some unignored code
+
+ # tell cpd to start ignoring code - CPD-OFF
+
+ # mission critical code, manually loop unroll
+ GoDoSomethingAwesome(x + x / 2);
+ GoDoSomethingAwesome(x + x / 2);
+ GoDoSomethingAwesome(x + x / 2);
+ GoDoSomethingAwesome(x + x / 2);
+ GoDoSomethingAwesome(x + x / 2);
+ GoDoSomethingAwesome(x + x / 2);
+
+ # resume CPD analysis - CPD-ON
+
+ # further code will *not* be ignored
+```
+
+Other languages are equivalent.
+
+#### Swift 4.1 Support
+
+Thanks to major contributions from [kenji21](https://github.com/kenji21) the Swift grammar has been updated to
+support Swift 4.1. This is a major update, since the old grammar was quite dated, and we are sure all iOS
+developers will enjoy it.
+
+Unfortunately, this change is not compatible. The grammar elements that have been removed (ie: the keywords `__FILE__`,
+`__LINE__`, `__COLUMN__` and `__FUNCTION__`) are no longer supported. We don't usually introduce such
+drastic / breaking changes in minor releases, however, given that the whole Swift ecosystem pushes hard towards
+always using the latest versions, and that Swift needs all code and libraries to be currently compiling against
+the same Swift version, we felt strongly this change was both safe and necessary to be shipped as soon as possible.
+We had great feedback from the community during the process but if you have a legitimate use case for older Swift
+versions, please let us know [on our Issue Tracker](https://github.com/pmd/pmd/issues).
+
+#### New Rules
+
+* The new Java rule [InsecureCryptoIv](pmd_rules_java_security.html#insecurecryptoiv) (`java-security`)
+ detects hard coded initialization vectors used in cryptographic operations. It is recommended to use
+ a randomly generated IV.
+
+#### Modified Rules
+
+* The Java rule [UnnecessaryConstructor](pmd_rules_java_codestyle.html#unnecessaryconstructor) (`java-codestyle`)
+ has been rewritten as a Java rule (previously it was a XPath-based rule). It supports a new property
+ `ignoredAnnotations` and ignores by default empty constructors,
+ that are annotated with `javax.inject.Inject`. Additionally, it detects now also unnecessary private constructors
+ in enums.
+
+* The property `checkNativeMethods` of the Java rule [MethodNamingConventions](pmd_rules_java_codestyle.html#methodnamingconventions) (`java-codestyle`)
+ is now deprecated, as it is now superseded by `nativePattern`. Support for that property will be maintained until
+ 7.0.0.
+
+* The Java rule [ControlStatementBraces](pmd_rules_java_codestyle.html#controlstatementbraces) (`java-codestyle`)
+ supports a new boolean property `checkSingleIfStmt`. When unset, the rule won't report `if` statements which lack
+ braces, if the statement is not part of an `if ... else if` chain. This property defaults to true.
+
+#### Deprecated Rules
+
+* The Java rule [AbstractNaming](pmd_rules_java_codestyle.html#abstractnaming) (`java-codestyle`) is deprecated
+ in favour of [ClassNamingConventions](pmd_rules_java_codestyle.html#classnamingconventions).
+ See [Naming rules enhancements](#naming-rules-enhancements).
+
+### Fixed Issues
+
+* all
+ * [#695](https://github.com/pmd/pmd/issues/695): \[core] Extend comment-based suppression to all JavaCC languages
+ * [#988](https://github.com/pmd/pmd/issues/988): \[core] FileNotFoundException for missing classes directory with analysis cache enabled
+ * [#1036](https://github.com/pmd/pmd/issues/1036): \[core] Non-XML output breaks XML-based CLI integrations
+* apex-errorprone
+ * [#776](https://github.com/pmd/pmd/issues/776): \[apex] AvoidHardcodingId false positives
+* documentation
+ * [#994](https://github.com/pmd/pmd/issues/994): \[doc] Delete duplicate page contributing.md on the website
+ * [#1057](https://github.com/pmd/pmd/issues/1057): \[doc] Documentation of ignoredAnnotations property is misleading
+* java
+ * [#894](https://github.com/pmd/pmd/issues/894): \[java] Maven PMD plugin fails to process some files without any explanation
+ * [#899](https://github.com/pmd/pmd/issues/899): \[java] JavaTypeDefinitionSimple.toString can cause NPEs
+ * [#1020](https://github.com/pmd/pmd/issues/1020): \[java] The CyclomaticComplexity rule runs forever in 6.2.0
+ * [#1030](https://github.com/pmd/pmd/pull/1030): \[java] NoClassDefFoundError when analyzing PMD with PMD
+ * [#1061](https://github.com/pmd/pmd/issues/1061): \[java] Update ASM to handle Java 10 bytecode
+* java-bestpractices
+ * [#370](https://github.com/pmd/pmd/issues/370): \[java] GuardLogStatementJavaUtil not considering lambdas
+ * [#558](https://github.com/pmd/pmd/issues/558): \[java] ProperLogger Warnings for enums
+ * [#719](https://github.com/pmd/pmd/issues/719): \[java] Unused Code: Java 8 receiver parameter with an internal class
+ * [#1009](https://github.com/pmd/pmd/issues/1009): \[java] JUnitAssertionsShouldIncludeMessage - False positive with assertEquals and JUnit5
+* java-codestyle
+ * [#1003](https://github.com/pmd/pmd/issues/1003): \[java] UnnecessaryConstructor triggered on required empty constructor (Dagger @Inject)
+ * [#1023](https://github.com/pmd/pmd/issues/1023): \[java] False positive for useless parenthesis
+ * [#1004](https://github.com/pmd/pmd/issues/1004): \[java] ControlStatementBraces is missing checkIfStmt property
+* java-design
+ * [#1056](https://github.com/pmd/pmd/issues/1056): \[java] Property ignoredAnnotations does not work for SingularField and ImmutableField
+* java-errorprone
+ * [#629](https://github.com/pmd/pmd/issues/629): \[java] NullAssignment false positive
+ * [#816](https://github.com/pmd/pmd/issues/816): \[java] SingleMethodSingleton false positives with inner classes
+* java-performance
+ * [#586](https://github.com/pmd/pmd/issues/586): \[java] AvoidUsingShortType erroneously triggered on overrides of 3rd party methods
+* swift
+ * [#678](https://github.com/pmd/pmd/issues/678): \[swift]\[cpd] Exception when running for Swift 4 code (KeyPath)
+
+### External Contributions
+
+* [#778](https://github.com/pmd/pmd/pull/778): \[swift] Support Swift 4 grammar - [kenji21](https://github.com/kenji21)
+* [#1002](https://github.com/pmd/pmd/pull/1002): \[doc] Delete duplicate page contributing.md on the website - [Ishan Srivastava](https://github.com/ishanSrt)
+* [#1008](https://github.com/pmd/pmd/pull/1008): \[core] DOC: fix closing tag for <pmdVersion> - [stonio](https://github.com/stonio)
+* [#1010](https://github.com/pmd/pmd/pull/1010): \[java] UnnecessaryConstructor triggered on required empty constructor (Dagger @Inject) - [BBG](https://github.com/djydewang)
+* [#1012](https://github.com/pmd/pmd/pull/1012): \[java] JUnitAssertionsShouldIncludeMessage - False positive with assertEquals and JUnit5 - [BBG](https://github.com/djydewang)
+* [#1024](https://github.com/pmd/pmd/pull/1024): \[java] Issue 558: Properlogger for enums - [Utku Cuhadaroglu](https://github.com/utkuc)
+* [#1041](https://github.com/pmd/pmd/pull/1041): \[java] Make BasicProjectMemoizer thread safe. - [bergander](https://github.com/bergander)
+* [#1042](https://github.com/pmd/pmd/pull/1042): \[java] New security rule: report usage of hard coded IV in crypto operations - [Sergey Gorbaty](https://github.com/sgorbaty)
+* [#1044](https://github.com/pmd/pmd/pull/1044): \[java] Fix for issue #816 - [Akshat Bahety](https://github.com/akshatbahety)
+* [#1048](https://github.com/pmd/pmd/pull/1048): \[core] Make MultiThreadProcessor more space efficient - [Gonzalo Exequiel Ibars Ingman](https://github.com/gibarsin)
+* [#1062](https://github.com/pmd/pmd/pull/1062): \[core] Update ASM to version 6.1.1 - [Austin Shalit](https://github.com/AustinShalit)
+
+
+## 26-March-2018 - 6.2.0
+
+The PMD team is pleased to announce PMD 6.2.0.
+
+This is a minor release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [Ecmascript (JavaScript)](#ecmascript-javascript)
+ * [Disable Incremental Analysis](#disable-incremental-analysis)
+ * [New Rules](#new-rules)
+ * [Modified Rules](#modified-rules)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### Ecmascript (JavaScript)
+
+The [Rhino Library](https://github.com/mozilla/rhino) has been upgraded from version 1.7.7 to version 1.7.7.2.
+
+Detailed changes for changed in Rhino can be found:
+* [For 1.7.7.2](https://github.com/mozilla/rhino/blob/master/RELEASE-NOTES.md#rhino-1772)
+* [For 1.7.7.1](https://github.com/mozilla/rhino/blob/master/RELEASE-NOTES.md#rhino-1771)
+
+Both are bugfixing releases.
+
+#### Disable Incremental Analysis
+
+Some time ago, we added support for [Incremental Analysis](pmd_userdocs_getting_started.html). On PMD 6.0.0, we
+started to add warns when not using it, as we strongly believe it's a great improvement to our user's experience as
+analysis time is greatly reduced; and in the future we plan to have it enabled by default. However, we realize some
+scenarios don't benefit from it (ie: CI jobs), and having the warning logged can be noisy and cause confusion.
+
+To this end, we have added a new flag to allow you to explicitly disable incremental analysis. On CLI, this is
+the new `-no-cache` flag. On Ant, there is a `noCache` attribute for the `` task.
+
+On both scenarios, disabling the cache takes precedence over setting a cache location.
+
+#### New Rules
+
+* The new Java rule [`MissingOverride`](pmd_rules_java_bestpractices.html#missingoverride)
+ (category `bestpractices`) detects overridden and implemented methods, which are not marked with the
+ `@Override` annotation. Annotating overridden methods with `@Override` ensures at compile time that
+ the method really overrides one, which helps refactoring and clarifies intent.
+
+* The new Java rule [`UnnecessaryAnnotationValueElement`](pmd_rules_java_codestyle.html#unnecessaryannotationvalueelement)
+ (category `codestyle`) detects annotations with a single element (`value`) that explicitely names it.
+ That is, doing `@SuppressWarnings(value = "unchecked")` would be flagged in favor of
+ `@SuppressWarnings("unchecked")`.
+
+* The new Java rule [`ControlStatementBraces`](pmd_rules_java_codestyle.html#controlstatementbraces)
+ (category `codestyle`) enforces the presence of braces on control statements where they are optional.
+ Properties allow to customize which statements are required to have braces. This rule replaces the now
+ deprecated rules `WhileLoopMustUseBraces`, `ForLoopMustUseBraces`, `IfStmtMustUseBraces`, and
+ `IfElseStmtMustUseBraces`. More than covering the use cases of those rules, this rule also supports
+ `do ... while` statements and `case` labels of `switch` statements (disabled by default).
+
+#### Modified Rules
+
+* The Java rule `CommentContentRule` (`java-documentation`) previously had the property `wordsAreRegex`. But this
+ property never had been implemented and is removed now.
+
+* The Java rule `UnusedPrivateField` (`java-bestpractices`) now has a new `ignoredAnnotations` property
+ that allows to configure annotations that imply the field should be ignored. By default `@java.lang.Deprecated`
+ and `@javafx.fxml.FXML` are ignored.
+
+* The Java rule `UnusedPrivateMethod` (`java-bestpractices`) now has a new `ignoredAnnotations` property
+ that allows to configure annotations that imply the method should be ignored. By default `@java.lang.Deprecated`
+ is ignored.
+
+* The Java rule `ImmutableField` (`java-design`) now has a new `ignoredAnnotations` property
+ that allows to configure annotations that imply the method should be ignored. By default several `lombok`
+ annotations are ignored
+
+* The Java rule `SingularField` (`java-design`) now has a new `ignoredAnnotations` property
+ that allows to configure annotations that imply the method should be ignored. By default several `lombok`
+ annotations are ignored
+
+#### Deprecated Rules
+
+* The Java rules `WhileLoopMustUseBraces`, `ForLoopMustUseBraces`, `IfStmtMustUseBraces`, and `IfElseStmtMustUseBraces`
+ are deprecated. They will be replaced by the new rule `ControlStatementBraces`, in the category `codestyle`.
+
+### Fixed Issues
+
+* all
+ * [#928](https://github.com/pmd/pmd/issues/928): \[core] PMD build failure on Windows
+* java-bestpracrtices
+ * [#907](https://github.com/pmd/pmd/issues/907): \[java] UnusedPrivateField false-positive with @FXML
+ * [#963](https://github.com/pmd/pmd/issues/965): \[java] ArrayIsStoredDirectly not triggered from variadic functions
+* java-codestyle
+ * [#974](https://github.com/pmd/pmd/issues/974): \[java] Merge \*StmtMustUseBraces rules
+ * [#983](https://github.com/pmd/pmd/issues/983): \[java] Detect annotations with single value element
+* java-design
+ * [#832](https://github.com/pmd/pmd/issues/832): \[java] AvoidThrowingNullPointerException documentation suggestion
+ * [#837](https://github.com/pmd/pmd/issues/837): \[java] CFGs of declared but not called lambdas are treated as parts of an enclosing method's CFG
+ * [#839](https://github.com/pmd/pmd/issues/839): \[java] SignatureDeclareThrowsException's IgnoreJUnitCompletely property not honored for constructors
+ * [#968](https://github.com/pmd/pmd/issues/968): \[java] UseUtilityClassRule reports false positive with lombok NoArgsConstructor
+* documentation
+ * [#978](https://github.com/pmd/pmd/issues/978): \[core] Broken link in CONTRIBUTING.md
+ * [#992](https://github.com/pmd/pmd/issues/992): \[core] Include info about rule doc generation in "Writing Documentation" md page
+
+### API Changes
+
+* A new CLI switch, `-no-cache`, disables incremental analysis and the related suggestion. This overrides the
+ `-cache` option. The corresponding Ant task parameter is `noCache`.
+
+* The static method `PMDParameters.transformParametersIntoConfiguration(PMDParameters)` is now deprecated,
+ for removal in 7.0.0. The new instance method `PMDParameters.toConfiguration()` replaces it.
+
+* The method `ASTConstructorDeclaration.getParameters()` has been deprecated in favor of the new method
+ `getFormalParameters()`. This method is available for both `ASTConstructorDeclaration` and
+ `ASTMethodDeclaration`.
+
+### External Contributions
+
+* [#941](https://github.com/pmd/pmd/pull/941): \[java] Use char notation to represent a character to improve performance - [reudismam](https://github.com/reudismam)
+* [#943](https://github.com/pmd/pmd/pull/943): \[java] UnusedPrivateField false-positive with @FXML - [BBG](https://github.com/djydewang)
+* [#951](https://github.com/pmd/pmd/pull/951): \[java] Add ignoredAnnotations property to unusedPrivateMethod rule - [BBG](https://github.com/djydewang)
+* [#952](https://github.com/pmd/pmd/pull/952): \[java] SignatureDeclareThrowsException's IgnoreJUnitCompletely property not honored for constructors - [BBG](https://github.com/djydewang)
+* [#958](https://github.com/pmd/pmd/pull/958): \[java] Refactor how we ignore annotated elements in rules - [BBG](https://github.com/djydewang)
+* [#965](https://github.com/pmd/pmd/pull/965): \[java] Make Varargs trigger ArrayIsStoredDirectly - [Stephen](https://github.com/pmd/pmd/issues/907)
+* [#967](https://github.com/pmd/pmd/pull/967): \[doc] Issue 959: fixed broken link to XPath Rule Tutorial - [Andrey Mochalov](https://github.com/epidemia)
+* [#969](https://github.com/pmd/pmd/pull/969): \[java] Issue 968 Add logic to handle lombok private constructors with utility classes - [Kirk Clemens](https://github.com/clem0110)
+* [#970](https://github.com/pmd/pmd/pull/970): \[java] Fixed inefficient use of keySet iterator instead of entrySet iterator - [Andrey Mochalov](https://github.com/epidemia)
+* [#984](https://github.com/pmd/pmd/pull/984): \[java] issue983 Add new UnnecessaryAnnotationValueElement rule - [Kirk Clemens](https://github.com/clem0110)
+* [#989](https://github.com/pmd/pmd/pull/989): \[core] Update Contribute.md to close Issue #978 - [Bolarinwa Saheed Olayemi](https://github.com/refactormyself)
+* [#990](https://github.com/pmd/pmd/pull/990): \[java] Updated Doc on AvoidThrowingNullPointerException to close Issue #832 - [Bolarinwa Saheed Olayemi](https://github.com/refactormyself)
+* [#993](https://github.com/pmd/pmd/pull/993): \[core] Update writing_documentation.md to fix Issue #992 - [Bolarinwa Saheed Olayemi](https://github.com/refactormyself)
+
+
+## 25-February-2018 - 6.1.0
+
+The PMD team is pleased to announce PMD 6.1.0.
+
+This is a minor release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [Designer UI](#designer-ui)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+ * [Changes to the Node interface](#changes-to-the-node-interface)
+ * [Changes to CPD renderers](#changes-to-cpd-renderers)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### Designer UI
+
+The Designer now supports configuring properties for XPath based rule development.
+The Designer is still under development and any feedback is welcome.
+
+You can start the designer via `run.sh designer` or `designer.bat`.
+
+### Fixed Issues
+
+* all
+ * [#569](https://github.com/pmd/pmd/issues/569): \[core] XPath support requires specific toString implementations
+ * [#795](https://github.com/pmd/pmd/issues/795): \[cpd] java.lang.OutOfMemoryError
+ * [#848](https://github.com/pmd/pmd/issues/848): \[doc] Test failures when building pmd-doc under Windows
+ * [#872](https://github.com/pmd/pmd/issues/872): \[core] NullPointerException at FileDataSource.glomName()
+ * [#854](https://github.com/pmd/pmd/issues/854): \[ci] Use Java9 for building PMD
+* doc
+ * [#791](https://github.com/pmd/pmd/issues/791): \[doc] Documentation site reorganisation
+ * [#891](https://github.com/pmd/pmd/issues/891): \[doc] Apex @SuppressWarnings should use single quotes instead of double quotes
+ * [#909](https://github.com/pmd/pmd/issues/909): \[doc] Please add new PMD Eclipse Plugin to tool integration section
+* java
+ * [#825](https://github.com/pmd/pmd/issues/825): \[java] Excessive\*Length ignores too much
+ * [#888](https://github.com/pmd/pmd/issues/888): \[java] ParseException occurs with valid '<>' in Java 1.8 mode
+ * [#920](https://github.com/pmd/pmd/pull/920): \[java] Update valid identifiers in grammar
+* java-bestpractices
+ * [#784](https://github.com/pmd/pmd/issues/784): \[java] ForLoopCanBeForeach false-positive
+ * [#925](https://github.com/pmd/pmd/issues/925): \[java] UnusedImports false positive for static import
+* java-design
+ * [#855](https://github.com/pmd/pmd/issues/855): \[java] ImmutableField false-positive with lambdas
+* java-documentation
+ * [#877](https://github.com/pmd/pmd/issues/877): \[java] CommentRequired valid rule configuration causes PMD error
+* java-errorprone
+ * [#885](https://github.com/pmd/pmd/issues/885): \[java] CompareObjectsWithEqualsRule trigger by enum1 != enum2
+* java-performance
+ * [#541](https://github.com/pmd/pmd/issues/541): \[java] ConsecutiveLiteralAppends with types other than string
+* scala
+ * [#853](https://github.com/pmd/pmd/issues/853): \[scala] Upgrade scala version to support Java 9
+* xml
+ * [#739](https://github.com/pmd/pmd/issues/739): \[xml] IllegalAccessException when accessing attribute using Saxon on JRE 9
+
+
+### API Changes
+
+#### Changes to the Node interface
+
+The method `getXPathNodeName` is added to the `Node` interface, which removes the
+use of the `toString` of a node to get its XPath element name (see [#569](https://github.com/pmd/pmd/issues/569)).
+A default implementation is provided in `AbstractNode`, to stay compatible
+with existing implementors.
+
+The `toString` method of a Node is not changed for the time being, and still produces
+the name of the XPath node. That behaviour may however change in future major releases,
+e.g. to produce a more useful message for debugging.
+
+#### Changes to CPD renderers
+
+The interface `net.sourceforge.pmd.cpd.Renderer` has been deprecated. A new interface `net.sourceforge.pmd.cpd.renderer.CPDRenderer`
+has been introduced to replace it. The main difference is that the new interface is meant to render directly to a `java.io.Writer`
+rather than to a String. This allows to greatly reduce the memory footprint of CPD, as on large projects, with many duplications,
+it was causing `OutOfMemoryError`s (see [#795](https://github.com/pmd/pmd/issues/795)).
+
+`net.sourceforge.pmd.cpd.FileReporter` has also been deprecated as part of this change, as it's no longer needed.
+
+### External Contributions
+
+* [#790](https://github.com/pmd/pmd/pull/790): \[java] Added some comments for JDK 9 - [Tobias Weimer](https://github.com/tweimer)
+* [#803](https://github.com/pmd/pmd/pull/803): \[doc] Added SpotBugs as successor of FindBugs - [Tobias Weimer](https://github.com/tweimer)
+* [#828](https://github.com/pmd/pmd/pull/828): \[core] Add operations to manipulate a document - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
+* [#830](https://github.com/pmd/pmd/pull/830): \[java] UseArraysAsList: Description added - [Tobias Weimer](https://github.com/tweimer)
+* [#845](https://github.com/pmd/pmd/pull/845): \[java] Fix false negative PreserveStackTrace on string concatenation - [Alberto Fernández](https://github.com/albfernandez)
+* [#868](https://github.com/pmd/pmd/pull/868): \[core] Improve XPath documentation && make small refactors - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
+* [#875](https://github.com/pmd/pmd/pull/875): \[core] Support shortnames when using filelist - [John Zhang](https://github.com/johnjiabinzhang)
+* [#886](https://github.com/pmd/pmd/pull/886): \[java] Fix #885 - [Matias Comercio](https://github.com/MatiasComercio)
+* [#900](https://github.com/pmd/pmd/pull/900): \[core] Use the isEmpty method instead of comparing the value of size() to 0 - [reudismam](https://github.com/reudismam)
+* [#914](https://github.com/pmd/pmd/pull/914): \[doc] Apex @SuppressWarnings documentation updated - [Akshat Bahety](https://github.com/akshatbahety)
+* [#918](https://github.com/pmd/pmd/pull/918): \[doc] Add qa-eclipse as new tool - [Akshat Bahety](https://github.com/akshatbahety)
+* [#927](https://github.com/pmd/pmd/pull/927): \[java]\[doc] Fix example of AbstractClassWithoutAnyMethod - [Kazuma Watanabe](https://github.com/wata727)
+
+
+## 21-January-2018 - 6.0.1
+
+The PMD team is pleased to announce PMD 6.0.1.
+
+This is a bug fixing release.
+
+### Table Of Contents
+
+* [Additional information about the new introduced rule categories](#additional-information-about-the-new-introduced-rule-categories)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+* [External Contributions](#external-contributions)
+
+### Additional information about the new introduced rule categories
+
+With the release of PMD 6.0.0, all rules have been sorted into one of the following eight categories:
+
+1. **Best Practices**: These are rules which enforce generally accepted best practices.
+2. **Code Style**: These rules enforce a specific coding style.
+3. **Design**: Rules that help you discover design issues.
+4. **Documentation**: These rules are related to code documentation.
+5. **Error Prone**: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+6. **Multithreading**: These are rules that flag issues when dealing with multiple threads of execution.
+7. **Performance**: Rules that flag suboptimal code.
+8. **Security**: Rules that flag potential security flaws.
+
+Please note, that not every category in every language may have a rule. There might be categories with no
+rules at all, such as `category/java/security.xml`, which has currently no rules.
+There are even languages, which only have rules of one category (e.g. `category/xml/errorprone.xml`).
+
+You can find the information about available rules in the generated rule documentation, available
+at .
+
+In order to help migrate to the new category scheme, the new name for the old, deprecated rule names will
+be logged as a warning. See [PR #865](https://github.com/pmd/pmd/pull/865). Please note, that the deprecated
+rule names will keep working throughout PMD 6. You can upgrade to PMD 6 without the immediate need
+to migrate your current ruleset. That backwards compatibility will be maintained until PMD 7.0.0 is released.
+
+### Fixed Issues
+
+* all
+ * [#842](https://github.com/pmd/pmd/issues/842): \[core] Use correct java bootclasspath for compiling
+* apex-errorprone
+ * [#792](https://github.com/pmd/pmd/issues/792): \[apex] AvoidDirectAccessTriggerMap incorrectly detects array access in classes
+* apex-security
+ * [#788](https://github.com/pmd/pmd/issues/788): \[apex] Method chaining breaks ApexCRUDViolation
+* doc
+ * [#782](https://github.com/pmd/pmd/issues/782): \[doc] Wrong information in the Release Notes about the Security ruleset
+ * [#794](https://github.com/pmd/pmd/issues/794): \[doc] Broken documentation links for 6.0.0
+* java
+ * [#793](https://github.com/pmd/pmd/issues/793): \[java] Parser error with private method in nested classes in interfaces
+ * [#814](https://github.com/pmd/pmd/issues/814): \[java] UnsupportedClassVersionError is failure instead of a warning
+ * [#831](https://github.com/pmd/pmd/issues/831): \[java] StackOverflow in JavaTypeDefinitionSimple.toString
+* java-bestpractices
+ * [#783](https://github.com/pmd/pmd/issues/783): \[java] GuardLogStatement regression
+ * [#800](https://github.com/pmd/pmd/issues/800): \[java] ForLoopCanBeForeach NPE when looping on `this` object
+* java-codestyle
+ * [#817](https://github.com/pmd/pmd/issues/817): \[java] UnnecessaryModifierRule crashes on valid code
+* java-design
+ * [#785](https://github.com/pmd/pmd/issues/785): \[java] NPE in DataClass rule
+ * [#812](https://github.com/pmd/pmd/issues/812): \[java] Exception applying rule DataClass
+ * [#827](https://github.com/pmd/pmd/issues/827): \[java] GodClass crashes with java.lang.NullPointerException
+* java-performance
+ * [#841](https://github.com/pmd/pmd/issues/841): \[java] InsufficientStringBufferDeclaration NumberFormatException
+* java-typeresolution
+ * [#866](https://github.com/pmd/pmd/issues/866): \[java] rulesets/java/typeresolution.xml lists non-existent rules
+
+### API Changes
+
+* The constant `net.sourceforge.pmd.PMD.VERSION` has been deprecated and will be removed with PMD 7.0.0.
+ Please use `net.sourceforge.pmd.PMDVersion.VERSION` instead.
+
+### External Contributions
+
+* [#796](https://github.com/pmd/pmd/pull/796): \[apex] AvoidDirectAccessTriggerMap incorrectly detects array access in classes - [Robert Sösemann](https://github.com/up2go-rsoesemann)
+* [#799](https://github.com/pmd/pmd/pull/799): \[apex] Method chaining breaks ApexCRUDViolation - [Robert Sösemann](https://github.com/up2go-rsoesemann)
+
+
+## 15-December-2017 - 6.0.0
+
+The PMD team is pleased to announce PMD 6.0.0.
+
+This is a major release.
+
+### Table Of Contents
+
+* [New and noteworthy](#new-and-noteworthy)
+ * [New Rule Designer](#new-rule-designer)
+ * [Java 9 support](#java-9-support)
+ * [Revamped Apex CPD](#revamped-apex-cpd)
+ * [Java Type Resolution](#java-type-resolution)
+ * [Metrics Framework](#metrics-framework)
+ * [Error Reporting](#error-reporting)
+ * [Apex Rule Suppression](#apex-rule-suppression)
+ * [Rule Categories](#rule-categories)
+ * [New Rules](#new-rules)
+ * [Modified Rules](#modified-rules)
+ * [Deprecated Rules](#deprecated-rules)
+ * [Removed Rules](#removed-rules)
+ * [Java Symbol Table](#java-symbol-table)
+ * [Apex Parser Update](#apex-parser-update)
+ * [Incremental Analysis](#incremental-analysis)
+ * [Rule and Report Properties](#rule-and-report-properties)
+* [Fixed Issues](#fixed-issues)
+* [API Changes](#api-changes)
+* [External Contributions](#external-contributions)
+
+### New and noteworthy
+
+#### New Rule Designer
+
+Thanks to [Clément Fournier](https://github.com/oowekyala), we now have a new rule designer GUI, which
+is based on JavaFX. It replaces the old designer and can be started via
+
+* `bin/run.sh designer` (on Unix-like platform such as Linux and Mac OS X)
+* `bin\designer.bat` (on Windows)
+
+Note: At least Java8 is required for the designer. The old designer is still available
+as `designerold` but will be removed with the next major release.
+
+#### Java 9 support
+
+The Java grammar has been updated to support analyzing Java 9 projects:
+
+* private methods in interfaces are possible
+* The underscore "\_" is considered an invalid identifier
+* Diamond operator for anonymous classes
+* The module declarations in `module-info.java` can be parsed
+* Concise try-with-resources statements are supported
+
+Java 9 support is enabled by default. You can switch back to an older java version
+via the command line, e.g. `-language java -version 1.8`.
+
+#### Revamped Apex CPD
+
+We are now using the Apex Jorje Lexer to tokenize Apex code for CPD. This change means:
+
+* All comments are now ignored for CPD. This is consistent with how other languages such as Java and Groovy work.
+* Tokenization honors the language specification, which improves accuracy.
+
+CPD will therefore have less false positives and false negatives.
+
+#### Java Type Resolution
+
+As part of Google Summer of Code 2017, [Bendegúz Nagy](https://github.com/WinterGrascph) worked on type resolution
+for Java. For this release he has extended support for method calls for both instance and static methods.
+
+Method shadowing and overloading are supported, as are varargs. However, the selection of the target method upon
+the presence of generics and type inference is still work in progress. Expect it in forecoming releases.
+
+As for fields, the basic support was in place for release 5.8.0, but has now been expanded to support static fields.
+
+#### Metrics Framework
+
+As part of Google Summer of Code 2017, [Clément Fournier](https://github.com/oowekyala) is worked
+on the new metrics framework for object-oriented metrics.
+
+There are already a couple of metrics (e.g. ATFD, WMC, Cyclo, LoC) implemented. More metrics are planned.
+Based on those metrics, rules like "GodClass" detection could be implemented more easily.
+The following rules benefit from the metrics framework: NcssCount (java), NPathComplexity (java),
+CyclomaticComplexity (both java and apex).
+
+The Metrics framework has been abstracted and is available in `pmd-core` for other languages. With this
+PMD release, the metrics framework is supported for both Java and Apex.
+
+#### Error Reporting
+
+A number of improvements on error reporting have taken place, meaning changes to some of the report formats.
+
+Also of note, the xml report now provides a XML Schema definition, allowing easier parsing and validation.
+
+##### Processing Errors
+
+Processing errors can now provide not only the message previously included on some reports, but also a full stacktrace.
+This will allow better error reports when providing feedback to the PMD team and help in debugging issues.
+
+The report formats providing full stacktrace of errors are:
+
+* html
+* summaryhtml
+* textcolor
+* vbhtml
+* xml
+
+##### Configuration Errors
+
+For a long time reports have been notified of configuration errors on rules, but they have remained hidden.
+On a push to make these more evident to users, and help them get the best results out of PMD, we have started
+to include them on the reports.
+
+So far, only reports that include processing errors are showing configuration errors. In other words, the report formats
+providing configuration error reporting are:
+
+* csv
+* html
+* summaryhtml
+* text
+* textcolor
+* vbhtml
+* xml
+
+As we move forward we will be able to detect and report more configuration errors (ie: incomplete `auxclasspath`)
+and include them to such reports.
+
+#### Apex Rule Suppression
+
+Apex violations can now be suppressed very similarly to how it's done in Java, by making use of a
+`@SuppressWarnings` annotation.
+
+Supported syntax includes:
+
+```
+@SupressWarnings('PMD') // to supress all Apex rules
+@SupressWarnings('all') // to supress all Apex rules
+@SupressWarnings('PMD.ARuleName') // to supress only the rule named ARuleName
+@SupressWarnings('PMD.ARuleName, PMD.AnotherRuleName') // to supress only the rule named ARuleName or AnotherRuleName
+```
+
+Notice this last scenario is slightly different to the Java syntax. This is due to differences in the Apex grammar for annotations.
+
+#### Rule Categories
+
+All built-in rules have been sorted into one of eight categories:
+
+1. **Best Practices**: These are rules which enforce generally accepted best practices.
+2. **Code Style**: These rules enforce a specific coding style.
+3. **Design**: Rules that help you discover design issues.
+4. **Documentation**: These rules are related to code documentation.
+5. **Error Prone**: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+6. **Multithreading**: These are rules that flag issues when dealing with multiple threads of execution.
+7. **Performance**: Rules that flag suboptimal code.
+8. **Security**: Rules that flag potential security flaws.
+
+These categories help you to find rules and figure out the relevance and impact for your project.
+
+All rules have been moved accordingly, e.g. the rule "JumbledIncrementer", which was previously defined in the
+ruleset "java-basic" has now been moved to the "Error Prone" category. The new rule reference to be used is
+` `.
+
+The old rulesets like "java-basic" are still kept for backwards-compatibility but will be removed eventually.
+The rule reference documentation has been updated to reflect these changes.
+
+#### New Rules
+
+* The new Java rule `NcssCount` (category `design`) replaces the three rules "NcssConstructorCount", "NcssMethodCount",
+ and "NcssTypeCount". The new rule uses the metrics framework to achieve the same. It has two properties, to
+ define the report level for method and class sizes separately. Constructors and methods are considered the same.
+
+* The new Java rule `DoNotExtendJavaLangThrowable` (category `errorprone`) is a companion for the
+ `java-strictexception.xml/DoNotExtendJavaLangError`, detecting direct extensions of `java.lang.Throwable`.
+
+* The new Java rule `ForLoopCanBeForeach` (category `errorprone`) helps to identify those for-loops that can
+ be safely refactored into for-each-loops available since java 1.5.
+
+* The new Java rule `AvoidFileStream` (category `performance`) helps to identify code relying on `FileInputStream` / `FileOutputStream`
+ which, by using a finalizer, produces extra / unnecessary overhead to garbage collection, and should be replaced with
+ `Files.newInputStream` / `Files.newOutputStream` available since java 1.7.
+
+* The new Java rule `DataClass` (category `design`) detects simple data-holders without behaviour. This might indicate
+ that the behaviour is scattered elsewhere and the data class exposes the internal data structure,
+ which breaks encapsulation.
+
+* The new Apex rule `AvoidDirectAccessTriggerMap` (category `errorprone`) helps to identify direct array access to triggers,
+ which can produce bugs by either accessing non-existing indexes, or leaving them out. You should use for-each-loops
+ instead.
+
+* The new Apex rule `AvoidHardcodingId` (category `errorprone`) detects hardcoded strings that look like identifiers
+ and flags them. Record IDs change between environments, meaning hardcoded ids are bound to fail under a different
+ setup.
+
+* The new Apex rule `CyclomaticComplexity` (category `design`) detects overly complex classes and methods. The
+ report threshold can be configured separately for classes and methods.
+
+* A whole bunch of new rules has been added to Apex. They all fit into the category `errorprone`.
+ The 5 rules are migrated for Apex from the equivalent Java rules and include:
+ * `EmptyCatchBlock` to detect catch blocks completely ignoring exceptions.
+ * `EmptyIfStmt` for if blocks with no content, that can be safely removed.
+ * `EmptyTryOrFinallyBlock` for empty try / finally blocks that can be safely removed.
+ * `EmptyWhileStmt` for empty while loops that can be safely removed.
+ * `EmptyStatementBlock` for empty code blocks that can be safely removed.
+
+* The new Apex rule `AvoidSoslInLoops` (category `performance`) is the companion of the old
+ `AvoidSoqlInLoops` rule, flagging SOSL (Salesforce Object Search Language) queries when within
+ loops, to avoid governor issues, and hitting the database too often.
+
+#### Modified Rules
+
+* The Java rule `UnnecessaryFinalModifier` (category `codestyle`, former ruleset `java-unnecessarycode`)
+ has been merged into the rule `UnnecessaryModifier`. As part of this, the rule has been revamped to detect more cases.
+ It will now flag anonymous class' methods marked as final (can't be overridden, so it's pointless), along with
+ final methods overridden / defined within enum instances. It will also flag `final` modifiers on try-with-resources.
+
+* The Java rule `UnnecessaryParentheses` (category `codestyle`, former ruleset `java-controversial`)
+ has been merged into `UselessParentheses` (category `codestyle`, former ruleset `java-unnecessary`).
+ The rule covers all scenarios previously covered by either rule.
+
+* The Java rule `UncommentedEmptyConstructor` (category `documentation`, former ruleset `java-design`)
+ will now ignore empty constructors annotated with `javax.inject.Inject`.
+
+* The Java rule `AbstractClassWithoutAnyMethod` (category `bestpractices`, former ruleset `java-design`)
+ will now ignore classes annotated with `com.google.auto.value.AutoValue`.
+
+* The Java rule `GodClass` (category `design', former ruleset `java-design`) has been revamped to use
+ the new metrics framework.
+
+* The Java rule `LooseCoupling` (category `bestpractices`, former ruleset `java-coupling`) has been
+ replaced by the typeresolution-based implementation.
+
+* The Java rule `CloneMethodMustImplementCloneable` (category `errorprone`, former ruleset `java-clone`)
+ has been replaced by the typeresolution-based
+ implementation and is now able to detect cases if a class implements or extends a Cloneable class/interface.
+
+* The Java rule `UnusedImports` (category `bestpractices`, former ruleset `java-imports`) has been
+ replaced by the typeresolution-based
+ implementation and is now able to detect unused on-demand imports.
+
+* The Java rule `SignatureDeclareThrowsException` (category `design`, former ruleset 'java-strictexception')
+ has been replaced by the
+ typeresolution-based implementation. It has a new property `IgnoreJUnitCompletely`, which allows all
+ methods in a JUnit testcase to throw exceptions.
+
+* The Java rule `NPathComplexity` (category `design`, former ruleset `java-codesize`) has been revamped
+ to use the new metrics framework.
+ Its report threshold can be configured via the property `reportLevel`, which replaces the now
+ deprecated property `minimum`.
+
+* The Java rule `CyclomaticComplexity` (category `design`, former ruleset `java-codesize`) has been
+ revamped to use the new metrics framework.
+ Its report threshold can be configured via the properties `classReportLevel` and `methodReportLevel` separately.
+ The old property `reportLevel`, which configured the level for both total class and method complexity,
+ is deprecated.
+
+* The Java rule `CommentRequired` (category `documentation`, former ruleset `java-comments`)
+ has been revamped to include 2 new properties:
+ * `accessorCommentRequirement` to specify documentation requirements for getters and setters (default to `ignored`)
+ * `methodWithOverrideCommentRequirement` to specify documentation requirements for methods annotated with `@Override` (default to `ignored`)
+
+* The Java rule `EmptyCatchBlock` (category `errorprone`, former ruleset `java-empty`) has been changed to ignore
+ exceptions named `ignore` or `expected` by default. You can still override this behaviour by setting the `allowExceptionNameRegex` property.
+
+* The Java rule `OptimizableToArrayCall` (category `performance`, former ruleset `design`) has been
+ modified to fit for the current JVM implementations: It basically detects now the opposite and suggests to
+ use `Collection.toArray(new E[0])` with a zero-sized array.
+ See [Arrays of Wisdom of the Ancients](https://shipilev.net/blog/2016/arrays-wisdom-ancients/).
+
+#### Deprecated Rules
+
+* The Java rules `NcssConstructorCount`, `NcssMethodCount`, and `NcssTypeCount` (ruleset `java-codesize`) have been
+ deprecated. They will be replaced by the new rule `NcssCount` in the category `design`.
+
+* The Java rule `LooseCoupling` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name
+ from category `bestpractices` instead.
+
+* The Java rule `CloneMethodMustImplementCloneable` in ruleset `java-typeresolution` is deprecated. Use the rule with
+ the same name from category `errorprone` instead.
+
+* The Java rule `UnusedImports` in ruleset `java-typeresolution` is deprecated. Use the rule with
+ the same name from category `bestpractices` instead.
+
+* The Java rule `SignatureDeclareThrowsException` in ruleset `java-typeresolution` is deprecated. Use the rule
+ with the same name from category `design` instead.
+
+* The Java rule `EmptyStaticInitializer` in ruleset `java-empty` is deprecated. Use the rule `EmptyInitializer`
+ from the category `errorprone`, which covers both static and non-static empty initializers.`
+
+* The Java rules `GuardDebugLogging` (ruleset `java-logging-jakarta-commons`) and `GuardLogStatementJavaUtil`
+ (ruleset `java-logging-java`) have been deprecated. Use the rule `GuardLogStatement` from the
+ category `bestpractices`, which covers all cases regardless of the logging framework.
+
+#### Removed Rules
+
+* The deprecated Java rule `UseSingleton` has been removed from the ruleset `java-design`. The rule has been renamed
+ long time ago to `UseUtilityClass` (category `design`).
+
+#### Java Symbol Table
+
+A [bug in symbol table](https://github.com/pmd/pmd/pull/549/commits/0958621ca884a8002012fc7738308c8dfc24b97c) prevented
+the symbol table analysis to properly match primitive arrays types. The issue [affected the `java-unsedcode/UnusedPrivateMethod`](https://github.com/pmd/pmd/issues/521)
+rule, but other rules may now produce improved results as consequence of this fix.
+
+#### Apex Parser Update
+
+The Apex parser version was bumped, from `1.0-sfdc-187` to `210-SNAPSHOT`. This update let us take full advantage
+of the latest improvements from Salesforce, but introduces some breaking changes:
+
+* `BlockStatements` are now created for all control structures, even if no brace is used. We have therefore added
+ a `hasCurlyBrace` method to differentiate between both scenarios.
+* New AST node types are available. In particular `CastExpression`, `ConstructorPreamble`, `IllegalStoreExpression`,
+ `MethodBlockStatement`, `Modifier`, `MultiStatement`, `NestedExpression`, `NestedStoreExpression`,
+ `NewKeyValueObjectExpression` and `StatementExecuted`
+* Some nodes have been removed. Such is the case of `TestNode`, `DottedExpression` and `NewNameValueObjectExpression`
+ (replaced by `NewKeyValueObjectExpression`)
+
+All existing rules have been updated to reflect these changes. If you have custom rules, be sure to update them.
+
+For more info about the included Apex parser, see the new pmd module "pmd-apex-jorje", which packages and provides
+the parser as a binary.
+
+#### Incremental Analysis
+
+The incremental analysis feature first introduced in PMD 5.6.0 has been enhanced. A few minor issues have been fixed,
+and several improvements have been performed to make it more accurate.
+
+The cache will now detect changes to the JARs referenced in the `auxclasspath` instead of simply looking at their paths
+and order. This means that if you are referencing a JAR you are overwriting in some way, the incremental analysis can
+now detect it and invalidate it's cache to avoid false reports.
+
+Similarly, any changes to the execution classpath of PMD will invalidate the cache. This means that if you have custom
+rules packaged in a jar, any changes to it will invalidate the cache automatically.
+
+We have also improved logging on the analysis code, allowing better insight into how the cache is performing,
+under debug / verbose builds you can even see individual hits / misses to the cache (and the reason for any miss!)
+
+Finally, as this feature keeps maturing, we are gently pushing this forward. If not using incremental analysis,
+a warning will now be produced suggesting users to adopt it for better performance.
+
+#### Rule and Report Properties
+
+The implementation around the properties support for rule properties and report properties has been revamped
+to be fully typesafe. Along with that change, the support classes have been moved into an own
+package `net.sourceforge.pmd.properties`. While there is no change necessary in the ruleset XML files,
+when using/setting values for rules, there are adjustments necessary when declaring properties in Java-implemented
+rules.
+
+Rule properties can be declared both for Java based rules and XPath rules.
+This is now very well documented in [Working with properties](pmd_devdocs_working_with_properties.html).
+
+With PMD 6.0.0, multivalued properties are now also possible with XPath rules.
+
+### Fixed Issues
+
+* all
+ * [#394](https://github.com/pmd/pmd/issues/394): \[core] PMD exclude rules are failing with IllegalArgumentException with non-default minimumPriority
+ * [#532](https://github.com/pmd/pmd/issues/532): \[core] security concerns on URL-based rulesets
+ * [#538](https://github.com/pmd/pmd/issues/538): \[core] Provide an XML Schema for XML reports
+ * [#600](https://github.com/pmd/pmd/issues/600): \[core] Nullpointer while creating cache File
+ * [#604](https://github.com/pmd/pmd/issues/604): \[core] Incremental analysis should detect changes to jars in classpath
+ * [#608](https://github.com/pmd/pmd/issues/608): \[core] Add DEBUG log when applying incremental analysis
+ * [#618](https://github.com/pmd/pmd/issues/618): \[core] Incremental Analysis doesn't close file correctly on Windows upon a cache hit
+ * [#643](https://github.com/pmd/pmd/issues/643): \[core] PMD Properties (dev-properties) breaks markup on CodeClimateRenderer
+ * [#680](https://github.com/pmd/pmd/pull/680): \[core] Isolate classloaders for runtime and auxclasspath
+ * [#762](https://github.com/pmd/pmd/issues/762): \[core] Remove method and file property from available property descriptors for XPath rules
+ * [#763](https://github.com/pmd/pmd/issues/763): \[core] Turn property descriptor util into an enum and enrich its interface
+* apex
+ * [#265](https://github.com/pmd/pmd/issues/265): \[apex] Make Rule suppression work
+ * [#488](https://github.com/pmd/pmd/pull/488): \[apex] Use Apex lexer for CPD
+ * [#489](https://github.com/pmd/pmd/pull/489): \[apex] Update Apex compiler
+ * [#500](https://github.com/pmd/pmd/issues/500): \[apex] Running through CLI shows jorje optimization messages
+ * [#605](https://github.com/pmd/pmd/issues/605): \[apex] java.lang.NoClassDefFoundError in the latest build
+ * [#637](https://github.com/pmd/pmd/issues/637): \[apex] Avoid SOSL in loops
+ * [#760](https://github.com/pmd/pmd/issues/760): \[apex] EmptyStatementBlock complains about missing rather than empty block
+ * [#766](https://github.com/pmd/pmd/issues/766): \[apex] Replace old Jorje parser with new one
+ * [#768](https://github.com/pmd/pmd/issues/768): \[apex] java.lang.NullPointerException from PMD
+* cpp
+ * [#448](https://github.com/pmd/pmd/issues/448): \[cpp] Write custom CharStream to handle continuation characters
+* java
+ * [#1454](https://sourceforge.net/p/pmd/bugs/1454/): \[java] OptimizableToArrayCall is outdated and invalid in current JVMs
+ * [#1513](https://sourceforge.net/p/pmd/bugs/1513/): \[java] Remove deprecated rule UseSingleton
+ * [#328](https://github.com/pmd/pmd/issues/328): \[java] java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/jsp/PageContext
+ * [#487](https://github.com/pmd/pmd/pull/487): \[java] Fix typeresolution for anonymous extending object
+ * [#496](https://github.com/pmd/pmd/issues/496): \[java] processing error on generics inherited from enclosing class
+ * [#510](https://github.com/pmd/pmd/issues/510): \[java] Typeresolution fails on a simple primary when the source is loaded from a class literal
+ * [#527](https://github.com/pmd/pmd/issues/527): \[java] Lombok getter annotation on enum is not recognized correctly
+ * [#534](https://github.com/pmd/pmd/issues/534): \[java] NPE in MethodTypeResolution for static methods
+ * [#603](https://github.com/pmd/pmd/issues/603): \[core] incremental analysis should invalidate upon Java rule plugin changes
+ * [#650](https://github.com/pmd/pmd/issues/650): \[java] ProcesingError analyzing code under 5.8.1
+ * [#732](https://github.com/pmd/pmd/issues/732): \[java] LinkageError with aux classpath
+* java-basic
+ * [#565](https://github.com/pmd/pmd/pull/565): \[java] False negative on DontCallThreadRun when extending Thread
+* java-comments
+ * [#396](https://github.com/pmd/pmd/issues/396): \[java] CommentRequired: add properties to ignore @Override method and getters / setters
+ * [#536](https://github.com/pmd/pmd/issues/536): \[java] CommentDefaultAccessModifierRule ignores constructors
+* java-controversial
+ * [#388](https://github.com/pmd/pmd/issues/388): \[java] controversial.AvoidLiteralsInIfCondition 0.0 false positive
+ * [#408](https://github.com/pmd/pmd/issues/408): \[java] DFA not analyzing asserts
+ * [#537](https://github.com/pmd/pmd/issues/537): \[java] UnnecessaryParentheses fails to detect obvious scenario
+* java-design
+ * [#357](https://github.com/pmd/pmd/issues/357): \[java] UncommentedEmptyConstructor consider annotations on Constructor
+ * [#438](https://github.com/pmd/pmd/issues/438): \[java] Relax AbstractClassWithoutAnyMethod when class is annotated by @AutoValue
+ * [#590](https://github.com/pmd/pmd/issues/590): \[java] False positive on MissingStaticMethodInNonInstantiatableClass
+* java-logging
+ * [#457](https://github.com/pmd/pmd/issues/457): \[java] Merge all log guarding rules
+ * [#721](https://github.com/pmd/pmd/issues/721): \[java] NPE in PMD 5.8.1 InvalidSlf4jMessageFormat
+* java-sunsecure
+ * [#468](https://github.com/pmd/pmd/issues/468): \[java] ArrayIsStoredDirectly false positive
+* java-unusedcode
+ * [#521](https://github.com/pmd/pmd/issues/521): \[java] UnusedPrivateMethod returns false positives with primitive data type in map argument
+* java-unnecessarycode
+ * [#412](https://github.com/pmd/pmd/issues/412): \[java] java-unnecessarycode/UnnecessaryFinalModifier missing cases
+ * [#676](https://github.com/pmd/pmd/issues/676): \[java] java-unnecessarycode/UnnecessaryFinalModifier on try-with-resources
+
+### API Changes
+
+* The class `net.sourceforge.pmd.lang.dfa.NodeType` has been converted to an enum.
+ All node types are enum members now instead of int constants. The names for node types are retained.
+
+* The *Properties API* (rule and report properties) has been revamped to be fully typesafe. This is everything
+ around `net.sourceforge.pmd.properties.PropertyDescriptor`.
+
+ Note: All classes related to properties have been moved into the package `net.sourceforge.pmd.properties`.
+
+* The rule classes `net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestClassShouldHaveAsserts`
+ and `net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestShouldNotUseSeeAllDataTrue` have been
+ renamed to `ApexUnitTestClassShouldHaveAssertsRule` and `ApexUnitTestShouldNotUseSeeAllDataTrueRule`,
+ respectively. This is to comply with the naming convention, that each rule class should be suffixed with "Rule".
+
+ This change has no impact on custom rulesets, since the rule names themselves didn't change.
+
+* The never implemented method `PMD.processFiles(PMDConfiguration, RuleSetFactory, Collection, RuleContext, ProgressMonitor)` along with the interface `ProgressMonitor` has been removed.
+
+* The method `PMD.setupReport(RuleSets, RuleContext, String)` is gone. It was used to report dysfunctional
+ rules. But PMD does this now automatically before processing the files, so there is no need for this
+ method anymore.
+
+* All APIs deprecated in older versions are now removed. This includes:
+ * `Renderer.getPropertyDefinitions`
+ * `AbstractRenderer.defineProperty(String, String)`
+ * `AbstractRenderer.propertyDefinitions`
+ * `ReportListener`
+ * `Report.addListener(ReportListener)`
+ * `SynchronizedReportListener`
+ * `CPDConfiguration.CPDConfiguration(int, Language, String)`
+ * `CPDConfiguration.getRendererFromString(String)`
+ * `StreamUtil`
+ * `StringUtil.appendXmlEscaped(StringBuilder, String)`
+ * `StringUtil.htmlEncode(String)`
+
+
+* Several methods in `net.sourceforge.pmd.util.CollectionUtil` have been deprecated and will be removed in PMD 7.0.0. In particular:
+ * `CollectionUtil.addWithoutDuplicates(T[], T)`
+ * `CollectionUtil.addWithoutDuplicates(T[], T[])`
+ * `CollectionUtil.areSemanticEquals(T[], T[])`
+ * `CollectionUtil.areEqual(Object, Object)`
+ * `CollectionUtil.arraysAreEqual(Object, Object)`
+ * `CollectionUtil.valuesAreTransitivelyEqual(Object[], Object[])`
+
+
+* Several methods in `net.sourceforge.pmd.util.StringUtil` have been deprecated and will be removed in PMD 7.0.0. In particular:
+ * `StringUtil.startsWithAny(String, String[])`
+ * `StringUtil.isNotEmpty(String)`
+ * `StringUtil.isEmpty(String)`
+ * `StringUtil.isMissing(String)`
+ * `StringUtil.areSemanticEquals(String, String)`
+ * `StringUtil.replaceString(String, String, String)`
+ * `StringUtil.replaceString(String, char, String)`
+ * `StringUtil.substringsOf(String, char)`
+ * `StringUtil.substringsOf(String, String)`
+ * `StringUtil.asStringOn(StringBuffer, Iterator, String)`
+ * `StringUtil.asStringOn(StringBuilder, Object[], String)`
+ * `StringUtil.lpad(String, int)`
+
+* The class `net.sourceforge.pmd.lang.java.typeresolution.typedefinition.JavaTypeDefinition` is now abstract, and has been enhanced
+ to provide several new methods.
+
+* The constructor of `net.sourceforge.pmd.RuleSetFactory`, which took a `ClassLoader` is deprecated.
+ Please use the alternative constructor with the `net.sourceforge.pmd.util.ResourceLoader` instead.
+
+* The following GUI related classes have been deprecated and will be removed in PMD 7.0.0.
+ The tool "bgastviewer", that could be started via the script `bgastviewer.bat` or `run.sh bgastviewer` is
+ deprecated, too, and will be removed in PMD 7.0.0.
+ Both the "old designer" and "bgastviewer" are replaced by the [New Rule Designer](#new-rule-designer).
+ * `net.sourceforge.pmd.util.designer.CodeEditorTextPane`
+ * `net.sourceforge.pmd.util.designer.CreateXMLRulePanel`
+ * `net.sourceforge.pmd.util.designer.Designer`
+ * `net.sourceforge.pmd.util.designer.DFAPanel`
+ * `net.sourceforge.pmd.util.designer.LineGetter`
+ * `net.sourceforge.pmd.util.viewer.Viewer`
+ * `net.sourceforge.pmd.util.viewer.gui.ActionCommands`
+ * `net.sourceforge.pmd.util.viewer.gui.ASTPanel`
+ * `net.sourceforge.pmd.util.viewer.gui.EvaluationResultsPanel`
+ * `net.sourceforge.pmd.util.viewer.gui.MainFrame`
+ * `net.sourceforge.pmd.util.viewer.gui.ParseExceptionHandler`
+ * `net.sourceforge.pmd.util.viewer.gui.SourceCodePanel`
+ * `net.sourceforge.pmd.util.viewer.gui.XPathPanel`
+ * `net.sourceforge.pmd.util.viewer.gui.menu.ASTNodePopupMenu`
+ * `net.sourceforge.pmd.util.viewer.gui.menu.AttributesSubMenu`
+ * `net.sourceforge.pmd.util.viewer.gui.menu.SimpleNodeSubMenu`
+ * `net.sourceforge.pmd.util.viewer.gui.menu.XPathFragmentAddingItem`
+ * `net.sourceforge.pmd.util.viewer.model.ASTModel`
+ * `net.sourceforge.pmd.util.viewer.model.AttributeToolkit`
+ * `net.sourceforge.pmd.util.viewer.model.SimpleNodeTreeNodeAdapter`
+ * `net.sourceforge.pmd.util.viewer.model.ViewerModel`
+ * `net.sourceforge.pmd.util.viewer.model.ViewerModelEvent`
+ * `net.sourceforge.pmd.util.viewer.model.ViewerModelListener`
+ * `net.sourceforge.pmd.util.viewer.util.NLS`
+
+* The following methods in `net.sourceforge.pmd.Rule` have been deprecated and will be removed in PMD 7.0.0.
+ All methods are replaced by their bean-like counterparts
+ * `void setUsesDFA()`. Use `void setDfa(boolean)` instead.
+ * `boolean usesDFA()`. Use `boolean isDfa()` instead.
+ * `void setUsesTypeResolution()`. Use `void setTypeResolution(boolean)` instead.
+ * `boolean usesTypeResolution()`. Use `boolean isTypeResolution()` instead.
+ * `void setUsesMultifile()`. Use `void setMultifile(boolean)` instead.
+ * `boolean usesMultifile()`. Use `boolean isMultifile()` instead.
+ * `boolean usesRuleChain()`. Use `boolean isRuleChain()` instead.
+
+### External Contributions
+
+* [#287](https://github.com/pmd/pmd/pull/287): \[apex] Make Rule suppression work - [Robert Sösemann](https://github.com/up2go-rsoesemann)
+* [#420](https://github.com/pmd/pmd/pull/420): \[java] Fix UR anomaly in assert statements - [Clément Fournier](https://github.com/oowekyala)
+* [#482](https://github.com/pmd/pmd/pull/482): \[java] Metrics testing framework + improved capabilities for metrics - [Clément Fournier](https://github.com/oowekyala)
+* [#484](https://github.com/pmd/pmd/pull/484): \[core] Changed linux usage to a more unix like path - [patriksevallius](https://github.com/patriksevallius)
+* [#486](https://github.com/pmd/pmd/pull/486): \[java] Add basic method typeresolution - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#492](https://github.com/pmd/pmd/pull/492): \[java] Typeresolution for overloaded methods - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#495](https://github.com/pmd/pmd/pull/495): \[core] Custom rule reinitialization code - [Clément Fournier](https://github.com/oowekyala)
+* [#479](https://github.com/pmd/pmd/pull/479): \[core] Typesafe and immutable properties - [Clément Fournier](https://github.com/oowekyala)
+* [#499](https://github.com/pmd/pmd/pull/499): \[java] Metrics memoization tests - [Clément Fournier](https://github.com/oowekyala)
+* [#501](https://github.com/pmd/pmd/pull/501): \[java] Add support for most specific vararg method type resolution - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#502](https://github.com/pmd/pmd/pull/502): \[java] Add support for static field type resolution - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#505](https://github.com/pmd/pmd/pull/505): \[java] Followup on metrics - [Clément Fournier](https://github.com/oowekyala)
+* [#506](https://github.com/pmd/pmd/pull/506): \[java] Add reduction rules to type inference - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#511](https://github.com/pmd/pmd/pull/511): \[core] Prepare abstraction of the metrics framework - [Clément Fournier](https://github.com/oowekyala)
+* [#512](https://github.com/pmd/pmd/pull/512): \[java] Add incorporation to type inference - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#513](https://github.com/pmd/pmd/pull/513): \[java] Fix for maximally specific method selection - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#514](https://github.com/pmd/pmd/pull/514): \[java] Add static method type resolution - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#517](https://github.com/pmd/pmd/pull/517): \[doc] Metrics documentation - [Clément Fournier](https://github.com/oowekyala)
+* [#518](https://github.com/pmd/pmd/pull/518): \[core] Properties refactoring: factorized enumerated property - [Clément Fournier](https://github.com/oowekyala)
+* [#523](https://github.com/pmd/pmd/pull/523): \[java] Npath complexity metric and rule - [Clément Fournier](https://github.com/oowekyala)
+* [#524](https://github.com/pmd/pmd/pull/524): \[java] Add support for explicit type arguments with method invocation - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#525](https://github.com/pmd/pmd/pull/525): \[core] Fix line ending and not ignored files issues - [Matias Comercio](https://github.com/MatiasComercio)
+* [#528](https://github.com/pmd/pmd/pull/528): \[core] Fix typo - [Ayoub Kaanich](https://github.com/kayoub5)
+* [#529](https://github.com/pmd/pmd/pull/529): \[java] Abstracted the Java metrics framework - [Clément Fournier](https://github.com/oowekyala)
+* [#530](https://github.com/pmd/pmd/pull/530): \[java] Fix issue #527: Lombok getter annotation on enum is not recognized correctly - [Clément Fournier](https://github.com/oowekyala)
+* [#533](https://github.com/pmd/pmd/pull/533): \[core] improve error message - [Dennis Kieselhorst](https://github.com/deki)
+* [#535](https://github.com/pmd/pmd/pull/535): \[apex] Fix broken Apex visitor adapter - [Clément Fournier](https://github.com/oowekyala)
+* [#542](https://github.com/pmd/pmd/pull/542): \[java] Metrics abstraction - [Clément Fournier](https://github.com/oowekyala)
+* [#545](https://github.com/pmd/pmd/pull/545): \[apex] Apex metrics framework - [Clément Fournier](https://github.com/oowekyala)
+* [#548](https://github.com/pmd/pmd/pull/548): \[java] Metrics documentation - [Clément Fournier](https://github.com/oowekyala)
+* [#550](https://github.com/pmd/pmd/pull/550): \[java] Add basic resolution to type inference - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#553](https://github.com/pmd/pmd/pull/553): \[java] Refactored ParserTst into a static utility class + add getSourceFromClass - [Clément Fournier](https://github.com/oowekyala)
+* [#554](https://github.com/pmd/pmd/pull/554): \[java] Fix #537: UnnecessaryParentheses fails to detect obvious scenario - [Clément Fournier](https://github.com/oowekyala)
+* [#555](https://github.com/pmd/pmd/pull/555): \[java] Changed metrics/CyclomaticComplexityRule to use WMC when reporting classes - [Clément Fournier](https://github.com/oowekyala)
+* [#556](https://github.com/pmd/pmd/pull/556): \[java] Fix #357: UncommentedEmptyConstructor consider annotations on Constructor - [Clément Fournier](https://github.com/oowekyala)
+* [#557](https://github.com/pmd/pmd/pull/557): \[java] Fix NPath metric not counting ternaries correctly - [Clément Fournier](https://github.com/oowekyala)
+* [#563](https://github.com/pmd/pmd/pull/563): \[java] Add support for basic method type inference for strict invocation - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#566](https://github.com/pmd/pmd/pull/566): \[java] New rule in migrating ruleset: ForLoopCanBeForeach - [Clément Fournier](https://github.com/oowekyala)
+* [#567](https://github.com/pmd/pmd/pull/567): \[java] Last API change for metrics (metric options) - [Clément Fournier](https://github.com/oowekyala)
+* [#570](https://github.com/pmd/pmd/pull/570): \[java] Model lower, upper and intersection types - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#573](https://github.com/pmd/pmd/pull/573): \[java] Data class rule - [Clément Fournier](https://github.com/oowekyala)
+* [#576](https://github.com/pmd/pmd/pull/576): \[doc]\[java] Add hint for Guava users in InefficientEmptyStringCheck - [mmoehring](https://github.com/mmoehring)
+* [#578](https://github.com/pmd/pmd/pull/578): \[java] Refactored god class rule - [Clément Fournier](https://github.com/oowekyala)
+* [#579](https://github.com/pmd/pmd/pull/579): \[java] Update parsing to produce upper and lower bounds - [Bendegúz Nagy](https://github.com/WinterGrascph)
+* [#580](https://github.com/pmd/pmd/pull/580): \[core] Add AbstractMetric to topple the class hierarchy of metrics - [Clément Fournier](https://github.com/oowekyala)
+* [#581](https://github.com/pmd/pmd/pull/581): \[java] Relax AbstractClassWithoutAnyMethod when class is annotated by @AutoValue - [Niklas Baudy](https://github.com/vanniktech)
+* [#583](https://github.com/pmd/pmd/pull/583): \[java] Documentation about writing metrics - [Clément Fournier](https://github.com/oowekyala)
+* [#585](https://github.com/pmd/pmd/pull/585): \[java] Moved NcssCountRule to codesize.xml - [Clément Fournier](https://github.com/oowekyala)
+* [#587](https://github.com/pmd/pmd/pull/587): \[core] Properties refactoring: Move static constants of ValueParser to class ValueParserConstants - [Clément Fournier](https://github.com/oowekyala)
+* [#588](https://github.com/pmd/pmd/pull/588): \[java] XPath function to compute metrics - [Clément Fournier](https://github.com/oowekyala)
+* [#598](https://github.com/pmd/pmd/pull/598): \[java] Fix #388: controversial.AvoidLiteralsInIfCondition 0.0 false positive - [Clément Fournier](https://github.com/oowekyala)
+* [#602](https://github.com/pmd/pmd/pull/602): \[java] \[apex] Separate multifile analysis from metrics - [Clément Fournier](https://github.com/oowekyala)
+* [#620](https://github.com/pmd/pmd/pull/620): \[core] Moved properties to n.s.pmd.properties - [Clément Fournier](https://github.com/oowekyala)
+* [#625](https://github.com/pmd/pmd/pull/625): \[apex] empty code ruleset for apex - [Jan Aertgeerts](https://github.com/JAertgeerts)
+* [#632](https://github.com/pmd/pmd/pull/632): \[apex] Add AvoidDirectAccessTriggerMap rule to the style set - [Jan Aertgeerts](https://github.com/JAertgeerts)
+* [#644](https://github.com/pmd/pmd/pull/644): \[core] Prevent internal dev-properties from being displayed on CodeClimate renderer - [Filipe Esperandio](https://github.com/filipesperandio)
+* [#660](https://github.com/pmd/pmd/pull/660): \[apex] avoid sosl in loops - [Jan Aertgeerts](https://github.com/JAertgeerts)
+* [#661](https://github.com/pmd/pmd/pull/661): \[apex] avoid hardcoding id's - [Jan Aertgeerts](https://github.com/JAertgeerts)
+* [#666](https://github.com/pmd/pmd/pull/666): \[java] Add DoNotExtendJavaLangThrowable rule - [Robert Painsi](https://github.com/robertpainsi)
+* [#668](https://github.com/pmd/pmd/pull/668): \[core] Fix javadoc warnings on pmd-core - [Clément Fournier](https://github.com/oowekyala)
+* [#669](https://github.com/pmd/pmd/pull/669): \[core] Builder pattern for properties - [Clément Fournier](https://github.com/oowekyala)
+* [#675](https://github.com/pmd/pmd/pull/675): \[java] Fix in Java grammar: Try with final resource node error - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
+* [#679](https://github.com/pmd/pmd/pull/679): \[core] Token scheme generalization - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
+* [#694](https://github.com/pmd/pmd/pull/694): \[core] Add minor fixes to root pom - [Matias Comercio](https://github.com/MatiasComercio)
+* [#696](https://github.com/pmd/pmd/pull/696): \[core] Add remove operation over nodes - [Matias Comercio](https://github.com/MatiasComercio)
+* [#711](https://github.com/pmd/pmd/pull/711): \[ui] New rule designer - [Clément Fournier](https://github.com/oowekyala)
+* [#722](https://github.com/pmd/pmd/pull/722): \[java] Move NPathComplexity from metrics to design - [Clément Fournier](https://github.com/oowekyala)
+* [#723](https://github.com/pmd/pmd/pull/723): \[core] Rule factory refactoring - [Clément Fournier](https://github.com/oowekyala)
+* [#726](https://github.com/pmd/pmd/pull/726): \[java] Fix issue #721 (NPE in InvalidSlf4jMessageFormat) - [Clément Fournier](https://github.com/oowekyala)
+* [#727](https://github.com/pmd/pmd/pull/727): \[core] Fix #725: numeric property descriptors now check their default value - [Clément Fournier](https://github.com/oowekyala)
+* [#733](https://github.com/pmd/pmd/pull/733): \[java] Some improvements to CommentRequired - [Clément Fournier](https://github.com/oowekyala)
+* [#734](https://github.com/pmd/pmd/pull/734): \[java] Move CyclomaticComplexity from metrics to design - [Clément Fournier](https://github.com/oowekyala)
+* [#736](https://github.com/pmd/pmd/pull/736): \[core] Make Saxon support multi valued XPath properties - [Clément Fournier](https://github.com/oowekyala)
+* [#737](https://github.com/pmd/pmd/pull/737): \[doc] Fix NPathComplexity documentation bad rendering - [Clément Fournier](https://github.com/oowekyala)
+* [#744](https://github.com/pmd/pmd/pull/744): \[doc] Added Apex to supported languages - [Michał Kuliński](https://github.com/coola)
+* [#746](https://github.com/pmd/pmd/pull/746): \[doc] Fix typo in incremental analysis log message - [Clément Fournier](https://github.com/oowekyala)
+* [#749](https://github.com/pmd/pmd/pull/749): \[doc] Update the documentation for properties - [Clément Fournier](https://github.com/oowekyala)
+* [#758](https://github.com/pmd/pmd/pull/758): \[core] Expose the full mapping from property type id to property extractor - [Clément Fournier](https://github.com/oowekyala)
+* [#764](https://github.com/pmd/pmd/pull/764): \[core] Prevent method and file property use in XPath rules - [Clément Fournier](https://github.com/oowekyala)
+* [#771](https://github.com/pmd/pmd/pull/771): \[apex] Fix Apex metrics framework failing on triggers, refs #768 - [Clément Fournier](https://github.com/oowekyala)
+* [#774](https://github.com/pmd/pmd/pull/774): \[java] Avoid using FileInput/Output - see JDK-8080225 - [Chas Honton](https://github.com/chonton)
## 01-July-2017 - 5.8.1
diff --git a/docs/pages/tags/tag_collaboration.md b/docs/pages/tags/tag_collaboration.md
deleted file mode 100644
index bec986c4ad7..00000000000
--- a/docs/pages/tags/tag_collaboration.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: "Collaboration pages"
-tagName: collaboration
-search: exclude
-permalink: tag_collaboration.html
-sidebar: mydoc_sidebar
-folder: tags
----
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_content_types.md b/docs/pages/tags/tag_content_types.md
deleted file mode 100644
index fe87eaab59b..00000000000
--- a/docs/pages/tags/tag_content_types.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: "Content types pages"
-tagName: content_types
-search: exclude
-permalink: tag_content_types.html
-sidebar: mydoc_sidebar
-folder: tags
----
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_customizing.md b/docs/pages/tags/tag_customizing.md
deleted file mode 100644
index fe1426428ed..00000000000
--- a/docs/pages/tags/tag_customizing.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: "Customizing PMD Pages"
-tagName: customizing
-search: exclude
-permalink: tag_customizing.html
-sidebar: pmd_sidebar
-folder: tags
----
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_devdocs.md b/docs/pages/tags/tag_devdocs.md
new file mode 100644
index 00000000000..87aa8aa5411
--- /dev/null
+++ b/docs/pages/tags/tag_devdocs.md
@@ -0,0 +1,11 @@
+---
+title: "Developer and contributor documentation"
+tagName: devdocs
+search: exclude
+permalink: tag_devdocs.html
+sidebar: pmd_sidebar
+folder: tags
+---
+{% include taglogic.html %}
+
+{% include links.html %}
diff --git a/docs/pages/tags/tag_extending.md b/docs/pages/tags/tag_extending.md
new file mode 100644
index 00000000000..28291803daf
--- /dev/null
+++ b/docs/pages/tags/tag_extending.md
@@ -0,0 +1,9 @@
+---
+title: "Extending PMD"
+tagName: extending
+search: exclude
+permalink: tag_extending.html
+sidebar: pmd_sidebar
+folder: tags
+---
+{% include taglogic.html %}
diff --git a/docs/pages/tags/tag_formatting.md b/docs/pages/tags/tag_formatting.md
deleted file mode 100644
index 83325023378..00000000000
--- a/docs/pages/tags/tag_formatting.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: "Formatting pages"
-tagName: formatting
-search: exclude
-permalink: tag_formatting.html
-sidebar: mydoc_sidebar
-folder: tags
----
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_languages.md b/docs/pages/tags/tag_languages.md
index 5cd56b1795d..886d150173d 100644
--- a/docs/pages/tags/tag_languages.md
+++ b/docs/pages/tags/tag_languages.md
@@ -3,7 +3,7 @@ title: "Supported Lanugages"
tagName: languages
search: exclude
permalink: tag_languages.html
-sidebar: mydoc_sidebar
+sidebar: pmd_sidebar
folder: tags
---
{% include taglogic.html %}
diff --git a/docs/pages/tags/tag_metrics.md b/docs/pages/tags/tag_metrics.md
new file mode 100644
index 00000000000..f189486a617
--- /dev/null
+++ b/docs/pages/tags/tag_metrics.md
@@ -0,0 +1,9 @@
+---
+title: "Code metrics"
+tagName: metrics
+search: exclude
+permalink: tag_metrics.html
+sidebar: pmd_sidebar
+folder: tags
+---
+{% include taglogic.html %}
diff --git a/docs/pages/tags/tag_mobile.md b/docs/pages/tags/tag_mobile.md
deleted file mode 100644
index 4f35333a27a..00000000000
--- a/docs/pages/tags/tag_mobile.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: "Mobile Pages"
-search: exclude
-tagName: mobile
-permalink: tag_mobile.html
-sidebar: mydoc_sidebar
-folder: tags
----
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_navigation.md b/docs/pages/tags/tag_navigation.md
deleted file mode 100644
index 480d087b8e6..00000000000
--- a/docs/pages/tags/tag_navigation.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: "Navigation pages"
-tagName: navigation
-search: exclude
-permalink: tag_navigation.html
-sidebar: mydoc_sidebar
-folder: tags
----
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_news.md b/docs/pages/tags/tag_news.md
deleted file mode 100644
index 3dc9414239d..00000000000
--- a/docs/pages/tags/tag_news.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: "News"
-tagName: news
-search: exclude
-permalink: tag_news.html
-sidebar: mydoc_sidebar
-folder: tags
----
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_publishing.md b/docs/pages/tags/tag_publishing.md
deleted file mode 100644
index 5d948f0e2f4..00000000000
--- a/docs/pages/tags/tag_publishing.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: "Publishing pages"
-tagName: publishing
-search: exclude
-permalink: tag_publishing.html
-sidebar: mydoc_sidebar
-folder: tags
----
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_release_notes.md b/docs/pages/tags/tag_release_notes.md
index 8d0685a831c..2804c0ff307 100644
--- a/docs/pages/tags/tag_release_notes.md
+++ b/docs/pages/tags/tag_release_notes.md
@@ -3,7 +3,7 @@ title: "Release Notes Pages"
tagName: release_notes
search: exclude
permalink: tag_release_notes.html
-sidebar: mydoc_sidebar
+sidebar: pmd_sidebar
folder: tags
---
{% include taglogic.html %}
diff --git a/docs/pages/tags/tag_rule_references.md b/docs/pages/tags/tag_rule_references.md
new file mode 100644
index 00000000000..2d0ca25b18c
--- /dev/null
+++ b/docs/pages/tags/tag_rule_references.md
@@ -0,0 +1,11 @@
+---
+title: "Rule references"
+tagName: rule_references
+search: exclude
+permalink: tag_rule_references.html
+sidebar: pmd_sidebar
+folder: tags
+---
+{% include taglogic.html %}
+
+{% include links.html %}
diff --git a/docs/pages/tags/tag_single_sourcing.md b/docs/pages/tags/tag_single_sourcing.md
deleted file mode 100644
index ae181e154ef..00000000000
--- a/docs/pages/tags/tag_single_sourcing.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: "Single sourcing pages"
-tagName: single_sourcing
-search: exclude
-permalink: tag_single_sourcing.html
-sidebar: mydoc_sidebar
-folder: tags
----
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_special_layouts.md b/docs/pages/tags/tag_special_layouts.md
deleted file mode 100644
index b010362e967..00000000000
--- a/docs/pages/tags/tag_special_layouts.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: "Special layout pages"
-tagName: special_layouts
-search: exclude
-permalink: tag_special_layouts.html
-sidebar: mydoc_sidebar
-folder: tags
----
-
-{% include taglogic.html %}
-
-{% include links.html %}
diff --git a/docs/pages/tags/tag_tools.md b/docs/pages/tags/tag_tools.md
new file mode 100644
index 00000000000..de8532dc7a5
--- /dev/null
+++ b/docs/pages/tags/tag_tools.md
@@ -0,0 +1,11 @@
+---
+title: "Tools and integrations"
+tagName: tools
+search: exclude
+permalink: tag_tools.html
+sidebar: pmd_sidebar
+folder: tags
+---
+{% include taglogic.html %}
+
+{% include links.html %}
diff --git a/docs/pages/tags/tag_userdocs.md b/docs/pages/tags/tag_userdocs.md
new file mode 100644
index 00000000000..6d7ffcb3fa1
--- /dev/null
+++ b/docs/pages/tags/tag_userdocs.md
@@ -0,0 +1,8 @@
+---
+title: "User documentation"
+tagName: userdocs
+search: exclude
+permalink: tag_userdocs.html
+sidebar: pmd_sidebar
+---
+{% include taglogic.html %}
diff --git a/docs/search.json b/docs/search.json
index a7f7dd0fe10..3a9de069120 100644
--- a/docs/search.json
+++ b/docs/search.json
@@ -7,6 +7,20 @@ search: exclude
[
{% for page in site.pages %}
{% unless page.search == "exclude" %}
+
+{% if page.permalink contains "pmd_rules_" and page.keywords %}
+{% assign rules = page.keywords | split: ", " %}
+{% for rule in rules %}
+{
+"title": "{{ rule | escape }} ({{page.language}}, {{page.title}})",
+"tags": "{{ page.tags }}",
+"keywords": "{{rule}}",
+"url": "{{ page.url | remove: "/"}}#{{ rule | downcase }}",
+"summary": "{{page.summary | strip }}"
+}
+{% unless forloop.last %},{% endunless %}
+{% endfor %}
+{% else %}
{
"title": "{{ page.title | escape }}",
"tags": "{{ page.tags }}",
@@ -14,6 +28,9 @@ search: exclude
"url": "{{ page.url | remove: "/"}}",
"summary": "{{page.summary | strip }}"
}
+{% endif %}
+
+
{% unless forloop.last and site.posts.size < 1 %},{% endunless %}
{% endunless %}
{% endfor %}
diff --git a/docs/update.sh b/docs/update.sh
deleted file mode 100755
index 42a3bece578..00000000000
--- a/docs/update.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-git add .
-git status
-git commit -m "content update"
-git push
\ No newline at end of file
diff --git a/example-toolchains.xml b/example-toolchains.xml
deleted file mode 100644
index ff0b1d5c954..00000000000
--- a/example-toolchains.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
- jdk
-
- 1.7
-
-
- /path/to/jdk/1.7
- /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
- C:\\java\\edition\\jdk1.7.0_80
-
-
-
- jdk
-
- 1.8
-
-
- /path/to/jdk/1.8
- /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
- C:\\java\\edition\\jdk1.8.0_131
-
-
-
\ No newline at end of file
diff --git a/mvnw b/mvnw
index 5bf251c0774..e96ccd5fbbb 100755
--- a/mvnw
+++ b/mvnw
@@ -108,7 +108,7 @@ if $cygwin ; then
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
-# For Migwn, ensure paths are in UNIX format before anything is touched
+# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
@@ -201,7 +201,9 @@ if [ -z "$BASE_DIR" ]; then
fi
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
-echo $MAVEN_PROJECTBASEDIR
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
diff --git a/mvnw.cmd b/mvnw.cmd
index 019bd74d766..6a6eec39baf 100755
--- a/mvnw.cmd
+++ b/mvnw.cmd
@@ -35,6 +35,8 @@
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
+@REM set title of command window
+title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
diff --git a/pmd-apex-jorje/pom.xml b/pmd-apex-jorje/pom.xml
new file mode 100644
index 00000000000..e4db1c5e79d
--- /dev/null
+++ b/pmd-apex-jorje/pom.xml
@@ -0,0 +1,138 @@
+
+
+ 4.0.0
+ pmd-apex-jorje
+ PMD Apex Jorje Parser Library
+ pom
+
+
+ net.sourceforge.pmd
+ pmd
+ 6.10.0-SNAPSHOT
+
+
+
+ 8
+
+ 1.${java.version}
+ 1.${java.version}
+ 2017-11-17
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.0.0
+
+
+