[java] UseUnderscoresInNumericLiterals - check the length before

and after decimal point separately
This commit is contained in:
Andreas Dangel
2019-03-29 19:57:48 +01:00
parent 921ee050bd
commit ae4b56e70f
2 changed files with 9 additions and 2 deletions

View File

@ -1407,8 +1407,12 @@ public class ClassInDefaultPackage {
[
some $num in tokenize(@Image, "[dDfFlLeE+\-]")
satisfies not(
string-length($num) <= $acceptableDecimalLength
and not(contains($num,"_"))
( contains($num, ".")
and string-length(substring-before($num, ".")) <= $acceptableDecimalLength
and string-length(substring-after($num, ".")) <= $acceptableDecimalLength
or string-length($num) <= $acceptableDecimalLength
)
and not(contains($num,"_"))
or matches($num, "^[0-9]{1,3}(_[0-9]{3})*(\.([0-9]{3}_)*[0-9]{1,3})?$")
)
]

View File

@ -327,6 +327,9 @@ public class Foo {
double value3 = -0.1;
double value4 = -0.123_456;
double value5 = +0.123_456;
double valid1 = 0.3936;
double valid2 = 1000.0;
}
]]></code>
</test-code>