Skip to content

Scalastyle proposed rules (Modifiers)

sschaef edited this page Dec 12, 2012 · 5 revisions

This page contains proposed rules for Scalastyle, section Modifiers.

Modifiers

ModifierOrder

Checks that the order of modifiers conforms to the suggestions in the Scala style guide. The correct order is: to be defined.

RedundantModifier

Checks for redundant modifiers in:

  • trait definitions (such as abstract trait T)
  • the final modifier on methods of final classes (final class Foo { final def foo() = 4 })

Rationale: It adds needless code to files.

Variables in interfaces and annotations are automatically public, static and final, so these modifiers are redundant as well.

As annotations are a form of interface, their fields are also automatically public, static and final just as their annotation fields are automatically public and abstract. Final classes by definition can not be extended so the final modifier on the method of a final class is redundant.

Public on inner methods

Do not raise the error message "public methods must have an explicit written type" when they are inside of another method:

def f {
  def g {} // g is public but not visible to the outside
}