scalastyle-sbt-plugin icon indicating copy to clipboard operation
scalastyle-sbt-plugin copied to clipboard

Trailing commas lead to very confusing scalastyle errors

Open steinybot opened this issue 7 years ago • 2 comments

Trailing commas lead to very confusing errors. Trailing commas were added in SIP-27 (Scala 2.12.2). I don't actually use them intentionally but it can take a very long time to find it since scalac passes but scalastyle fails without any line information and usually on an unrelated token.

For example:

[error] MySpec.scala: illegal start of simple expression: Token(RPAREN,),295,))
import org.scalatest.FlatSpec
import org.scalatest.prop.GeneratorDrivenPropertyChecks

class MySpec extends FlatSpec with GeneratorDrivenPropertyChecks {

  case class Foo(a: String, b: Int)

  Foo(
    "hello",
    123,
  )
}

steinybot avatar Oct 17 '18 01:10 steinybot

Relevant ticket is https://github.com/scalastyle/scalastyle/issues/276

jtjeferreira avatar Jan 23 '19 10:01 jtjeferreira

This comment may be of interest https://github.com/scalastyle/scalastyle/issues/327#issuecomment-531173988

BardurArantsson avatar Sep 13 '19 09:09 BardurArantsson