Merge branch 'suspicious-equals' into master

This commit is contained in:
Clément Fournier
2020-08-25 14:40:33 +02:00
2 changed files with 8 additions and 2 deletions

View File

@ -96,6 +96,7 @@ For the changes, see [PMD Designer Changelog](https://github.com/pmd/pmd-designe
* [#2108](https://github.com/pmd/pmd/issues/2108): \[java] \[doc] ImmutableField rule: Description should clarify shallow immutability
* [#2461](https://github.com/pmd/pmd/issues/2461): \[java] ExcessiveParameterListRule must ignore a private constructor
* java-errorprone
* [#2264](https://github.com/pmd/pmd/issues/2264): \[java] SuspiciousEqualsMethodName: Improve description about error-prone overloading of equals()
* [#2410](https://github.com/pmd/pmd/issues/2410): \[java] ProperCloneImplementation not valid for final class
* [#2431](https://github.com/pmd/pmd/issues/2431): \[java] InvalidLogMessageFormatRule throws IndexOutOfBoundsException when only logging exception message
* [#2439](https://github.com/pmd/pmd/issues/2439): \[java] AvoidCatchingThrowable can not detect the case: catch (java.lang.Throwable t)
@ -178,6 +179,7 @@ are deprecated as internal API.
* [#2700](https://github.com/pmd/pmd/pull/2700): \[java] Fix OnlyOneReturn code example - [Jan-Lukas Else](https://github.com/jlelse)
* [#2722](https://github.com/pmd/pmd/pull/2722): \[doc] \[java] ImmutableField: extend description, fixes #2108 - [Mateusz Stefanski](https://github.com/mateusz-stefanski)
* [#2723](https://github.com/pmd/pmd/pull/2723): \[doc] \[java] SimplifyStartsWith: update description and example, fixes #1868 - [Mateusz Stefanski](https://github.com/mateusz-stefanski)
* [#2724](https://github.com/pmd/pmd/pull/2724): \[doc] [java] SuspiciousEqualsMethodName: update description, fixes #2264 - [Mateusz Stefanski](https://github.com/mateusz-stefanski)
* [#2725](https://github.com/pmd/pmd/pull/2725): Cleanup: change valueOf to parse when we need primitive return value. - [XenoAmess](https://github.com/XenoAmess)
* [#2726](https://github.com/pmd/pmd/pull/2726): Cleanup: replace StringBuffer with StringBuilder - [XenoAmess](https://github.com/XenoAmess)
* [#2727](https://github.com/pmd/pmd/pull/2727): Cleanup: replace indexOf() < 0 with contains - [XenoAmess](https://github.com/XenoAmess)

View File

@ -3052,8 +3052,12 @@ StringBuilder sb4 = new StringBuilder("c");
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#suspiciousequalsmethodname">
<description>
The method name and parameter number are suspiciously close to equals(Object), which can denote an
intention to override the equals(Object) method.
The method name and parameter number are suspiciously close to `Object.equals`, which can denote an
intention to override it. However, the method does not override `Object.equals`, but overloads it instead.
Overloading `Object.equals` method is confusing for other programmers, error-prone and hard to maintain,
especially when using inheritance, because `@Override` annotations used in subclasses can provide a false
sense of security. For more information on `Object.equals` method, see Effective Java, 3rd Edition,
Item 10: Obey the general contract when overriding equals.
</description>
<priority>2</priority>
<properties>