Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComposeViewModelForwarding doesn't check nested blocks #148

Open
Ilya-Gh opened this issue Jul 10, 2023 · 3 comments
Open

ComposeViewModelForwarding doesn't check nested blocks #148

Ilya-Gh opened this issue Jul 10, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@Ilya-Gh
Copy link

Ilya-Gh commented Jul 10, 2023

The following codes report the error(as expected):

@Composable
fun ComposableOk(
    viewModel: ViewModel,
    modifier: Modifier = Modifier
) {
    ComposableWithViewModel(viewModel = viewModel)
}

In the following screnario, the rule fails to detect the issue when the viewModel is transferred between Composable layers, leading to a false-negative:

@Composable
fun ComposableFalseNegative(
    viewModel: ViewModel,
    modifier: Modifier = Modifier
) {
    Row {
        ComposableWithViewModel(viewModel = viewModel)
    }
}
@ZacSweers
Copy link
Collaborator

Can you please paste the error or screenshot?

@Ilya-Gh
Copy link
Author

Ilya-Gh commented Jul 10, 2023

@ZacSweers Sorry for not stating it clear enough. The issue is that the ComposeViewModelForwarding rule does not report the error when it should.

The case:

@Composable
fun ComposableFalseNegative(
    viewModel: ViewModel,
    modifier: Modifier = Modifier
) {
    Row {
        ComposableWithViewModel(viewModel = viewModel)
    }
}

@mkaomwakuni
Copy link

Could be the ViewModel logic since this approach makes it hard to reuse or replace it some cases

@ZacSweers ZacSweers changed the title ComposeViewModelForwarding produces false negative results ComposeViewModelForwarding doesn't check nested blocks Jan 24, 2024
@ZacSweers ZacSweers added the help wanted Extra attention is needed label Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants