You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-Xfatal-warnings (or -Werror) might prevent a Scalafix rule from being applied if a project does not compile without warnings with the Scala version set by scalafixEnable. I noticed this while testing a Scalafix migration rule for Cats Effect (scala-steward-org/scala-steward#1982) in Scala Steward itself. Scala Steward uses -Xfatal-warnings and sbt-scalafix 0.9.26 but is still on Scala 2.13.4. I tested the migration rule via sbt ;scalafixEnable ;scalafix github:typelevel/cats-effect/v2_4_0?sha=series/2.x and noticed that it couldn't be applied because compilation fails under Scala 2.13.5 which introduced new warnings. Scala 2.13.5 is used instead of 2.13.4 because scalafixEnable also changes the scalaVersion. If I remove -Xfatal-warnings from scalacOptions in the build, compilation succeeds and the Scalafix rule is applied.
This is not really an issue if one runs the Scalafix manually (since one can always remove that option by hand) but it is more problematic when Scalafix is used in automation. One example is when Scala Steward runs Scalafix migration rules in other projects as part of its update PRs. It currently does this by adding the latest sbt-scalafix version to the build of the project it is updating and then running sbt ;scalafixEnable ;scalafix .... If that project is using -Xfatal-warnings it could run into the situation mentioned above which prevents the Scalafix rule from being applied.
I tried to salvage this in Scala Steward by adding another sbt command that is executed after scalafixEnable which removes -Xfatal-warnings from all sbt projects but this is unfortunately not possible due to bug in sbt: sbt/sbt#5459. I therefore propose that scalafixEnable also removes -Xfatal-warnings and -Werror from scalacOptions to make using sbt-scalafix easier in projects where the actual scalaVersion and the one set by scalafixEnable differ.
The text was updated successfully, but these errors were encountered:
As discussed on gitter, I think it's a good idea. I was concerned about relaxing -Xfatal-warnings for the entire session after scalafixEnable, but I think I got something decent with scalacenter/sbt-scalafix#195. Could you confirm this PR addresses your use case?
-Xfatal-warnings
(or-Werror
) might prevent a Scalafix rule from being applied if a project does not compile without warnings with the Scala version set byscalafixEnable
. I noticed this while testing a Scalafix migration rule for Cats Effect (scala-steward-org/scala-steward#1982) in Scala Steward itself. Scala Steward uses-Xfatal-warnings
and sbt-scalafix 0.9.26 but is still on Scala 2.13.4. I tested the migration rule viasbt ;scalafixEnable ;scalafix github:typelevel/cats-effect/v2_4_0?sha=series/2.x
and noticed that it couldn't be applied because compilation fails under Scala 2.13.5 which introduced new warnings. Scala 2.13.5 is used instead of 2.13.4 becausescalafixEnable
also changes thescalaVersion
. If I remove-Xfatal-warnings
fromscalacOptions
in the build, compilation succeeds and the Scalafix rule is applied.This is not really an issue if one runs the Scalafix manually (since one can always remove that option by hand) but it is more problematic when Scalafix is used in automation. One example is when Scala Steward runs Scalafix migration rules in other projects as part of its update PRs. It currently does this by adding the latest sbt-scalafix version to the build of the project it is updating and then running
sbt ;scalafixEnable ;scalafix ...
. If that project is using-Xfatal-warnings
it could run into the situation mentioned above which prevents the Scalafix rule from being applied.I tried to salvage this in Scala Steward by adding another sbt command that is executed after
scalafixEnable
which removes-Xfatal-warnings
from all sbt projects but this is unfortunately not possible due to bug in sbt: sbt/sbt#5459. I therefore propose thatscalafixEnable
also removes-Xfatal-warnings
and-Werror
fromscalacOptions
to make using sbt-scalafix easier in projects where the actualscalaVersion
and the one set byscalafixEnable
differ.The text was updated successfully, but these errors were encountered: