From 26907e0d0cf39f6345c34da46477a3f2f1835127 Mon Sep 17 00:00:00 2001 From: Xavier Le Vourch Date: Thu, 30 Nov 2006 05:18:16 +0000 Subject: [PATCH] False positives + bug fix git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4842 51baf565-9d33-0410-a72c-fc3788e3496d --- .../pmd/rules/xml/BigIntegerInstantiation.xml | 12 ++++++++++++ .../pmd/rules/basic/BigIntegerInstantiation.java | 3 +++ 2 files changed, 15 insertions(+) diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/xml/BigIntegerInstantiation.xml b/pmd/regress/test/net/sourceforge/pmd/rules/xml/BigIntegerInstantiation.xml index f116cd31a0..bfae4d3258 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/xml/BigIntegerInstantiation.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/xml/BigIntegerInstantiation.xml @@ -35,6 +35,18 @@ public class Foo { + 0 + + + + 0 diff --git a/pmd/src/net/sourceforge/pmd/rules/basic/BigIntegerInstantiation.java b/pmd/src/net/sourceforge/pmd/rules/basic/BigIntegerInstantiation.java index 1ab554a503..463d981a63 100644 --- a/pmd/src/net/sourceforge/pmd/rules/basic/BigIntegerInstantiation.java +++ b/pmd/src/net/sourceforge/pmd/rules/basic/BigIntegerInstantiation.java @@ -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) == '"')) {