False positives + bug fix

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4842 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch
2006-11-30 05:18:16 +00:00
parent 3998500fa8
commit 26907e0d0c
2 changed files with 15 additions and 0 deletions

View File

@ -35,6 +35,18 @@ public class Foo {
</test-code>
<test-code>
<description><![CDATA[
Pass, BigDecimal(i - 1)
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
int i = 42;
BigDecimal b = new BigDecimal(i - 1);
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
Pass, BigInteger("10") and BigDecimal in 1.4 mode
]]></description>
<expected-problems>0</expected-problems>

View File

@ -32,6 +32,9 @@ public class BigIntegerInstantiation extends AbstractRule {
ASTArguments args = (ASTArguments) node.getFirstChildOfType(ASTArguments.class);
if (args.getArgumentCount() == 1) {
ASTLiteral literal = (ASTLiteral) node.getFirstChildOfType(ASTLiteral.class);
if (literal == null || literal.jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent() != args) {
return super.visit(node, data);
}
img = literal.getImage();
if ((img.length() > 2 && img.charAt(0) == '"')) {