diff --git a/docs/pages/pmd/rules/java.md b/docs/pages/pmd/rules/java.md
index 0930e39913..f8d2a78f1c 100644
--- a/docs/pages/pmd/rules/java.md
+++ b/docs/pages/pmd/rules/java.md
@@ -98,6 +98,7 @@ folder: pmd/rules
* [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.
+* [NumericLiteralConvention](pmd_rules_java_codestyle.html#numericliteralconvention): Numeric literals with more than 3 digits must use '_' as a separator.
* [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...
@@ -116,7 +117,6 @@ folder: pmd/rules
* [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): Numeric literals with more than 3 digits must use '_' as a separator.
* [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...
diff --git a/docs/pages/pmd/rules/java/codestyle.md b/docs/pages/pmd/rules/java/codestyle.md
index e4f9a6ba21..247b846cac 100644
--- a/docs/pages/pmd/rules/java/codestyle.md
+++ b/docs/pages/pmd/rules/java/codestyle.md
@@ -5,7 +5,7 @@ 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
+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, NumericLiteralConvention, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryAnnotationValueElement, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
language: Java
---
## AbstractNaming
@@ -1508,6 +1508,38 @@ public class ClassInDefaultPackage {
```
+## NumericLiteralConvention
+
+**Since:** PMD 6.9.0
+
+**Priority:** Medium (3)
+
+**Minimum Language Version:** Java 1.7
+
+Numeric literals with more than 3 digits must use '_' as a separator.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Literal[@IntLiteral = true() or
+ @LongLiteral = true() or
+ @DoubleLiteral = true() or
+ @FloatLiteral = true()]
+ [not(matches(@Image, "^[0-9]{1,3}(_[0-9]{3})*(l|L|\.[0-9]+)?(d|D|f|F)?$"))]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private int num = 1000000; // should be 1_000_000
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
## OnlyOneReturn
**Since:** PMD 1.0
@@ -2203,40 +2235,6 @@ public class Foo {
```
-## UseUnderscoresInNumericLiterals
-
-**Since:** PMD 6.10.0
-
-**Priority:** Medium (3)
-
-**Minimum Language Version:** Java 1.7
-
-Numeric literals with more than 3 digits must use '_' as a separator.
-
-**This rule is defined by the following XPath expression:**
-``` xpath
-//Literal[@IntLiteral = true() or
- @LongLiteral = true() or
- @DoubleLiteral = true() or
- @FloatLiteral = true()]
- [not (matches(@Image, "^(0([xb]?[0-9a-fA-F]+)?|[1-9][0-9]{0,2}(_[0-9]{3})*)(l|L|\.[0-9_]+)?([eE][\+-]?[0-9]+)?[dDfF]?$"))]
- [ancestor::VariableDeclarator[not (@Name = 'serialVersionUID')] or
- not (ancestor::VariableDeclarator)]
-```
-
-**Example(s):**
-
-``` java
-public class Foo {
- private int num = 1000000; // should be 1_000_000
-}
-```
-
-**Use this rule by referencing it:**
-``` xml
-
-```
-
## VariableNamingConventions
Deprecated
diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml
index f1f3361ac1..e7ef25cdda 100644
--- a/pmd-java/src/main/resources/category/java/codestyle.xml
+++ b/pmd-java/src/main/resources/category/java/codestyle.xml
@@ -1366,8 +1366,6 @@ public class ClassInDefaultPackage {
3
-
diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UseUnderscoresInNumericLiterals.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UseUnderscoresInNumericLiterals.xml
index 7b598d5975..3861a372b4 100644
--- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UseUnderscoresInNumericLiterals.xml
+++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UseUnderscoresInNumericLiterals.xml
@@ -4,9 +4,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
-
- ok, numeric literal with correct '_' usage
-
+
0
-
- bad, numeric literal without '_'
-
+
1
-
- bad, numeric literal used as a method parameter without '_'
-
+
1
-
- ok, float value with less than 3 numbers.
-
+
0
-
- bad, double value without '_'
-
+
1
-
- ok, numeric literal used as a method parameter with '_'
-
+
0
-
- ok, Long value with 'l' used as a method parameter with '_'
-
+
0
-
- bad, numeric literal with incorrect '_' usage
-
+
1
-
- ok, Double value with 'D' used as a method parameter with '_'
-
+
0
-
- ok, Float value with 'F' with less than 3 numbers
-
+
0
-
- ok, Double value with 'd' with correct '_' usage
-
+
0
-
- ok, Long value with 'L' used as a method parameter with '_'
-
+
0
-
- ok, String value with '_'
-
+
0
-
- ok, String value without '_'
-
+
0
-
- ok, Numeric Literal in binary
-
+
0
-
- ok, Numeric Literal in octal
-
+
0
-
- ok, Numeric Literal in hexadecimal
-
+
0
-
- ok, Numeric Literal in negative binary
-
+
0
-
- ok, Numeric Literal in negative octal
-
+
0
-
- ok, Numeric Literal in negative hexadecimal
-
+
0
-
- ok, Numeric Literal with exponent
-
+
0
-
- bad, Negative exponent without '_'
-
- 1
+
+ 0
-
- ok, Numeric Literal with positive exponent
-
+
0
-
- ok, Lengthy numeric literal with variable name as serialVersionUID
-
+
0