Why this matters
null is never an instance of any class, making explicit null checks redundant when using instanceof. This check should be removed.
instanceofEnsure that explicit null checks are not used with instanceof, as null is never an instance of any class.
null is never an instance of any class, making explicit null checks redundant when using instanceof. This check should be removed.
Side-by-side examples engineers can pattern-match during review.
if (x != null && x instanceof MyClass) { ... } // Noncompliant
if (x == null || ! x instanceof MyClass) { ... } // Noncompliantif (x instanceof MyClass) { ... }
if (! x instanceof MyClass) { ... }From the same buckets as this rule.