detekt/detekt

Support function type args in `ForbiddenMethodCall`

Open

#8,124 opened on 2025年5月8日

GitHub で見る
 (3 comments) (2 reactions) (0 assignees)Kotlin (834 forks)batch import
featurehelp wanted

Repository metrics

Stars
 (6,942 stars)
PR merge metrics
 (平均マージ 4d 9h) (30d で 65 merged PRs)

説明

If I want to forbid this method call using ForbiddenMethodCall :

  • androidx.navigation.NavController(T, androidx.navigation.NavOptionsBuilder.() -> kotlin.Unit)

I currently have to specify this:

  • androidx.navigation.NavController.navigate(T, kotlin.Function1)

but I would like to be able to specify this instead:

  • androidx.navigation.NavController(T, androidx.navigation.NavOptionsBuilder.() -> kotlin.Unit)

DescriptorRendererImpl in the compiler has all the code you would need for this:

see StringBuilder.renderFunctionType https://github.com/JetBrains/kotlin/blob/db825efc9f8cf648f33d30fb730d47a484519497/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt#L339

コントリビューターガイド