From d900e64abc6d60955665900ba3b292f840b689eb Mon Sep 17 00:00:00 2001 From: Xavier Le Vourch Date: Mon, 20 Nov 2006 22:28:33 +0000 Subject: [PATCH] bug fix: octal pattern can contain optional 'L' at the end git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4821 51baf565-9d33-0410-a72c-fc3788e3496d --- .../sourceforge/pmd/rules/AvoidUsingOctalValuesTest.java | 6 ++++++ .../sourceforge/pmd/rules/basic/AvoidUsingOctalValues.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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();