Fixed another missed hit

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3593 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2005-06-16 21:12:39 +00:00
parent 58b43edf19
commit 47f7797b30
2 changed files with 14 additions and 0 deletions

View File

@ -20,6 +20,7 @@ public class CompareObjectsWithEqualsTest extends SimpleAggregatorTst{
new TestDescriptor(TEST2, "primitives are ok", 0, rule),
new TestDescriptor(TEST3, "skip nulls", 0, rule),
new TestDescriptor(TEST4, "missed hit - qualified names. that's ok, we can't resolve the types yet, so better to skip this for now", 0, rule),
new TestDescriptor(TEST5, "more qualified name skippage", 0, rule),
});
}
@ -51,4 +52,11 @@ public class CompareObjectsWithEqualsTest extends SimpleAggregatorTst{
" }" + PMD.EOL +
"}";
private static final String TEST5 =
"public class Foo {" + PMD.EOL +
" boolean bar(String a, String b) {" + PMD.EOL +
" return a.charAt(0) == b.charAt(0);" + PMD.EOL +
" }" + PMD.EOL +
"}";
}

View File

@ -27,6 +27,12 @@ public class CompareObjectsWithEquals extends AbstractRule {
return data;
}
// skip if either is a qualified name
if (((SimpleNode)node.jjtGetChild(0).jjtGetChild(0).jjtGetChild(0)).getImage().indexOf(".") != -1
|| ((SimpleNode)node.jjtGetChild(1).jjtGetChild(0).jjtGetChild(0)).getImage().indexOf(".") != -1) {
return data;
}
// skip static initializers... missing some cases here
if (!node.getParentsOfType(ASTInitializer.class).isEmpty()) {
return data;