#1431 SuspiciousEqualsMethodName false positive

This commit is contained in:
Andreas Dangel
2015-11-19 22:06:51 +01:00
parent f2ec1be93f
commit d621707e2f
3 changed files with 16 additions and 0 deletions

View File

@ -318,6 +318,7 @@ intention to override the equals(Object) method.
count(FormalParameters/*) = 2
and ../ResultType/Type/PrimitiveType[@Image = 'boolean']
and FormalParameters//ClassOrInterfaceType[@Image = 'Object' or @Image = 'java.lang.Object']
and not(../../Annotation/MarkerAnnotation/Name[@Image='Override'])
)
]
| //MethodDeclarator[@Image = 'equal']

View File

@ -33,4 +33,17 @@ public class Foo {
}
]]></code>
</test-code>
<test-code>
<description>#1431 SuspiciousEqualsMethodName false positive</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Demo implements org.hibernate.usertype.UserType {
@Override
public boolean equals(Object x, Object y) throws HibernateException {
return x == null ? y == null : x.equals(y);
}
}
]]></code>
</test-code>
</test-data>