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

[Bug] scalafmt 2.3.0-RC2 throws error when trying to format my code #1583

Closed
tanvn opened this issue Dec 3, 2019 · 2 comments · Fixed by #1588
Closed

[Bug] scalafmt 2.3.0-RC2 throws error when trying to format my code #1583

tanvn opened this issue Dec 3, 2019 · 2 comments · Fixed by #1588

Comments

@tanvn
Copy link

tanvn commented Dec 3, 2019

  • Integration: IntelliJ
  • Configuration:
version = 2.3.0-RC2
docstrings = ScalaDoc
maxColumn = 100

newlines.alwaysBeforeTopLevelStatements = true

rewrite.rules = [
  AvoidInfix        
  RedundantBraces   
  RedundantParens   
  SortImports 
  PreferCurlyFors 
]

rewrite.redundantBraces.generalExpressions = false

rewrite.redundantBraces.maxLines = 1
trailingCommas = preserve

Steps

Given code like this:

package fmt

import java.time.LocalDateTime

object Test {

  def main(args: Array[String]): Unit = {

    val profiles = Seq(
      Profile("TanVn", Some(LocalDateTime.now())),
      Profile("TanVn2",Some(LocalDateTime.now().minusDays(10)))
    )
    val patitions = profiles.partition( p => p.createdAt match {
      case Some(value) => value.getYear < 2019
      case None =>false
    })
  }

}

case class Profile(
    name: String,
    createdAt: Option[LocalDateTime]
)

When I run scalafmt like this:

scalafmt

Problem

Scalafmt formats code like this:

error: { expected but case found
@olafurpg
Copy link
Member

olafurpg commented Dec 3, 2019

Thank you for reporting and minimizing the issue! @kitbellew this looks related to RedundantBraces

@kitbellew
Copy link
Collaborator

@olafurpg thank you, will take a look. travelling this week, might be slightly delayed.

kitbellew added a commit to kitbellew/scalafmt that referenced this issue Dec 5, 2019
kitbellew added a commit to kitbellew/scalafmt that referenced this issue Dec 5, 2019
kitbellew added a commit that referenced this issue Dec 6, 2019
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.

3 participants