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

Update dependency org.jmailen.gradle:kotlinter-gradle to v4 #4488

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ij_kotlin_packages_to_use_import_on_demand = java.util.*, io.ktor.**
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_no-empty-first-line-in-class-body = disabled
ktlint_standard_filename = disabled
ktlint_standard_class-naming = disabled
ktlint_standard_annotation = disabled
Expand Down
12 changes: 1 addition & 11 deletions buildSrc/src/main/kotlin/KotlinExtensions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
import org.gradle.api.*
import org.gradle.kotlin.dsl.*
Expand Down Expand Up @@ -47,16 +47,6 @@ fun NamedDomainObjectContainer<KotlinSourceSet>.jvmAndPosixTest(block: KotlinSou
block(sourceSet)
}

fun NamedDomainObjectContainer<KotlinSourceSet>.jvmAndNixMain(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("jvmAndNixMain") ?: getByName("jvmMain")
block(sourceSet)
}

fun NamedDomainObjectContainer<KotlinSourceSet>.jvmAndNixTest(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("jvmAndNixTest") ?: getByName("jvmTest")
block(sourceSet)
}

fun NamedDomainObjectContainer<KotlinSourceSet>.nixTest(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("nixTest") ?: return
block(sourceSet)
Expand Down
4 changes: 0 additions & 4 deletions buildSrc/src/main/kotlin/KtorBuildProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import org.gradle.api.tasks.testing.*
import org.gradle.jvm.toolchain.*
import org.gradle.kotlin.dsl.*

/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

private val java_version: String = System.getProperty("java.version", "8.0.0")

private val versionComponents = java_version
Expand Down
10 changes: 2 additions & 8 deletions buildSrc/src/main/kotlin/TargetsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ import java.io.*
private val Project.files: Array<File> get() = project.projectDir.listFiles() ?: emptyArray()
val Project.hasCommon: Boolean get() = files.any { it.name == "common" }
val Project.hasJvmAndPosix: Boolean get() = hasCommon || files.any { it.name == "jvmAndPosix" }
val Project.hasJvmAndNix: Boolean get() = hasCommon || files.any { it.name == "jvmAndNix" }
val Project.hasPosix: Boolean get() = hasCommon || hasJvmAndPosix || files.any { it.name == "posix" }
val Project.hasDesktop: Boolean get() = hasPosix || files.any { it.name == "desktop" }
val Project.hasNix: Boolean get() = hasPosix || hasJvmAndNix || files.any { it.name == "nix" }
val Project.hasNix: Boolean get() = hasPosix || files.any { it.name == "nix" }
val Project.hasLinux: Boolean get() = hasNix || files.any { it.name == "linux" }
val Project.hasDarwin: Boolean get() = hasNix || files.any { it.name == "darwin" }
val Project.hasAndroidNative: Boolean get() = hasPosix || files.any { it.name == "androidNative" }
val Project.hasWindows: Boolean get() = hasPosix || files.any { it.name == "windows" }
val Project.hasJsAndWasmShared: Boolean get() = files.any { it.name == "jsAndWasmShared" }
val Project.hasJs: Boolean get() = hasCommon || files.any { it.name == "js" } || hasJsAndWasmShared
val Project.hasWasmJs: Boolean get() = hasCommon || files.any { it.name == "wasmJs" } || hasJsAndWasmShared
val Project.hasJvm: Boolean get() = hasCommon || hasJvmAndNix || hasJvmAndPosix || files.any { it.name == "jvm" }
val Project.hasJvm: Boolean get() = hasCommon || hasJvmAndPosix || files.any { it.name == "jvm" }

val Project.hasExplicitNative: Boolean
get() = hasNix || hasPosix || hasLinux || hasAndroidNative || hasDarwin || hasDesktop || hasWindows
Expand Down Expand Up @@ -110,11 +109,6 @@ private val hierarchyTemplate = KotlinHierarchyTemplate {
group("posix")
}

group("jvmAndNix") {
withJvm()
group("nix")
}

group("desktop") {
group("linux")
group("windows")
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/test/server/tests/Events.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package test.server.tests

import io.ktor.http.*
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/test/server/tests/WebSockets.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package test.server.tests

import io.ktor.server.application.*
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ serialization = "1.7.3"
binaryCompatibilityValidator = "0.16.3"
dokka = "1.9.20"
kover = "0.8.3"
ktlint = "3.15.0"
ktlint = "4.5.0"
kotlinx-browser = "0.2"

# Used for test server in buildSrc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.engine.apache5
Expand All @@ -22,6 +22,7 @@ import java.nio.*
import java.util.concurrent.*
import kotlin.coroutines.*

@Suppress("FunctionName")
@OptIn(InternalAPI::class)
internal fun ApacheRequestProducer(
requestData: HttpRequestData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.engine.cio

Expand All @@ -18,7 +18,7 @@ import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.sync.*
import kotlinx.io.EOFException
import kotlinx.io.*
import java.nio.channels.*
import kotlin.coroutines.*
import io.ktor.utils.io.ByteChannel as KtorByteChannel
Expand Down Expand Up @@ -61,9 +61,7 @@ internal actual class ConnectionPipeline actual constructor(
} catch (_: CancellationException) {
} finally {
responseChannel.close()
/**
* Workaround bug with socket.close
*/
// Workaround bug with socket.close
// outputChannel.close()
}
}
Expand Down Expand Up @@ -109,7 +107,9 @@ internal actual class ConnectionPipeline actual constructor(
val proxyChannel = KtorByteChannel()
skipTask = skipCancels(responseChannel, proxyChannel)
proxyChannel
} else ByteReadChannel.Empty
} else {
ByteReadChannel.Empty
}

callJob.invokeOnCompletion {
body.cancel()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.plugins.websocket.cio
Expand Down Expand Up @@ -37,7 +37,9 @@ public suspend fun HttpClient.webSocketRawSession(
session.outgoing.invokeOnClose {
if (it != null) {
sessionCompleted.completeExceptionally(it)
} else sessionCompleted.complete(Unit)
} else {
sessionCompleted.complete(Unit)
}
}
sessionCompleted.await()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.engine.cio
Expand All @@ -18,7 +18,6 @@ import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.ktor.utils.io.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.junit5.*
import org.junit.jupiter.api.extension.*
Expand Down Expand Up @@ -102,7 +101,8 @@ class ConnectErrorsTest {
}
client.getInputStream().readBytes()
}
} catch (_: Exception) { }
} catch (_: Exception) {
}
}
assertEquals("OK", client.get("http://localhost:${serverSocket.localPort}/").body())
thread.join()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ktlint-disable filename
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.engine.cio

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ktlint-disable filename
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.engine.cio

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ktlint-disable filename
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.engine.cio

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.engine

