During refactoring I often do something like: ```...
# detekt
d
During refactoring I often do something like:
Copy code
// before
val itemId = 3
onClick = { someListener(itemId) }
// after
onClick = { someListener() }
// OR
onClick = { itemId -> someListener(itemId) }
in the latter cases this can be simplified to (no extra wrapping lambda):
Copy code
onClick = someListener
I'm about to try to write a custom check for this, but I thought maybe there already is one?
c
I think the closest in the detekt repo is https://detekt.github.io/detekt/style.html#objectliteraltolambda, but there could be other detekt custom extensions that implemented this. If you have time, please help us by contributing a rule like such 🙏
d
I suspect it would need to use type resolution to work correctly. This feature is new to me, most of my checks are not using it. But that makes it more interesting:)
e
that conversion can be ambiguous in case of overloaded functions, so it probably is only sound with type resolution. seems interesting though
c
The longer term solution for type resolution is going to be either detekt-compiler-plugin or the incoming frontend-IR based solution in the new K2 compiler