String functions should not be used on number values

  • BAD_NUMBER_FUNC
  • Error
  • High
  • No tags

This rule applies when string functions are used on number values.

When string functions are called on number values, a TypeError exception occurs.

Noncompliant Code Example

View with compliant examples side by side
var x = 1234;
var y = (x / 100).indexOf('.'); // BAD_NUMBER_FUNC alarm

Compliant Code Example

View with noncompliant examples side by side
var x = 1234;
var y = String(x / 100).indexOf('.');

Version

This rule was introduced in DeepScan 1.0.0-alpha.

See

Was this documentation helpful?