merged from trunk: Fixed bug 1481051 - false + UnusedNullCheckInEquals (and other false positives too)

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6440 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch 2008-09-03 20:22:39 +00:00
parent 7ed88ed4cf
commit 39e59dd02f
3 changed files with 31 additions and 2 deletions

View File

@ -1,5 +1,7 @@
???? - 4.2.4: ???? - 4.2.4:
Fixed bug 1481051 - false + UnusedNullCheckInEquals (and other false positives too)
August 31, 2008 - 4.2.3: August 31, 2008 - 4.2.3:
JavaCC generated artifacts updated to JavaCC 4.1d1. JavaCC generated artifacts updated to JavaCC 4.1d1.

View File

@ -50,6 +50,33 @@ public class Foo {
if (x != null && "Foo".equals(y)) {} if (x != null && "Foo".equals(y)) {}
if (y.equals(x)) {} if (y.equals(x)) {}
} }
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
var is not used in equals() call
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
public void bar() {
if (c != null && A.b(c).equals(d)) {}
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
[ 1481051 ] false + UnusedNullCheckInEquals
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
public void bar() {
if(o1!=null && o1[0] != null && o2[0].getName()!=null && o2[0].getName().equals(o1[0].getName()) ){ }
if(o1!=null && o2.equals(o1.getName()) ){ }
}
} }
]]></code> ]]></code>
</test-code> </test-code>

View File

@ -873,8 +873,8 @@ public class Foo {
<value> <value>
<![CDATA[ <![CDATA[
//PrimarySuffix[@Image='equals' and not(../PrimaryPrefix/Literal)] //PrimarySuffix[@Image='equals' and not(../PrimaryPrefix/Literal)]
/../PrimarySuffix/Arguments/ArgumentList/Expression /following-sibling::PrimarySuffix/Arguments/ArgumentList/Expression
/PrimaryExpression/PrimaryPrefix /PrimaryExpression[count(PrimarySuffix)=0]/PrimaryPrefix
/Name[@Image = ./../../../../../../../../../../Expression/ConditionalAndExpression /Name[@Image = ./../../../../../../../../../../Expression/ConditionalAndExpression
/EqualityExpression[@Image="!=" and count(./preceding-sibling::*)=0 and /EqualityExpression[@Image="!=" and count(./preceding-sibling::*)=0 and
./PrimaryExpression/PrimaryPrefix/Literal/NullLiteral] ./PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]