From 01e6a41a0fd4c0e5536ca7fb647dbb76b2e575f3 Mon Sep 17 00:00:00 2001 From: Michel Davit Date: Mon, 13 Nov 2023 15:25:46 +0100 Subject: [PATCH] Prefer explicit imports instead of trait mixin --- .../magnolify/cats/BandDerivationSuite.scala | 3 +- .../CommutativeGroupDerivationSuite.scala | 5 ++- .../CommutativeMonoidDerivationSuite.scala | 5 ++- .../CommutativeSemigroupDerivationSuite.scala | 5 ++- .../magnolify/cats/EqDerivationSuite.scala | 35 ++++++++++--------- .../magnolify/cats/GroupDerivationSuite.scala | 3 +- .../magnolify/cats/HashDerivationSuite.scala | 23 ++++++------ .../cats/MonoidDerivationSuite.scala | 8 +++-- .../cats/SemigroupDerivationSuite.scala | 11 +++--- .../magnolify/cats/ShowDerivationSuite.scala | 5 +-- 10 files changed, 53 insertions(+), 50 deletions(-) diff --git a/cats/src/test/scala/magnolify/cats/BandDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/BandDerivationSuite.scala index b3dce2a59..bad6d1a4e 100644 --- a/cats/src/test/scala/magnolify/cats/BandDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/BandDerivationSuite.scala @@ -26,8 +26,9 @@ import org.scalacheck.* import scala.reflect.* -class BandDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations { +class BandDerivationSuite extends MagnolifySuite { import BandDerivationSuite.* + import magnolify.scalacheck.auto.genArbitrary import magnolify.cats.auto.genBand private def test[T: Arbitrary: ClassTag: Eq: Band]: Unit = { diff --git a/cats/src/test/scala/magnolify/cats/CommutativeGroupDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/CommutativeGroupDerivationSuite.scala index eab8ad3f0..1e556311e 100644 --- a/cats/src/test/scala/magnolify/cats/CommutativeGroupDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/CommutativeGroupDerivationSuite.scala @@ -26,10 +26,9 @@ import org.scalacheck.* import scala.reflect.* -class CommutativeGroupDerivationSuite - extends MagnolifySuite - with magnolify.scalacheck.AutoDerivations { +class CommutativeGroupDerivationSuite extends MagnolifySuite { import CommutativeGroupDerivationSuite.* + import magnolify.scalacheck.auto.genArbitrary import magnolify.cats.auto.genCommutativeGroup private def test[T: Arbitrary: ClassTag: Eq: CommutativeGroup]: Unit = { diff --git a/cats/src/test/scala/magnolify/cats/CommutativeMonoidDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/CommutativeMonoidDerivationSuite.scala index ed38f8463..064f5b094 100644 --- a/cats/src/test/scala/magnolify/cats/CommutativeMonoidDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/CommutativeMonoidDerivationSuite.scala @@ -26,10 +26,9 @@ import org.scalacheck.* import scala.reflect.* -class CommutativeMonoidDerivationSuite - extends MagnolifySuite - with magnolify.scalacheck.AutoDerivations { +class CommutativeMonoidDerivationSuite extends MagnolifySuite { import CommutativeMonoidDerivationSuite.* + import magnolify.scalacheck.auto.genArbitrary import magnolify.cats.auto.genCommutativeMonoid private def test[T: Arbitrary: ClassTag: Eq: CommutativeMonoid]: Unit = { diff --git a/cats/src/test/scala/magnolify/cats/CommutativeSemigroupDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/CommutativeSemigroupDerivationSuite.scala index d72910b17..757505b8b 100644 --- a/cats/src/test/scala/magnolify/cats/CommutativeSemigroupDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/CommutativeSemigroupDerivationSuite.scala @@ -26,10 +26,9 @@ import org.scalacheck.* import scala.reflect.* -class CommutativeSemigroupDerivationSuite - extends MagnolifySuite - with magnolify.scalacheck.AutoDerivations { +class CommutativeSemigroupDerivationSuite extends MagnolifySuite { import CommutativeSemigroupDerivationSuite.* + import magnolify.scalacheck.auto.genArbitrary import magnolify.cats.auto.genCommutativeSemigroup private def test[T: Arbitrary: ClassTag: Eq: CommutativeSemigroup]: Unit = { diff --git a/cats/src/test/scala/magnolify/cats/EqDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/EqDerivationSuite.scala index 282e56dd8..5c11f07d2 100644 --- a/cats/src/test/scala/magnolify/cats/EqDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/EqDerivationSuite.scala @@ -16,29 +16,30 @@ package magnolify.cats -import cats.Eq._ -import cats._ -import cats.kernel.laws.discipline._ -import magnolify.cats.auto.genEq -import magnolify.cats.TestEq.eqArray -import magnolify.cats.TestEq.eqDuration -import magnolify.cats.TestEq.eqUri -import magnolify.scalacheck.TestArbitrary._ -import magnolify.scalacheck.TestCogen._ -import magnolify.test.ADT._ -import magnolify.test.Simple._ -import magnolify.test._ -import org.scalacheck._ - -import scala.reflect._ - -class EqDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations { +import cats.* +import cats.kernel.laws.discipline.* +import magnolify.test.* +import magnolify.test.ADT.* +import magnolify.test.Simple.* +import org.scalacheck.* + +import scala.reflect.* + +class EqDerivationSuite extends MagnolifySuite { + import magnolify.cats.auto.genEq + private def test[T: Arbitrary: ClassTag: Cogen: Eq]: Unit = { // TODO val eq = ensureSerializable(implicitly[Eq[T]]) val eq = Eq[T] include(EqTests[T](eq).eqv.all, className[T] + ".") } + import magnolify.scalacheck.TestArbitrary.* + import magnolify.scalacheck.TestCogen.* + import magnolify.cats.TestEq.eqArray + import magnolify.cats.TestEq.eqDuration + import magnolify.cats.TestEq.eqUri + test[Numbers] test[Required] test[Nullable] diff --git a/cats/src/test/scala/magnolify/cats/GroupDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/GroupDerivationSuite.scala index 865ff50ff..4a5759bcc 100644 --- a/cats/src/test/scala/magnolify/cats/GroupDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/GroupDerivationSuite.scala @@ -25,8 +25,9 @@ import org.scalacheck.* import scala.reflect.* -class GroupDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations { +class GroupDerivationSuite extends MagnolifySuite { import GroupDerivationSuite.* + import magnolify.scalacheck.auto.genArbitrary import magnolify.cats.auto.genGroup private def test[T: Arbitrary: ClassTag: Eq: Group]: Unit = { diff --git a/cats/src/test/scala/magnolify/cats/HashDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/HashDerivationSuite.scala index 0de75ed12..c978e795d 100644 --- a/cats/src/test/scala/magnolify/cats/HashDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/HashDerivationSuite.scala @@ -16,23 +16,20 @@ package magnolify.cats -import cats._ -import cats.kernel.laws.discipline._ -import magnolify.test.ADT._ -import magnolify.test.Simple._ -import magnolify.test._ -import org.scalacheck._ - -import scala.reflect._ +import cats.* +import cats.kernel.laws.discipline.* +import magnolify.test.* +import magnolify.test.ADT.* +import magnolify.test.Simple.* +import org.scalacheck.* import java.net.URI import java.time.Duration -import cats.Eq._ -import magnolify.scalacheck.TestArbitrary._ -import magnolify.scalacheck.TestCogen._ +import scala.reflect.* -class HashDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations { +class HashDerivationSuite extends MagnolifySuite { import magnolify.cats.auto.genHash + import magnolify.scalacheck.auto.genArbitrary private def test[T: Arbitrary: ClassTag: Cogen: Hash](exclusions: String*): Unit = { // TODO val hash = ensureSerializable(implicitly[Hash[T]]) @@ -43,6 +40,8 @@ class HashDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoD } } + import magnolify.scalacheck.TestArbitrary.* + import magnolify.scalacheck.TestCogen.* // Use `scala.util.hashing.Hashing[T]` for `Array[Int]`, equivalent to `x.##` and `x.hashCode` implicit val hash: Hash[Array[Int]] = Hash.fromHashing[Array[Int]] implicit val hashUri: Hash[URI] = Hash.fromUniversalHashCode diff --git a/cats/src/test/scala/magnolify/cats/MonoidDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/MonoidDerivationSuite.scala index b7a7616d8..38fea79cd 100644 --- a/cats/src/test/scala/magnolify/cats/MonoidDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/MonoidDerivationSuite.scala @@ -21,7 +21,6 @@ import cats.kernel.laws.discipline.* import magnolify.cats.TestEq.* import magnolify.cats.Types.MiniInt import magnolify.cats.semiauto.* -import magnolify.scalacheck.TestArbitrary.* import magnolify.test.* import magnolify.test.Simple.* import org.scalacheck.* @@ -30,8 +29,9 @@ import java.net.URI import java.time.Duration import scala.reflect.* -class MonoidDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations { +class MonoidDerivationSuite extends MagnolifySuite { import MonoidDerivationSuite.* + import magnolify.scalacheck.auto.genArbitrary import magnolify.cats.auto.genMonoid private def test[T: Arbitrary: ClassTag: Eq: Monoid]: Unit = { @@ -40,11 +40,13 @@ class MonoidDerivationSuite extends MagnolifySuite with magnolify.scalacheck.Aut include(MonoidTests[T](mon).monoid.all, className[T] + ".") } + import magnolify.scalacheck.TestArbitrary.* implicit val eqRecord: Eq[Record] = Eq.gen[Record] implicit val mBool: Monoid[Boolean] = Monoid.instance(false, _ || _) implicit val mUri: Monoid[URI] = Monoid.instance(URI.create(""), (x, y) => URI.create(x.toString + y.toString)) - implicit val mDuration: Monoid[Duration] = Monoid.instance(Duration.ZERO, _ plus _) + implicit val mDuration: Monoid[Duration] = + Monoid.instance(Duration.ZERO, _ plus _) implicit val mMiniInt: Monoid[MiniInt] = Monoid.instance(MiniInt(0), (x, y) => MiniInt(x.i + y.i)) diff --git a/cats/src/test/scala/magnolify/cats/SemigroupDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/SemigroupDerivationSuite.scala index 789c29686..f7a220901 100644 --- a/cats/src/test/scala/magnolify/cats/SemigroupDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/SemigroupDerivationSuite.scala @@ -18,11 +18,8 @@ package magnolify.cats import cats.* import cats.kernel.laws.discipline.* -import magnolify.cats.semiauto.* -import magnolify.cats.TestEq.* import magnolify.cats.Types.MiniInt -import magnolify.cats.auto.genSemigroup -import magnolify.scalacheck.TestArbitrary.* +import magnolify.cats.semiauto.* import magnolify.test.* import magnolify.test.Simple.* import org.scalacheck.* @@ -31,8 +28,10 @@ import java.net.URI import java.time.Duration import scala.reflect.* -class SemigroupDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations { +class SemigroupDerivationSuite extends MagnolifySuite { import SemigroupDerivationSuite.* + import magnolify.cats.auto.genSemigroup + import magnolify.scalacheck.auto.genArbitrary private def test[T: Arbitrary: ClassTag: Eq: Semigroup]: Unit = { // TODO val sg = ensureSerializable(implicitly[Semigroup[T]]) @@ -40,6 +39,8 @@ class SemigroupDerivationSuite extends MagnolifySuite with magnolify.scalacheck. include(SemigroupTests[T](sg).semigroup.all, className[T] + ".") } + import magnolify.scalacheck.TestArbitrary.* + import magnolify.cats.TestEq.* implicit val eqRecord: Eq[Record] = Eq.gen[Record] implicit val sgBool: Semigroup[Boolean] = Semigroup.instance(_ ^ _) implicit val sgUri: Semigroup[URI] = diff --git a/cats/src/test/scala/magnolify/cats/ShowDerivationSuite.scala b/cats/src/test/scala/magnolify/cats/ShowDerivationSuite.scala index 70715e535..13152c96c 100644 --- a/cats/src/test/scala/magnolify/cats/ShowDerivationSuite.scala +++ b/cats/src/test/scala/magnolify/cats/ShowDerivationSuite.scala @@ -20,7 +20,6 @@ import cats.Show import cats.laws.discipline.{ContravariantTests, MiniInt} import cats.laws.discipline.arbitrary.* import cats.laws.discipline.eq.* -import magnolify.scalacheck.TestArbitrary.* import magnolify.test.* import magnolify.test.ADT.* import magnolify.test.Simple.* @@ -30,7 +29,8 @@ import java.net.URI import java.time.Duration import scala.reflect.* -class ShowDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations { +class ShowDerivationSuite extends MagnolifySuite { + import magnolify.scalacheck.auto.genArbitrary import magnolify.cats.auto.genShow private def test[T: Arbitrary: ClassTag: Show]: Unit = { @@ -48,6 +48,7 @@ class ShowDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoD } } + import magnolify.scalacheck.TestArbitrary.* implicit val showArray: Show[Array[Int]] = Show.fromToString implicit val showUri: Show[URI] = Show.fromToString implicit val showDuration: Show[Duration] = Show.fromToString