instanceof operators that always return true or false are either useless or the result of a misunderstanding which could lead to unexpected behavior in production.

Noncompliant Code Example

public boolean isSuitable(Integer param) {
...
  String name = null;

  if (name instanceof String) { // Noncompliant; always false since name is null
    //...
  }

  if(param instanceof Number) {  // Noncompliant; always true unless param is null, because param is an Integer
    doSomething();
  }
...
}

Compliant Solution

public boolean isSuitable(Integer param) {
...
  doSomething();
...
}

Deprecated

This rule is deprecated; use {rule:java:S2589} instead.