Find Compose navigation / coroutine misuse

Proprietary

Calls that need to be wrapped in an effect handler or event handler: navController.navigate(...) from a composable body, scope.launch { … } outside LaunchedEffect, lifecycle-naive collectAsState instead of collectAsStateWithLifecycle.

org.openrewrite.kotlin.compose.FindComposeNavigationIssues$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.compose.FindComposeNavigationIssues$KtRecipe'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Find NavController.navigate(...) calls in a @Composable body
  2. Find scope.launch { … } calls inside a @Composable body
  3. Find Flow.collectAsState() calls — prefer collectAsStateWithLifecycle()