Find lambda / functional smells

Proprietary

Redundant map { it.toString() } / forEach { it.toString() }, debug-leftover .also { println(it) } / forEach { println(it) }, xs.toList().forEach { } over already-iterable receivers, .also { it.add(...) }-built mutable collections, and forEach { ys.add(it) } (use addAll).

org.openrewrite.kotlin.bestpractices.FindLambdaSmells$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.bestpractices.FindLambdaSmells$KtRecipe'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Find map { it.toString() } / map { x -> x.toString() } patterns
  2. Find forEach { it.toString() } patterns
  3. Find .also { println(it) } debug patterns
  4. Find forEach { println(it) } patterns
  5. Find xs.toList().forEach { … } patterns
  6. Find mutableListOf<T>().also { it.add(x) } patterns
  7. Find mutableMapOf<K,V>().also { it.put(...) } patterns
  8. Find mutableSetOf<T>().also { it.add(x) } patterns
  9. Find xs.forEach { ys.add(it) } patterns