28 lines
850 B
Plaintext
28 lines
850 B
Plaintext
== Why is this an issue?
|
|
|
|
The `suspend` function modifier is used to mark a function which might take some time to execute and could suspend the caller coroutine. The location where such function is called is a "suspension point". Functions marked as `suspend` ("suspending functions") should themselves contain at least one suspension point, otherwise it makes no sense to mark it as `suspend`
|
|
|
|
This rule reports an issue if a function with `suspend` modifier has no calls to other `suspend` functions inside its body.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,kotlin]
|
|
----
|
|
suspend fun function() { // Noncompliant, redundant 'suspend' modifier
|
|
println("Hello!")
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,kotlin]
|
|
----
|
|
fun function() {
|
|
println("Hello!")
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
* https://kotlinlang.org/docs/coroutines-guide.html[Coroutines guide]
|