Skip to content

Commit 260ab7b

Browse files
committed
Fix detekt
1 parent ab7bd83 commit 260ab7b

File tree

15 files changed

+27
-22
lines changed

15 files changed

+27
-22
lines changed

detekt/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ empty-blocks:
219219
EmptyForBlock:
220220
active: true
221221
EmptyFunctionBlock:
222-
active: true
222+
active: false
223223
ignoreOverridden: false
224224
EmptyIfBlock:
225225
active: true
@@ -288,7 +288,7 @@ exceptions:
288288
ThrowingNewInstanceOfSameException:
289289
active: true
290290
TooGenericExceptionCaught:
291-
active: true
291+
active: false
292292
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
293293
exceptionNames:
294294
- 'ArrayIndexOutOfBoundsException'

krpc/krpc-client/src/commonMain/kotlin/kotlinx/rpc/krpc/client/KrpcClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ public abstract class KrpcClient : RpcClient, KrpcEndpoint {
480480

481481
// stop the flow and its coroutine, other flows are not affected
482482
throw e
483-
} catch (@Suppress("detekt.TooGenericExceptionCaught") cause: Throwable) {
483+
} catch (cause: Throwable) {
484484
val serializedReason = serializeException(cause)
485485
val message = KrpcCallMessage.StreamCancel(
486486
callId = outgoingStream.callId,

krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/BufferResult.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package kotlinx.rpc.krpc.internal
66

77
internal sealed interface BufferResult<T> {
88
class Success<T>(val message: T) : BufferResult<T>
9-
class Failure<T>() : BufferResult<T>
9+
class Failure<T> : BufferResult<T>
1010
class Closed<T>(val cause: Throwable?) : BufferResult<T>
1111
}
1212

krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/KrpcConnector.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,10 @@ public class KrpcConnector(
287287
}
288288

289289
else -> {
290-
logger.error { "Unsupported serialization format: ${serialFormat::class} for ${transportMessage::class}" }
290+
logger.error {
291+
"Unsupported serialization format: ${serialFormat::class} for ${transportMessage::class}"
292+
}
293+
291294
return null
292295
}
293296
}

krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/KrpcReceiveHandler.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ internal fun decodeWindow(message: KrpcGenericMessage): WindowResult {
243243
}
244244

245245
val updateParam = windowParam.toIntOrNull()
246-
?: return WindowResult.Failure("Window param must be of the form <available>/<windowId> and in form of two longs")
246+
?: return WindowResult.Failure(
247+
"Window param must be of the form <available>/<windowId> and in form of two longs"
248+
)
247249

248250
val windowKey = message.pluginParams[KrpcPluginKey.WINDOW_KEY]?.split("/").orEmpty()
249251
val serviceType = windowKey.getOrNull(0)

krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/KrpcSendHandler.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ internal class KrpcSendHandler(
4141
private val continuationsLock = ReentrantLock()
4242

4343
// internal for tests
44-
@Suppress("PropertyName")
44+
@Suppress("PropertyName", "detekt.VariableNaming")
4545
internal val __continuations = mutableListOf<CancellableContinuation<Unit>>()
4646

4747
fun updateWindowSize(update: Int) {
@@ -61,13 +61,15 @@ internal class KrpcSendHandler(
6161
}
6262

6363
continuationsLock.withLock {
64-
(0 until window).forEach { _ ->
64+
@Suppress("unused")
65+
for (i in 0 until window) {
6566
__continuations.removeFirstOrNull()?.resume(Unit)
6667
}
6768
}
6869
}
6970
}
7071

72+
@Suppress("detekt.ThrowsCount")
7173
suspend fun sendMessage(message: KrpcTransportMessage) {
7274
if (closed.value) {
7375
throw ClosedSendChannelException("KrpcSendHandler closed")

krpc/krpc-core/src/commonTest/kotlin/kotlinx/rpc/krpc/KrpcConnectorTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import kotlin.test.Test
3535
import kotlin.test.assertEquals
3636
import kotlin.test.assertIs
3737
import kotlin.test.assertTrue
38+
import kotlin.test.fail
3839
import kotlin.time.Duration
3940
import kotlin.time.Duration.Companion.milliseconds
4041
import kotlin.time.Duration.Companion.seconds
@@ -276,7 +277,7 @@ class KrpcConnectorTest : KrpcConnectorBaseTest() {
276277
client.subscribeToMessages(HandlerKey.Protocol) {
277278
if (it is KrpcProtocolMessage.Failure) {
278279
if (!hsResult.clientShookHands.isCompleted) {
279-
throw IllegalStateException("Handshake must be first message, but got: $it")
280+
fail("Handshake must be first message, but got: $it")
280281
}
281282

282283
clientExceptionsChannel.send(it)
@@ -288,7 +289,7 @@ class KrpcConnectorTest : KrpcConnectorBaseTest() {
288289
server.subscribeToMessages(HandlerKey.Protocol) {
289290
if (it is KrpcProtocolMessage.Failure) {
290291
if (!hsResult.serverShookHands.isCompleted) {
291-
throw IllegalStateException("Handshake must be first message, but got: $it")
292+
fail("Handshake must be first message, but got: $it")
292293
}
293294

294295
serverExceptionsChannel.send(it)

krpc/krpc-server/src/commonMain/kotlin/kotlinx/rpc/krpc/server/internal/KrpcServerService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ internal class KrpcServerService<@Rpc T : Any>(
187187
val wrapped = ManualCancellationException(cause)
188188

189189
failure = wrapped
190-
} catch (@Suppress("detekt.TooGenericExceptionCaught") cause: Throwable) {
190+
} catch (cause: Throwable) {
191191
failure = cause
192192
} finally {
193193
if (failure != null) {
@@ -309,7 +309,7 @@ internal class KrpcServerService<@Rpc T : Any>(
309309
)
310310
} catch (cause: CancellationException) {
311311
throw cause
312-
} catch (@Suppress("detekt.TooGenericExceptionCaught") cause: Throwable) {
312+
} catch (cause: Throwable) {
313313
val serializedCause = serializeException(cause)
314314
connector.sendMessage(
315315
KrpcCallMessage.StreamCancel(

krpc/krpc-test/src/commonMain/kotlin/kotlinx/rpc/krpc/test/KrpcTestServiceBackend.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package kotlinx.rpc.krpc.test
66

77
import kotlinx.coroutines.*
88
import kotlinx.coroutines.flow.*
9-
import kotlinx.coroutines.test.TestScope
109
import kotlinx.serialization.Serializable
1110
import kotlin.coroutines.resumeWithException
1211
import kotlin.test.assertContentEquals
@@ -107,7 +106,9 @@ class KrpcTestServiceBackend : KrpcTestService {
107106
return arg1
108107
}
109108

110-
override suspend fun returnTestClassThatThrowsWhileDeserialization(value: Int): TestClassThatThrowsWhileDeserialization {
109+
override suspend fun returnTestClassThatThrowsWhileDeserialization(
110+
value: Int,
111+
): TestClassThatThrowsWhileDeserialization {
111112
return TestClassThatThrowsWhileDeserialization(value)
112113
}
113114

krpc/krpc-test/src/commonMain/kotlin/kotlinx/rpc/krpc/test/KrpcTransportTestBase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ abstract class KrpcTransportTestBase {
349349
}
350350

351351
@Test
352-
@Suppress("detekt.TooGenericExceptionCaught", "detekt.ThrowsCount")
352+
@Suppress("detekt.ThrowsCount")
353353
fun testExceptionSerializationAndPropagating() = runTest {
354354
try {
355355
client.throwsIllegalArgument("me")

0 commit comments

Comments
 (0)