We enhanced our Kotlin analyzer by adding 12 rules to help you avoid mistakes when using the coroutines library.
The coroutines library for Kotlin is the most used libraries according to 2020 JetBrains survey. As we want to help a maximum of developers, providing rules dedicated to coroutines was a natural choice.
Here are all the rules dedicated to coroutines:
- S6314: Flow intermediate operation results should not be left unused
- S6306: Coroutine usage should adhere to structured concurrency principles
- S6307 1: Suspending functions should be main-safe
- S6310: Dispatchers should be injectable
- S6311: Suspending functions should not be called on a different dispatcher
- S6313: ViewModel classes should create coroutines
- S6315 1: The return value of functions returning “Deferred” should be used
- S6316: Kotlin coroutines api for timeouts should be used
- S6312: Extension functions on CoroutineScopes should not be declared as “suspend”
- S6309: Functions returning Flow/Channel should not be suspending
- S6305: “MutableStateFlow” and “MutableSharedFlow” should not be exposed
- S6318: “suspend” modifier should not be redundant