https://kotlinlang.org logo
#detekt
Title
# detekt
m

Marcelo Hernandez

08/10/2022, 11:25 PM
Let's say I want to forbid
androidx.paging.compose.items
using
ForbiddenMethodCall
instead of
ForbiddenImport
, what pattern would I have to use given the following signature:
Copy code
public fun <T : Any> LazyListScope.items(
    items: LazyPagingItems<T>,
    key: ((item: T) -> Any)? = null,
    itemContent: @Composable LazyItemScope.(value: T?) -> Unit
)
I tried the following but the rule is not triggering a violation:
Copy code
androidx.paging.compose.items(androidx.compose.foundation.lazy.LazyListScope, androidx.paging.compose.LazyPagingItems, kotlin.jvm.functions.Function1, kotlin.jvm.functions.Function2)
Guess I was able to get away with just
Copy code
androidx.paging.compose.items
b

Brais Gabin

08/11/2022, 10:53 AM
If that function is not overloaded I think that's the best solution. It's doable to match by parameters too but the signature of this function is really complex so it would be a complex one.
4 Views