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

Rule to detect not passing modifier to all branches #466

Open
ansman opened this issue Feb 18, 2025 · 0 comments
Open

Rule to detect not passing modifier to all branches #466

ansman opened this issue Feb 18, 2025 · 0 comments

Comments

@ansman
Copy link

ansman commented Feb 18, 2025

A common issue I find is when using a when in a composable and not propagating the modifier parameter to all branches, typically when a new branch is added. For example:

@Composable
fun SomeScreenContent(
  state: SomeViewState,
  modifier: Modifier = Modifier,
) {
  when (state) {
    is SomeViewState.Loading -> SomeScreenLoadingContent()
    is SomeViewState.Loaded -> SomeScreenLoadedContent(modifier)
  }
}

I'd like to see a warning/error on the is SomeViewState.Loading -> SomeScreenLoadingContent() branch saying that you probably want to pass the modifier parameter. The exception is if the composable doesn't accept a modifier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant