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
This commit is contained in:
Xavier Le Vourch
2006-11-20 22:28:33 +00:00
parent 816e04b905
commit d900e64abc
2 changed files with 7 additions and 1 deletions

View File

@ -21,6 +21,7 @@ public class AvoidUsingOctalValuesTest extends SimpleAggregatorTst {
new TestDescriptor(TEST3, "OK, long value", 0, rule), new TestDescriptor(TEST3, "OK, long value", 0, rule),
new TestDescriptor(TEST4, "OK, double value", 0, rule), new TestDescriptor(TEST4, "OK, double value", 0, rule),
new TestDescriptor(TEST5, "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 + " float f = 0f;" + PMD.EOL +
"}"; "}";
private static final String TEST6 =
"public class Foo {" + PMD.EOL +
" long x = 012L;" + PMD.EOL +
"}";
} }

View File

@ -7,7 +7,7 @@ import net.sourceforge.pmd.ast.ASTLiteral;
public class AvoidUsingOctalValues extends AbstractRule { 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) { public Object visit(ASTLiteral node, Object data) {
String img = node.getImage(); String img = node.getImage();