Class, trait or object name does not start with an upper-case letter
ID |
scala.maintainability.naming_class |
Severity |
info |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Naming |
Language |
Scala |
Description
Reports a class, trait or object whose name begins with a lower-case letter or an underscore. Package objects, which are lower-case by convention, are excluded.
Rationale
Capitalisation is not decoration in Scala - it is how a reader, and the pattern matcher, tell a type from a value. In a case pattern a lower-case identifier binds a fresh variable while a capitalised one refers to an existing stable identifier, so a lower-case type name reads as a binding at exactly the place where the distinction decides behaviour.
The following code illustrates the pattern detected by this rule:
// FLAGGED: Class, trait or object name does not start with an upper-case letter
class orderService(repo: String) {
def find(id: Long): String = repo
}