rspec/rules/S6318/kotlin/rule.adoc

24 lines
769 B
Plaintext
Raw Normal View History

In Kotlin, the `suspend` function modifier is used to mark a function which might take some time to execute and could suspend the caller thread. The location where such a function is called is a "suspension point". Functions marked as `suspend` 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
----
suspend fun function() { // Noncompliant, redundant 'suspend' modifier
println("Hello!")
}
----
== Compliant Solution
----
fun function() {
println("Hello!")
}
----
== See
* https://kotlinlang.org/docs/coroutines-guide.html[Coroutines guide]