Skip to content

Instantly share code, notes, and snippets.

@julien-truffaut
Created August 7, 2025 14:50
Show Gist options
  • Save julien-truffaut/218204865105e9607ee07f5a198c4a4a to your computer and use it in GitHub Desktop.
Save julien-truffaut/218204865105e9607ee07f5a198c4a4a to your computer and use it in GitHub Desktop.
RenameExpectToExpectSame with swapped parameter order
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