Reports calls to equals(), compareTo() or similar, that compare an object for equality with itself. The method contracts of these methods specify that such calls will always return true for equals() or 0 for compareTo(). The inspection also checks calls to Objects.equals(), Objects.deepEquals(), Arrays.equals(), Comparator.compare(), assertEquals() methods of test frameworks (JUnit, TestNG, AssertJ), Integer.compare(), Integer.compareUnsigned() and similar methods.

Example:


  class Foo {
    boolean foo(Object o) {
        return o.equals(o); // warning
    }

    boolean bar(String[] ss) {
        return Arrays.equals(ss, ss); // warning
    }
}

Use the option to report test assertions report only on non-extendable library classes (like String) and primitive types. This option can be useful, when testing equals() methods.