associateBy() または associateWith() に置換できる associate() および associateTo() の呼び出しを報告します。
どちらの関数も、所定のシーケンスまたはコレクションの要素に (レシーバーとして) 適用される変換関数を受け付けます。
これらはその後、生成される Map をビルドするために使用されます。
変換関数が it を参照することを考慮すると、associate[To]() の呼び出しは、より高いパフォーマンスを提供する associateBy() または associateWith() に置換できます。
例:
fun getKey(i: Int) = 1L
fun getValue(i: Int) = 1L
fun test() {
arrayOf(1).associate { getKey(it) to it } // 置換可能な 'associate()'
listOf(1).associate { it to getValue(it) } // 置換可能な 'associate()'
}
クイックフィックス適用後:
fun getKey(i: Int) = 1L
fun getValue(i: Int) = 1L
fun test() {
arrayOf(1).associateBy { getKey(it) }
listOf(1).associateWith { getValue(it) }
}