OverrideBothEqualsAndHashcode bug with interfaces
A source code analyzer
Brought to you by:
adangel,
juansotuyo
Hope this is a) a real bug and b) not posted yet (havent found anything here)
OverrideBothEqualsAndHashcode does not work correctly with classes implementing an interface.
Example:
package de.my.package.ui;
// PMD reports correctly a violation prio 1
public class XX {
public boolean equals(Object obj) {
return true;
}
}
package de.my.package.ui;
// PMD does NOT report a violation
public class YY implements java.io.Serializable {
public boolean equals(Object obj) {
return true;
}
}
We are using PMD 4.2.5 and Eclipse 3.4.2
Thanks
I failed to reproduce your issue.... Would mind try to reproduce it out of Eclipse (using a pmd command line or inside ant/maven) ?
Thanks.
I ran PMD on console with the classes above.
<pmd version="4.2.5" timestamp="2009-04-28T13:13:45.077">
<file name="C:\Dokumente und Einstellungen\gisja\Desktop\download\pmd-4.2.5\bin\XX.java">
<violation beginline="2" endline="2" begincolumn="20" endcolumn="35" rule="OverrideBothEqualsAndHashcode" ruleset="Basic Rules" class="" method="equals" externalinfourl="http://pmd.sourceforge.net/rules/basic.html#OverrideBothEqualsAndHashcode" priority="3">
Ensure you override both equals() and hashCode()
</violation>
</file>
</pmd>
So this is correct....
with the YY.java class:
<pmd version="4.2.5" timestamp="2009-04-28T13:14:23.685">
</pmd>
Which is NOT correct - should have complained
This was done with a fresh download of pmd 4.2.5
Thanks
Any new status for that ?