Fixed bug, thx to Don for the good catch

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1380 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2003-01-27 19:42:24 +00:00
parent 70630626e6
commit df66f04d84
4 changed files with 12 additions and 0 deletions

View File

@ -3,6 +3,7 @@ Added numbering to the HTMLRenderer; thx to Luke Francl for the code.
Fixed bug 672742 - grammar typo was hosing up ASTConstructorDeclaration which was hosing up UseSingletonRule
Fixed bug 674393 - OnlyOneReturn rule no longer counts returns that are inside anonymous inner classes as being inside the containing method. Thx to C. Lamont Gilbert for the bug report.
Fixed bug 674420 - AvoidReassigningParametersRule no longer counts parameter field reassignment as a violation. Thx to C. Lamont Gilbert for the bug report.
Fixed bug in OverrideBothEqualsAndHashcodeRule - it no longer bails out with a NullPtrException on interfaces that declare a method signature "equals(Object)". Thx to Don Leckie for catching that.
January 22, 2003 - 1.02:
Added new rules: ImportFromSamePackageRule, SwitchDensityRule, NullAssignmentRule, UnusedModifierRule, ForLoopShouldBeWhileLoopRule

View File

@ -23,4 +23,7 @@ public class OverrideBothEqualsAndHashcodeRuleTest extends RuleTst {
public void testEqualsSignatureUsesStringNotObject() throws Throwable{
runTest("OverrideBothEqualsAndHashcode5.java", 1, new OverrideBothEqualsAndHashcodeRule());
}
public void testInterface() throws Throwable{
runTest("OverrideBothEqualsAndHashcode6.java", 0, new OverrideBothEqualsAndHashcodeRule());
}
}

View File

@ -12,6 +12,7 @@ import net.sourceforge.pmd.ast.ASTClassBody;
import net.sourceforge.pmd.ast.ASTMethodDeclarator;
import net.sourceforge.pmd.ast.AccessNode;
import net.sourceforge.pmd.ast.SimpleNode;
import net.sourceforge.pmd.ast.ASTInterfaceDeclaration;
public class OverrideBothEqualsAndHashcodeRule extends AbstractRule implements Rule {
@ -48,6 +49,10 @@ public class OverrideBothEqualsAndHashcodeRule extends AbstractRule implements R
return data;
}
public Object visit(ASTInterfaceDeclaration node, Object data) {
return data;
}
public Object visit(ASTMethodDeclarator node, Object data) {
AccessNode parent = (AccessNode)node.jjtGetParent();
// hashcode has no params & (TODO) returns an int

View File

@ -0,0 +1,3 @@
public interface OverrideBothEqualsAndHashcode6 {
public boolean equals(Object o);
}