-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8ecdfb
commit 2e305bf
Showing
9 changed files
with
116 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
lazy val V = _root_.scalafix.sbt.BuildInfo | ||
inThisBuild( | ||
List( | ||
organization := "dev.zio", | ||
homepage := Some(url("https://zio.dev")), | ||
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), | ||
developers := List( | ||
Developer( | ||
"jdegoes", | ||
"John De Goes", | ||
"[email protected]", | ||
url("http://degoes.net") | ||
) | ||
), | ||
scalaVersion := V.scala212, | ||
addCompilerPlugin(scalafixSemanticdb), | ||
scalacOptions ++= List( | ||
"-Yrangepos", | ||
"-P:semanticdb:synthetics:on" | ||
) | ||
) | ||
) | ||
|
||
skip in publish := true | ||
|
||
lazy val rules = project.settings( | ||
moduleName := "scalafix", | ||
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % V.scalafixVersion | ||
) | ||
|
||
lazy val input = project.settings( | ||
skip in publish := true, | ||
libraryDependencies += "dev.zio" %% "zio-test" % "1.0.0-RC17" | ||
) | ||
|
||
lazy val output = project.settings( | ||
skip in publish := true | ||
) | ||
|
||
lazy val tests = project | ||
.settings( | ||
skip in publish := true, | ||
libraryDependencies += "ch.epfl.scala" % "scalafix-testkit" % V.scalafixVersion % Test cross CrossVersion.full, | ||
compile.in(Compile) := | ||
compile.in(Compile).dependsOn(compile.in(input, Compile)).value, | ||
scalafixTestkitOutputSourceDirectories := | ||
sourceDirectories.in(output, Compile).value, | ||
scalafixTestkitInputSourceDirectories := | ||
sourceDirectories.in(input, Compile).value, | ||
scalafixTestkitInputClasspath := | ||
fullClasspath.in(input, Compile).value, | ||
) | ||
.dependsOn(rules) | ||
.enablePlugins(ScalafixTestkitPlugin) |
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 @@ | ||
/* | ||
rule = CurriedAssert | ||
*/ | ||
package fix | ||
|
||
import zio._ | ||
import zio.clock._ | ||
import zio.test._ | ||
import zio.test.Assertion._ | ||
|
||
object CurriedAssert { | ||
assertM(nanoTime, equalTo(0)) | ||
assert(Right(Some(3)), isRight(isSome(isGreaterThan(4)))) | ||
} |
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,11 @@ | ||
package fix | ||
|
||
import zio._ | ||
import zio.clock._ | ||
import zio.test._ | ||
import zio.test.Assertion._ | ||
|
||
object CurriedAssert { | ||
assertM(nanoTime)(equalTo(0)) | ||
assert(Right(Some(3)))(isRight(isSome(isGreaterThan(4)))) | ||
} |
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 @@ | ||
sbt.version=1.3.8 |
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 @@ | ||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.11") |
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,7 @@ | ||
# Scalafix rules for zio | ||
|
||
To develop rule: | ||
``` | ||
sbt ~tests/test | ||
# edit rules/src/main/scala/fix/CurriedAssert.scala | ||
``` |
1 change: 1 addition & 0 deletions
1
scalafix/rules/src/main/resources/META-INF/services/scalafix.v1.Rule
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 @@ | ||
fix.CurriedAssert |
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,20 @@ | ||
package fix | ||
|
||
import scalafix.v1._ | ||
import scala.meta._ | ||
|
||
class CurriedAssert extends SemanticRule("CurriedAssert") { | ||
|
||
val assert = SymbolMatcher.normalized( | ||
"zio.test.package.assert", | ||
"zio.test.package.assertM" | ||
) | ||
|
||
override def fix(implicit doc: SemanticDocument): Patch = | ||
doc.tree.collect { | ||
case t @ assert(Term.Apply(name, List(value, assertion))) => | ||
Patch.replaceTree(t, name + "(" + value + ")(" + assertion + ")") | ||
case _ => | ||
Patch.empty | ||
}.asPatch | ||
} |
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,7 @@ | ||
package fix | ||
|
||
import scalafix.testkit.SemanticRuleSuite | ||
|
||
class RuleSuite extends SemanticRuleSuite() { | ||
runAllTests() | ||
} |