-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix usage of scalafix via another task
Regression of 0cf5501: initial (cold) invocations to a task delegating to scalafix would result in scalafix being called before compilation (because scalafixRunExplicitly == false) causing false negatives.
- Loading branch information
1 parent
12c6475
commit 3fd832e
Showing
8 changed files
with
58 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rules = [RemoveUnused] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
val V = _root_.scalafix.sbt.BuildInfo | ||
|
||
scalaVersion := V.scala212 | ||
addCompilerPlugin(scalafixSemanticdb) | ||
scalacOptions ++= Seq("-Yrangepos", "-Ywarn-unused") |
24 changes: 24 additions & 0 deletions
24
src/sbt-test/sbt-scalafix/wrapper/project/LintAllPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import sbt._ | ||
import scalafix.sbt.ScalafixPlugin | ||
import scalafix.sbt.ScalafixPlugin.autoImport._ | ||
|
||
object LintAllPlugin extends AutoPlugin { | ||
|
||
override def trigger: PluginTrigger = allRequirements | ||
|
||
override def requires: Plugins = ScalafixPlugin | ||
|
||
object autoImport { | ||
val lintAll = taskKey[Unit]("run all linters") | ||
} | ||
|
||
import autoImport._ | ||
|
||
override def projectSettings: Seq[Def.Setting[_]] = | ||
Seq( | ||
lintAll := { | ||
scalafixAll.toTask(" --check").value | ||
// & other linters... | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
resolvers += Resolver.sonatypeRepo("public") | ||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version")) |
5 changes: 5 additions & 0 deletions
5
src/sbt-test/sbt-scalafix/wrapper/src/main/scala/example/Example.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package example | ||
|
||
import imported.Imported | ||
|
||
object Example |
3 changes: 3 additions & 0 deletions
3
src/sbt-test/sbt-scalafix/wrapper/src/main/scala/imported/Imported.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package imported | ||
|
||
object Imported |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# check that missing rewrites are detected, with or without a warm compilation cache | ||
> set scalafixOnCompile := false | ||
-> lintAll | ||
> compile | ||
-> lintAll | ||
|
||
# apply the rewrite via an explicit call | ||
> scalafix | ||
|
||
# confirms that `lintAll` sees that rewrite, with or without a warm compilation cache | ||
> clean | ||
> lintAll | ||
> compile | ||
> lintAll |