Skip to content

Commit

Permalink
Update scalafmt-core to 3.8.1 (#3649)
Browse files Browse the repository at this point in the history
Co-authored-by: scala-steward <scala-steward>
  • Loading branch information
softwaremill-ci committed Apr 3, 2024
1 parent 79239eb commit 9605fdf
Show file tree
Hide file tree
Showing 41 changed files with 147 additions and 121 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ c40dbf3aafd72299a21b38125140249337c83e0f

# Scala Steward: Reformat with scalafmt 3.7.17
ab79cadbb13aac7c32015ce5caf24d57290ee59b

# Scala Steward: Reformat with scalafmt 3.8.1
e003ec3b61e3bd582ae6a5200177fa6433099c09
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.7.17
version = 3.8.1
maxColumn = 140
runner.dialect = scala3
fileOverride {
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ val scala3 = "3.3.3"

// The `idea.managed` property is set automatically by IntelliJ when it runs sbt for build or import
val ideaManaged = System.getProperty("idea.managed", "false").toBoolean
val ideScalaVersion = if(ideaManaged) scala2_13 else scala3
val ideScalaVersion = if (ideaManaged) scala2_13 else scala3

val scala2Versions = List(scala2_12, scala2_13)
val scala2And3Versions = scala2Versions ++ List(scala3)
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/sttp/tapir/Endpoint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ trait EndpointErrorOutputVariantsOps[A, I, E, O, -R] {
def errorOutVariantPrepend[E2 >: E](o: OneOfVariant[_ <: E2]): EndpointType[A, I, E2, O, R] =
withErrorOutputVariant(oneOf[E2](o, oneOfDefaultVariant(errorOutput)), identity)

/** Same as [[errorOutVariantPrepend]], but allows appending multiple variants in one go. */
/** Same as [[errorOutVariantPrepend]], but allows appending multiple variants in one go. */
def errorOutVariantsPrepend[E2 >: E](first: OneOfVariant[_ <: E2], other: OneOfVariant[_ <: E2]*): EndpointType[A, I, E2, O, R] =
withErrorOutputVariant(oneOf[E2](oneOfDefaultVariant(errorOutput), first +: other: _*), identity)

/** Same as [[errorOutVariant]], but allows appending multiple variants in one go. */
def errorOutVariants[E2 >: E](first: OneOfVariant[_ <: E2], other: OneOfVariant[_ <: E2]*)(implicit
ct: ClassTag[E],
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/sttp/tapir/Schema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ object Schema extends LowPrioritySchema with SchemaCompanionMacros {
implicit def schemaForOption[T: Schema]: Schema[Option[T]] = implicitly[Schema[T]].asOption
implicit def schemaForArray[T: Schema]: Schema[Array[T]] = implicitly[Schema[T]].asArray
implicit def schemaForIterable[T: Schema, C[X] <: Iterable[X]]: Schema[C[T]] = implicitly[Schema[T]].asIterable[C]
implicit def schemaForSet[T: Schema, C[X] <: scala.collection.Set[X]]: Schema[C[T]] =
implicit def schemaForSet[T: Schema, C[X] <: scala.collection.Set[X]]: Schema[C[T]] =
schemaForIterable[T, C].attribute(Schema.UniqueItems.Attribute, Schema.UniqueItems(true))
implicit def schemaForPart[T: Schema]: Schema[Part[T]] = implicitly[Schema[T]].map(_ => None)(_.body)

Expand Down Expand Up @@ -339,7 +339,7 @@ object Schema extends LowPrioritySchema with SchemaCompanionMacros {
object Title {
val Attribute: AttributeKey[Title] = new AttributeKey[Title]("sttp.tapir.Schema.Title")
}

case class UniqueItems(uniqueItems: Boolean)
object UniqueItems {
val Attribute: AttributeKey[UniqueItems] = new AttributeKey[UniqueItems]("sttp.tapir.Schema.UniqueItems")
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/sttp/tapir/generic/Configuration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ final case class Configuration(toEncodedName: String => String, discriminator: O
def withKebabCaseMemberNames: Configuration = copy(toEncodedName = Configuration.kebabCaseTransformation)
def withDiscriminator(d: String): Configuration = copy(discriminator = Some(d))
def withSnakeCaseDiscriminatorValues: Configuration = copy(toDiscriminatorValue = Configuration.shortSnakeCaseSubtypeTransformation)
def withScreamingSnakeCaseDiscriminatorValues: Configuration = copy(toDiscriminatorValue = Configuration.shortScreamingSnakeCaseSubtypeTransformation)
def withScreamingSnakeCaseDiscriminatorValues: Configuration =
copy(toDiscriminatorValue = Configuration.shortScreamingSnakeCaseSubtypeTransformation)
def withKebabCaseDiscriminatorValues: Configuration = copy(toDiscriminatorValue = Configuration.shortKebabCaseSubtypeTransformation)
def withFullDiscriminatorValues: Configuration = copy(toDiscriminatorValue = Configuration.fullIdentitySubtypeTransformation)
def withFullSnakeCaseDiscriminatorValues: Configuration = copy(toDiscriminatorValue = Configuration.fullSnakeCaseSubtypeTransformation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import sttp.tapir.{AnyEndpoint, Codec, CodecFormat, EndpointIO, EndpointInput}
import scala.collection.immutable.ListMap

private[asyncapi] class EndpointToAsyncAPIWebSocketChannel(
tschemaToASchema: TSchemaToASchema,
tschemaToASchema: TSchemaToASchema,
codecToMessageKey: Map[Codec[_, _, _ <: CodecFormat], MessageKey],
options: AsyncAPIDocsOptions
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object HelloWorldPekkoServer extends App {
println("Got result: " + result)

assert(result == "Hello, Frodo!")

binding
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ object CustomErrorsOnDecodeFailurePekkoServer extends App {
)
.options

val amountRoute: Route = PekkoHttpServerInterpreter(customServerOptions).toRoute(amountEndpoint.serverLogicSuccess(_ => Future.successful(())))
val amountRoute: Route =
PekkoHttpServerInterpreter(customServerOptions).toRoute(amountEndpoint.serverLogicSuccess(_ => Future.successful(())))

// starting the server
val bindAndCheck = Http().newServerAt("localhost", 8080).bindFlow(amountRoute).map { binding =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object IronRefinementErrorsNettyServer extends IOApp.Simple {
// Decoder throwing custom exception when refinement fails
inline given (using inline constraint: Constraint[Int, Positive]): Decoder[Age] = summon[Decoder[Int]].map(unrefinedValue =>
unrefinedValue.refineEither[Positive] match
case Right(value) => value
case Right(value) => value
case Left(errorMessage) => throw IronException(s"Could not refine value $unrefinedValue: $errorMessage")
)

Expand All @@ -58,8 +58,8 @@ object IronRefinementErrorsNettyServer extends IOApp.Simple {
// and we can add the failure details to the error message.
private def failureDetailMessage(failure: DecodeResult.Failure): Option[String] = failure match {
case Error(_, JsonDecodeException(_, IronException(errorMessage))) => Some(errorMessage)
case Error(_, IronException(errorMessage)) => Some(errorMessage)
case other => FailureMessages.failureDetailMessage(other)
case Error(_, IronException(errorMessage)) => Some(errorMessage)
case other => FailureMessages.failureDetailMessage(other)
}

private def failureMessage(ctx: DecodeFailureContext): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ package sttp.tapir.examples.logging

import org.slf4j.{Logger, LoggerFactory}

/**
* Defines a [[org.slf4j.Logger]] instance `logger` named according to the class
* into which this trait is mixed.
*
* In a real-life project, you might rather want to use a macros-based SLF4J wrapper
* or logging backend.
*/
/** Defines a [[org.slf4j.Logger]] instance `logger` named according to the class into which this trait is mixed.
*
* In a real-life project, you might rather want to use a macros-based SLF4J wrapper or logging backend.
*/
trait Logging {
protected val logger: Logger = LoggerFactory.getLogger(getClass.getName)

protected val logger: Logger = LoggerFactory.getLogger(getClass.getName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object BasicAuthenticationPekkoServer extends App {
println("Got result: " + result)
assert(result.code == StatusCode.Ok)
assert(result.body == Right("Hello, user!"))

binding
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ object CorsInterceptorPekkoServer extends App {
// Add CORSInterceptor to ServerOptions. Allow http://example.com origin, GET methods, credentials and some custom
// headers.
val customServerOptions: PekkoHttpServerOptions = PekkoHttpServerOptions.customiseInterceptors
.corsInterceptor(CORSInterceptor.customOrThrow(CORSConfig.default
.allowOrigin(Origin.Host("http", "example.com"))
.allowMethods(Method.GET)
.allowHeaders("X-Foo", "X-Bar")
.allowCredentials
.maxAge(42.seconds)
)).options
.corsInterceptor(
CORSInterceptor.customOrThrow(
CORSConfig.default
.allowOrigin(Origin.Host("http", "example.com"))
.allowMethods(Method.GET)
.allowHeaders("X-Foo", "X-Bar")
.allowCredentials
.maxAge(42.seconds)
)
)
.options

val helloCorsRoute: Route =
PekkoHttpServerInterpreter(customServerOptions).toRoute(helloCors.serverLogicSuccess(name => Future.successful(s"Hello!")))
Expand All @@ -44,8 +48,9 @@ object CorsInterceptorPekkoServer extends App {
.options(uri"http://localhost:8080/hello")
.headers(
Header.origin(Origin.Host("http", "example.com")),
Header.accessControlRequestMethod(Method.GET),
).send(backend)
Header.accessControlRequestMethod(Method.GET)
)
.send(backend)

assert(preflightResponse.code == StatusCode.NoContent)
assert(preflightResponse.headers.contains(Header.accessControlAllowOrigin("http://example.com")))
Expand All @@ -60,8 +65,9 @@ object CorsInterceptorPekkoServer extends App {
.options(uri"http://localhost:8080/hello")
.headers(
Header.origin(Origin.Host("http", "unallowed.com")),
Header.accessControlRequestMethod(Method.GET),
).send(backend)
Header.accessControlRequestMethod(Method.GET)
)
.send(backend)

// Check response does not contain allowed origin header
assert(preflightResponseForUnallowedOrigin.code == StatusCode.NoContent)
Expand All @@ -70,7 +76,9 @@ object CorsInterceptorPekkoServer extends App {
println("Got expected response for preflight request for wrong origin. No allowed origin header in response")

// Sending regular request from allowed origin
val requestResponse = basicRequest.response(asStringAlways).get(uri"http://localhost:8080/hello")
val requestResponse = basicRequest
.response(asStringAlways)
.get(uri"http://localhost:8080/hello")
.headers(Header.origin(Origin.Host("http", "example.com")), Header.authorization("Bearer", "dummy-credentials"))
.send(backend)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object ServerSecurityLogicPekko extends App {
assert(testWith("hello", "Cześć", "berries") == "Cześć, Papa Smurf!")
assert(testWith("hello", "Hello", "apple") == "1001")
assert(testWith("hello", "Hello", "smurf") == "Not saying hello to Gargamel!")

binding
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object ServerSecurityLogicRefreshCookiesPekko extends App {

assert(response.body == "Welcome, Steve!")
assert(response.unsafeCookies.map(_.value).toList == List("new token"))

binding
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object StaticContentSecurePekkoServer extends App {

assert(response2.code == StatusCode.Ok)
assert(response2.body == "f1 content")

binding
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object StreamingPekkoServer extends App {
println("Got result: " + result)

assert(result == "Hello!" * 10)

binding
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import sttp.tapir.AnyEndpoint
import sttp.tapir.grpc.protobuf.model._

object ProtoSchemaGenerator {

private val logger = LoggerFactory.getLogger(getClass.getName)
def renderToFile(path: String, packageName: PackageName, endpoints: Iterable[AnyEndpoint]): Unit = {
logger.info("Generating proto file")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ final case class PicklerConfiguration(genericDerivationConfig: Configuration) {
export genericDerivationConfig.{toEncodedName, discriminator, toDiscriminatorValue}

def withSnakeCaseMemberNames: PicklerConfiguration = PicklerConfiguration(genericDerivationConfig.withSnakeCaseMemberNames)
def withScreamingSnakeCaseMemberNames: PicklerConfiguration = PicklerConfiguration(genericDerivationConfig.withScreamingSnakeCaseMemberNames)
def withScreamingSnakeCaseMemberNames: PicklerConfiguration = PicklerConfiguration(
genericDerivationConfig.withScreamingSnakeCaseMemberNames
)
def withKebabCaseMemberNames: PicklerConfiguration = PicklerConfiguration(genericDerivationConfig.withKebabCaseMemberNames)
def withDiscriminator(d: String): PicklerConfiguration = PicklerConfiguration(genericDerivationConfig.withDiscriminator(d))
def withToEncodedName(toEncodedName: String => String) = PicklerConfiguration(genericDerivationConfig.copy(toEncodedName = toEncodedName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ class EndpointGenerator {
.map { case (k, v) =>
val camelCaseK = strippedToCamelCase(k)
val uncapitalisedName = camelCaseK.head.toLower + camelCaseK.tail
s""".attribute[${camelCaseK.capitalize}Extension](${uncapitalisedName}ExtensionKey, ${SpecificationExtensionRenderer.renderValue(v)})"""
s""".attribute[${camelCaseK.capitalize}Extension](${uncapitalisedName}ExtensionKey, ${SpecificationExtensionRenderer.renderValue(
v
)})"""
}
.mkString("\n")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ trait Endpoints {

def genEndpointsFuture(count: Int): List[ServerEndpoint[Any, Future]] = genServerEndpoints(count)(Future.successful)
def genEndpointsIO(count: Int): List[ServerEndpoint[Any, IO]] = genServerEndpoints(count)(IO.pure)
def genEndpointsId(count: Int): List[ServerEndpoint[Any, Id]] = genServerEndpoints[Id](count)(x => x: Id[String])
def genEndpointsId(count: Int): List[ServerEndpoint[Any, Id]] = genServerEndpoints[Id](count)(x => x: Id[String])
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ object NettyFuture {

object TapirServer extends ServerRunner { override def start = NettyFuture.runServer(Tapir.genEndpointsFuture(1)) }
object TapirMultiServer extends ServerRunner { override def start = NettyFuture.runServer(Tapir.genEndpointsFuture(128)) }
object TapirInterceptorMultiServer extends ServerRunner { override def start = NettyFuture.runServer(Tapir.genEndpointsFuture(128), withServerLog = true) }
object TapirInterceptorMultiServer extends ServerRunner {
override def start = NettyFuture.runServer(Tapir.genEndpointsFuture(128), withServerLog = true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ case class PerfTestSuiteParams(

/** Returns list of server names
*/
def serverNames: List[ServerName] = if (shortServerNames.nonEmpty) shortServerNames.map(ServerName.fromShort).distinct else List(ExternalServerName)
def serverNames: List[ServerName] =
if (shortServerNames.nonEmpty) shortServerNames.map(ServerName.fromShort).distinct else List(ExternalServerName)

/** Returns pairs of (fullSimulationName, shortSimulationName), for example: (sttp.tapir.perf.SimpleGetSimulation, SimpleGet)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ case class GatlingSimulationResult(
latencyP75: Double,
latencyP50: Double
)

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ private[armeria] final class ArmeriaRequestBody[F[_], S <: Streams[S]](

override def toStream(serverRequest: ServerRequest, maxBytes: Option[Long]): streams.BinaryStream = {
streamCompatible
.fromArmeriaStream(armeriaCtx(serverRequest).request().filter(x => x.isInstanceOf[HttpData]).asInstanceOf[StreamMessage[HttpData]], maxBytes)
.fromArmeriaStream(
armeriaCtx(serverRequest).request().filter(x => x.isInstanceOf[HttpData]).asInstanceOf[StreamMessage[HttpData]],
maxBytes
)
.asInstanceOf[streams.BinaryStream]
}

Expand Down

0 comments on commit 9605fdf

Please sign in to comment.