An object expression implements a single-method Java interface that a lambda could implement
What it finds
object : Runnable { override fun run() { work() } } is what Runnable { work() } says. Reported for the common single-method interfaces of the JDK and Android, when the object has nothing but that one function.
From the rule's source, object_for_fun_interface.rs.
val task = object : Runnable {tx0 reports: this Runnable can be a lambda override fun run() { work() }}val other = object : Runnable { val count = 1 override fun run() {}} Turn it on, off or suppress it
The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:object-instead-of-lambda" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:object-instead-of-lambda] reason="..."tx0 explain tx0/kotlin:object-instead-of-lambda shows the same in the terminal. Found a false positive? Report it.