|
1 | | -# CAUTIONS! |
2 | | -Current released Scalafix supports ExplicitNonNullaryApply [ONLY in Scala 2.12](https://github.com/scala/scala-rewrites/issues/31). |
3 | | -Scalafix will support 2.13 and 2.11 with cross-building ExplicitNonNullaryApply rule against them. |
4 | | - |
5 | 1 | # Scalafix Rewrites for Scala |
6 | 2 |
|
7 | | -## To develop a rewrite |
| 3 | +## How to run the rewrites |
| 4 | + |
| 5 | +Add the `sbt-scalafix` sbt plugin, with the SemanticDB compiler plugin enabled ([official docs][1]): |
8 | 6 |
|
| 7 | +```scala |
| 8 | +// project/plugins.sbt |
| 9 | +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.17") |
9 | 10 | ``` |
10 | | -sbt ~tests/test |
11 | | -# edit rewrites/src/main/scala/... |
| 11 | + |
| 12 | +```scala |
| 13 | +// build.sbt |
| 14 | +inThisBuild(List( |
| 15 | + semanticdbEnabled := true, |
| 16 | + semanticdbOptions += "-P:semanticdb:synthetics:on", // make sure to add this |
| 17 | + semanticdbVersion := scalafixSemanticdb.revision, |
| 18 | +)) |
12 | 19 | ``` |
13 | 20 |
|
14 | | -## To run the rewrites |
| 21 | +Then run the desired rewrite(s) ([official docs][2]), in sbt: |
| 22 | + |
| 23 | +```scala |
| 24 | +> scalafix dependency:fix.scala213.ExplicitNonNullaryApply@org.scala-lang:scala-rewrites:0.1.0` |
| 25 | +> Test/scalafix dependency:fix.scala213.ExplicitNonNullaryApply@org.scala-lang:scala-rewrites:0.1.0 |
| 26 | +``` |
| 27 | + |
| 28 | +You can also add the following to your `build.sbt`: |
| 29 | + |
| 30 | +```scala |
| 31 | +ThisBuild / scalafixDependencies += "org.scala-lang" %% "scala-rewrites" % "0.1.0" |
| 32 | +``` |
15 | 33 |
|
16 | | -1. [Install Scalafix](https://scalacenter.github.io/scalafix/docs/users/installation.html) |
17 | | -2. Enable synthetics in SemanticDB; e.g. `semanticdbOptions += "-P:semanticdb:synthetics:on"` in sbt 1.3+ |
18 | | -3. Run the [external rule](https://scalacenter.github.io/scalafix/docs/rules/external-rules.html), e.g.: |
19 | | - * `scalafix dependency:ExplicitNonNullaryApply@org.scala-lang:scala-rewrites:VERSION` |
20 | | - * `Test/scalafix dependency:ExplicitNonNullaryApply@org.scala-lang:scala-rewrites:VERSION` |
| 34 | +and then: |
| 35 | + |
| 36 | +```scala |
| 37 | +> scalafix fix.scala213.ExplicitNonNullaryApply |
| 38 | +> Test/scalafix fix.scala213.ExplicitNonNullaryApply |
| 39 | +``` |
| 40 | + |
| 41 | +[1]: https://scalacenter.github.io/scalafix/docs/users/installation.html |
| 42 | +[2]: https://scalacenter.github.io/scalafix/docs/rules/external-rules.html |
| 43 | + |
| 44 | +## To develop/contribute to any of the rewrites |
| 45 | + |
| 46 | +``` |
| 47 | +sbt ~tests/test |
| 48 | +# edit rewrites/src/main/scala/... |
| 49 | +``` |
0 commit comments