Scala

Scala

Made by DeepSource

Duplicate case in pattern-matching SC-W1007

Bug risk
Major

Duplicate cases in pattern matching are unreachable and are usually the result of human error. Because such cases are unreachable, they have the potential to affect the overall control-flow and the behaviour of the program. It is suggested that you remove such duplicate cases.

Bad Practice

someVar match {
  case foo => ...
  case bar => ...
  case baz => ...
  case foo => ... // This case is unreachable!
}

Recommended

someVar match {
  case foo => ...
  case bar => ...
  case baz => ...
}