in and instanceof should have a right operand of proper type

  • BAD_OPERAND_TYPE
  • Error
  • High
  • No tags

This rule applies when in and instanceof operators have a right operand of wrong type.

It can be applied to the following:

  1. Right operand of in operator is not an object
  2. Right operand of instanceof operator is not a constructor

Noncompliant Code Example

// Example 1
"prop" in 42; // BAD_OPERAND_TYPE alarm

// Example 2
function f() {
}
var x = new f();
var b = x instanceof "string"; // BAD_OPERAND_TYPE alarm

Compliant Code Example

function f() {
}
var x = new f();
var b = x instanceof f;

Version

This rule was introduced in DeepScan 1.0.0-alpha.

See