Modifier or supertype the compiler already implies
ID |
scala.maintainability.redundant_syntax |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Redundant Code |
Language |
Scala |
Description
Reports declarations that restate what the language already guarantees: final on an object, which is final by construction, and an explicit extends AnyRef on a class or object, which is the default supertype.
Rationale
A modifier that changes nothing still has to be read and understood. final object invites the reader to look for the non-final case that motivated it, and extends AnyRef suggests a deliberate choice of supertype where none was made — so the reader spends attention on a distinction that does not exist, and later edits preserve the noise by imitation.
The following code illustrates the pattern detected by this rule:
// FLAGGED: Modifier or supertype the compiler already implies
final object Registry {
val entries: Map[String, Int] = Map.empty
}