Skip to content

Commit

Permalink
Merge pull request #669 from scala-steward/update/scalafmt-core-3.5.1
Browse files Browse the repository at this point in the history
scalafmt-core 3.5.1 (was 2.7.5)
  • Loading branch information
mergify[bot] committed Apr 11, 2022
2 parents 0ef82f6 + d1e2a46 commit 7a41d6a
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 89 deletions.
8 changes: 5 additions & 3 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
align = true
runner.dialect = scala213
align.preset = true
assumeStandardLibraryStripMargin = true
danglingParentheses = true
danglingParentheses.preset = true
docstrings.style = Asterisk
docstrings.wrap = false
maxColumn = 120
project.git = true
rewrite.rules = [ AvoidInfix, ExpandImportSelectors, RedundantParens, SortModifiers, PreferCurlyFors ]
rewrite.sortModifiers.order = [ "private", "protected", "final", "sealed", "abstract", "implicit", "override", "lazy" ]
spaces.inImportCurlyBraces = true # more idiomatic to include whitepsace in import x.{ yyy }
trailingCommas = preserve
newlines.afterCurlyLambda = preserve
version = 2.7.5
version = 3.5.1
40 changes: 20 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ lazy val mimaSettings = Seq(
)

lazy val commonSettings = Def.settings(
organization := "com.typesafe.play",
organizationName := "Lightbend Inc.",
organization := "com.typesafe.play",
organizationName := "Lightbend Inc.",
organizationHomepage := Some(url("https://www.lightbend.com/")),
homepage := Some(url("https://www.playframework.com/documentation/latest/")),
homepage := Some(url("https://www.playframework.com/documentation/latest/")),
scmInfo := Some(ScmInfo(url("https://github.com/playframework/play-ws"), "git@github.com:playframework/play-ws.git")),
developers += Developer(
"contributors",
"Contributors",
"https://gitter.im/playframework/",
url("https://gitter.im/playframework/contributors")
),
licenses := Seq("Apache-2.0" -> url("http://opensource.org/licenses/Apache-2.0")),
scalaVersion := scala213,
licenses := Seq("Apache-2.0" -> url("http://opensource.org/licenses/Apache-2.0")),
scalaVersion := scala213,
crossScalaVersions := Seq(scala213, scala3),
conflictWarning := {
if (scalaBinaryVersion.value == "3") {
Expand All @@ -122,10 +122,10 @@ lazy val commonSettings = Def.settings(
)

lazy val shadedCommonSettings = Seq(
//scalaVersion := scala213,
//crossScalaVersions := Seq(scala213),
// scalaVersion := scala213,
// crossScalaVersions := Seq(scala213),
// No need to cross publish the shaded libraries
crossPaths := false,
crossPaths := false,
autoScalaLibrary := false,
)

Expand Down Expand Up @@ -196,7 +196,7 @@ lazy val `shaded-asynchttpclient` = project
.settings(shadeAssemblySettings)
.settings(
libraryDependencies ++= asyncHttpClient,
name := "shaded-asynchttpclient",
name := "shaded-asynchttpclient",
assembly / logLevel := Level.Error,
assembly / assemblyMergeStrategy := {
val NettyPropertiesPath = "META-INF" + File.separator + "io.netty.versions.properties"
Expand All @@ -212,7 +212,7 @@ lazy val `shaded-asynchttpclient` = project
oldStrategy(x)
}: String => MergeStrategy)
},
//logLevel in assembly := Level.Debug,
// logLevel in assembly := Level.Debug,
assembly / assemblyShadeRules := Seq(
ShadeRule.rename("org.asynchttpclient.**" -> "play.shaded.ahc.@0").inAll,
ShadeRule.rename("io.netty.**" -> "play.shaded.ahc.@0").inAll,
Expand All @@ -226,11 +226,11 @@ lazy val `shaded-asynchttpclient` = project
// https://stackoverflow.com/questions/24807875/how-to-remove-projectdependencies-from-pom
// Remove dependencies from the POM because we have a FAT jar here.
makePomConfiguration := makePomConfiguration.value.withProcess(process = dependenciesFilter),
//ivyXML := <dependencies></dependencies>,
//ivyLoggingLevel := UpdateLogging.Full,
//logLevel := Level.Debug,
// ivyXML := <dependencies></dependencies>,
// ivyLoggingLevel := UpdateLogging.Full,
// logLevel := Level.Debug,
assembly / assemblyOption := (assembly / assemblyOption).value.withIncludeBin(false).withIncludeScala(false),
Compile / packageBin := assembly.value
Compile / packageBin := assembly.value
)

//---------------------------------------------------------------
Expand All @@ -245,16 +245,16 @@ lazy val `shaded-oauth` = project
.settings(
libraryDependencies ++= oauth,
name := "shaded-oauth",
//logLevel in assembly := Level.Debug,
// logLevel in assembly := Level.Debug,
assembly / assemblyShadeRules := Seq(
ShadeRule.rename("oauth.**" -> "play.shaded.oauth.@0").inAll,
ShadeRule.rename("org.apache.commons.**" -> "play.shaded.oauth.@0").inAll
),
// https://stackoverflow.com/questions/24807875/how-to-remove-projectdependencies-from-pom
// Remove dependencies from the POM because we have a FAT jar here.
makePomConfiguration := makePomConfiguration.value.withProcess(process = dependenciesFilter),
makePomConfiguration := makePomConfiguration.value.withProcess(process = dependenciesFilter),
assembly / assemblyOption := (assembly / assemblyOption).value.withIncludeBin(false).withIncludeScala(false),
Compile / packageBin := assembly.value
Compile / packageBin := assembly.value
)

// Make the shaded version of AHC available downstream
Expand Down Expand Up @@ -318,7 +318,7 @@ lazy val `play-ahc-ws-standalone` = project
.in(file("play-ahc-ws-standalone"))
.settings(
commonSettings ++ shadedAhcSettings ++ shadedOAuthSettings ++ Seq(
Test / fork := true,
Test / fork := true,
Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit, "-a", "-v")),
libraryDependencies ++= standaloneAhcWSDependencies,
// This will not work if you do a publishLocal, because that uses ivy...
Expand Down Expand Up @@ -357,7 +357,7 @@ lazy val `play-ws-standalone-json` = project
.settings(commonSettings)
.settings(mimaSettings)
.settings(
Test / fork := true,
Test / fork := true,
Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit, "-a", "-v")),
libraryDependencies ++= standaloneAhcWSJsonDependencies
)
Expand All @@ -376,7 +376,7 @@ lazy val `play-ws-standalone-xml` = project
.settings(commonSettings)
.settings(mimaSettings)
.settings(
Test / fork := true,
Test / fork := true,
Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit, "-a", "-v")),
libraryDependencies ++= standaloneAhcWSXMLDependencies(scalaVersion.value)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,18 @@ class AhcCurlRequestLoggerSpec(implicit val executionEnv: ExecutionEnv)
.toScala
.awaitFor(defaultTimeout)

testLogger.getLoggingEvents.get(0).getMessage must beEqualTo(s"""
|curl \\
| --verbose \\
| --request GET \\
| --header 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\
| --header 'content-type: text/plain' \\
| --header 'My-Header: My-Header-Value' \\
| --data 'the-body' \\
| 'http://localhost:$testServerPort/'
""".stripMargin.trim)
testLogger.getLoggingEvents.get(0).getMessage must beEqualTo(
s"""
|curl \\
| --verbose \\
| --request GET \\
| --header 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\
| --header 'content-type: text/plain' \\
| --header 'My-Header: My-Header-Value' \\
| --data 'the-body' \\
| 'http://localhost:$testServerPort/'
""".stripMargin.trim
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,18 @@ class AhcCurlRequestLoggerSpec(implicit val executionEnv: ExecutionEnv)
.get()
.awaitFor(defaultTimeout)

testLogger.getLoggingEvents.get(0).getMessage must beEqualTo(s"""
|curl \\
| --verbose \\
| --request GET \\
| --header 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\
| --header 'My-Header: My-Header-Value' \\
| --header 'Content-Type: text/plain' \\
| --data 'the-body' \\
| 'http://localhost:$testServerPort/'
""".stripMargin.trim)
testLogger.getLoggingEvents.get(0).getMessage must beEqualTo(
s"""
|curl \\
| --verbose \\
| --request GET \\
| --header 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\
| --header 'My-Header: My-Header-Value' \\
| --header 'Content-Type: text/plain' \\
| --data 'the-body' \\
| 'http://localhost:$testServerPort/'
""".stripMargin.trim
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ trait CurlFormat {
b.append(s" --request ${request.method}")
b.append(" \\\n")

//authentication
// authentication
request.auth match {
case Some((userName, password, WSAuthScheme.BASIC)) =>
val encodedPassword =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,24 @@ class AhcHttpCache(underlying: standaloneAhc.cache.Cache, heuristicsEnabled: Boo
if (isUnsafeMethod(request) && isNonErrorResponse(response)) {
val requestHost = request.getUri.getHost

//A cache MUST invalidate the effective request URI (Section 5.5 of
//[RFC7230]) when it receives a non-error response to a request with a
//method whose safety is unknown.
// A cache MUST invalidate the effective request URI (Section 5.5 of
// [RFC7230]) when it receives a non-error response to a request with a
// method whose safety is unknown.
val responseKey = EffectiveURIKey(request.getMethod, response.getUri.toJavaNetURI)
invalidateKey(responseKey)

//A cache MUST invalidate the effective Request URI (Section 5.5 of
//[RFC7230]) as well as the URI(s) in the Location and Content-Location
//response header fields (if present) when a non-error status code is
//received in response to an unsafe request method.
// A cache MUST invalidate the effective Request URI (Section 5.5 of
// [RFC7230]) as well as the URI(s) in the Location and Content-Location
// response header fields (if present) when a non-error status code is
// received in response to an unsafe request method.

// https://tools.ietf.org/html/rfc7231#section-3.1.4.2
// https://tools.ietf.org/html/rfc7230#section-5.5
getURI(response, "Content-Location").foreach { contentLocation =>
//However, a cache MUST NOT invalidate a URI from a Location or
//Content-Location response header field if the host part of that URI
//differs from the host part in the effective request URI (Section 5.5
//of [RFC7230]). This helps prevent denial-of-service attacks.
// However, a cache MUST NOT invalidate a URI from a Location or
// Content-Location response header field if the host part of that URI
// differs from the host part in the effective request URI (Section 5.5
// of [RFC7230]). This helps prevent denial-of-service attacks.
if (requestHost.equalsIgnoreCase(contentLocation.getHost)) {
val key = EffectiveURIKey(request.getMethod, contentLocation)
invalidateKey(key)
Expand Down Expand Up @@ -234,8 +234,8 @@ class AhcHttpCache(underlying: standaloneAhc.cache.Cache, heuristicsEnabled: Boo
}

protected def isNonErrorResponse(response: CacheableResponse): Boolean = {
//Here, a "non-error response" is one with a 2xx (Successful) or 3xx
//(Redirection) status code.
// Here, a "non-error response" is one with a 2xx (Successful) or 3xx
// (Redirection) status code.
response.getStatusCode match {
case success if success >= 200 && success < 300 =>
true
Expand Down Expand Up @@ -324,12 +324,12 @@ class AhcHttpCache(underlying: standaloneAhc.cache.Cache, heuristicsEnabled: Boo

// Need to freshen this stale response
// https://tools.ietf.org/html/rfc7234#section-4.3.4
//If a stored response is selected for update, the cache MUST:
//o delete any Warning header fields in the stored response with
//warn-code 1xx (see Section 5.5);
// If a stored response is selected for update, the cache MUST:
// o delete any Warning header fields in the stored response with
// warn-code 1xx (see Section 5.5);
//
//o retain any Warning header fields in the stored response with
//warn-code 2xx; and,
// o retain any Warning header fields in the stored response with
// warn-code 2xx; and,
val headers = response.headers
val headersMap: HttpHeaders = new DefaultHttpHeaders().add(headers)
val filteredWarnings = headersMap
Expand All @@ -342,9 +342,9 @@ class AhcHttpCache(underlying: standaloneAhc.cache.Cache, heuristicsEnabled: Boo
.asJava
headersMap.set("Warning", filteredWarnings)

//o use other header fields provided in the 304 (Not Modified)
//response to replace all instances of the corresponding header
//fields in the stored response.
// o use other header fields provided in the 304 (Not Modified)
// response to replace all instances of the corresponding header
// fields in the stored response.
headersMap.set(newHeaders)

response.copy(headers = headersMap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ class AsyncCachingHandler[T](
if (cache.isNotModified(response)) {
processNotModifiedResponse(response)
} else if (cache.isError(response)) {
//o However, if a cache receives a 5xx (Server Error) response while
//attempting to validate a response, it can either forward this
//response to the requesting client, or act as if the server failed
//to respond. In the latter case, the cache MAY send a previously
//stored response (see Section 4.2.4).
// o However, if a cache receives a 5xx (Server Error) response while
// attempting to validate a response, it can either forward this
// response to the requesting client, or act as if the server failed
// to respond. In the latter case, the cache MAY send a previously
// stored response (see Section 4.2.4).

maybeAction match {
case Some(Validate(reason, staleIfError)) if staleIfError =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,25 @@ class CachingAsyncHttpClient(underlying: AsyncHttpClient, ahcHttpCache: AhcHttpC
// https://tools.ietf.org/html/rfc7234#section-4.3.1
// https://tools.ietf.org/html/rfc7232#section-2.4

//A client:
// A client:
//
//o MUST send that entity-tag in any cache validation request (using
// o MUST send that entity-tag in any cache validation request (using
// If-Match or If-None-Match) if an entity-tag has been provided by
//the origin server.
// the origin server.
//
//o SHOULD send the Last-Modified value in non-subrange cache
//validation requests (using If-Modified-Since) if only a
//Last-Modified value has been provided by the origin server.
// o SHOULD send the Last-Modified value in non-subrange cache
// validation requests (using If-Modified-Since) if only a
// Last-Modified value has been provided by the origin server.
//
//o MAY send the Last-Modified value in subrange cache validation
//requests (using If-Unmodified-Since) if only a Last-Modified value
//has been provided by an HTTP/1.0 origin server. The user agent
//SHOULD provide a way to disable this, in case of difficulty.
// o MAY send the Last-Modified value in subrange cache validation
// requests (using If-Unmodified-Since) if only a Last-Modified value
// has been provided by an HTTP/1.0 origin server. The user agent
// SHOULD provide a way to disable this, in case of difficulty.
//
//o SHOULD send both validators in cache validation requests if both
//an entity-tag and a Last-Modified value have been provided by the
//origin server. This allows both HTTP/1.0 and HTTP/1.1 caches to
//respond appropriately.
// o SHOULD send both validators in cache validation requests if both
// an entity-tag and a Last-Modified value have been provided by the
// origin server. This allows both HTTP/1.0 and HTTP/1.1 caches to
// respond appropriately.

composeRequest(request) { rb =>
val headers = response.getHeaders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AhcWSResponseSpec extends Specification with Mockito with DefaultBodyReada

"get the body as bytes from the AHC response" in {
val ahcResponse: AHCResponse = mock[AHCResponse]
val bytes = ByteString(-87, -72, 96, -63, -32, 46, -117, -40, -128, -7, 61, 109, 80, 45, 44, 30)
val bytes = ByteString(-87, -72, 96, -63, -32, 46, -117, -40, -128, -7, 61, 109, 80, 45, 44, 30)
ahcResponse.getResponseBodyAsBytes.returns(bytes.toArray)
val response = StandaloneAhcWSResponse(ahcResponse)
response.body[ByteString] must_== bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class CacheAsyncHandlerSpec extends Specification {

"validate" in {
pending
//val cache = generateCache
//val handler = new CacheAsyncHandler(cache)
// val cache = generateCache
// val handler = new CacheAsyncHandler(cache)
}

}
Expand Down
4 changes: 2 additions & 2 deletions project/CleanShadedPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ object CleanShadedPlugin extends AutoPlugin {
override def projectSettings =
Seq(
cleanCacheIvyDirectory := ivyPaths.value.ivyHome.getOrElse(Path.userHome / ".ivy2"),
cleanCache := IO.delete(cleanCacheFiles.evaluated),
cleanLocal := IO.delete(cleanLocalFiles.evaluated),
cleanCache := IO.delete(cleanCacheFiles.evaluated),
cleanLocal := IO.delete(cleanLocalFiles.evaluated),
cleanCacheFiles := {
val base = cleanCacheIvyDirectory.value / "cache"
val param = CleanShaded.parseParam.parsed
Expand Down

0 comments on commit 7a41d6a

Please sign in to comment.