Introduction
Any style guide written in English is either so brief that it’s ambiguous, or so long that no one reads it. - Bob Nystrom, Hardest Program I've Ever Written, Dart, Google.
scalafmt turns the mess on left
on the top into the (hopefully)
readable, idiomatic and consistently formatted Scala code
on the right
at the bottom.
object FormatMe { List(number) match
{ case head :: Nil
if head % 2 == 0 => "number is even"
case head :: Nil =>
"number is not even"
case Nil =>
"List is empty" }
function(arg1,
arg2(arg3(arg4,
arg5, "arg6")
, arg7 + arg8),
arg9.select(1, 2,
3, 4, 5, 6)) }
object FormatMe {
List(number) match {
case head :: Nil if head % 2 == 0 =>
"number is even"
case head :: Nil =>
"number is not even"
case Nil =>
"List is empty"
}
function(
arg1,
arg2(
arg3(arg4, arg5, "arg6"),
arg7 + arg8
),
arg9.select(1, 2, 3, 4, 5, 6)
)
}
The goal of scalafmt is to produce good enough formatted code so that you can focus on programming instead of manipulating syntax trivia. Scalafmt can be used in several environments such as the command line, text editors and build tools.
It is not a goal to format every single Scala source file under the sun. In particular, scalafmt cannot format deeply nested computer generated code.
Scalafmt is maintained by @olafurpg in his free time. Bug reports, feature requests, questions and PRs are welcome. Complaints and unfriendly attitude is not welcome.
Curious to learn more about scalafmt? Check out this talk: