scalafix icon indicating copy to clipboard operation
scalafix copied to clipboard

sbt-scalafix: default scalafixScalaBinaryVersion to scalaBinaryVersion

Open bjaglin opened this issue 2 years ago • 3 comments

For ExplicitResultTypes to work out of the box, it would better to set by default

scalafixScalaBinaryVersion := scalaBinaryVersion.value

Current blockers:

  • confirm all major rules are cross-published in _2.12 and _2.13 (no need for _3 assuming we have an automatic fallback to _213 in reflect_3)
  • more actionnable message when community rules cannot be found
  • https://github.com/scalacenter/scalafix/issues/1583

bjaglin avatar Aug 16 '22 12:08 bjaglin

In the short term would a note about adding the scalafixScalaBinaryVersion to build.sbt in ExplicitResultTypes documentation be of any use?

Eg.

The ExplicitResultTypes rule needs to run with the same Scala binary version as the one used to compile target sources. Please add the following scalafixScalaBinaryVersion to your build.sbt file:

scalafixScalaBinaryVersion := scalaBinaryVersion.value //supported versions are 2.11, 2.12, 2.13

I stumbled across this issue recently and would have found some documentation about configuring scalafixScalaBinaryVersion at the location of the rule configuration helpful.

ssanj avatar Aug 17 '22 11:08 ssanj

In the short term would a note about adding the scalafixScalaBinaryVersion to build.sbt in ExplicitResultTypes documentation be of any use?

Feel free to open a PR to update the docs. Remember this page is about scalafix, so your message should mention that this hint is for sbt only.

I am not familiar with community clients, but it looks like the scala binary version is not configurable for the mill and the maven ones (to be confirmed):

  • https://github.com/joan38/mill-scalafix/blob/05eedb866b52fbb88070987c83d14a169a77b16d/mill-scalafix/src/com/goyeau/mill/scalafix/ScalafixModule.scala#L26
  • https://github.com/evis/scalafix-maven-plugin/blob/dc5d953b9614b0883a46249e567b3929074f83fd/pom.xml#L37

bjaglin avatar Aug 17 '22 21:08 bjaglin

Feel free to open a PR to update the docs. Remember this page is about scalafix, so your message should mention that this hint is for sbt only.

Sure. The installation page only has explicit config for SBT, so I was going to do something similar to that.

I will mention that it's only for SBT.

ssahayam-zd avatar Aug 18 '22 00:08 ssahayam-zd