import io.ktor.http.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.plugins

Expand Down Expand Up @@ -155,7 +155,7 @@ internal object ReceiveError : ClientHook<suspend (HttpRequest, Throwable) -> Th
}
}

private fun HttpRequest(builder: HttpRequestBuilder) = object : HttpRequest {
private fun HttpRequest(builder: HttpRequestBuilder): HttpRequest = object : HttpRequest {
override val call: HttpClientCall get() = error("Call is not initialized")
override val method: HttpMethod = builder.method
override val url: Url = builder.url.build()
Expand All @@ -169,6 +169,7 @@ private fun HttpRequest(builder: HttpRequestBuilder) = object : HttpRequest {
/**
* Install [HttpCallValidator] with [block] configuration.
*/
@Suppress("FunctionName")
public fun HttpClientConfig<*>.HttpResponseValidator(block: HttpCallValidatorConfig.() -> Unit) {
install(HttpCallValidator, block)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.plugins
Expand Down Expand Up @@ -264,7 +264,9 @@ public val HttpRequestRetry: ClientPlugin<HttpRequestRetryConfig> = createClient
val subRequestJob = subRequest.executionContext as CompletableJob
if (cause == null) {
subRequestJob.complete()
} else subRequestJob.completeExceptionally(cause)
} else {
subRequestJob.completeExceptionally(cause)
}
}
return subRequest
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.plugins

Expand Down Expand Up @@ -35,6 +35,7 @@ public val UserAgent: ClientPlugin<UserAgentConfig> = createClientPlugin("UserAg
/**
* Installs the [UserAgent] plugin with a browser-like user agent.
*/
@Suppress("FunctionName")
public fun HttpClientConfig<*>.BrowserUserAgent() {
install(UserAgent) {
agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) " +
Expand All @@ -45,6 +46,7 @@ public fun HttpClientConfig<*>.BrowserUserAgent() {
/**
* Installs the [UserAgent] plugin with a CURL user agent.
*/
@Suppress("FunctionName")
public fun HttpClientConfig<*>.CurlUserAgent() {
install(UserAgent) {
agent = "curl/7.61.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.plugins.api

import io.ktor.client.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.plugins.cache

Expand Down Expand Up @@ -137,5 +137,7 @@ internal fun shouldValidate(
}

internal enum class ValidateStatus {
ShouldValidate, ShouldNotValidate, ShouldWarn
ShouldValidate,
ShouldNotValidate,
ShouldWarn,
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2023 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.plugins.sse

Expand All @@ -21,6 +21,7 @@ internal val showRetryEventsAttr = AttributeKey<Boolean>("SSEShowRetryEvents")
/**
* Installs the [SSE] plugin using the [config] as configuration.
*/
@Suppress("FunctionName")
public fun HttpClientConfig<*>.SSE(config: SSEConfig.() -> Unit) {
install(SSE) {
config()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ public class WebSockets internal constructor(
return@intercept
}
if (status != HttpStatusCode.SwitchingProtocols) {
@Suppress("ktlint:standard:max-line-length")
throw WebSocketException(
"Handshake exception, expected status code ${HttpStatusCode.SwitchingProtocols.value} but was ${status.value}" // ktlint-disable max-line-length
"Handshake exception, expected status code ${HttpStatusCode.SwitchingProtocols.value} but was ${status.value}"
)
}
if (session !is WebSocketSession) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.plugins.websocket

Expand All @@ -14,6 +14,7 @@ import kotlinx.coroutines.*
/**
* Installs the [WebSockets] plugin using the [config] as configuration.
*/
@Suppress("FunctionName")
public fun HttpClientConfig<*>.WebSockets(config: WebSockets.Config.() -> Unit) {
install(WebSockets) {
config()
Expand Down Expand Up @@ -44,7 +45,9 @@ public suspend fun HttpClient.webSocketSession(
session.outgoing.invokeOnClose {
if (it != null) {
sessionCompleted.completeExceptionally(it)
} else sessionCompleted.complete(Unit)
} else {
sessionCompleted.complete(Unit)
}
}
sessionCompleted.await()
}
Expand Down
Loading