Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.8.x]: Update scalafmt-core to 2.3.2 and applied formatting #9893

Merged
merged 3 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ rewrite.rules = [ AvoidInfix, ExpandImportSelectors, RedundantParens, SortModifi
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
version = 2.2.2
version = 2.3.2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import scala.reflect.ClassTag
* The cache API
*/
trait AsyncCacheApi {

/**
* Get an instance of [[SyncCacheApi]] to make synchronous calls.
*/
Expand Down
2 changes: 2 additions & 0 deletions cache/play-cache/src/main/scala/play/api/cache/Cached.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import scala.concurrent.duration._
* A helper to add caching to an Action.
*/
class Cached @Inject() (cache: AsyncCacheApi)(implicit materializer: Materializer) {

/**
* Cache an action.
*
Expand Down Expand Up @@ -133,6 +134,7 @@ final class CachedBuilder(
key: RequestHeader => String,
caching: PartialFunction[ResponseHeader, Duration]
)(implicit materializer: Materializer) {

/**
* Compose the cache with an action
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import scala.reflect.ClassTag
* A cache API that uses synchronous calls rather than async calls. Useful when you know you have a fast in-memory cache.
*/
trait SyncCacheApi {

/**
* Set a value into the cache.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class GuiceApplicationLoader(protected val initialBuilder: GuiceApplicationBuild
}

object GuiceApplicationLoader {

/**
* The default overrides provided by the Scala and Java GuiceApplicationLoaders.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ object GuiceKey {
* Play Injector backed by a Guice Injector.
*/
class GuiceInjector @Inject() (injector: com.google.inject.Injector) extends PlayInjector {

/**
* Get an instance of the given class from the injector.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ trait ActorModule extends AbstractModule {
/** The companion object to hold [[ActorModule]]'s [[ActorModule.Aux]] type alias. */
@ApiMayChange
object ActorModule {

/** A convenience to refer to the type of an [[ActorModule]] with the given message type [[A]]. */
type Aux[A] = ActorModule { type Message = A }
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.google.inject.util.Types
/** Utility methods related to using Akka's typed API. */
@ApiMayChange
private[play] object TypedAkka {

/** Equivalent to `new TypeLiteral[ActorRef[T]]() {}`, but with a `ClassTag[T]`. */
def actorRefOf[T: ClassTag]: TypeLiteral[ActorRef[T]] = typeLiteral(classTag[T].runtimeClass)
def behaviorOf[T: ClassTag]: TypeLiteral[Behavior[T]] = typeLiteral(classTag[T].runtimeClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,13 @@ class GuiceApplicationBuilderSpec extends Specification {

"set module loader" in {
val injector = new GuiceApplicationBuilder()
.load(
(env, conf) =>
Seq(
new BuiltinModule,
new I18nModule,
new CookiesModule,
bind[GuiceApplicationBuilderSpec.A].to[GuiceApplicationBuilderSpec.A1]
)
.load((env, conf) =>
Seq(
new BuiltinModule,
new I18nModule,
new CookiesModule,
bind[GuiceApplicationBuilderSpec.A].to[GuiceApplicationBuilderSpec.A1]
)
)
.injector()

Expand Down
1 change: 1 addition & 0 deletions core/play-guice/src/test/scala/play/core/test/Fakes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import play.api.inject.Injector
* Utilities to help with testing
*/
object Fakes {

/**
* Create an injector from the given bindings.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import scala.collection.mutable.ArrayBuffer
* Test utility for testing Play logs
*/
object LogTester {

/** Record log events and return them for analysis. */
def recordLogEvents[T](block: => T): (T, immutable.Seq[ILoggingEvent]) = {

/** Collects all log events that occur */
class RecordingAppender extends AppenderBase[ILoggingEvent] {
private val eventBuffer = ArrayBuffer[ILoggingEvent]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ trait ServerIntegrationSpecification extends PendingUntilFixed with AroundEach {
}

implicit class UntilAkkaHttpFixed[T: AsResult](t: => T) {

/**
* We may want to skip some tests if they're slow due to timeouts. This tag
* won't remind us if the tests start passing.
Expand All @@ -49,6 +50,7 @@ trait ServerIntegrationSpecification extends PendingUntilFixed with AroundEach {
}

implicit class UntilNettyHttpFixed[T: AsResult](t: => T) {

/**
* We may want to skip some tests if they're slow due to timeouts. This tag
* won't remind us if the tests start passing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ class AkkaResponseHeaderHandlingSpec extends PlaySpecification with AkkaHttpInte
}
}

"correct support invalid Authorization header" in withServer(
(Action, _) =>
Action { rh =>
// authorization is a invalid response header
Results.Ok.withHeaders("Authorization" -> "invalid")
}
"correct support invalid Authorization header" in withServer((Action, _) =>
Action { rh =>
// authorization is a invalid response header
Results.Ok.withHeaders("Authorization" -> "invalid")
}
) { port =>
val responses = BasicHttpClient.makeRequests(port, trickleFeed = Some(100L))(
// Second request ensures that Play switches back to its normal handler
Expand All @@ -47,12 +46,11 @@ class AkkaResponseHeaderHandlingSpec extends PlaySpecification with AkkaHttpInte
responses(0).headers.get("Authorization") must_== Some("invalid")
}

"don't strip quotes from Link header" in withServer(
(Action, _) =>
Action { rh =>
// Test the header reported in https://github.com/playframework/playframework/issues/7733
Results.Ok.withHeaders("Link" -> """<http://example.com/some/url>; rel="next"""")
}
"don't strip quotes from Link header" in withServer((Action, _) =>
Action { rh =>
// Test the header reported in https://github.com/playframework/playframework/issues/7733
Results.Ok.withHeaders("Link" -> """<http://example.com/some/url>; rel="next"""")
}
) { port =>
val responses = BasicHttpClient.makeRequests(port)(
BasicRequest("GET", "/", "HTTP/1.1", Map(), "")
Expand All @@ -62,12 +60,11 @@ class AkkaResponseHeaderHandlingSpec extends PlaySpecification with AkkaHttpInte

"don't log a warning for Set-Cookie headers with negative ages" in {
val problemHeaderValue = "PLAY_FLASH=; Max-Age=-86400; Expires=Tue, 30 Jan 2018 06:29:53 GMT; Path=/; HTTPOnly"
withServer(
(Action, _) =>
Action { rh =>
// Test the header reported in https://github.com/playframework/playframework/issues/8205
Results.Ok.withHeaders("Set-Cookie" -> problemHeaderValue)
}
withServer((Action, _) =>
Action { rh =>
// Test the header reported in https://github.com/playframework/playframework/issues/8205
Results.Ok.withHeaders("Set-Cookie" -> problemHeaderValue)
}
) { port =>
val (Seq(response), logMessages) = LogTester.recordLogEvents {
BasicHttpClient.makeRequests(port)(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import play.core.utils.CaseInsensitiveOrdered
import scala.collection.immutable.TreeMap

object BasicHttpClient {

/**
* Very basic HTTP client, for when we want to be very low level about our assertions.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ trait Expect100ContinueSpec extends PlaySpecification with ServerIntegrationSpec
responses(1).status must_== 200
}

"not read body when expecting 100 continue but action iteratee is done" in withServer(
_ => EssentialAction(_ => Accumulator.done(Results.Ok))
"not read body when expecting 100 continue but action iteratee is done" in withServer(_ =>
EssentialAction(_ => Accumulator.done(Results.Ok))
) { port =>
val responses = BasicHttpClient.makeRequests(port)(
BasicRequest("POST", "/", "HTTP/1.1", Map("Expect" -> "100-continue", "Content-Length" -> "100000"), "foo")
Expand All @@ -58,8 +58,8 @@ trait Expect100ContinueSpec extends PlaySpecification with ServerIntegrationSpec
// close the connection.
//
// See https://issues.jboss.org/browse/NETTY-390 for more details.
"close the connection after rejecting a Expect: 100-continue body" in withServer(
_ => EssentialAction(_ => Accumulator.done(Results.Ok))
"close the connection after rejecting a Expect: 100-continue body" in withServer(_ =>
EssentialAction(_ => Accumulator.done(Results.Ok))
) { port =>
val responses = BasicHttpClient.makeRequests(port, checkClosed = true)(
BasicRequest("POST", "/", "HTTP/1.1", Map("Expect" -> "100-continue", "Content-Length" -> "100000"), "foo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FlashCookieSpec
with EndpointIntegrationSpecification
with OkHttpEndpointSupport
with ApplicationFactories {

/** Makes an app that we use while we're testing */
def withFlashCookieApp(additionalConfiguration: Map[String, Any] = Map.empty): ApplicationFactory = {
withConfigAndRouter(additionalConfiguration) { components =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ trait JavaResultsHandlingSpec
Results.ok("Hello world").discardingCookie("Result-Discard")
}
}) { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.startsWith("Result-Discard=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/")
response.headers("Set-Cookie") must contain((s: String) =>
s.startsWith("Result-Discard=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/")
)
}

Expand All @@ -256,8 +256,8 @@ trait JavaResultsHandlingSpec
Results.ok("Hello world").discardingCookie("Result-Discard", "/path")
}
}) { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.startsWith("Result-Discard=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/path")
response.headers("Set-Cookie") must contain((s: String) =>
s.startsWith("Result-Discard=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/path")
)
}

Expand All @@ -266,11 +266,10 @@ trait JavaResultsHandlingSpec
Results.ok("Hello world").discardingCookie("Result-Discard", "/path", "playframework.com")
}
}) { response =>
response.headers("Set-Cookie") must contain(
(s: String) =>
s.startsWith(
"Result-Discard=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/path; Domain=playframework.com"
)
response.headers("Set-Cookie") must contain((s: String) =>
s.startsWith(
"Result-Discard=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/path; Domain=playframework.com"
)
)
}

Expand All @@ -279,11 +278,10 @@ trait JavaResultsHandlingSpec
Results.ok("Hello world").discardingCookie("Result-Discard", "/path", "playframework.com", true)
}
}) { response =>
response.headers("Set-Cookie") must contain(
(s: String) =>
s.startsWith(
"Result-Discard=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/path; Domain=playframework.com; Secure"
)
response.headers("Set-Cookie") must contain((s: String) =>
s.startsWith(
"Result-Discard=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/path; Domain=playframework.com; Secure"
)
)
}
}
Expand Down Expand Up @@ -327,8 +325,8 @@ trait JavaResultsHandlingSpec
}
}
} { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/")
response.headers("Set-Cookie") must contain((s: String) =>
s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/")
)
}

Expand All @@ -340,8 +338,8 @@ trait JavaResultsHandlingSpec
}
}
} { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/")
response.headers("Set-Cookie") must contain((s: String) =>
s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/")
)
}

Expand All @@ -353,8 +351,8 @@ trait JavaResultsHandlingSpec
}
}
} { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/")
response.headers("Set-Cookie") must contain((s: String) =>
s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/")
)
}

Expand All @@ -370,8 +368,8 @@ trait JavaResultsHandlingSpec
}
}
} { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.equalsIgnoreCase("LANG_TEST_COOKIE=pt-BR; SameSite=Lax; Path=/")
response.headers("Set-Cookie") must contain((s: String) =>
s.equalsIgnoreCase("LANG_TEST_COOKIE=pt-BR; SameSite=Lax; Path=/")
)
}

Expand Down Expand Up @@ -405,8 +403,8 @@ trait JavaResultsHandlingSpec
}
}
} { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/; Secure")
response.headers("Set-Cookie") must contain((s: String) =>
s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/; Secure")
)
}

Expand All @@ -422,8 +420,8 @@ trait JavaResultsHandlingSpec
}
}
} { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/; HttpOnly")
response.headers("Set-Cookie") must contain((s: String) =>
s.equalsIgnoreCase("PLAY_LANG=pt-BR; SameSite=Lax; Path=/; HttpOnly")
)
}
}
Expand All @@ -438,8 +436,8 @@ trait JavaResultsHandlingSpec
}
}
} { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.equalsIgnoreCase("PLAY_LANG=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/")
response.headers("Set-Cookie") must contain((s: String) =>
s.equalsIgnoreCase("PLAY_LANG=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/")
)
}

Expand All @@ -451,8 +449,8 @@ trait JavaResultsHandlingSpec
}
}
} { response =>
response.headers("Set-Cookie") must contain(
(s: String) => s.equalsIgnoreCase("PLAY_LANG=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/")
response.headers("Set-Cookie") must contain((s: String) =>
s.equalsIgnoreCase("PLAY_LANG=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/")
)
}
}
Expand Down