appKODE / detekt-rules-compose

A collection of Detekt rules for Jetpack Compose
MIT License
136 stars 8 forks source link

False positive on ReusedModifierInstance with theme as direct child #28

Closed mike-wideman closed 1 year ago

mike-wideman commented 1 year ago

Hello!

The following causes ReusedModifierInstance to fire:

@Composable
fun MyComposable(
    modifier: Modifier = Modifier
) {
    MaterialTheme {
        Row(
            modifier = modifier,
        ) { }
    }
}

This seems like a false positive given that the direct child is a theme.

dimsuz commented 1 year ago

Thank you for the report!

This is a duplicate of #5 and is already fixed in master.

The upcoming release (I plan to publish it in a few days) will contain the fix. For now you can temporarily @Suppress this false positive.

You'll have to use detekt in a type resolution mode though (which is preferable in any case, many useful rules will depend on it).