-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix usage of scalafix via another task #152
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rules = [RemoveUnused] |
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") |
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 := { | ||
scalafix.in(Compile).toTask(" --check").value | ||
// & other linters... | ||
} | ||
) | ||
} |
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")) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package example | ||
|
||
import imported.Imported | ||
|
||
object Example |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package imported | ||
|
||
object Imported |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on master
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I investigated where the concurrent Without the fix, the test logs now shows:
|
||
> 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 |
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.
👍