From 5923841f0e94449516156388d6a80aa574550a4d Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Mon, 11 Apr 2022 13:20:29 +0200 Subject: [PATCH] Adjust scalafmt config --- .scalafmt.conf | 6 ++- .../libs/ws/ahc/AhcCurlRequestLogger.scala | 2 +- .../api/libs/ws/ahc/cache/AhcHttpCache.scala | 42 +++++++++---------- .../ws/ahc/cache/AsyncCachingHandler.scala | 10 ++--- .../ws/ahc/cache/CachingAsyncHttpClient.scala | 28 ++++++------- 5 files changed, 45 insertions(+), 43 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 8ed987ded..c7f0bc9cc 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,7 +1,9 @@ -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 ] diff --git a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/AhcCurlRequestLogger.scala b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/AhcCurlRequestLogger.scala index 37e086dee..5be590452 100644 --- a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/AhcCurlRequestLogger.scala +++ b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/AhcCurlRequestLogger.scala @@ -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 = diff --git a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AhcHttpCache.scala b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AhcHttpCache.scala index 1a2a018c3..446b0d3a8 100644 --- a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AhcHttpCache.scala +++ b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AhcHttpCache.scala @@ -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) @@ -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 @@ -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 @@ -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) diff --git a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AsyncCachingHandler.scala b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AsyncCachingHandler.scala index 114444d20..aefb604c9 100644 --- a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AsyncCachingHandler.scala +++ b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AsyncCachingHandler.scala @@ -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 => diff --git a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/CachingAsyncHttpClient.scala b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/CachingAsyncHttpClient.scala index f740ea518..cedd1feb0 100644 --- a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/CachingAsyncHttpClient.scala +++ b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/CachingAsyncHttpClient.scala @@ -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