else
in else if
SC-R1015else
in else if
becomes redundant and can be dropped if the last statement under if's then
block is a return
statement. This improves code-readability and is easy to maintain.
if (/* some condition */) {
// do something
return someValue
} else if (/* some other condition */) { // simplification - `else` can be dropped here
// do something
return otherValue
}
if (/* some condition */) {
// do something
return someValue
}
if (/* some other condition */) {
// do something
return otherValue
}