Created
August 7, 2025 14:50
-
-
Save julien-truffaut/218204865105e9607ee07f5a198c4a4a to your computer and use it in GitHub Desktop.
RenameExpectToExpectSame with swapped parameter order
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.v1._ | |
| import scala.meta._ | |
| class RenameExpectToExpectSame extends SemanticRule("RenameExpectToExpectSame") { | |
| override def fix(implicit doc: SemanticDocument): Patch = { | |
| val expectMethod = | |
| SymbolMatcher.normalized("weaver/Expectations.Helpers#expect.") | |
| doc.tree.collect { | |
| case expectMethod(tree) => | |
| tree match { | |
| case q"expect($lhs == $rhs)" => | |
| Patch.replaceTree(tree, s"expect.same($rhs, $lhs)") | |
| case _ => | |
| Patch.empty | |
| } | |
| }.asPatch | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment