From 2e5269f9943fd092548efe3d081c0559ce497cb9 Mon Sep 17 00:00:00 2001 From: Seonghyeon Cho Date: Fri, 9 Feb 2024 20:12:37 +0900 Subject: [PATCH] Apply ktlint with `max_line_length` as 112 --- .editorconfig | 2 ++ .../common/kotlin/AnnotatedServiceFlowBenchmark.kt | 3 ++- .../server/graphql/kotlin/GraphqlArmeriaClient.kt | 3 ++- .../example/armeria/grpc/kotlin/HelloServiceImpl.kt | 5 ++++- .../server/grpc/kotlin/CoroutineServerInterceptor.kt | 4 +++- .../grpc/kotlin/CoroutineServerInterceptorTest.kt | 12 +++++++++--- .../linecorp/armeria/grpc/kotlin/TestServiceImpl.kt | 8 ++++++-- .../armeria/it/AnnotatedServiceErrorMessageTest.kt | 3 ++- .../common/kotlin/ArmeriaRequestCoroutineContext.kt | 5 ++++- .../server/kotlin/FlowAnnotatedServiceTest.kt | 4 +++- .../server/kotlin/SuspendingAnnotatedServiceTest.kt | 4 +++- 11 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..ee09afeac3e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,2 @@ +[*.{kt,kts}] +max_line_length = 112 diff --git a/benchmarks/jmh/src/jmh/kotlin/com/linecorp/armeria/internal/common/kotlin/AnnotatedServiceFlowBenchmark.kt b/benchmarks/jmh/src/jmh/kotlin/com/linecorp/armeria/internal/common/kotlin/AnnotatedServiceFlowBenchmark.kt index 49972eb8fd2..16de1c4d5ec 100644 --- a/benchmarks/jmh/src/jmh/kotlin/com/linecorp/armeria/internal/common/kotlin/AnnotatedServiceFlowBenchmark.kt +++ b/benchmarks/jmh/src/jmh/kotlin/com/linecorp/armeria/internal/common/kotlin/AnnotatedServiceFlowBenchmark.kt @@ -58,7 +58,8 @@ open class AnnotatedServiceFlowBenchmark { @Get("/publisher") @ProducesJsonSequences - fun publisherBm(): Publisher = Flux.fromStream(IntStream.range(0, 1000).mapToObj { it.toString() }) + fun publisherBm(): Publisher = + Flux.fromStream(IntStream.range(0, 1000).mapToObj { it.toString() }) }, ) .build() diff --git a/examples/graphql-kotlin/src/test/kotlin/example/armeria/server/graphql/kotlin/GraphqlArmeriaClient.kt b/examples/graphql-kotlin/src/test/kotlin/example/armeria/server/graphql/kotlin/GraphqlArmeriaClient.kt index 934f98ce86d..f1adb2a8dcc 100644 --- a/examples/graphql-kotlin/src/test/kotlin/example/armeria/server/graphql/kotlin/GraphqlArmeriaClient.kt +++ b/examples/graphql-kotlin/src/test/kotlin/example/armeria/server/graphql/kotlin/GraphqlArmeriaClient.kt @@ -20,7 +20,8 @@ class GraphqlArmeriaClient( private val serializer: GraphQLClientSerializer = defaultGraphQLSerializer(), // TODO(ikhoon): support Automatic Persisted Queries // See: https://github.com/ExpediaGroup/graphql-kotlin/issues/1640 - override val automaticPersistedQueriesSettings: AutomaticPersistedQueriesSettings = AutomaticPersistedQueriesSettings(), + override val automaticPersistedQueriesSettings: AutomaticPersistedQueriesSettings = + AutomaticPersistedQueriesSettings(), ) : GraphQLClient { override suspend fun execute( request: GraphQLClientRequest, diff --git a/examples/grpc-kotlin/src/main/kotlin/example/armeria/grpc/kotlin/HelloServiceImpl.kt b/examples/grpc-kotlin/src/main/kotlin/example/armeria/grpc/kotlin/HelloServiceImpl.kt index 109b558535e..4c8f41397cd 100644 --- a/examples/grpc-kotlin/src/main/kotlin/example/armeria/grpc/kotlin/HelloServiceImpl.kt +++ b/examples/grpc-kotlin/src/main/kotlin/example/armeria/grpc/kotlin/HelloServiceImpl.kt @@ -99,7 +99,10 @@ class HelloServiceImpl : HelloServiceGrpcKt.HelloServiceCoroutineImplBase() { suspend fun withArmeriaBlockingContext(block: suspend CoroutineScope.() -> T): T = withContext(ServiceRequestContext.current().blockingTaskExecutor().asCoroutineDispatcher(), block) - private fun buildReply(message: String): HelloReply = HelloReply.newBuilder().setMessage(message).build() + private fun buildReply(message: String): HelloReply = + HelloReply.newBuilder().setMessage( + message, + ).build() private fun toMessage(message: String): String = "Hello, $message!" } diff --git a/grpc-kotlin/src/main/kotlin/com/linecorp/armeria/server/grpc/kotlin/CoroutineServerInterceptor.kt b/grpc-kotlin/src/main/kotlin/com/linecorp/armeria/server/grpc/kotlin/CoroutineServerInterceptor.kt index 2a644a38ce0..483d51e9142 100644 --- a/grpc-kotlin/src/main/kotlin/com/linecorp/armeria/server/grpc/kotlin/CoroutineServerInterceptor.kt +++ b/grpc-kotlin/src/main/kotlin/com/linecorp/armeria/server/grpc/kotlin/CoroutineServerInterceptor.kt @@ -95,7 +95,9 @@ interface CoroutineServerInterceptor : AsyncServerInterceptor { CoroutineContextServerInterceptor::class.let { kclass -> val companionObject = checkNotNull(kclass.companionObject) val property = companionObject.memberProperties.single { it.name == "COROUTINE_CONTEXT_KEY" } - checkNotNull(property.getter.call(kclass.companionObjectInstance)) as Context.Key + checkNotNull( + property.getter.call(kclass.companionObjectInstance), + ) as Context.Key } } } diff --git a/grpc-kotlin/src/test/kotlin/com/linecorp/armeria/server/grpc/kotlin/CoroutineServerInterceptorTest.kt b/grpc-kotlin/src/test/kotlin/com/linecorp/armeria/server/grpc/kotlin/CoroutineServerInterceptorTest.kt index ba1cc7c3f72..baf008c14f9 100644 --- a/grpc-kotlin/src/test/kotlin/com/linecorp/armeria/server/grpc/kotlin/CoroutineServerInterceptorTest.kt +++ b/grpc-kotlin/src/test/kotlin/com/linecorp/armeria/server/grpc/kotlin/CoroutineServerInterceptorTest.kt @@ -394,7 +394,9 @@ internal class CoroutineServerInterceptorTest { return SimpleResponse.getDefaultInstance() } - override fun streamingOutputCall(request: StreamingOutputCallRequest): Flow { + override fun streamingOutputCall( + request: StreamingOutputCallRequest, + ): Flow { return flow { for (i in 1..5) { delay(500) @@ -404,7 +406,9 @@ internal class CoroutineServerInterceptorTest { } } - override suspend fun streamingInputCall(requests: Flow): StreamingInputCallResponse { + override suspend fun streamingInputCall( + requests: Flow, + ): StreamingInputCallResponse { val names = requests.map { it.payload.body.toString() }.toList() assertContextPropagation() @@ -412,7 +416,9 @@ internal class CoroutineServerInterceptorTest { return buildReply(names) } - override fun fullDuplexCall(requests: Flow): Flow { + override fun fullDuplexCall( + requests: Flow, + ): Flow { return flow { requests.collect { delay(500) diff --git a/it/grpc/kotlin/src/test/kotlin/com/linecorp/armeria/grpc/kotlin/TestServiceImpl.kt b/it/grpc/kotlin/src/test/kotlin/com/linecorp/armeria/grpc/kotlin/TestServiceImpl.kt index 3c6b6a2b5ab..7758a699ee9 100644 --- a/it/grpc/kotlin/src/test/kotlin/com/linecorp/armeria/grpc/kotlin/TestServiceImpl.kt +++ b/it/grpc/kotlin/src/test/kotlin/com/linecorp/armeria/grpc/kotlin/TestServiceImpl.kt @@ -105,12 +105,16 @@ class TestServiceImpl : TestServiceGrpcKt.TestServiceCoroutineImplBase() { ServiceRequestContext.current().blockingTaskExecutor().asCoroutineDispatcher() // A blocking dispatcher that does not propagate a request context - fun blockingDispatcher(): CoroutineDispatcher = CommonPools.blockingTaskExecutor().asCoroutineDispatcher() + fun blockingDispatcher(): CoroutineDispatcher = + CommonPools.blockingTaskExecutor().asCoroutineDispatcher() suspend fun withArmeriaBlockingContext(block: suspend CoroutineScope.() -> T): T = withContext(ServiceRequestContext.current().blockingTaskExecutor().asCoroutineDispatcher(), block) - private fun buildReply(message: String): HelloReply = HelloReply.newBuilder().setMessage(message).build() + private fun buildReply(message: String): HelloReply = + HelloReply.newBuilder().setMessage( + message, + ).build() private fun toMessage(message: String): String = "Hello, $message!" } diff --git a/it/kotlin/src/test/kotlin/com/linecorp/armeria/it/AnnotatedServiceErrorMessageTest.kt b/it/kotlin/src/test/kotlin/com/linecorp/armeria/it/AnnotatedServiceErrorMessageTest.kt index 9e78b9ab095..5904d0270e2 100644 --- a/it/kotlin/src/test/kotlin/com/linecorp/armeria/it/AnnotatedServiceErrorMessageTest.kt +++ b/it/kotlin/src/test/kotlin/com/linecorp/armeria/it/AnnotatedServiceErrorMessageTest.kt @@ -31,7 +31,8 @@ class AnnotatedServiceErrorMessageTest { assertThatThrownBy { serverBuilder.build() } .hasMessageContaining( - "Kotlin suspending functions are supported only when you added 'armeria-kotlin' as a dependency.", + "Kotlin suspending functions are supported" + + " only when you added 'armeria-kotlin' as a dependency.", ) } diff --git a/kotlin/src/main/kotlin/com/linecorp/armeria/internal/common/kotlin/ArmeriaRequestCoroutineContext.kt b/kotlin/src/main/kotlin/com/linecorp/armeria/internal/common/kotlin/ArmeriaRequestCoroutineContext.kt index a35e948589a..d7b5415cf3c 100644 --- a/kotlin/src/main/kotlin/com/linecorp/armeria/internal/common/kotlin/ArmeriaRequestCoroutineContext.kt +++ b/kotlin/src/main/kotlin/com/linecorp/armeria/internal/common/kotlin/ArmeriaRequestCoroutineContext.kt @@ -25,7 +25,10 @@ import kotlin.coroutines.CoroutineContext /** * Propagates [ServiceRequestContext] over coroutines. */ -@Deprecated("Use RequestContext.asCoroutineContext() instead.", ReplaceWith("RequestContext.asCoroutineContext()")) +@Deprecated( + "Use RequestContext.asCoroutineContext() instead.", + ReplaceWith("RequestContext.asCoroutineContext()"), +) class ArmeriaRequestCoroutineContext( private val requestContext: ServiceRequestContext, ) : ThreadContextElement, AbstractCoroutineContextElement(Key) { diff --git a/kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/FlowAnnotatedServiceTest.kt b/kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/FlowAnnotatedServiceTest.kt index 800ef367bb0..dca21cd8c92 100644 --- a/kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/FlowAnnotatedServiceTest.kt +++ b/kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/FlowAnnotatedServiceTest.kt @@ -243,7 +243,9 @@ internal class FlowAnnotatedServiceTest { fun runsWithinEventLoop() = flow { ServiceRequestContext.current() - assertThat(Thread.currentThread().name).contains("armeria-common-worker") + assertThat( + Thread.currentThread().name, + ).contains("armeria-common-worker") emit("OK") } }, diff --git a/kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/SuspendingAnnotatedServiceTest.kt b/kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/SuspendingAnnotatedServiceTest.kt index b19f4699e36..c3c94595f90 100644 --- a/kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/SuspendingAnnotatedServiceTest.kt +++ b/kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/SuspendingAnnotatedServiceTest.kt @@ -256,7 +256,9 @@ class SuspendingAnnotatedServiceTest { @Get("/baz") suspend fun baz(): String { ServiceRequestContext.current() - assertThat(Thread.currentThread().name).contains("armeria-common-blocking-tasks") + assertThat( + Thread.currentThread().name, + ).contains("armeria-common-blocking-tasks") return "OK" } },