Created
February 19, 2022 06:39
-
-
Save xuwei-k/96726bd86e70d599c3a6b0666f6bbb3d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package fix | |
import scalafix.Patch | |
import scalafix.v1.SyntacticDocument | |
import scalafix.v1.SyntacticRule | |
import scala.meta.Term | |
import scala.meta.Type | |
class MockitoPureEff extends SyntacticRule("MockitoPureEff") { | |
override def fix(implicit doc: SyntacticDocument): Patch = { | |
doc.tree.collect { | |
case Term.Apply( | |
Term.Select( | |
Term.Apply( | |
Term.Name("when"), | |
List( | |
Term.Apply( | |
Term.ApplyType( | |
Term.Select( | |
_, | |
_ | |
), | |
List( | |
Type.Name(tpe) | |
) | |
), | |
_ | |
) | |
) | |
), | |
Term.Name("thenReturn") | |
), | |
List( | |
ret @ Term.Select( | |
_, | |
Term.Name("pureEff") | |
) | |
) | |
) => | |
Patch.addRight(ret, s"[${tpe}]") | |
}.asPatch | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment