'equals()' called on itself
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:
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
EqualsWithItself- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
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.
Inspection options
Here you can find the description of settings available for the 'equals()' called on itself inspection, and the reference of their default values.
- Warn about test assertions only on final library class types or primitives
Not selected
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 242.22892 |