Inspectopedia Help

'StringBuilder.append(CharArray, offset, len)' call on the JVM

Reports a StringBuilder.append(CharArray, offset, len) function call on the JVM platform that should be replaced with a StringBuilder.appendRange(CharArray, startIndex, endIndex) function call.

The append function behaves differently on the JVM, JS and Native platforms, so using the appendRange function is recommended.

Example:

fun f(charArray: CharArray, offset: Int, len: Int): String { return buildString { append(charArray, offset, len) } }

After the quick-fix is applied:

fun f(charArray: CharArray, offset: Int, len: Int): String { return buildString { appendRange(charArray, offset, offset + len) } }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023