From 39001abbe5a88a4ec84ca8788d3de899cbf79ef4 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 28 Oct 2024 14:42:28 +0000 Subject: [PATCH 1/2] Applied Scalafix rule(s) github:typelevel/cats-effect/v3_0_0?sha=v3.0.0 --- api/src/test/scala/slog4s/EffectTest.scala | 5 +++-- api/src/test/scala/slog4s/MockClock.scala | 2 +- .../slog4s/console/internal/LoggingRuntimeImpl.scala | 2 +- .../slog4s/console/internal/SyncFormatter.scala | 2 +- .../scala/slog4s/console/ConsoleConfigTest.scala | 9 +++++---- .../scala/slog4s/console/ConsoleLoggerTest.scala | 10 +++++----- .../src/test/scala/slog4s/shared/ContextTest.scala | 12 ++++++------ 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/api/src/test/scala/slog4s/EffectTest.scala b/api/src/test/scala/slog4s/EffectTest.scala index 991933a..a758782 100644 --- a/api/src/test/scala/slog4s/EffectTest.scala +++ b/api/src/test/scala/slog4s/EffectTest.scala @@ -1,17 +1,18 @@ package slog4s import cats.effect.syntax.all._ -import cats.effect.{ConcurrentEffect, Sync, Timer} +import cats.effect.{ConcurrentEffect, Sync} import cats.syntax.flatMap._ import org.scalactic.source import org.scalatest.funspec.FixtureAnyFunSpec import scala.concurrent.duration._ +import cats.effect.Temporal abstract class EffectTest[F[_]] extends FixtureAnyFunSpec { protected def asEffect(fixtureParam: FixtureParam): ConcurrentEffect[F] - protected def asTimer(fixtureParam: FixtureParam): Timer[F] + protected def asTimer(fixtureParam: FixtureParam): Temporal[F] protected def timeout: FiniteDuration = 10.seconds def it_( diff --git a/api/src/test/scala/slog4s/MockClock.scala b/api/src/test/scala/slog4s/MockClock.scala index 4c84be4..0ed7b6b 100644 --- a/api/src/test/scala/slog4s/MockClock.scala +++ b/api/src/test/scala/slog4s/MockClock.scala @@ -3,12 +3,12 @@ package slog4s import java.util.concurrent.TimeUnit import cats.Monad -import cats.effect.concurrent.Ref import cats.effect.{Clock, Sync} import cats.syntax.flatMap._ import cats.syntax.functor._ import scala.concurrent.duration.Duration +import cats.effect.Ref class MockClock[F[_]](val real: Ref[F, Long], val mono: Ref[F, Long])(implicit F: Monad[F] diff --git a/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala b/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala index d313423..956d2d6 100644 --- a/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala +++ b/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala @@ -1,11 +1,11 @@ package slog4s.console.internal -import cats.effect.concurrent.Semaphore import cats.effect.{Clock, Concurrent, Sync} import cats.syntax.functor._ import slog4s.console.ConsoleConfig import slog4s.shared.{AsContext, LoggingRuntime} import slog4s.{Logger, LoggerFactory, LoggingContext, StructureBuilder} +import cats.effect.std.Semaphore private[console] class LoggingRuntimeImpl[F[ _ diff --git a/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala b/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala index 83d7893..e8beb09 100644 --- a/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala +++ b/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala @@ -2,8 +2,8 @@ package slog4s.console.internal import java.time.Instant -import cats.effect.concurrent.Semaphore import slog4s.{Level, Location} +import cats.effect.std.Semaphore private[console] class SyncFormatter[F[_], T]( semaphore: Semaphore[F], diff --git a/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala b/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala index d2d7a12..c2ee83b 100644 --- a/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala +++ b/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala @@ -1,6 +1,6 @@ package slog4s.console -import cats.effect.{ConcurrentEffect, ContextShift, IO, Timer} +import cats.effect.{ConcurrentEffect, IO} import cats.syntax.functor._ import cats.syntax.flatMap._ import org.scalactic.source.Position @@ -9,19 +9,20 @@ import slog4s.{EffectTest, Level} import slog4s.console.ConsoleConfigTest.Fixture import scala.concurrent.ExecutionContext +import cats.effect.Temporal class ConsoleConfigTest extends EffectTest[IO] { override protected def asEffect( fixtureParam: FixtureParam ): ConcurrentEffect[IO] = fixtureParam.F - override protected def asTimer(fixtureParam: FixtureParam): Timer[IO] = + override protected def asTimer(fixtureParam: FixtureParam): Temporal[IO] = fixtureParam.timer override protected def withFixture(test: OneArgTest): Outcome = { implicit val contextShift: ContextShift[IO] = IO.contextShift(ExecutionContext.global) - implicit val timer: Timer[IO] = IO.timer(ExecutionContext.global) + implicit val timer: Temporal[IO] = IO.timer(ExecutionContext.global) test(new Fixture[IO]()) } @@ -57,7 +58,7 @@ object ConsoleConfigTest { import org.scalatest.matchers.should.Matchers._ class Fixture[F[_]](implicit val F: ConcurrentEffect[F], - val timer: Timer[F] + val timer: Temporal[F] ) { def validateLevel( fLevel: F[Level] diff --git a/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala b/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala index 74c107d..e55cfdd 100644 --- a/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala +++ b/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala @@ -2,8 +2,7 @@ package slog4s.console import java.io.{ByteArrayOutputStream, PrintStream} import java.util.concurrent.{Executors, ThreadFactory} -import cats.effect.concurrent.Ref -import cats.effect.{ConcurrentEffect, ContextShift, IO, Resource, Sync, Timer} +import cats.effect.{ConcurrentEffect, IO, Resource, Sync} import cats.syntax.all._ import slog4s.Location.Code import slog4s.console.ConsoleLoggerTest.{Fixture, Output} @@ -16,13 +15,14 @@ import slog4s.shared.{ import slog4s._ import scala.concurrent.ExecutionContext +import cats.effect.{ Ref, Temporal } abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] { override protected def asEffect( fixtureParam: FixtureParam ): ConcurrentEffect[F] = fixtureParam.F - override protected def asTimer(fixtureParam: FixtureParam): Timer[F] = + override protected def asTimer(fixtureParam: FixtureParam): Temporal[F] = fixtureParam.T override type FixtureParam = ConsoleLoggerTest.Fixture[F] @@ -46,7 +46,7 @@ abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] { implicit val contextShift: ContextShift[IO] = IO.contextShift(ec) implicit val F: Sync[IO] = ConcurrentEffect[IO] implicit val mockClock: MockClock[IO] = MockClock.make[IO].unsafeRunSync() - implicit val timer: Timer[IO] = IO.timer(ec) + implicit val timer: Temporal[IO] = IO.timer(ec) val contextRuntimeBuilder = new ContextRuntimeBuilder[IO] { override def make[T](empty: T): IO[ContextRuntime[IO, T]] = { Ref.of(empty).map { context => @@ -101,7 +101,7 @@ object ConsoleLoggerTest { )(implicit val F: ConcurrentEffect[F], val C: MockClock[F], - val T: Timer[F] + val T: Temporal[F] ) { val loggerName = "test-logger" val logger = loggerFactory.make(loggerName) diff --git a/shared/src/test/scala/slog4s/shared/ContextTest.scala b/shared/src/test/scala/slog4s/shared/ContextTest.scala index 405dc31..3c19388 100644 --- a/shared/src/test/scala/slog4s/shared/ContextTest.scala +++ b/shared/src/test/scala/slog4s/shared/ContextTest.scala @@ -1,19 +1,19 @@ package slog4s.shared -import cats.effect.concurrent.Deferred import cats.effect.syntax.all._ -import cats.effect.{Bracket, ConcurrentEffect, Timer} +import cats.effect.ConcurrentEffect import cats.syntax.flatMap._ import cats.syntax.functor._ import slog4s.EffectTest import slog4s.shared.ContextTest.Fixture +import cats.effect.{ Deferred, MonadCancel, Temporal } abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { override type FixtureParam = Fixture[F] override protected def asEffect( fixtureParam: Fixture[F] ): ConcurrentEffect[F] = fixtureParam.F - override protected def asTimer(fixtureParam: Fixture[F]): Timer[F] = + override protected def asTimer(fixtureParam: Fixture[F]): Temporal[F] = fixtureParam.T describe(s"$runtimeName-based context") { @@ -95,8 +95,8 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { promise <- Deferred[F, Unit] // promise used to indicate that a fiber has entered inside `guarantee`. fiberStarted <- Deferred[F, Unit] - fiber <- Bracket[F, Throwable] - .guarantee(fiberCode(fiberStarted))(promise.complete(())) + fiber <- MonadCancel[F, Throwable] + .guarantee(fiberCode(fiberStarted), promise.complete(())) .start _ <- fiberStarted.get _ <- fiber.cancel.start @@ -110,7 +110,7 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { object ContextTest { final class Fixture[F[_]](implicit val F: ConcurrentEffect[F], - val T: Timer[F], + val T: Temporal[F], val asContext: AsContext[F, Int], val useContext: UseContext[F, Int] ) From a8224e725424cecc3cb5a8b9b107844aab66d2cf Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 28 Oct 2024 14:43:30 +0000 Subject: [PATCH 2/2] Update cats-effect to 3.5.5 --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 4fd0640..8e6000b 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -2,7 +2,7 @@ import sbt._ object Dependencies { lazy val catsCore = "org.typelevel" %% "cats-core" % "2.12.0" - lazy val catsEffect = "org.typelevel" %% "cats-effect" % "2.5.5" + lazy val catsEffect = "org.typelevel" %% "cats-effect" % "3.5.5" lazy val catsMtl = "org.typelevel" %% "cats-mtl-core" % "0.7.1" lazy val circeCore = "io.circe" %% "circe-core" % "0.14.9" lazy val circeLiteral =