diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/AvoidUsingOctalValuesTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidUsingOctalValuesTest.java index 3072cbbba0..8b938e4b74 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/AvoidUsingOctalValuesTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidUsingOctalValuesTest.java @@ -21,6 +21,7 @@ public class AvoidUsingOctalValuesTest extends SimpleAggregatorTst { new TestDescriptor(TEST3, "OK, long value", 0, rule), new TestDescriptor(TEST4, "OK, double value", 0, rule), new TestDescriptor(TEST5, "OK, double value", 0, rule), + new TestDescriptor(TEST6, "bad, 012L", 1, rule), }); } @@ -49,4 +50,9 @@ public class AvoidUsingOctalValuesTest extends SimpleAggregatorTst { " float f = 0f;" + PMD.EOL + "}"; + private static final String TEST6 = + "public class Foo {" + PMD.EOL + + " long x = 012L;" + PMD.EOL + + "}"; + } diff --git a/pmd/src/net/sourceforge/pmd/rules/basic/AvoidUsingOctalValues.java b/pmd/src/net/sourceforge/pmd/rules/basic/AvoidUsingOctalValues.java index 1258aba054..3e2a33f870 100644 --- a/pmd/src/net/sourceforge/pmd/rules/basic/AvoidUsingOctalValues.java +++ b/pmd/src/net/sourceforge/pmd/rules/basic/AvoidUsingOctalValues.java @@ -7,7 +7,7 @@ import net.sourceforge.pmd.ast.ASTLiteral; public class AvoidUsingOctalValues extends AbstractRule { - public static final Pattern OCTAL_PATTERN = Pattern.compile("0[0-7]+"); + public static final Pattern OCTAL_PATTERN = Pattern.compile("0[0-7]+[lL]?"); public Object visit(ASTLiteral node, Object data) { String img = node.getImage();