sbt-typelevel icon indicating copy to clipboard operation
sbt-typelevel copied to clipboard

Provide an option to exclude a certain version of Scala from running scalafix

Open iRevive opened this issue 3 years ago • 3 comments

When tlCiScalafixCheck := true the following step is generated:

- name: Check scalafix lints
  if: matrix.java == 'temurin@8'
  run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'scalafixAll --check'

Unfortunately, some scalafix rules do not work with Scala 3.

It would be nice to have an option to exclude a certain version of scala from running scalafix. For example:

tlCiScalafixExcludedScalaVersion := List("3.1.2")

Generated step:

- name: Check scalafix lints
  if: matrix.java == 'temurin@8' && matrix.scala != '3.1.2'
  run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'scalafixAll --check'

iRevive avatar Jun 19 '22 10:06 iRevive

Thanks, this is a thorny issue. The good news is scalafix might be coming to Scala 3 in the near future.

I'd like to think of alternative solutions for this as well. For example, some projects have Scala 3-only sources (alongside shared and Scala 2-only sources), and it would be a shame if they can not benefit from at least the supported rules, for example organizing imports (without removing unused). One way would be to use different .scalafix-2.conf and .scalafix-3.conf.

armanbilge avatar Jun 19 '22 14:06 armanbilge

The idea to use different configs sounds like a great option.

iRevive avatar Jun 19 '22 14:06 iRevive

Scalafix may be available for Scala 3 in the near future.

  • https://github.com/scalacenter/scalafix/pull/1629

armanbilge avatar Jul 15 '22 19:07 armanbilge

Scalafix support for Scala 3 already merged, and will hopefully be published soon. So IMO there is no reason to pursue this issue any further.

https://contributors.scala-lang.org/t/scalafix-cross-compiled-for-scala-3-gsoc-2022/6001

armanbilge avatar Nov 09 '22 20:11 armanbilge