Applied patch 1574988 - false + in OverrideBothEqualsAndHashcode

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4628 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch
2006-10-12 03:31:20 +00:00
parent cf20efc5a6
commit 0e2eb81fa6
3 changed files with 10 additions and 1 deletions

View File

@ -11,6 +11,7 @@ Fixed bug 1573795 - PreserveStackTrace doesn't throw CastClassException on excep
Fixed bug 1573591 - NonThreadSafeSingleton doesn't throw NPE when using this keyword
CloseResource rule now checks code without java.sql import.
Applied patch 1573981 - false + in CloneMethodMustImplementCloneable
Applied patch 1574988 - false + in OverrideBothEqualsAndHashcode
October 4, 2006 - 3.8:
New rules:

View File

@ -31,6 +31,7 @@ public class OverrideBothEqualsAndHashcodeTest extends SimpleAggregatorTst {
new TestDescriptor(TEST10, "overloaded hashCode", 0, rule),
new TestDescriptor(TEST11, "overloaded both", 0, rule),
new TestDescriptor(TEST12, "overloaded hashCode, should fail on equals", 1, rule),
new TestDescriptor(TEST13, "implements hashCode but with args", 0, rule),
});
}
@ -109,4 +110,11 @@ public class OverrideBothEqualsAndHashcodeTest extends SimpleAggregatorTst {
" public boolean equals(Object o1) { return false; }" + PMD.EOL +
" public int hashCode(Object o1) { return false; }" + PMD.EOL +
"}";
private static final String TEST13 =
"public class Foo {" + PMD.EOL +
" public int hashCode(double a[]) {" + PMD.EOL +
" return 0;" + PMD.EOL +
" }" + PMD.EOL +
"}";
}

View File

@ -60,11 +60,11 @@ public class OverrideBothEqualsAndHashcode extends AbstractRule {
if (sn.getClass().equals(ASTFormalParameters.class)) {
List allParams = ((ASTFormalParameters) sn).findChildrenOfType(ASTFormalParameter.class);
for (int i = 0; i < allParams.size(); i++) {
iFormalParams++;
ASTFormalParameter formalParam = (ASTFormalParameter) allParams.get(i);
ASTClassOrInterfaceType param = (ASTClassOrInterfaceType) formalParam.getFirstChildOfType(ASTClassOrInterfaceType.class);
if (param != null) {
paramName = param.getImage();
iFormalParams++;
}
}
}