Skip to content

scalafmt 3.7.2 does not respect verticalMultiline.arityThreshold #3509

@keywordsalad

Description

@keywordsalad

Configuration (required)

Please paste the contents of your .scalafmt.conf file here:

version: 3.7.2

runner.dialect: scala213

maxColumn: 120
docstrings.style: Asterisk
docstrings.wrap: "yes"
assumeStandardLibraryStripMargin: true
align.preset: none
trailingCommas: multiple
lineEndings: unix

continuationIndent {
  callSite: 2
  defnSite: 2
  extendSite: 2
}

newlines {
  alwaysBeforeElseAfterCurlyIf: false
  beforeCurlyLambdaParams: never
}

verticalMultiline {
  atDefnSite: true
  newlineAfterOpenParen: true
  arityThreshold: 5
}

Command-line parameters (required)

When I run scalafmt via CLI like this: sbt scalafmtAll

Steps

Given code like this:

package logging

object Log {
  def redactIds(s: String): String = s.replaceAll("\\d{5,}", "<redacted>")

  def showThrowable(e: Throwable): String =
     Option(e.getMessage)
       .filter(_.nonEmpty)
       .fold(e.getClass.getName)(m => s"${e.getClass.getName}: ${redactIds(m)}")

Problem

Scalafmt formats code like this:

package logging

object Log {
  def redactIds(
    s: String
  ): String = s.replaceAll("\\d{5,}", "<redacted>")

  def showThrowable(
    e: Throwable
  ): String =
     Option(e.getMessage)
       .filter(_.nonEmpty)
       .fold(e.getClass.getName)(m => s"${e.getClass.getName}: ${redactIds(m)}")

Expectation

I would like the formatted output to look like this:

package logging

object Log {
  def redactIds(s: String): String = s.replaceAll("\\d{5,}", "<redacted>")

  def showThrowable(e: Throwable): String =
     Option(e.getMessage)
       .filter(_.nonEmpty)
       .fold(e.getClass.getName)(m => s"${e.getClass.getName}: ${redactIds(m)}")

Workaround

Use 3.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions