Make sure to read this post before raising a thread here:
Then tell us:
- Which product: Sonarqube Cloud
- What language is this for? Kotlin
- Which rule? kotlin:S6311
- Why do you believe it’s a false-positive/false-negative? This is idiomatic usage according to official Android documentation: https://developer.android.com/kotlin/coroutines/coroutines-best-practices#viewmodel-coroutines
- How can we reproduce the problem? Self contained snippet:
class MyViewModel() : ViewModel() {
private val _actions = MutableSharedFlow<Unit>()
val actions: Flow<Unit> = _actions
fun nonSuspendingFunction() {
viewModelScope.launch {
_actions.emit(Unit)
}
}
}