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
543 stars 20 forks source link

Look into `modifier` shadowing in ModifierReused rule #236

Closed mrmans0n closed 4 months ago

mrmans0n commented 4 months ago

Stuff like the below snippet can trip over the rule (e.g. something else shadowing modifier). We should try to avoid those cases. One could argue that they should rename those modifiers instead to avoid shadowing, but that could be its own (different) rule.

@Composable
fun A(modifier: Modifier = Modifier) {
  Box(modifier) {
    val bleh = @Composable { modifier: Modifier -> 
      Text("Bleh", modifier = modifier)
    }
  }
}