val or var name is written in snake_case

ID

scala.maintainability.naming_identifier_style

Severity

info

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

low

Resource

Naming

Language

Scala

Description

Reports a val or var whose name is snake_case - a lower-case start followed by an underscore. Scala names values and variables in lowerCamelCase. Constants declared with final val are covered by their own rule and are not reported here.

Rationale

Mixing snake_case into a lowerCamelCase codebase makes names unpredictable: a reader who wants userName has to guess whether this file spells it user_name, and a search for one spelling misses the other. Underscores also carry meaning of their own in Scala - in identifiers ending in , in *, in operator names - so a mid-name underscore is a form a reader has to stop and parse.

The following code illustrates the pattern detected by this rule:

class NamingIdentifierStyle {
  // FLAGGED: val or var name is written in snake_case
  val user_name = "alice"
}

Remediation

Rename to lowerCamelCase - user_name becomes userName - and let the IDE update the references. Keep snake_case only where the name mirrors an external wire or column name, and in that case isolate it in the mapping layer rather than letting it spread.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved