Skip to content

Commit

Permalink
Upgrade sbt and sbt plugins / Clean up
Browse files Browse the repository at this point in the history
* sbt to 1.9.7
* sbt-devoops to 3.0.0
* sbt-docusaur to 0.15.0
* Clean up the code as suggested by sbt-tpolecat
  • Loading branch information
kevin-lee committed Nov 22, 2023
1 parent dea6bb9 commit ba5f0f2
Show file tree
Hide file tree
Showing 66 changed files with 284 additions and 441 deletions.
14 changes: 3 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ lazy val docs = (project in file("docs-gen-tmp/docs"))
mdocIn := file("docs/latest"),
mdocOut := file("generated-docs/docs"),
cleanFiles += ((ThisBuild / baseDirectory).value / "generated-docs" / "docs"),
scalacOptions ~= (_.filterNot(props.isScala3IncompatibleScalacOption)),
scalacOptions ~= (_.filterNot(props.isScala3IncompatibleScalacOption).filter(opt => opt != "-Xfatal-warnings")),
libraryDependencies ++= {
val latestTag = getTheLatestTaggedVersion()
List(
Expand All @@ -274,7 +274,7 @@ lazy val docsV1 = (project in file("docs-gen-tmp/docs-v1"))
mdocIn := file("docs/v1"),
mdocOut := file("website/versioned_docs/version-v1/docs"),
cleanFiles += ((ThisBuild / baseDirectory).value / "website" / "versioned_docs" / "version-v1"),
scalacOptions ~= (_.filterNot(props.isScala3IncompatibleScalacOption)),
scalacOptions ~= (_.filterNot(props.isScala3IncompatibleScalacOption).filter(opt => opt != "-Xfatal-warnings")),
libraryDependencies ++= List(
"io.kevinlee" %% "effectie-cats-effect" % "1.16.0",
"io.kevinlee" %% "effectie-monix" % "1.16.0",
Expand Down Expand Up @@ -447,15 +447,7 @@ def module(projectName: ProjectName, crossProject: CrossProject.Builder): CrossP
.settings(
name := prefixedName,
fork := true,
scalacOptions := {
(
if (scalaVersion.value.startsWith("3."))
List("-Ykind-projector:underscores")
else
List.empty[String]
) ++
scalacOptions.value.filterNot(props.isScala3IncompatibleScalacOption)
},
scalacOptions := scalacOptions.value.filterNot(props.isScala3IncompatibleScalacOption),
scalafixConfig := (
if (scalaVersion.value.startsWith("3"))
((ThisBuild / baseDirectory).value / ".scalafix-scala3.conf").some
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ object Ce2ResourceMaker {
@deprecated(message = "Please use Ce2ResourceMaker.maker instead", since = "2.0.0-beta10")
def forAutoCloseable[F[*]: Sync: BracketThrow]: ResourceMaker[F] = maker

def maker[F[*]: Sync: BracketThrow]: ResourceMaker[F] = new Ce2ResourceMaker[F]
def maker[F[*]: Sync]: ResourceMaker[F] = new Ce2ResourceMaker[F]

private final class Ce2ResourceMaker[F[*]: Sync: BracketThrow] extends ResourceMaker[F] {
private final class Ce2ResourceMaker[F[*]: Sync] extends ResourceMaker[F] {

override def forAutoCloseable[A <: AutoCloseable](fa: F[A]): ReleasableResource[F, A] =
Ce2Resource.fromAutoCloseable[F, A](fa)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import canCatch._
import cats._
import cats.data.EitherT
import cats.effect._
import cats.instances.all._
import cats.syntax.all._
import effectie.SomeControlThrowable
import effectie.core._
Expand Down Expand Up @@ -168,7 +167,7 @@ object canCatchSpec extends Properties {
def throwThrowable[A](throwable: => Throwable): A =
throw throwable // scalafix:ok DisableSyntax.throw

def run[F[*]: FxCtor: Functor, A](a: => A): F[A] =
def run[F[*]: FxCtor, A](a: => A): F[A] =
effectOf[F](a)

object IoSpec {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import canHandleError._
import cats._
import cats.data.EitherT
import cats.effect.IO
import cats.instances.all._
import cats.syntax.all._
import effectie.SomeControlThrowable
import effectie.core._
Expand Down Expand Up @@ -307,7 +306,7 @@ object canHandleErrorSpec extends Properties {
def throwThrowable[A](throwable: => Throwable): A =
throw throwable // scalafix:ok DisableSyntax.throw

def run[F[*]: FxCtor: Functor, A](a: => A): F[A] =
def run[F[*]: FxCtor, A](a: => A): F[A] =
effectOf[F](a)

object IoSpec {
Expand All @@ -321,6 +320,8 @@ object canHandleErrorSpec extends Properties {
.handleNonFatalWith(fa) {
case NonFatal(`expectedExpcetion`) =>
IO.pure(expected)
case err =>
throw err // scalafix:ok DisableSyntax.throw
}
.unsafeRunSync()

Expand Down Expand Up @@ -535,6 +536,8 @@ object canHandleErrorSpec extends Properties {
.handleNonFatal(fa) {
case NonFatal(`expectedExpcetion`) =>
expected
case err =>
throw err // scalafix:ok DisableSyntax.throw
}
.unsafeRunSync()

Expand Down Expand Up @@ -861,7 +864,7 @@ object canHandleErrorSpec extends Properties {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(CanHandleError[Future].handleEitherNonFatalWith(fa2)(err => Future(expected)))
)(CanHandleError[Future].handleEitherNonFatalWith(fa2)(_ => Future(expected)))

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down Expand Up @@ -925,7 +928,7 @@ object canHandleErrorSpec extends Properties {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(CanHandleError[Future].handleEitherTNonFatalWith(fa2)(err => Future(expected)).value)
)(CanHandleError[Future].handleEitherTNonFatalWith(fa2)(_ => Future(expected)).value)

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down Expand Up @@ -1080,7 +1083,7 @@ object canHandleErrorSpec extends Properties {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(CanHandleError[Future].handleEitherNonFatal(fa2)(err => expected))
)(CanHandleError[Future].handleEitherNonFatal(fa2)(_ => expected))

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down Expand Up @@ -1139,7 +1142,7 @@ object canHandleErrorSpec extends Properties {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(CanHandleError[Future].handleEitherTNonFatal(fa2)(err => expected).value)
)(CanHandleError[Future].handleEitherTNonFatal(fa2)(_ => expected).value)

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package effectie.instances.ce2
import cats._
import cats.data.EitherT
import cats.effect.IO
import cats.instances.all._
import cats.syntax.all._
import effectie.SomeControlThrowable
import effectie.core._
Expand Down Expand Up @@ -309,7 +308,7 @@ object canRecoverSpec extends Properties {
def throwThrowable[A](throwable: => Throwable): A =
throw throwable // scalafix:ok DisableSyntax.throw

def run[F[*]: FxCtor: Functor, A](a: => A): F[A] =
def run[F[*]: FxCtor, A](a: => A): F[A] =
effectOf[F](a)

object IOSpec {
Expand Down Expand Up @@ -964,7 +963,7 @@ object canRecoverSpec extends Properties {
)(
CanRecover[Future]
.recoverEitherFromNonFatalWith(fa2) {
case err => Future(expected)
case err @ _ => Future(expected)
}
)

Expand Down Expand Up @@ -1042,7 +1041,7 @@ object canRecoverSpec extends Properties {
)(
CanRecover[Future]
.recoverEitherTFromNonFatalWith(fa2) {
case err => Future(expected)
case err @ _ => Future(expected)
}
.value
)
Expand Down Expand Up @@ -1217,7 +1216,7 @@ object canRecoverSpec extends Properties {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(CanRecover[Future].recoverEitherFromNonFatal(fa2) { case err => expected })
)(CanRecover[Future].recoverEitherFromNonFatal(fa2) { case err @ _ => expected })

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down Expand Up @@ -1285,7 +1284,7 @@ object canRecoverSpec extends Properties {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(CanRecover[Future].recoverEitherTFromNonFatal(fa2) { case err => expected }.value)
)(CanRecover[Future].recoverEitherTFromNonFatal(fa2) { case err @ _ => expected }.value)

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package effectie.instances.ce2
import cats.effect._
import effectie.specs.fxCtorSpec.FxCtorSpecs
import effectie.testing.tools
import extras.concurrent.testing.types.ErrorLogger
import fxCtor._
import hedgehog._
import hedgehog.runner._
Expand All @@ -21,8 +20,6 @@ object fxCtorSpec extends Properties {
(actual ==== expected).log(s"$actual does not equal to $expected")
}

implicit private val errorLogger: ErrorLogger[Throwable] = ErrorLogger.printlnDefaultErrorLogger

private val unit: Unit = ()

private val ioSpecs = List(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package effectie.instances.ce2
import cats.data.EitherT
import cats.effect._
import cats.syntax.all._
import cats.{Eq, Functor}
import cats.Eq
import effectie.SomeControlThrowable
import effectie.core._
import effectie.instances.ce2.fx._
Expand All @@ -12,7 +12,6 @@ import effectie.specs.fxSpec.FxSpecs
import effectie.syntax.error._
import effectie.testing.tools
import effectie.testing.types.SomeError
import extras.concurrent.testing.types.ErrorLogger
import hedgehog._
import hedgehog.runner._

Expand All @@ -25,8 +24,6 @@ object fxSpec extends Properties {

override def tests: List[Test] = ioSpecs

private implicit val errorLogger: ErrorLogger[Throwable] = ErrorLogger.printlnDefaultErrorLogger

private val assertWithAttempt: (IO[Int], Either[Throwable, Int]) => Result = { (io, expected) =>
val actual = io.attempt.unsafeRunSync()
(actual ==== expected).log(s"$actual does not equal to $expected")
Expand Down Expand Up @@ -371,7 +368,7 @@ object fxSpec extends Properties {
def throwThrowable[A](throwable: => Throwable): A =
throw throwable // scalafix:ok DisableSyntax.throw

def run[F[*]: Fx: Functor, A](a: => A): F[A] =
def run[F[*]: Fx, A](a: => A): F[A] =
Fx[F].effectOf(a)

object IoSpec {
Expand All @@ -382,8 +379,6 @@ object fxSpec extends Properties {
implicit val eqIo: Eq[IO[Int]] =
(x, y) => x.flatMap(xx => y.map(_ === xx)).unsafeRunSync()

implicit val ioFx: Fx[IO] = effectie.instances.ce2.fx.ioFx

MonadSpec.testMonadLaws[IO]("IO")
}

Expand Down Expand Up @@ -576,6 +571,8 @@ object fxSpec extends Properties {
.handleNonFatalWith(fa) {
case NonFatal(`expectedExpcetion`) =>
IO.pure(expected)
case err =>
throw err // scalafix:ok DisableSyntax.throw
}
.unsafeRunSync()

Expand Down Expand Up @@ -790,6 +787,8 @@ object fxSpec extends Properties {
.handleNonFatal(fa) {
case NonFatal(`expectedExpcetion`) =>
expected
case err =>
throw err // scalafix:ok DisableSyntax.throw
}
.unsafeRunSync()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ object toFutureSpec extends Properties {
val fa = IO(expected)

implicit val es: ExecutorService = ConcurrentSupport.newExecutorService(2)
@SuppressWarnings(Array("org.wartremover.warts.ExplicitImplicitTypes"))
implicit val ec =
ConcurrentSupport.newExecutionContextWithLogger(es, ErrorLogger.printlnExecutionContextErrorLogger)
ConcurrentSupport.runAndShutdown(es, waitFor800Millis) {
val future = ToFuture[IO].unsafeToFuture(fa)
val ioResult = fa.unsafeRunSync() ==== expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ object CanCatchSyntaxSpec {
def throwThrowable[A](throwable: => Throwable): A =
throw throwable // scalafix:ok DisableSyntax.throw

def run[F[*]: FxCtor: Functor, A](a: => A): F[A] =
def run[F[*]: FxCtor, A](a: => A): F[A] =
effectOf[F](a)

object IoSpec {
Expand Down Expand Up @@ -1069,7 +1069,7 @@ object CanHandleErrorSyntaxSpec {
def throwThrowable[A](throwable: => Throwable): A =
throw throwable // scalafix:ok DisableSyntax.throw

def run[F[*]: FxCtor: Functor, A](a: => A): F[A] =
def run[F[*]: FxCtor, A](a: => A): F[A] =
effectOf[F](a)

object IoSpec {
Expand All @@ -1083,6 +1083,8 @@ object CanHandleErrorSyntaxSpec {
.handleNonFatalWith {
case NonFatal(`expectedExpcetion`) =>
IO.pure(expected)
case err =>
throw err // scalafix:ok DisableSyntax.throw
}
.unsafeRunSync()

Expand Down Expand Up @@ -1295,6 +1297,8 @@ object CanHandleErrorSyntaxSpec {
.handleNonFatal {
case NonFatal(`expectedExpcetion`) =>
expected
case err =>
throw err // scalafix:ok DisableSyntax.throw
}
.unsafeRunSync()

Expand Down Expand Up @@ -1620,7 +1624,7 @@ object CanHandleErrorSyntaxSpec {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(fa2.handleEitherNonFatalWith(err => Future(expected)))
)(fa2.handleEitherNonFatalWith(_ => Future(expected)))

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down Expand Up @@ -1679,7 +1683,7 @@ object CanHandleErrorSyntaxSpec {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(fa2.handleEitherTNonFatalWith(err => Future(expected)).value)
)(fa2.handleEitherTNonFatalWith(_ => Future(expected)).value)

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down Expand Up @@ -1830,7 +1834,7 @@ object CanHandleErrorSyntaxSpec {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(fa2.handleEitherNonFatal(err => expected))
)(fa2.handleEitherNonFatal(_ => expected))

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down Expand Up @@ -1889,7 +1893,7 @@ object CanHandleErrorSyntaxSpec {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(fa2.handleEitherTNonFatal(err => expected).value)
)(fa2.handleEitherTNonFatal(_ => expected).value)

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down Expand Up @@ -2673,7 +2677,7 @@ object CanRecoverSyntaxSpec {
def throwThrowable[A](throwable: => Throwable): A =
throw throwable // scalafix:ok DisableSyntax.throw

def run[F[*]: FxCtor: Functor, A](a: => A): F[A] =
def run[F[*]: FxCtor, A](a: => A): F[A] =
effectOf[F](a)

object IOSpec {
Expand Down Expand Up @@ -3312,7 +3316,7 @@ object CanRecoverSyntaxSpec {
executorService,
waitFor,
)(fa2.recoverEitherFromNonFatalWith {
case err => Future(expected)
case err @ _ => Future(expected)
})

actualFailedResult ==== expectedFailedResult and actual ==== expected
Expand Down Expand Up @@ -3379,7 +3383,7 @@ object CanRecoverSyntaxSpec {
executorService,
waitFor,
)(fa2.recoverEitherTFromNonFatalWith {
case err => Future(expected)
case err @ _ => Future(expected)
}.value)

actualFailedResult ==== expectedFailedResult and actual ==== expected
Expand Down Expand Up @@ -3543,7 +3547,7 @@ object CanRecoverSyntaxSpec {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(fa2.recoverEitherFromNonFatal { case err => expected })
)(fa2.recoverEitherFromNonFatal { case err @ _ => expected })

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down Expand Up @@ -3606,7 +3610,7 @@ object CanRecoverSyntaxSpec {
ConcurrentSupport.futureToValueAndTerminate(
executorService,
waitFor,
)(fa2.recoverEitherTFromNonFatal { case err => expected }.value)
)(fa2.recoverEitherTFromNonFatal { case err @ _ => expected }.value)

actualFailedResult ==== expectedFailedResult and actual ==== expected
}
Expand Down
Loading

0 comments on commit ba5f0f2

Please sign in to comment.