Skip to content

[UnnecessaryEventHandlerParameter] False positive when there is a shadow variable #41

@BraisGabin

Description

@BraisGabin

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: detekt/detekt#7741

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions