Scala

Scala

Made by DeepSource

Duplicated then and else blocks SC-W1027

Bug risk
Critical

The same code is duplicated in the then and else blocks of this if expression, meaning that regardless of whether this condition is true or false, the program executes the same set of instructions.

Usually, an if expression's then and else blocks perform different actions. However, the analyzer has detected that in this case, both the blocks are the same. This means that your program will execute the same code regardless of the if condition's outcome, making it redundant. This is usually due to human error and warrants investigation.

Bad practice

if (/* some if-condition */) {
  // SOME_BLOCK
} else {
  // SOME_BLOCK
}

Recommended

if (/* some if-condition */) {
  // THEN_BLOCK
} else {
  // ELSE_BLOCK
}