Built-in API should be called with arguments of correct types
- High, Medium
- No tags
This rule applies when built-in API is called with arguments of wrong types.
Because built-in has the specification for its arguments, arguments can cause error or unintended behavior if the types of arguments are wrong.
Noncompliant Code ExampleView with compliant examples side by side
var arr = Array.from(items); var pos_of_three = arr.findIndex(3); // MISMATCHED_TYPE_OF_ARG alarm because 'Array.prototype.findIndex()' takes a function as an argument.
Compliant Code ExampleView with noncompliant examples side by side
var arr = Array.from(items); var pos_of_three = arr.findIndex(item => item === 3);
This rule was introduced in DeepScan 1.4.0-beta.