diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 45b2938aae..931b26a82a 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -8,6 +8,7 @@ Fix small bug in Rule Designer UI Improve TooManyMethods rule - thanks to a patch from Riku Nykanen Improve DoNotCallSystemExit - thanks to a patch from Steven Christou Fix false negative for UseArraysAsList when the array was passed as method parameter - thanks to Andy Throgmorton +Enhanced SuspiciousEqualsMethodName rule - thanks to Andy Throgmorton New Rule: Basic ruleset: DontCallThreadRun - thanks to Andy Throgmorton diff --git a/pmd/rulesets/naming.xml b/pmd/rulesets/naming.xml index b4318421b0..599e5c1d38 100644 --- a/pmd/rulesets/naming.xml +++ b/pmd/rulesets/naming.xml @@ -308,21 +308,24 @@ method. +| //MethodDeclarator[@Image = 'equal'] +[ + count(FormalParameters/*) = 1 + and FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType + [@Image = 'Object' or @Image = 'java.lang.Object'] +] ]]> @@ -335,6 +338,9 @@ public class Foo { public boolean equals(String s) { // oops, this probably was supposed to be equals(Object) } + public boolean equals(Object o1, Object o2) { + // oops, this probably was supposed to be equals(Object) + } } ]]>