Back to Intellij Community

ReplaceStringFormatWithLiteral

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ReplaceStringFormatWithLiteral.html

2025.3-rc-2454 B
Original Source

Reports String.format calls that can be replaced with string templates.

Using string templates makes your code simpler.

The quick-fix replaces the call with a string template.

Example:

fun main() {
      val id = "abc"
      val date = "123"
      val s = String.format("%s_%s_%s", id, date, id)
  }

After the quick-fix is applied:

fun main() {
      val id = "abc"
      val date = "123"
      val s = "${id}_${date}_$id"
  }