mrmans0n / compose-rules

Lint rules for ktlint/detekt aimed to contribute to a healthier usage of Compose. Actively maintained and evolved fork of the Twitter Compose rules.
https://mrmans0n.github.io/compose-rules
Other
550 stars 21 forks source link

Incorrect compose:lambda-param-in-effect rule failure #327

Closed necatisozer closed 2 weeks ago

necatisozer commented 2 weeks ago

This code fails because of the same named ViewModel.onClick() function.

@Composable
fun MyComposable(onClick: () -> Unit, viewModel: MyViewModel = viewModel()) {
    val latestOnClick by rememberUpdatedState(onClick)
    LaunchedEffect(Unit) {
        latestOnClick()
        viewModel.onClick()
    }
    // ...
}
mrmans0n commented 2 weeks ago

Good catch, will fix it asap