scalafix icon indicating copy to clipboard operation
scalafix copied to clipboard

sbt "++${{ scala-version }} scalafixAll --check" not parsed correctly

Open ruippeixotog opened this issue 4 years ago • 5 comments
trafficstars

I'm trying to configure scalafix to run on CI on PureConfig. We run one CI job per Scala version and the command we need to run is sbt "++${{ matrix.scala-version }} scalafixAll --check". However, the InputTask that implements scalafixAll doesn't seem to be dealing with the ++ operator correctly:

[info] set current project to pureconfig (in build file:/Users/rui/Documents/Dev/own/pureconfig/)
[error] (core / scalafixAll) scalafix.sbt.InvalidArgument: 27 errors
[error] [E0] Unknown rule 'testkit/scalafixAll'
[error] [E1] Unknown rule 'tests/scalafixAll'
[error] [E2] Unknown rule 'bundle/scalafixAll'
[error] [E3] Unknown rule 'docs/scalafixAll'
[error] [E4] Unknown rule 'akka/scalafixAll'
[error] [E5] Unknown rule 'akka-http/scalafixAll'
[error] [E6] Unknown rule 'cats/scalafixAll'
(...)

This error doesn't happen if I run it without the version selector (sbt "scalafixAll --check").

ruippeixotog avatar Oct 15 '21 00:10 ruippeixotog

I am afraid this is an sbt bug, due to some conflict between the parser of the ++ command and the implementation of task aggregation. There is a somewhat similar issue for the all command parser upstream, so it seems that input tasks parameters don't play well for at least 2 commands (++ & all). I have tried to tweak the syntax, but ran into a wall.

The good news is that + does not seem to be impacted by this limitation (at least that's my conclusion after testing on your project), so instead of upstreaming the scalafixCheckAll from https://github.com/pureconfig/pureconfig/pull/1188, I would rather recommend other users impacted by this (and unable to switch to the superior sbt-projectmatrix for cross-building) to use +scalafixAll --check.

It does come with a few downsides as it won't allow a per-scala version view and will require full compilation of all sources (potentially in a separate, cache-cold CI workflow), but it appears to work out of the box on all sbt/scalafix versions.

bjaglin avatar Feb 18 '24 22:02 bjaglin