Skip to content
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

Misuv 6971 proto: DO NOT MERGE #2077

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules = [
DisableSyntax
]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ sbt clean coverage test it:test coverageOff coverageReport

This code is open source software licensed under the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html")

ScalaFix rule to rewrite imports:

scalafix --rules=file:rules/ImportRewriteRules.scala

test:scalafix --rules=file:rules/ImportRewriteRules.scala

5 changes: 4 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ lazy val microservice = Project(appName, file("."))
.settings(scoverageSettings: _*)
.settings(defaultSettings(): _*)
.settings(majorVersion := 1)
.settings(semanticdbEnabled := true) // enable SemanticDB
.settings(semanticdbVersion := scalafixSemanticdb.revision)
.settings(scalacOptions += "-Wconf:cat=lint-multiarg-infix:silent")
.settings(scalacOptions += "-Xfatal-warnings")
.settings(scalafixOnCompile := true)
//.settings(scalacOptions += "-Xfatal-warnings")
.settings(
Test / Keys.fork := true,
Test / javaOptions += "-Dlogger.resource=logback-test.xml",
Expand Down
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

addSbtPlugin("io.github.irundaia" % "sbt-sassify" % "1.5.2")

addDependencyTreePlugin
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")

addDependencyTreePlugin
20 changes: 20 additions & 0 deletions rules/ImportRewriteRules.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package fix

import metaconfig.Configured
import scalafix.v1._
import scala.meta._
import scalafix.patch.Patch

class ImportRewriteRules extends SemanticRule("ImportRewrite") {

override def fix(implicit doc: SemanticDocument): Patch = {
doc.tree.collect {
case t @ importer"scala.concurrent.ExecutionContext.Implicits.{..$importees}" =>
importees.foldLeft(Patch.empty)(_ + Patch.removeImportee(_))
Patch.addGlobalImport(importer"play.api.libs.concurrent.Execution.Implicits.defaultContext")
case _ =>
Patch.empty
}.asPatch
}

}