I wanted to Suppress an issue raised by UnnecessaryEventHandlerParameter because it is a false positive (more about this in #13)
But when I add the @Suppress to the parameter like this:
@Composable
internal fun MyButton(
state: State,
@Suppress("UnnecessaryEventHandlerParameter") onClick: (String) -> Unit,
) {
when (state) {
State.Loading -> Text("Loading")
is State.Data -> Button(onClick = { onClick(state.id) }) { Text("Click here") }
}
}
I'm getting this exception:
> Analyzing /Users/brais.gabin/Workspace/lidl/features/selfscanning/src/main/java/es/lidlplus/features/selfscanning/checkout/AA.kt led to an exception.
Location: ru.kode.detekt.rule.compose.UnnecessaryEventHandlerParameter$UnnecessaryHandlerArgumentsVisitor.reportError(UnnecessaryEventHandlerParameter.kt:114)
The original exception message was: class org.jetbrains.kotlin.psi.KtDeclarationModifierList cannot be cast to class org.jetbrains.kotlin.psi.KtTypeReference (org.jetbrains.kotlin.psi.KtDeclarationModifierList and org.jetbrains.kotlin.psi.KtTypeReference are in unnamed module of loader java.net.URLClassLoader @54724ee9)
Running detekt '1.21.0-RC2' on Java '11.0.11+9' on OS 'Mac OS X'
The interesting part of the stack trace is this:
Caused by: java.lang.ClassCastException: class org.jetbrains.kotlin.psi.KtDeclarationModifierList cannot be cast to class org.jetbrains.kotlin.psi.KtTypeReference (org.jetbrains.kotlin.psi.KtDeclarationModifierList and org.jetbrains.kotlin.psi.KtTypeReference are in unnamed module of loader java.net.URLClassLoader @54724ee9)
at ru.kode.detekt.rule.compose.UnnecessaryEventHandlerParameter$UnnecessaryHandlerArgumentsVisitor.reportError(UnnecessaryEventHandlerParameter.kt:114)
at ru.kode.detekt.rule.compose.UnnecessaryEventHandlerParameter$UnnecessaryHandlerArgumentsVisitor.visitCallExpression(UnnecessaryEventHandlerParameter.kt:107)
If I set the suppress at the function level all works as expected.
I wanted to Suppress an issue raised by
UnnecessaryEventHandlerParameter
because it is a false positive (more about this in #13)But when I add the
@Suppress
to the parameter like this:I'm getting this exception:
The interesting part of the stack trace is this:
If I set the suppress at the function level all works as expected.