Skip to content

Commit 7924e89

Browse files
mmienkoMichael Mienko
and
Michael Mienko
authored
Update scalafmt to latest in 3.x.x series; 3.9.0 (#970)
* Update scalafmt to latest in 2.x.x series; 2.7.5 * Revert "Update scalafmt to latest in 2.x.x series; 2.7.5" This reverts commit 9f50fe6. * Use latest version --------- Co-authored-by: Michael Mienko <[email protected]>
1 parent a283b66 commit 7924e89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+472
-449
lines changed

.scalafmt.conf

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
version = "2.4.2"
1+
version = "3.9.0"
2+
runner.dialect = "scala213source3"
23
align.openParenCallSite = false
34
align.tokens = ["%", "%%", {code = "=>", owner = "Case"}, {code = "=", owner = "(Enumerator.Val|Defn.(Va(l|r)|Def|Type))"}, ]
45
align.arrowEnumeratorGenerator = true
56
binPack.parentConstructors = false
6-
danglingParentheses = true
7+
danglingParentheses.preset = true
8+
newlines.implicitParamListModifierForce = [before]
79
maxColumn = 120
8-
newlines.afterImplicitKWInVerticalMultiline = true
9-
newlines.beforeImplicitKWInVerticalMultiline = true
1010
project.excludeFilters = [ .scalafmt.conf ]
1111
project.git = true
1212
rewrite.rules = [PreferCurlyFors, RedundantBraces, RedundantParens, SortImports]
1313
spaces.inImportCurlyBraces = true
1414
style = defaultWithAlign
15-
unindentTopLevelOperators = true
1615

1716
rewriteTokens {
1817
"⇒" = "=>"

modules/core/src/main/scala-2/dev/profunktor/redis4cats/TypeInqualityCompat.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ package dev.profunktor.redis4cats
1818

1919
private[redis4cats] trait TypeInequalityCompat {
2020

21-
/**
22-
* Type inequality
21+
/** Type inequality
2322
*
2423
* Credits: https://stackoverflow.com/a/6929051
2524
*/

modules/core/src/main/scala/dev/profunktor/redis4cats/codecs/Codecs.scala

+5-8
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ import java.nio.ByteBuffer
2323

2424
object Codecs {
2525

26-
/**
27-
* Given a base RedisCodec[K, V1] and a split epimorphism between V1 and V2,
28-
* a new RedisCodec[K, V2] can be derived.
29-
* */
26+
/** Given a base RedisCodec[K, V1] and a split epimorphism between V1 and V2, a new RedisCodec[K, V2] can be derived.
27+
*/
3028
def derive[K, V1, V2](
3129
baseCodec: RedisCodec[K, V1],
3230
epi: SplitEpi[V1, V2]
@@ -42,10 +40,9 @@ object Codecs {
4240
)
4341
}
4442

45-
/**
46-
* Given a base RedisCodec[K1, V1], a split epimorphism between K1 and K2, and
47-
* a split epimorphism between V1 and V2, a new RedisCodec[K2, V2] can be derived.
48-
* */
43+
/** Given a base RedisCodec[K1, V1], a split epimorphism between K1 and K2, and a split epimorphism between V1 and V2,
44+
* a new RedisCodec[K2, V2] can be derived.
45+
*/
4946
def derive[K1, K2, V1, V2](
5047
baseCodec: RedisCodec[K1, V1],
5148
epiKeys: SplitEpi[K1, K2],

modules/core/src/main/scala/dev/profunktor/redis4cats/config.scala

+7-6
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ object config {
5353
def apply(): Redis4CatsConfig = Redis4CatsConfigImpl(ShutdownConfig())
5454
}
5555

56-
/**
57-
* Configure the shutdown of the lettuce redis client,
58-
* controlling the time spent on shutting down Netty's thread pools.
56+
/** Configure the shutdown of the lettuce redis client, controlling the time spent on shutting down Netty's thread
57+
* pools.
5958
*
60-
* @param quietPeriod the quiet period to allow the executor to gracefully shut down.
61-
* @param timeout timeout the maximum amount of time to wait until the backing executor is shutdown regardless if a task was
62-
* submitted during the quiet period.
59+
* @param quietPeriod
60+
* the quiet period to allow the executor to gracefully shut down.
61+
* @param timeout
62+
* timeout the maximum amount of time to wait until the backing executor is shutdown regardless if a task was
63+
* submitted during the quiet period.
6364
*/
6465
// Shutdown values from new Lettuce defaults coming in version 6 (#974dd70), defaults in 5.3 are causing long waiting time.
6566
case class ShutdownConfig(quietPeriod: FiniteDuration = 0.seconds, timeout: FiniteDuration = 2.seconds)

modules/core/src/main/scala/dev/profunktor/redis4cats/connection/RedisClient.scala

+20-20
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ object RedisClient {
4343

4444
val release: RedisClient => F[Unit] = client =>
4545
Log[F].info(s"Releasing Redis connection: $uri") *>
46-
FutureLift[F]
47-
.lift(
48-
client.underlying.shutdownAsync(
49-
config.shutdown.quietPeriod.toNanos,
50-
config.shutdown.timeout.toNanos,
51-
TimeUnit.NANOSECONDS
52-
)
46+
FutureLift[F]
47+
.lift(
48+
client.underlying.shutdownAsync(
49+
config.shutdown.quietPeriod.toNanos,
50+
config.shutdown.timeout.toNanos,
51+
TimeUnit.NANOSECONDS
5352
)
54-
.void
53+
)
54+
.void
5555

5656
(acquire, release)
5757
}
@@ -68,20 +68,20 @@ object RedisClient {
6868
implicit val fl: FutureLift[F] = MkRedis[F].futureLift
6969
implicit val log: Log[F] = MkRedis[F].log
7070

71-
/**
72-
* Creates a [[RedisClient]] with default options.
71+
/** Creates a [[RedisClient]] with default options.
7372
*
7473
* Example:
7574
*
7675
* {{{
7776
* RedisClient[IO].from("redis://localhost")
7877
* }}}
7978
*/
80-
def from(strUri: => String)(implicit F: Sync[F]): Resource[F, RedisClient] =
79+
def from(strUri: => String)(
80+
implicit F: Sync[F]
81+
): Resource[F, RedisClient] =
8182
Resource.eval(RedisURI.make[F](strUri)).flatMap(this.fromUri(_))
8283

83-
/**
84-
* Creates a [[RedisClient]] with default options from a validated URI.
84+
/** Creates a [[RedisClient]] with default options from a validated URI.
8585
*
8686
* Example:
8787
*
@@ -94,11 +94,12 @@ object RedisClient {
9494
*
9595
* You may prefer to use [[from]] instead, which takes a raw string.
9696
*/
97-
def fromUri(uri: => RedisURI)(implicit F: Sync[F]): Resource[F, RedisClient] =
97+
def fromUri(uri: => RedisURI)(
98+
implicit F: Sync[F]
99+
): Resource[F, RedisClient] =
98100
Resource.eval(Sync[F].delay(ClientOptions.create())).flatMap(this.custom(uri, _))
99101

100-
/**
101-
* Creates a [[RedisClient]] with the supplied options.
102+
/** Creates a [[RedisClient]] with the supplied options.
102103
*
103104
* Example:
104105
*
@@ -115,8 +116,7 @@ object RedisClient {
115116
): Resource[F, RedisClient] =
116117
Resource.eval(RedisURI.make[F](strUri)).flatMap(this.custom(_, opts))
117118

118-
/**
119-
* Creates a [[RedisClient]] with the supplied options from a validated URI.
119+
/** Creates a [[RedisClient]] with the supplied options from a validated URI.
120120
*
121121
* Example:
122122
*
@@ -128,8 +128,8 @@ object RedisClient {
128128
* } yield cli
129129
* }}}
130130
*
131-
* Additionally, it can take a [[dev.profunktor.redis4cats.config.Redis4CatsConfig]] to configure the shutdown timeouts,
132-
* for example. However, you don't need to worry about this in most cases.
131+
* Additionally, it can take a [[dev.profunktor.redis4cats.config.Redis4CatsConfig]] to configure the shutdown
132+
* timeouts, for example. However, you don't need to worry about this in most cases.
133133
*
134134
* {{{
135135
* RedisClient[IO].custom(uri, ops, Redis4CatsConfig())

modules/core/src/main/scala/dev/profunktor/redis4cats/connection/RedisClusterClient.scala

+18-18
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import dev.profunktor.redis4cats.JavaConversions._
2626
import dev.profunktor.redis4cats.config._
2727
import dev.profunktor.redis4cats.data.NodeId
2828
import dev.profunktor.redis4cats.effect._
29-
import io.lettuce.core.cluster.models.partitions.{ RedisClusterNode, Partitions => JPartitions }
29+
import io.lettuce.core.cluster.models.partitions.{ Partitions => JPartitions, RedisClusterNode }
3030
import io.lettuce.core.cluster.{
3131
ClusterClientOptions,
3232
ClusterTopologyRefreshOptions,
33-
SlotHash,
34-
RedisClusterClient => JClusterClient
33+
RedisClusterClient => JClusterClient,
34+
SlotHash
3535
}
3636

3737
sealed abstract case class RedisClusterClient private (underlying: JClusterClient)
@@ -45,25 +45,25 @@ object RedisClusterClient {
4545

4646
val acquire: F[RedisClusterClient] =
4747
Log[F].info(s"Acquire Redis Cluster client") *>
48-
FutureLift[F]
49-
.delay {
50-
val javaUris = uri.map(_.underlying).asJava
51-
config.clientResources.fold(JClusterClient.create(javaUris))(JClusterClient.create(_, javaUris))
52-
}
53-
.flatTap(initializeClusterTopology[F](_, config.topologyViewRefreshStrategy, config.nodeFilter))
54-
.map(new RedisClusterClient(_) {})
48+
FutureLift[F]
49+
.delay {
50+
val javaUris = uri.map(_.underlying).asJava
51+
config.clientResources.fold(JClusterClient.create(javaUris))(JClusterClient.create(_, javaUris))
52+
}
53+
.flatTap(initializeClusterTopology[F](_, config.topologyViewRefreshStrategy, config.nodeFilter))
54+
.map(new RedisClusterClient(_) {})
5555

5656
val release: RedisClusterClient => F[Unit] = client =>
5757
Log[F].info(s"Releasing Redis Cluster client: ${client.underlying}") *>
58-
FutureLift[F]
59-
.lift(
60-
client.underlying.shutdownAsync(
61-
config.shutdown.quietPeriod.toNanos,
62-
config.shutdown.timeout.toNanos,
63-
TimeUnit.NANOSECONDS
64-
)
58+
FutureLift[F]
59+
.lift(
60+
client.underlying.shutdownAsync(
61+
config.shutdown.quietPeriod.toNanos,
62+
config.shutdown.timeout.toNanos,
63+
TimeUnit.NANOSECONDS
6564
)
66-
.void
65+
)
66+
.void
6767

6868
(acquire, release)
6969
}

modules/core/src/main/scala/dev/profunktor/redis4cats/connection/RedisMasterReplica.scala

+8-11
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ import dev.profunktor.redis4cats.effect.{ FutureLift, Log }
2525
import io.lettuce.core.masterreplica.{ MasterReplica, StatefulRedisMasterReplicaConnection }
2626
import io.lettuce.core.{ ClientOptions, ReadFrom => JReadFrom }
2727

28-
/**
29-
* It encapsulates an underlying `MasterReplica` connection
28+
/** It encapsulates an underlying `MasterReplica` connection
3029
*/
3130
sealed abstract case class RedisMasterReplica[K, V] private (underlying: StatefulRedisMasterReplicaConnection[K, V])
3231

@@ -50,18 +49,17 @@ object RedisMasterReplica {
5049

5150
val release: RedisMasterReplica[K, V] => F[Unit] = connection =>
5251
Log[F].info(s"Releasing Redis Master/Replica connection: ${connection.underlying}") *>
53-
FutureLift[F].lift(connection.underlying.closeAsync()).void
52+
FutureLift[F].lift(connection.underlying.closeAsync()).void
5453

5554
(acquire, release)
5655
}
5756

5857
class MasterReplicaPartiallyApplied[F[_]: Async: Log] {
5958

60-
/**
61-
* Creates a [[RedisMasterReplica]]
59+
/** Creates a [[RedisMasterReplica]]
6260
*
63-
* It will also create an underlying [[RedisClient]] with default client options to
64-
* establish connection with Redis.
61+
* It will also create an underlying [[RedisClient]] with default client options to establish connection with
62+
* Redis.
6563
*
6664
* Example:
6765
*
@@ -80,11 +78,10 @@ object RedisMasterReplica {
8078
.eval(Sync[F].delay(ClientOptions.create()))
8179
.flatMap(withOptions(codec, _, Redis4CatsConfig(), uris: _*)(readFrom))
8280

83-
/**
84-
* Creates a [[RedisMasterReplica]] using the supplied client options
81+
/** Creates a [[RedisMasterReplica]] using the supplied client options
8582
*
86-
* It will also create an underlying [[RedisClient]] using the supplied client options
87-
* to establish connection with Redis.
83+
* It will also create an underlying [[RedisClient]] using the supplied client options to establish connection with
84+
* Redis.
8885
*
8986
* Example:
9087
*

modules/core/src/main/scala/dev/profunktor/redis4cats/data.scala

+8-13
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,20 @@ object data {
5151
val Utf8: RedisCodec[String, String] = RedisCodec(StringCodec.UTF8)
5252
val Bytes: RedisCodec[Array[Byte], Array[Byte]] = RedisCodec(ByteArrayCodec.INSTANCE)
5353

54-
/**
55-
* It compresses every value sent to Redis and it decompresses every value read
56-
* from Redis using the DEFLATE compression algorithm.
54+
/** It compresses every value sent to Redis and it decompresses every value read from Redis using the DEFLATE
55+
* compression algorithm.
5756
*/
5857
def deflate[K, V](codec: RedisCodec[K, V]): RedisCodec[K, V] =
5958
RedisCodec(CompressionCodec.valueCompressor(codec.underlying, CompressionCodec.CompressionType.DEFLATE))
6059

61-
/**
62-
* It compresses every value sent to Redis and it decompresses every value read
63-
* from Redis using the GZIP compression algorithm.
60+
/** It compresses every value sent to Redis and it decompresses every value read from Redis using the GZIP
61+
* compression algorithm.
6462
*/
6563
def gzip[K, V](codec: RedisCodec[K, V]): RedisCodec[K, V] =
6664
RedisCodec(CompressionCodec.valueCompressor(codec.underlying, CompressionCodec.CompressionType.GZIP))
6765

68-
/**
69-
* It encrypts every value sent to Redis and it decrypts every value read from
70-
* Redis using the supplied CipherSuppliers.
66+
/** It encrypts every value sent to Redis and it decrypts every value read from Redis using the supplied
67+
* CipherSuppliers.
7168
*/
7269
def secure[K, V](
7370
codec: RedisCodec[K, V],
@@ -76,16 +73,14 @@ object data {
7673
): RedisCodec[K, V] =
7774
RedisCodec(CipherCodec.forValues(codec.underlying, encrypt, decrypt))
7875

79-
/**
80-
* It creates a CipherSupplier given a secret key for encryption.
76+
/** It creates a CipherSupplier given a secret key for encryption.
8177
*
8278
* A CipherSupplier is needed for [[RedisCodec.secure]]
8379
*/
8480
def encryptSupplier[F[_]: Sync](key: SecretKeySpec): F[CipherCodec.CipherSupplier] =
8581
cipherSupplier[F](key, Cipher.ENCRYPT_MODE)
8682

87-
/**
88-
* It creates a CipherSupplier given a secret key for decryption.
83+
/** It creates a CipherSupplier given a secret key for decryption.
8984
*
9085
* A CipherSupplier is needed for [[RedisCodec.secure]]
9186
*/

modules/core/src/main/scala/dev/profunktor/redis4cats/effect/FutureLift.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ object FutureLift {
5252

5353
implicit final class FutureLiftOps[F[_]: ApplicativeThrow: FutureLift: Log, A](fa: => RedisFuture[A]) {
5454
def futureLift: F[A] =
55-
FutureLift[F].lift(fa).onError {
56-
case e: ExecutionException => Log[F].error(s"${e.getMessage()} - ${Option(e.getCause())}")
55+
FutureLift[F].lift(fa).onError { case e: ExecutionException =>
56+
Log[F].error(s"${e.getMessage()} - ${Option(e.getCause())}")
5757
}
5858
}
5959

modules/core/src/main/scala/dev/profunktor/redis4cats/effect/Log.scala

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ package dev.profunktor.redis4cats.effect
1919
import cats.Applicative
2020
import cats.effect.kernel.Sync
2121

22-
/**
23-
* Typeclass used for internal logging such as acquiring and releasing connections.
22+
/** Typeclass used for internal logging such as acquiring and releasing connections.
2423
*
25-
* It is recommended to use `log4cats` for production usage but if you do not want
26-
* the extra dependency, you can opt to use either of the simple instances provided.
24+
* It is recommended to use `log4cats` for production usage but if you do not want the extra dependency, you can opt to
25+
* use either of the simple instances provided.
2726
*
2827
* If you don't need logging at all, you can use [[Log.NoOp]]
2928
*
@@ -36,15 +35,17 @@ import cats.effect.kernel.Sync
3635
* {{{
3736
* import dev.profunktor.redis4cats.effect.Log.Stdout._
3837
* }}}
39-
* */
38+
*/
4039
trait Log[F[_]] {
4140
def debug(msg: => String): F[Unit]
4241
def error(msg: => String): F[Unit]
4342
def info(msg: => String): F[Unit]
4443
}
4544

4645
object Log {
47-
def apply[F[_]](implicit ev: Log[F]): Log[F] = ev
46+
def apply[F[_]](
47+
implicit ev: Log[F]
48+
): Log[F] = ev
4849

4950
object NoOp {
5051
implicit def instance[F[_]: Applicative]: Log[F] =

modules/core/src/main/scala/dev/profunktor/redis4cats/effect/MkRedis.scala

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ import dev.profunktor.redis4cats.config.Redis4CatsConfig
2424
import dev.profunktor.redis4cats.tx.TxRunner
2525
import io.lettuce.core.ClientOptions
2626

27-
/**
28-
* MkRedis is a capability trait that abstracts over the creation of RedisClient,
29-
* RedisClusterClient, among other things.
27+
/** MkRedis is a capability trait that abstracts over the creation of RedisClient, RedisClusterClient, among other
28+
* things.
3029
*
31-
* It serves the internal purpose to orchastrate creation of such instances while
32-
* avoiding impure constraints such as `Async` or `Sync`.
30+
* It serves the internal purpose to orchastrate creation of such instances while avoiding impure constraints such as
31+
* `Async` or `Sync`.
3332
*
3433
* Users only need a `MkRedis` constraint and `MonadThrow` to create a `Redis` instance.
3534
*/

modules/core/src/main/scala/dev/profunktor/redis4cats/effect/TxExecutor.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ private[redis4cats] object TxExecutor {
5353
private def exitOnFatal(ec: ExecutionContext): ExecutionContext = new ExecutionContext {
5454
def execute(r: Runnable): Unit =
5555
ec.execute(() =>
56-
try {
56+
try
5757
r.run()
58-
} catch {
58+
catch {
5959
case NonFatal(t) =>
6060
reportFailure(t)
6161

0 commit comments

Comments
 (0)