-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RenameInjectProdAndCoproduct, RenameTupleApplySyntax and RemoveSplit Scalafix rewrites #1813
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e0e975e
Upgrade Scalafix to 0.5.0-M3
gabro aae219a
Remove ONLY in test.
gabro 6fc2c6e
Add RenameInjectProdAndCoproduct Scalafix rewrite
gabro d0ad2a9
Add RenameTupleApplySyntax Scalafix rewrite
gabro 1b0e491
Add RemoveSplit Scalafix rewrite
gabro 94a8050
Replace cats.syntax.split._ with cats.syntax.arrow._
gabro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
scalafix/input/src/main/scala/fix/v1_0_0/RemoveCartesianBuilder2.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* ONLY | ||
/* | ||
rewrite = "scala:fix.v1_0_0.RemoveCartesianBuilder" | ||
*/ | ||
package fix | ||
|
17 changes: 17 additions & 0 deletions
17
scalafix/input/src/main/scala/fix/v1_0_0/RemoveSplit.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
rewrite = "scala:fix.v1_0_0.RemoveSplit" | ||
*/ | ||
package fix | ||
package to1_0_0 | ||
|
||
import cats.implicits._ | ||
import cats.arrow.Split | ||
import cats.syntax.split._ | ||
|
||
object RemoveSplitTests { | ||
val toLong: Int => Long = _.toLong | ||
val toDouble: Float => Double = _.toDouble | ||
val f: ((Int, Float)) => (Long, Double) = | ||
Split[Function1].split(toLong, toDouble) | ||
f((3, 4.0f)) | ||
} |
14 changes: 14 additions & 0 deletions
14
scalafix/input/src/main/scala/fix/v1_0_0/RenameInjectProdAndCoproduct.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
rewrite = "scala:fix.v1_0_0.RenameInjectProdAndCoproduct" | ||
*/ | ||
package fix | ||
package to1_0_0 | ||
|
||
import cats.free.Inject | ||
import cats.data.{ Coproduct, Prod } | ||
|
||
object RenameInjectProdAndCoproductTests { | ||
def inject[F[_], G[_]](implicit inj: Inject[F, G]) = ??? | ||
def prod[F[_], G[_], A](implicit prod: Prod[F, G, A]) = ??? | ||
def coprod[F[_], G[_], A](implicit coprod: Coproduct[F, G, A]) = ??? | ||
} |
31 changes: 31 additions & 0 deletions
31
scalafix/input/src/main/scala/fix/v1_0_0/RenameTupleApplySyntax.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
rewrite = "scala:fix.v1_0_0.RenameTupleApplySyntax" | ||
*/ | ||
package fix | ||
package to1_0_0 | ||
|
||
object RenameTupleApplySyntaxTests { | ||
import cats.{Eq, Semigroup} | ||
import cats.instances.all._ | ||
import cats.syntax.tuple._ | ||
|
||
(Option(1), Option(2)).map2(_ + _) | ||
(Option(1), Option(2), Option(3)).map3(_ + _ + _) | ||
(Option(1), Option(2), Option(3), Option(4)).map4(_ + _ + _ + _) | ||
|
||
case class Foo2(a: Int, b: Int) | ||
case class Foo3(a: Int, b: Int, c: Int) | ||
case class Foo4(a: Int, b: Int, c: Int, d: Int) | ||
|
||
(Eq[Int], Eq[Int]).contramap2((f: Foo2) => (f.a, f.b)) | ||
(Eq[Int], Eq[Int], Eq[Int]).contramap3((f: Foo3) => (f.a, f.b, f.c)) | ||
(Eq[Int], Eq[Int], Eq[Int], Eq[Int]).contramap4((f: Foo4) => | ||
(f.a, f.b, f.c, f.d)) | ||
|
||
(Semigroup[Int], Semigroup[Int]) | ||
.imap2(Foo2.apply)(Function.unlift(Foo2.unapply)) | ||
(Semigroup[Int], Semigroup[Int], Semigroup[Int]) | ||
.imap3(Foo3.apply)(Function.unlift(Foo3.unapply)) | ||
(Semigroup[Int], Semigroup[Int], Semigroup[Int], Semigroup[Int]) | ||
.imap4(Foo4.apply)(Function.unlift(Foo4.unapply)) | ||
} |
13 changes: 13 additions & 0 deletions
13
scalafix/output/src/main/scala/fix/v1_0_0/RemoveSplit.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package fix | ||
package to1_0_0 | ||
|
||
import cats.implicits._ | ||
import cats.arrow.Arrow | ||
|
||
object RemoveSplitTests { | ||
val toLong: Int => Long = _.toLong | ||
val toDouble: Float => Double = _.toDouble | ||
val f: ((Int, Float)) => (Long, Double) = | ||
Arrow[Function1].split(toLong, toDouble) | ||
f((3, 4.0f)) | ||
} |
11 changes: 11 additions & 0 deletions
11
scalafix/output/src/main/scala/fix/v1_0_0/RenameInjectProdAndCoproduct.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package fix | ||
package to1_0_0 | ||
|
||
import cats.InjectK | ||
import cats.data.{ EitherK, Tuple2K } | ||
|
||
object RenameInjectProdAndCoproductTests { | ||
def inject[F[_], G[_]](implicit inj: InjectK[F, G]) = ??? | ||
def prod[F[_], G[_], A](implicit prod: Tuple2K[F, G, A]) = ??? | ||
def coprod[F[_], G[_], A](implicit coprod: EitherK[F, G, A]) = ??? | ||
} |
28 changes: 28 additions & 0 deletions
28
scalafix/output/src/main/scala/fix/v1_0_0/RenameTupleApplySyntax.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package fix | ||
package to1_0_0 | ||
|
||
object RenameTupleApplySyntaxTests { | ||
import cats.{Eq, Semigroup} | ||
import cats.instances.all._ | ||
import cats.syntax.apply._ | ||
|
||
(Option(1), Option(2)).mapN(_ + _) | ||
(Option(1), Option(2), Option(3)).mapN(_ + _ + _) | ||
(Option(1), Option(2), Option(3), Option(4)).mapN(_ + _ + _ + _) | ||
|
||
case class Foo2(a: Int, b: Int) | ||
case class Foo3(a: Int, b: Int, c: Int) | ||
case class Foo4(a: Int, b: Int, c: Int, d: Int) | ||
|
||
(Eq[Int], Eq[Int]).contramapN((f: Foo2) => (f.a, f.b)) | ||
(Eq[Int], Eq[Int], Eq[Int]).contramapN((f: Foo3) => (f.a, f.b, f.c)) | ||
(Eq[Int], Eq[Int], Eq[Int], Eq[Int]).contramapN((f: Foo4) => | ||
(f.a, f.b, f.c, f.d)) | ||
|
||
(Semigroup[Int], Semigroup[Int]) | ||
.imapN(Foo2.apply)(Function.unlift(Foo2.unapply)) | ||
(Semigroup[Int], Semigroup[Int], Semigroup[Int]) | ||
.imapN(Foo3.apply)(Function.unlift(Foo3.unapply)) | ||
(Semigroup[Int], Semigroup[Int], Semigroup[Int], Semigroup[Int]) | ||
.imapN(Foo4.apply)(Function.unlift(Foo4.unapply)) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.0-M2") | ||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.0-M3") | ||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-RC3") | ||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.6.1") | ||
addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.0.0") |
This file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
split
syntax isn't actually used below, and if it was used it, this import would clash withcats.implicits._
.If you want to test the split syntax you would have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good catch, thanks. That's a half-baked attempt that I accidentally left in there.
I just pushed a proper version of that fix.
By the way, it'd be nice if scalafix tests were run by the CI (so that these kind of mistake would be caught). Do you think it's possible to add them to the build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add them to the build. We can tackle it in another PR.