Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalafmt 3.7.2 does not respect verticalMultiline.arityThreshold #3509

Closed
keywordsalad opened this issue Mar 14, 2023 · 0 comments · Fixed by #3511
Closed

scalafmt 3.7.2 does not respect verticalMultiline.arityThreshold #3509

keywordsalad opened this issue Mar 14, 2023 · 0 comments · Fixed by #3511

Comments

@keywordsalad
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant