报告可替换为 stdlib 运算的序列(如 mapfilter 等)的 for 循环。

示例:


fun foo(list: List<String>): List<Int> {
  val result = ArrayList<Int>()
  for (s in list) {
     if (s.length > 0)
       result.add(s.hashCode())
     }
  return result
}

在应用快速修复后:


fun foo(list: List<String>): List<Int> {
  val result = list
    .filter { it.length > 0 }
    .map { it.hashCode() }
  return result
}