minor regex change

This commit is contained in:
rajeshggwp
2018-11-10 16:04:29 +05:30
parent 9b6b1a4d15
commit 750381c65a
3 changed files with 16 additions and 6 deletions

View File

@ -2219,14 +2219,13 @@ Numeric literals with more than 3 digits must use '_' as a separator.
@LongLiteral = true() or
@DoubleLiteral = true() or
@FloatLiteral = true()]
[ not (matches(@Image, "^0([xb]?[0-9a-fA-F]+)?$"))]
[ not (matches(@Image, "^0[^.]"))]
[
some $num in tokenize(@Image, "[.dDfFlL]|[eE][\+-]?")
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})*$")
)

View File

@ -1375,9 +1375,9 @@ public class ClassInDefaultPackage {
@LongLiteral = true() or
@DoubleLiteral = true() or
@FloatLiteral = true()]
[ not (matches(@Image, "^0([xb]?[0-9a-fA-F]+)?$"))]
[ not (matches(@Image, "^0[^.]"))]
[
some $num in tokenize(@Image, "[.dDfFlL]|[eE][\+-]?")
some $num in tokenize(@Image, "[.dDfFlLeE\-\+]")
satisfies not(
string-length($num) <= $acceptableDecimalLength
and (

View File

@ -307,11 +307,22 @@ public class Foo {
<description>
bad, testing acceptableDecimalLength
</description>
<rule-property name="acceptableDecimalLength">10</rule-property>
<rule-property name="acceptableDecimalLength">15</rule-property>
<expected-problems>1</expected-problems>
<code><![CDATA[
public class Foo {
int value = -32_3639_6_9;
}
]]></code>
</test-code>
<test-code>
<description>
ok, Decimal number test
</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
int value = 0.3936;
}
]]></code>
</test-code>