Result of built-in API call should not be ignored when it has no side effect

  • Error
  • Medium
  • cwe

This rule applies when the result of built-in API call, which has no side effects, is not used.

For example, calling substring API on the string has no side effect on itself. So it is useless if the result is not used.

This is likely to be a programmer's misunderstanding. Therefore, the result should not be ignored or the code should be removed.

Noncompliant Code Example

View with compliant examples side by side
var s = 'foobar';
s.substring(0, 3); // NO_EFFECT_CALL alarm because the return value of 'substring' is not used.

Compliant Code Example

View with noncompliant examples side by side
var s = 'foobar';
var ret = s.substring(0, 3);


This rule was introduced in DeepScan 1.0.0-alpha.