[java] UseUnderscoresInNumericLiterals false positive on floating point numbers
Fixes #1527
This commit is contained in:
@ -60,6 +60,7 @@ The designer will still be shipped with PMD's binaries.
|
||||
* java-bestpractices
|
||||
* [#1701](https://github.com/pmd/pmd/issues/1701): \[java] UseTryWithResources does not handle multiple argument close methods
|
||||
* java-codestyle
|
||||
* [#1527](https://github.com/pmd/pmd/issues/1527): \[java] UseUnderscoresInNumericLiterals false positive on floating point numbers
|
||||
* [#1674](https://github.com/pmd/pmd/issues/1674): \[java] documentation of CommentDefaultAccessModifier is wrong
|
||||
|
||||
### API Changes
|
||||
|
@ -1405,11 +1405,11 @@ public class ClassInDefaultPackage {
|
||||
(: Filter out ignored field name :)
|
||||
[not(ancestor::VariableDeclarator[1][@Name = 'serialVersionUID'])]
|
||||
[
|
||||
some $num in tokenize(@Image, "[.dDfFlLeE+\-]")
|
||||
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})*$")
|
||||
or matches($num, "^[0-9]{1,3}(_[0-9]{3})*(\.([0-9]{3}_)*[0-9]{1,3})?$")
|
||||
)
|
||||
]
|
||||
]]>
|
||||
|
@ -322,8 +322,23 @@ public class Foo {
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int value = 0.3936;
|
||||
double value1 = 0.393_6;
|
||||
double value2 = 0.39;
|
||||
double value3 = -0.1;
|
||||
double value4 = -0.123_456;
|
||||
double value5 = +0.123_456;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>#1527 [java] UseUnderscoresInNumericLiterals false positive on floating point numbers</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
double value1 = 36.363_636_363_636_37;
|
||||
double value2 = 0.000_000_1;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user