Scala

Scala

Made by DeepSource

Redundant else in else if SC-R1015

Anti-pattern
Minor

else 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.

Bad practice

if (/* some condition */) {
  // do something
  return someValue
} else if (/* some other condition */) {            // simplification - `else` can be dropped here
  // do something
  return otherValue
}

Recommended

if (/* some condition */) {
  // do something
  return someValue
}

if (/* some other condition */) {
  // do something
  return otherValue
}