Return value of function without any return statement should not be used

  • MISSING_RETURN_VALUE
  • Error
  • Medium
  • No tags

This rule applies when return value is used even though the function has no return statement.

In such a case, it could be a programmer's mistake forgetting a return statement.

Note: This rule applies only when the return value is assigned to an object property because in other cases, it is often intended or harmless.

Noncompliant Code Example

View with compliant examples side by side
function add(x, y) {
    x + y;
}
obj.total = add(1, 2); // MISSING_RETURN_VALUE alarm because function 'add' does not return a value.

Compliant Code Example

View with noncompliant examples side by side
function add(x, y) {
    return x + y;
}
obj.total = add(1, 2);

Version

This rule was introduced in DeepScan 1.0.0-alpha.

Was this documentation helpful?