```private suspend fun DefaultClientWebSocketSessi...
# coroutines
u
Copy code
private suspend fun DefaultClientWebSocketSession.send(outgoingSubmission: OutgoingSubmission) {
    when (outgoingSubmission) {
        is OutgoingSubmission.Text -> {
            val outgoingEnvelope = OutgoingEnvelope.HandleMessage(
                ...
            )
            send(OutgoingEnvelope.HandleMessage.serializer(), outgoingEnvelope) <-------
        }
        ...
    }
}
detekt
flags this code with
suspend function uses CoroutineScope as receiver. [SuspendFunWithCoroutineScopeReceiver]
is this a false positive? what's wrong with it? Sure ktor's
DefaultClientWebSocketSession
is a coroutine scope but im pretty sure it's not meant to launch sends into it?
e
generally a function can use a
CoroutineScope
or be
suspend
, but both is usually not a good pattern, as it could allow the function to unexpectedly escape structured concurrency. in this case it doesn't seem avoidable though
1
u
I agree in spirit, but the ktor clienr type already declares a suspend function despite itself being a corputine scope.. isnt that the original sin?