Skip to content

Scalastyle proposed rules (Pattern matching)

Matthew Farwell edited this page Jul 22, 2012 · 1 revision

This page contains proposed rules for Scalastyle, section Modifiers.

Pattern Matching

Pattern Matching against existing uncapitalized identifier

This rule detect when pattern-matching against an existing uncapitalized identifier. Since the matching will ignore/shadow the existing identifier, it could be a sign of mistake by the developer. Any time a pattern variable match an in-scope identifier. Even with backtick.

Configuration

In any case the check does not pass when the previous case occurs. But there are different configurable resolution for which the check will pass when the code try to match on an existing identifier value:

  • nobacktick: the check will refuse backticked identifier.
  • constant: the check will accept constant identifier (ie identifier passing the constant check (todo: link)). This could imply backtick if the constant pattern tolerate uncapitalized names.
  • backtickOrConstant: any explicitation will make the check pass.