Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Jan 12, 2024
1 parent ba77973 commit 7e1a8bd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 60 deletions.
35 changes: 35 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,41 @@ lazy val rules = projectMatrix
publishTo := sonatypePublishToBundle.value,
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % V.scalafixVersion,
libraryDependencies += "org.scalatest" %% "scalatest-funsuite" % "3.2.17" % Test,
Compile / sourceGenerators += task {
val dir = (Compile / sourceManaged).value
Seq(
"DiscardScalaFuture" -> "scala/concurrent/Future#",
"DiscardMonixTask" -> "monix/eval/Task#",
"DiscardEff" -> "org/atnos/eff/Eff#",
).map { case (ruleName, tpe) =>
val f = dir / "fix" / s"${ruleName}.scala"
IO.write(
f,
s"""package fix
|
|import scalafix.Patch
|import scalafix.v1.Configuration
|import scalafix.v1.Rule
|import scalafix.v1.SemanticDocument
|import scalafix.v1.SemanticRule
|import metaconfig.Configured
|
|class ${ruleName}(config: DiscardSingleConfig) extends SemanticRule("${ruleName}") {
|
| def this() = this(DiscardSingleConfig.default)
|
| override def withConfiguration(config: Configuration): Configured[Rule] =
| config.conf.getOrElse("${ruleName}")(this.config).map(newConfig => new ${ruleName}(newConfig))
|
| override def fix(implicit doc: SemanticDocument): Patch =
| DiscardValue.typeRef(config.toDiscardValueConfig("${tpe}"))
|
|}
|""".stripMargin
)
f
}
},
Compile / doc / scalacOptions ++= {
val hash = sys.process.Process("git rev-parse HEAD").lineStream_!.head
if (scalaBinaryVersion.value != "3") {
Expand Down
20 changes: 0 additions & 20 deletions rules/src/main/scala/fix/DiscardEff.scala

This file was deleted.

20 changes: 0 additions & 20 deletions rules/src/main/scala/fix/DiscardMonixTask.scala

This file was deleted.

20 changes: 0 additions & 20 deletions rules/src/main/scala/fix/DiscardScalaFuture.scala

This file was deleted.

0 comments on commit 7e1a8bd

Please sign in to comment.