Skip to content

Releases: scalameta/scalafmt

v2.5.0-RC2

25 Apr 15:24
Compare
Choose a tag to compare

Pull Requests

v2.5.0-RC1

15 Apr 16:44
Compare
Choose a tag to compare

TL;DR

This release candidate may be unstable but we will be grateful for early adoption and bug reports. More detailed release notes coming soon with stable release.

Migration Guide

In this release changed default formatting of hex literals and literals in scientific notation. Currently hex digits and e symbol will lowercased. More details is in the documentation. If you don't want large diff after scalafmt update, you can set

literals.hexDigits=unchanged
literals.scientific=unchanged

newlines.alwaysBeforeMultilineDef may seem too aggressive now. You can disable it if you don't like newlines in diff newlines.alwaysBeforeMultilineDef=false.

Usage Improvements

Formatting Improvements

Bugfixes

  • Fixed AST changes after formatting variant types with symbolic name (#1762) @poslegm
  • Router bugfix: extend line break past infix for any block (#1766) @kitbellew
  • Router bugfix: regression in statement/comments (#1854) @kitbellew
  • "// format: off" enabled for comments, literals, etc. (#1773) @poslegm
  • Fixed contradiction between blankLineBeforeDocstring name and value (#1768) @poslegm
  • Fixed newlines on NewAnonymous with empty arguments lambda (#1833) @poslegm
  • Fixed alignment overriding (#1869) @poslegm

Documentation

Build and Code Health

Dependency Updates

Scalafmt v2.4.2

22 Feb 23:52
Compare
Choose a tag to compare

Features

Bug fixes

Fixes: #448 #1462 #1482 #1485 #1599 #1659 #1714 #1717 #1718 #1720

Pull Requests

Scalafmt v2.4.1

16 Feb 02:00
Compare
Choose a tag to compare

Pull requests

FormatWriter: {} => (): don't rewrite some lambdas (#1709) @kitbellew

Fixes

#1707 #1708

Scalafmt v2.4.0

15 Feb 08:46
Compare
Choose a tag to compare

Pull Requests

Dependency updates

Scalafmt v2.4.0-RC2

09 Feb 15:58
Compare
Choose a tag to compare

Edition 2020-01

Formatting and rewrite of single-line curly lambdas

Allow curly lambdas to format on a single line

Screen Shot 2020-02-09 at 07 34 56

RedundantBraces: Replace inner braces and parens with outer braces for single-line lambdas (previously, only multiline)

Screen Shot 2020-02-09 at 07 46 31

RedundantBraces: Format single-line curly lambdas using parens

Screen Shot 2020-02-09 at 07 41 55

Other apply and init rewrites

RedundantParens: Remove parens around an apply of block

Screen Shot 2020-02-09 at 07 44 12

RedundantBraces: Remove braces around an apply argument

Screen Shot 2020-02-09 at 07 51 08

RedundantBraces: Remove braces around a single-statement lambda in constructors

Screen Shot 2020-02-09 at 07 52 13

Don't force break before parameters of lambda as the only constructor argument

Screen Shot 2020-02-09 at 07 56 17

Fixes

#965 #1027 #1246 #1321

Pull Requests

Dependency updates

Scalafmt v2.4.0-RC1

01 Feb 16:12
1a09e1f
Compare
Choose a tag to compare

Edition 2020-01

Line breaks

Allow breaks after assignment

Screen Shot 2020-02-01 at 07 46 31

Preserve line breaks before single-line comments when bin-packing

Screen Shot 2020-02-01 at 07 48 35

Breaks within a method call if a long single-line comment follows

Screen Shot 2020-02-01 at 07 54 00

Preserve single-line formatting for if/try: fixed issues #271 #1002 #1043

Screen Shot 2020-02-01 at 08 15 13

Fix formatting for lambda functions in infix expressions:

Screen Shot 2020-02-01 at 08 07 43

Avoid line-too-long in lambda functions:

Screen Shot 2020-02-01 at 08 09 04

Rewrite rules

  • Abide by "no-format" tags when rewriting
  • Fix rewrite rules for infix expressions
  • Fix newline handling while rewriting, such as to preserve config-style formatting

Fixes

#271 #1002 #1043 #1413 #1506 #1547 #1592 #1624 #1631 #1633

Pull Requests

Dependency updates

Scalafmt v2.3.2

09 Dec 13:30
43801fd
Compare
Choose a tag to compare

Pull Requests

Scalafmt v2.3.1

06 Dec 10:02
Compare
Choose a tag to compare

This release is mostly identical to 2.3.0-RC1 excluding a small regression fix for RedundantBraces and library dependency updates from Scala Steward.

v2.3.0-RC2 Release notes

See https://github.com/scalameta/scalafmt/releases/tag/v2.3.0-RC2

Pull Requests

Dependency updates

Scalafmt v2.3.0-RC2

27 Nov 16:57
Compare
Choose a tag to compare

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.

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

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

List(1).map(x =>
  someOperation(x)
    .map(fn)
    .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 scalafmt-macos.zip and scalafmt-linux.zip 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 (https://github.com/scalameta/scalafmt/actions) 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 https://github.com/mroth/scalafmt-native, 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