Avoid functions with inconsistent return types

Impact area

Manageability

Severity

Medium

Affected element

Lightning

Rule ID

SF-0056

Impact

When a function returns a value explicitly but the code path does not, it might be a typing mistake, especially in a large function.

Remediation

Refactor the code to use consisten return statements.

// Ok
function foo() {
if (condition1) {return true;}
return false;
}

// Bad
function bar() {
if (condition1) {return;}
return false;
}

Time to fix

30 min

References

See the PMD documentation article: ConsistentReturn.

What's here


Related content

PMD - Lightning rules




Last modified on Jun 10, 2020