detekt-rules-compose
detekt-rules-compose copied to clipboard
[UnnecessaryEventHandlerParameter] False positive when there is a shadow variable
This component have little sense (infinite recursion) but it's a really easy reproducer of this false positive:
@Composable
fun Asdf(rotation: Float, onClick: (Float) -> Unit) {
Column {
Asdf(rotation, { rotation -> onClick(rotation) })
}
}
This code fires UnnecessaryEventHandlerParameter but if I change the code to this:
@Composable
fun Asdf(rotation: Float, onClick: (Float) -> Unit) {
Column {
Asdf(rotation, { foo -> onClick(foo) })
}
}
The rule works perfectly.
Probably using type solving this could be solvable. The other issue is on detekt itself. The shadowing rule doesn't catch that type of shadowing. I opened this other issue to track it: https://github.com/detekt/detekt/issues/7741
Interesting! Thanks, I'll investigate this more closely and will think about how this could be solved, maybe it'll require to switch this rule to use type resolution indeed...