forked from phoedos/pmd
Applied patch 2822131: Enhance SuspiciousEqualsMethodName, thanks to Andy Throgmorton
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.3.x@7402 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
14cc641316
commit
f2ac93a42d
@ -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
|
||||
|
@ -308,21 +308,24 @@ method.
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//MethodDeclarator[
|
||||
(
|
||||
@Image = 'equals'
|
||||
and count(FormalParameters/*) = 1
|
||||
//MethodDeclarator[@Image = 'equals']
|
||||
[
|
||||
(count(FormalParameters/*) = 1
|
||||
and not (FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
|
||||
[@Image = 'Object' or @Image = 'java.lang.Object'])
|
||||
or not (../ResultType/Type/PrimitiveType[@Image = 'boolean'])
|
||||
) or (
|
||||
count(FormalParameters/*) = 2
|
||||
and ../ResultType/Type/PrimitiveType[@Image = 'boolean']
|
||||
and FormalParameters//ClassOrInterfaceType[@Image = 'Object' or @Image = 'java.lang.Object']
|
||||
)
|
||||
or
|
||||
@Image='equal'
|
||||
and count(FormalParameters/*) = 1
|
||||
and (FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
|
||||
[@Image = 'Object' or @Image = 'java.lang.Object'])
|
||||
|
||||
]
|
||||
]]>
|
||||
| //MethodDeclarator[@Image = 'equal']
|
||||
[
|
||||
count(FormalParameters/*) = 1
|
||||
and FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
|
||||
[@Image = 'Object' or @Image = 'java.lang.Object']
|
||||
] ]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
|
Loading…
x
Reference in New Issue
Block a user