-
Notifications
You must be signed in to change notification settings - Fork 285
Closed
Description
The Scala Style Guide suggest the following:
Modifiers
Method modifiers should be given in the following order (when each is applicable):
- Annotations, each on their own line
- Override modifier (override)
- Access modifier (protected, private)
- Implicit modifier (implicit)
- Final modifier (final)
- def
@Transaction @throws(classOf[IOException]) override protected final def foo(): Unit = { ... }
Is the current sorting of the modifiers correct and the Scala Style Guide is outdated or is it the other way around?
Configuration (required)
version = 3.8.0 - main branch
...
object SortSettings {
final case class ModKey(
name: String,
matches: Mod => Boolean
)
val defaultOrder: List[ModKey] = List(
ModKey("implicit", _.is[Mod.Implicit]),
//
ModKey("final", _.is[Mod.Final]),
ModKey("sealed", _.is[Mod.Sealed]),
ModKey("abstract", _.is[Mod.Abstract]),
//
ModKey("override", _.is[Mod.Override]),
//
ModKey("private", _.is[Mod.Private]),
ModKey("protected", _.is[Mod.Protected]),
//
ModKey("lazy", _.is[Mod.Lazy]),
ModKey("open", _.is[Mod.Open]),
ModKey("transparent", _.is[Mod.Transparent]),
ModKey("inline", _.is[Mod.Inline]),
ModKey("infix", _.is[Mod.Infix]),
ModKey("opaque", _.is[Mod.Opaque])
)
Command-line parameters (required)
When I run scalafmt via CLI like this: scalafmtAll
Steps
Given code like this:
override protected final def foo(): Unit = {
...
}
Problem
Scalafmt formats code like this:
final override protected def foo(): Unit = {
...
}
Expectation
I would like the formatted output to look like this:
override protected final def foo(): Unit = {
Metadata
Metadata
Assignees
Labels
No labels