Skip to content

@release-drafter release-drafter released this Nov 27, 2019 · 46 commits to master since this release

Thanks to the heroic efforts of @kitbellew, a lot of longstanding formatting quirks have been fixed in this release. If no issues are reported before December 4th, then this release will be promoted to v2.3.0.

Lambda parameters no longer force a newline

Previously, Scalafmt would force a newline before lambda parameters inside parentheses like this.

  x =>
      .collect { ... })

Now, Scalafmt puts the parameter on the same line as the opening parenthesis

List(1).map(x =>
    .collect { ... })

Example diffs from the wild

Screenshot 2019-11-27 at 15 09 00

Screenshot 2019-11-27 at 15 08 28

For more examples, see the huge diff in kitbellew/scala-repos@0ea4865?diff=unified

try/finally format similarly to if/else now

Previously, Scalafmt formatted try/finally in a funny way, see #350. Now, try/finally blocks format the same way as if/else.

One example:

// original
val template: String = try source.mkString finally source.close()
// before (old behavior)
val template: String = try source.mkString
finally source.close()
// after (new behavior)
val template: String =
  try source.mkString
  finally source.close()

For more example, see the huge diff in kitbellew/scala-repos@6199bb3?w=1&diff=unified

Native images for macOS and Linux

Our CI now builds native scalafmt binaries with instant startup and fast performance for short-lived runs. Download and in this release to try it out. To download a native binary for any pull request or merged commit in master open the "Actions" section on GitHub ( and download from the "Artifacts" tab under a given CI run

Screenshot 2019-11-27 at 10 57 45

Big thanks to @mroth for creating, which was the inspiration for this feature!

Steady performance improvements

The performance of Scalafmt has consistently improved over recent releases. The same benchmark formatting a ~4665 line file now completes in 0.63x of the time with v2.3.0 compared to v1.5.1 (which was released in April 2018).

# v2.3.0 (this release)
[info] Micro.ExtraLarge.scalafmt  avgt   30  831.742 ± 49.979  ms/op
# v2.2.1
[info] Micro.ExtraLarge.scalafmt  avgt   30  901.238 ± 10.708  ms/op
# v2.1.1
[info] Micro.ExtraLarge.scalafmt  avgt   30  1262.053 ± 24.818  ms/op
# v1.5.1
[info] Micro.ExtraLarge.scalafmt  avgt   30  1314.987 ± 47.105  ms/op

Staying on the old formatting behavior

To preserve the formatting behavior of the previous release, add the following to .scalafmt.conf

edition = 2019-10

The edition setting exists to allow users to upgrade to the latest Scalafmt version while keeping the old formatting output. We always recommend upgrading to the latest Scalafmt to enjoy performance improvements and the latest fixes in the parser. We encourage everybody to stay on the latest edition in order to enjoy the latest improvements in formatting output.

Please report issues if you encounter unwanted formatting changes when upgrading Scalafmt without upgrading the edition.

Pull Requests

Assets 4
You can’t perform that action at this time.