Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created July 14, 2022 06:26
Show Gist options
  • Save xuwei-k/cf77236973dac396a54feb47432abf9b to your computer and use it in GitHub Desktop.
Save xuwei-k/cf77236973dac396a54feb47432abf9b to your computer and use it in GitHub Desktop.
package fix
import scalafix.Patch
import scalafix.v1.SyntacticDocument
import scalafix.v1.SyntacticRule
import scala.meta.Term
class MapSequenceTraverse extends SyntacticRule("MapSequenceTraverse") {
override def fix(implicit doc: SyntacticDocument): Patch = {
doc.tree.collect {
case t @ Term.Select(
Term.Apply(
Term.Select(
qual,
Term.Name("map")
),
arg :: Nil
),
Term.Name("sequence")
) =>
Patch.replaceTree(t, s"${qual}.traverse(${arg})")
}
}.asPatch
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment