Skip to content

Commit

Permalink
#1431 SuspiciousEqualsMethodName false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
adangel committed Nov 19, 2015
1 parent f2ec1be commit d621707
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions pmd-java/src/main/resources/rulesets/java/naming.xml
Expand Up @@ -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']
Expand Down
Expand Up @@ -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>
2 changes: 2 additions & 0 deletions src/site/markdown/overview/changelog.md
Expand Up @@ -23,6 +23,8 @@
* [#1438](https://sourceforge.net/p/pmd/bugs/1438/): UseNotifyAllInsteadOfNotify gives false positive
* java-finalizers/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
* [#1443](https://sourceforge.net/p/pmd/bugs/1443/): RedundantFieldInitializer: False positive for small floats
* java-unusedcode/UnusedPrivateField
Expand Down

0 comments on commit d621707

Please sign in to comment.