Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Commit 788acb1

Browse files
Update scalafmt-core to 3.0.0 (#215)
* Update scalafmt-core to 3.0.0 * Reformat with scalafmt 3.0.0 * Update scalafmt Signed-off-by: Bendix Saeltz <bendix@saeltz.de> Co-authored-by: scala-steward <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bendix Saeltz <bendix@saeltz.de>
1 parent 4398b40 commit 788acb1

File tree

7 files changed

+70
-43
lines changed

7 files changed

+70
-43
lines changed

.scalafmt.conf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# https://scalameta.org/scalafmt/docs/configuration.html
2-
version = "2.7.5"
2+
version = "3.0.0"
3+
runner.dialect = scala213source3
34
preset = defaultWithAlign
45
align.preset = most
56
align.multiline = false
@@ -10,10 +11,14 @@ rewrite.rules = [
1011
PreferCurlyFors,
1112
RedundantBraces,
1213
RedundantParens,
13-
SortImports
14+
SortImports,
15+
SortModifiers
1416
]
17+
rewrite.redundantBraces.stringInterpolation = true
18+
rewrite.redundantBraces.parensForOneLineApply = true
1519
align.tokens = [{code = "="}, {code = "=>", owner = "Case"}, {code = "%", owner = "Term.ApplyInfix"}, {code = "%%", owner = "Term.ApplyInfix"}]
1620
rewrite.neverInfix.excludeFilters = [
21+
// Default list from http://scalameta.org/scalafmt/#Other
1722
until
1823
to
1924
by
@@ -30,6 +35,7 @@ rewrite.neverInfix.excludeFilters = [
3035
synchronized
3136
have
3237
when
38+
// custom entries here
3339
is
3440
ignore
3541
not
@@ -41,4 +47,5 @@ rewrite.neverInfix.excludeFilters = [
4147
called
4248
wasNever
4349
calledAgain
50+
returns
4451
]

src/main/scala/io/moia/scalaHttpClient/AwsRequestSigner.scala

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ class AwsRequestSigner private (credentialsProvider: AwsCredentialsProvider, reg
3030

3131
/** Signs the given HttpRequest
3232
*
33-
* @param request `HttpRequest` to be signed
34-
* @return `Future[HttpRequest]` the signed `HttpRequest`
35-
* @throws AlreadyAuthorizedException if the given `HttpRequest` already includes an "Authorize" header
33+
* @param request
34+
* `HttpRequest` to be signed
35+
* @return
36+
* `Future[HttpRequest]` the signed `HttpRequest`
37+
* @throws AlreadyAuthorizedException
38+
* if the given `HttpRequest` already includes an "Authorize" header
3639
*/
3740
def signRequest(request: HttpRequest): Future[HttpRequest] =
3841
if (isAlreadyAuthorized(request.headers))
@@ -53,15 +56,19 @@ class AwsRequestSigner private (credentialsProvider: AwsCredentialsProvider, reg
5356

5457
/** Checks if the given collection of `HttpHeader`s includes one "Authorization" header
5558
*
56-
* @param headers `Seq[HttpHeader]` headers of an Akka `HttpRequest`
57-
* @return true if "Authorization" header exists
59+
* @param headers
60+
* `Seq[HttpHeader]` headers of an Akka `HttpRequest`
61+
* @return
62+
* true if "Authorization" header exists
5863
*/
5964
private def isAlreadyAuthorized(headers: Seq[HttpHeader]): Boolean = headers.exists(_.is("authorization"))
6065

6166
/** Constructs an `SdkHttpFullRequest` from Akka's `HttpRequest` for signing.
6267
*
63-
* @param request HttpRequest to convert
64-
* @return SdkHttpFullRequest
68+
* @param request
69+
* HttpRequest to convert
70+
* @return
71+
* SdkHttpFullRequest
6572
*/
6673
private def toSdkRequest(request: HttpRequest): SdkHttpFullRequest = {
6774
val content: InputStream = request.entity.dataBytes.runWith(StreamConverters.asInputStream())
@@ -89,8 +96,10 @@ class AwsRequestSigner private (credentialsProvider: AwsCredentialsProvider, reg
8996

9097
/** Extracts the headers from the `SdkHttpFullRequest` as collection of Akka's `HttpHeader`s
9198
*
92-
* @param signedSdkRequest `SdkHttpFullRequest` after signing
93-
* @return `Seq[HttpHeader]` of the signedSdkRequest
99+
* @param signedSdkRequest
100+
* `SdkHttpFullRequest` after signing
101+
* @return
102+
* `Seq[HttpHeader]` of the signedSdkRequest
94103
*/
95104
private def getSdkHeaders(signedSdkRequest: SdkHttpFullRequest): scala.collection.immutable.Seq[HttpHeader] =
96105
signedSdkRequest
@@ -117,9 +126,12 @@ object AwsRequestSigner extends StrictLogging {
117126

118127
/** Construct an `AwsRequestSigner` from the given configuration.
119128
*
120-
* @param config `AwsRequestSignerConfig` to be used to construct one of the three config providers
121-
* @param mat `Materializer` on which the `Future`s run
122-
* @return `AwsRequestSigner`
129+
* @param config
130+
* `AwsRequestSignerConfig` to be used to construct one of the three config providers
131+
* @param mat
132+
* `Materializer` on which the `Future`s run
133+
* @return
134+
* `AwsRequestSigner`
123135
*/
124136
def fromConfig(config: AwsRequestSignerConfig)(implicit mat: Materializer): AwsRequestSigner =
125137
config match {

src/main/scala/io/moia/scalaHttpClient/HttpClientConfig.scala

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ import scala.concurrent.duration.{FiniteDuration, _}
66

77
/** Configuration of a particular HTTP client.
88
*
9-
* @param scheme For example "http" or "https"
10-
* @param host Name of the host
11-
* @param port Port of the host
12-
* @param awsRequestSignerConfig Optional config for AWS request signing
9+
* @param scheme
10+
* For example "http" or "https"
11+
* @param host
12+
* Name of the host
13+
* @param port
14+
* Port of the host
15+
* @param awsRequestSignerConfig
16+
* Optional config for AWS request signing
1317
*/
1418
final case class HttpClientConfig(
1519
scheme: String,
@@ -20,22 +24,27 @@ final case class HttpClientConfig(
2024

2125
/** Retry configuration of HTTP clients.
2226
*
23-
* @param retriesRequestTimeout Number of retries for HTTP 408
24-
* @param retriesTooManyRequests Number of retries for HTTP 429 (usually in combination with retry-after header)
25-
* @param retriesClientError Number of retries for all other 4xx codes
26-
* @param retriesInternalServerError Number of retries for HTTP 500
27-
* @param retriesBadGateway Number of retries for HTTP 502
28-
* @param retriesServiceUnavailable Number of retries for HTTP 503
29-
* @param retriesServerError Number of retries for all other 5xx codes
30-
* @param retriesException Number of retries for exceptions in the underlying akka-http client
31-
* @param initialBackoff Time to wait until the first retry. Is multiplied with 2^(# of retry).
32-
* Example:
33-
* 10ms * 2^0 => 10ms
34-
* 10ms * 2^1 => 20ms
35-
* 10ms * 2^2 => 40ms
36-
* 10ms * 2^3 => 80ms
37-
* 10ms * 2^4 => 160ms
38-
* @param strictifyResponseTimeout Time to wait for streaming data to complete
27+
* @param retriesRequestTimeout
28+
* Number of retries for HTTP 408
29+
* @param retriesTooManyRequests
30+
* Number of retries for HTTP 429 (usually in combination with retry-after header)
31+
* @param retriesClientError
32+
* Number of retries for all other 4xx codes
33+
* @param retriesInternalServerError
34+
* Number of retries for HTTP 500
35+
* @param retriesBadGateway
36+
* Number of retries for HTTP 502
37+
* @param retriesServiceUnavailable
38+
* Number of retries for HTTP 503
39+
* @param retriesServerError
40+
* Number of retries for all other 5xx codes
41+
* @param retriesException
42+
* Number of retries for exceptions in the underlying akka-http client
43+
* @param initialBackoff
44+
* Time to wait until the first retry. Is multiplied with 2^(# of retry). Example: 10ms * 2^0 => 10ms 10ms * 2^1 => 20ms 10ms * 2^2 => 40ms 10ms * 2^3 =>
45+
* 80ms 10ms * 2^4 => 160ms
46+
* @param strictifyResponseTimeout
47+
* Time to wait for streaming data to complete
3948
*/
4049
final case class RetryConfig(
4150
retriesRequestTimeout: Int,

src/test/scala/io/moia/scalaHttpClient/AwsRequestSignerTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import org.scalatest.wordspec.AnyWordSpecLike
1010
import scala.concurrent.duration.{FiniteDuration, _}
1111

1212
class AwsRequestSignerTest extends AnyWordSpecLike with Matchers with FutureValues {
13-
private implicit val system: ActorSystem = ActorSystem("test")
14-
protected implicit val patienceConfig: FiniteDuration = 2.seconds
13+
implicit private val system: ActorSystem = ActorSystem("test")
14+
implicit protected val patienceConfig: FiniteDuration = 2.seconds
1515

1616
val underTest: AwsRequestSigner =
1717
AwsRequestSigner.fromConfig(AwsRequestSignerConfig.BasicCredentials("AKIDEXAMPLE", "secret-key", "eu-central-1"))

src/test/scala/io/moia/scalaHttpClient/FutureValues.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import org.scalatest.Assertions
55
import scala.concurrent.duration.{Duration, DurationLong, FiniteDuration}
66
import scala.concurrent.{Await, Future, TimeoutException}
77

8-
/** This is a helper similar to `OptionValues`.
9-
* It awaits a `Future` value within an accepted duration.
10-
* That is much nicer that `ScalaFutures` with their stupid patience config!
8+
/** This is a helper similar to `OptionValues`. It awaits a `Future` value within an accepted duration. That is much nicer that `ScalaFutures` with their stupid
9+
* patience config!
1110
*
1211
* Example:
1312
*
@@ -18,7 +17,7 @@ import scala.concurrent.{Await, Future, TimeoutException}
1817
* ```
1918
*/
2019
trait FutureValues extends Assertions {
21-
protected implicit val defaultAwaitDuration: FiniteDuration = 1000.millis
20+
implicit protected val defaultAwaitDuration: FiniteDuration = 1000.millis
2221

2322
implicit class WithFutureValue[T](future: Future[T]) {
2423
def futureValue(implicit awaitDuration: Duration): T =

src/test/scala/io/moia/scalaHttpClient/LoggingHttpClientTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class LoggingHttpClientTest extends TestSetup {
1515

1616
case class LoggingContext(context: String)
1717

18-
private implicit val canLogString: CanLog[LoggingContext] = new CanLog[LoggingContext] {
18+
implicit private val canLogString: CanLog[LoggingContext] = new CanLog[LoggingContext] {
1919
val prevContext: String = MDC.get("context")
2020

2121
override def logMessage(originalMsg: String, ctx: LoggingContext): String = {
@@ -32,7 +32,7 @@ class LoggingHttpClientTest extends TestSetup {
3232
}
3333

3434
private val theLogger: LoggerTakingImplicit[LoggingContext] = Logger.takingImplicit(LoggerFactory.getLogger(getClass.getName))
35-
private implicit val ctx: LoggingContext = LoggingContext("Logging Context")
35+
implicit private val ctx: LoggingContext = LoggingContext("Logging Context")
3636

3737
classOf[LoggingHttpClient[LoggingContext]].getSimpleName should {
3838
"take a customer logger" in {

src/test/scala/io/moia/scalaHttpClient/StatusCodesTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import scala.collection.immutable
1010
import scala.concurrent.duration._
1111

1212
class StatusCodesTest extends TestSetup with MockServer {
13-
override implicit val defaultAwaitDuration: FiniteDuration = 1.second
13+
implicit override val defaultAwaitDuration: FiniteDuration = 1.second
1414

1515
"respect retry configuration" when {
1616
s"the server responds with ${StatusCodes.TooManyRequests}" in {

0 commit comments

Comments
 (0)