scalastyle icon indicating copy to clipboard operation
scalastyle copied to clipboard

Parsing sources with trailing commas (supported since Scala 2.12.2+)

Open nktpro opened this issue 7 years ago • 17 comments

Scala 2.12.2+ added support for trailing commas. However scalastyle currently doesn't parse source files correctly when trailing commas are used. An error similarly to "Expected identifier, but got Token(RPAREN,),xxx,))" is thrown.

As a very simple example:

package foo.bar

object TrailingCommaTest {
  def trailingCommaTest(
    foo: String,
    bar: Boolean,
  ) = {}
}

nktpro avatar Aug 27 '17 01:08 nktpro

It looks like a scalariform issue.. The exception you receive is thrown by scalariform parser.. It would be great if you file an issue here.

canoztokmak avatar Sep 21 '17 16:09 canoztokmak

It is unfortunately true that we are dependent upon scalariform here. We'll need to get them to change it.

matthewfarwell avatar Sep 26 '17 17:09 matthewfarwell

I've commented on a Scalariform PR to push for making incremental progress here: if Scalaiform can get to a point where the parser doesn't crash, even if preservation of trailing commas doesn't work during automated reformatting, then that unblocks a fix here in Scalastyle (solving the problem for folks who use only Scalastyle and not Scalariform) and solves a huge usability issue (confusing error messages). See https://github.com/scala-ide/scalariform/pull/262#issuecomment-427599200

JoshRosen avatar Oct 06 '18 19:10 JoshRosen

Scalariform 0.2.7 has been released (with trailing comma support).

godenji avatar Feb 08 '19 03:02 godenji

https://github.com/scalastyle/scalastyle/pull/332 does the upgrade

SethTisue avatar Feb 08 '19 18:02 SethTisue

Any news on when this might be fixed/released?

adam-ah avatar Feb 13 '19 06:02 adam-ah

hmm, the contributions graph at https://github.com/matthewfarwell doesn't look promising. silence at https://twitter.com/matthewfarwell also

anyone know Matthew IRL and could ask him if he could anoint additional maintainers?

SethTisue avatar Feb 14 '19 20:02 SethTisue

Is there any update on this? It is quite annoying since the error message does not even show where the violation is - may take a while to find out.

zatekusen avatar Mar 07 '19 00:03 zatekusen

issue on new release is https://github.com/scalastyle/scalastyle/issues/327

@matthewfarwell merged #332 a couple days ago

SethTisue avatar Mar 07 '19 00:03 SethTisue

Looking forward to this fix for a long time. @matthewfarwell can you help release a new version or annoint additional maintainers who can help regarding this?

anilkumarmyla avatar Mar 11 '19 20:03 anilkumarmyla

There seems to be no activity on this thread for 2 weeks already. What are our options?

anilkumarmyla avatar Mar 25 '19 23:03 anilkumarmyla

There seems to be no activity on this thread for 2 weeks already. What are our options?

Fork ? I have no answer for 1 year on https://github.com/scalastyle/scalastyle/pull/290

gmarti avatar Mar 26 '19 15:03 gmarti

I've asked for a new release many times now e.g. here and here, but unfortunately had no luck. @matthewfarwell @ScrapCodes @y-yoshinoya are you guys still maintaining this repo? If you need any help, I'm sure there are many people in the community who would be willing to help out and maintain this project.

mwz avatar Mar 26 '19 16:03 mwz

Any one has a workaround for this in gradle? Can we override the scalariform dependency version in the scalastyle gradle plugin?

zatekusen avatar May 02 '19 20:05 zatekusen

Maybe it's time to just fork under a new domain name, even if it's just for a single release?

BardurArantsson avatar May 18 '19 20:05 BardurArantsson

This is still an active issue for my team.

niebloomj avatar Aug 07 '19 01:08 niebloomj

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

BardurArantsson avatar Sep 13 '19 14:09 BardurArantsson