Scala

Scala

Made by DeepSource

Pattern matching only mentions wildcard patterns SC-R1066

Anti-pattern
Major

Classes that are either case or that implement the unapply() method allow you to utilize pattern matching. However, in this case, all the patterns specified in the pattern matching are wildcard patterns. Either this is a mistake or you meant to simply match a specific type. In the latter's case, consider using the syntax v: Tpe.

Bad Practice

c match {
  case C(_, _, _) => // matched!
  // ...
}

Recommended

// Resolution 1: Specify a non-wildcard pattern
c match {
  case C(1, _, _) => // matched!
  // ...
}

// Resolution 2: Match type
c match {
  case v: C => // matched!
  // ...
}