#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 count(FormalParameters/*) = 2
and ../ResultType/Type/PrimitiveType[@Image = 'boolean'] and ../ResultType/Type/PrimitiveType[@Image = 'boolean']
and FormalParameters//ClassOrInterfaceType[@Image = 'Object' or @Image = 'java.lang.Object'] and FormalParameters//ClassOrInterfaceType[@Image = 'Object' or @Image = 'java.lang.Object']
and not(../../Annotation/MarkerAnnotation/Name[@Image='Override'])
) )
] ]
| //MethodDeclarator[@Image = 'equal'] | //MethodDeclarator[@Image = 'equal']

View File

@ -33,4 +33,17 @@ public class Foo {
} }
]]></code> ]]></code>
</test-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> </test-data>

View File

@ -23,6 +23,8 @@
* [#1438](https://sourceforge.net/p/pmd/bugs/1438/): UseNotifyAllInsteadOfNotify gives false positive * [#1438](https://sourceforge.net/p/pmd/bugs/1438/): UseNotifyAllInsteadOfNotify gives false positive
* java-finalizers/AvoidCallingFinalize * java-finalizers/AvoidCallingFinalize
* [#1440](https://sourceforge.net/p/pmd/bugs/1440/): NPE in AvoidCallingFinalize * [#1440](https://sourceforge.net/p/pmd/bugs/1440/): NPE in AvoidCallingFinalize
* java-naming/SuspiciousEqualsMethodName
* [#1431](https://sourceforge.net/p/pmd/bugs/1431/): SuspiciousEqualsMethodName false positive
* java-optimizations/RedundantFieldInitializer * java-optimizations/RedundantFieldInitializer
* [#1443](https://sourceforge.net/p/pmd/bugs/1443/): RedundantFieldInitializer: False positive for small floats * [#1443](https://sourceforge.net/p/pmd/bugs/1443/): RedundantFieldInitializer: False positive for small floats
* java-unusedcode/UnusedPrivateField * java-unusedcode/UnusedPrivateField