Result of built-in API call should not be ignored when it has no side effect
- NO_EFFECT_CALL
- 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.
This rule also applies to common Lodash APIs without side effects like omit()
.
Noncompliant Code Example
View with compliant examples side by sidevar 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 sidevar s = 'foobar';
var ret = s.substring(0, 3);
Version
This rule was introduced in DeepScan 1.0.0-alpha.