-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure scalafix
#20
Conversation
build.sbt
Outdated
cond = Some(s"matrix.java == 'temurin@8' && matrix.scala != '$Scala3'") | ||
) | ||
|
||
scalafixStep +: (ThisBuild / githubWorkflowBuild).value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified after typelevel/sbt-typelevel#306
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this a bit and have also been following the discussion in #3.
It seems like this project will likely have separate Scala 2 and Scala 3 sources. Therefore I propose the right thing to do here is to have two separate scalafix configurations, .scalafix-2.conf
and .scalafix-3.conf
. That way only the supported rules can be enabled in the scalafix-3.conf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scalafixAll
requires an expensive compile step, so it should be done before after the fast header/formatting checks.
build.sbt
Outdated
ThisBuild / scalaVersion := Scala213 // the default Scala | ||
|
||
lazy val root = tlCrossRootProject.aggregate(core, java) | ||
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0" | ||
ThisBuild / semanticdbEnabled := !tlIsScala3.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause problems with metals which relies on semantic db.
build.sbt
Outdated
val scalafixStep = WorkflowStep.Sbt( | ||
List("root/scalafixAll --check"), | ||
name = Some("Check that scalafix has been run"), | ||
cond = Some(s"matrix.java == 'temurin@8' && matrix.scala != '$Scala3'") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root/scalafixAll
will run for all modules. scalafixAll
will run for only the current active project, which in CI is either rootJVM
or rootJS
, which is more efficient.
build.sbt
Outdated
cond = Some(s"matrix.java == 'temurin@8' && matrix.scala != '$Scala3'") | ||
) | ||
|
||
scalafixStep +: (ThisBuild / githubWorkflowBuild).value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scalafixAll
requires an expensive compile step, so it should be done before after the fast header/formatting checks.
build.sbt
Outdated
ThisBuild / semanticdbEnabled := true | ||
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision | ||
|
||
ThisBuild / tlCiScalafixCheck := true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point you can remove these settings and just use sbt-typelevel-scalafix
instead :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Looks much better now, thanks 🙂
3e0600e
to
41116ee
Compare
# Conflicts: # java/src/main/scala/org/typelevel/otel4s/java/impl.scala
# Conflicts: # core/src/main/scala/org/typelevel/otel4s/otel4s.scala # java/src/main/scala/org/typelevel/otel4s/java/impl.scala
scalafix
offers handy lints and rewrites. The majority of typelevel projects use it.