Add the sbt-scalafix
sbt plugin, with the SemanticDB compiler plugin enabled (official docs):
// project/plugins.sbt
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.24")
// build.sbt
inThisBuild(List(
semanticdbEnabled := true,
semanticdbOptions += "-P:semanticdb:synthetics:on", // make sure to add this
semanticdbVersion := scalafixSemanticdb.revision,
scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaVersion.value),
))
Then run the desired rewrite(s) (official docs), in sbt:
> scalafixAll dependency:fix.scala213.ExplicitNonNullaryApply@org.scala-lang:scala-rewrites:0.1.2
You can also add the following to your build.sbt
:
ThisBuild / scalafixDependencies += "org.scala-lang" %% "scala-rewrites" % "0.1.3"
and then:
> scalafixAll fix.scala213.ExplicitNonNullaryApply
sbt ~tests/test
# edit rewrites/src/main/scala/...