Skip to content

Commit

Permalink
Add scalafix rule for renaming EitherT.liftT
Browse files Browse the repository at this point in the history
  • Loading branch information
aeons committed Oct 3, 2017
1 parent 8b5df3f commit 6395fdc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scalafix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ sbt scalafix github:typelevel/cats/v1.0.0

- [x] The creation methods (left, right, apply, pure, etc.) in EitherT were improved to take less type arguments.

- [x] EitherT.liftT was renamed to EitherT.liftF

- [x] CartesianBuilder (i.e. |@|) syntax is deprecated, use the apply syntax on tuples instead. E.g. (x |@| y |@| z).map(...) should be replaced by (x, y, z).mapN(...)

- [x] Free.suspend is renamed to Free.defer for consistency.
Expand Down
15 changes: 15 additions & 0 deletions scalafix/input/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
rule = "scala:fix.v1_0_0.RenameEitherTLiftT"
*/
package fix
package to1_0_0

object RenameEitherTLiftTTests {
import cats.instances.option._
import cats.data._
import cats.data.EitherT._

val fa: Option[Int] = Some(42)
val et1: EitherT[Option, Nothing, Int] = EitherT.liftT(fa)
val et2: EitherT[Option, Nothing, Int] = liftT(fa)
}
12 changes: 12 additions & 0 deletions scalafix/output/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package fix
package to1_0_0

object RenameEitherTLiftTTests {
import cats.instances.option._
import cats.data._
import cats.data.EitherT._

val fa: Option[Int] = Some(42)
val et1: EitherT[Option, Nothing, Int] = EitherT.liftF(fa)
val et2: EitherT[Option, Nothing, Int] = liftF(fa)
}
11 changes: 11 additions & 0 deletions scalafix/rules/src/main/scala/fix/Cats_v1_0_0.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,14 @@ case class RemoveSplit(index: SemanticdbIndex)
}

}

// ref: https://github.com/typelevel/cats/pull/1947
case class RenameEitherTLiftT(index: SemanticdbIndex)
extends SemanticRule(index, "RenameEitherTLiftT") {

override def fix(ctx: RuleCtx): Patch =
ctx.replaceSymbols(
"_root_.cats.data.EitherTFunctions.liftT." -> "liftF"
)

}

0 comments on commit 6395fdc

Please sign in to comment.