Inspectopedia Help

Unnecessary 'null' check before method call

Reports null checks followed by a method call that will definitely return false when null is passed (e.g. Class.isInstance).

Such a check seems excessive as the method call will always return false in this case.

Example:

if (x != null && myClass.isInstance(x)) { ... }

After the quick-fix is applied:

if (myClass.isInstance(x)) { ... }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023