Unnecessary 'null' check before 'equals()' call
Reports comparisons to null
that are followed by a call to equals()
with a constant argument.
Example:
if (s != null && s.equals("literal")) {}
After the quick-fix is applied:
if ("literal".equals(s)) {}
Use the inspection settings to report equals()
calls with a non-constant argument when the argument to equals()
is proven not to be null
.
Inspection options
Option | Type | Default |
---|---|---|
Report equals with non-constant not-null argument | Checkbox | true |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023