-
Notifications
You must be signed in to change notification settings - Fork 484
Description
Description
Please consider updating the default version of ktfmt used in Spotless to the latest stable release — com.facebook:ktfmt:0.56 (June 2025).
Problem
The current default version of ktfmt bundled in Spotless is not fully compatible with Kotlin 2.2.0. When upgrading projects to Kotlin 2.2.0, spotlessCheck fails on otherwise valid code — particularly:
• Multiline string literals
• Long string concatenations in test fixtures (e.g., JSON or CSV constants)
Example error:
ktfmt(ktfmt) error: expected token: '"..."'; generated + instead (...)
These issues are caused by older ktfmt versions not supporting the Kotlin 2.2.0 parser and grammar rules correctly.
Resolution
The latest version, ktfmt:0.56, brings full compatibility with Kotlin 2.2.0 and resolves these formatting errors. After explicitly setting the version:
ktfmt("0.56") {
kotlinlangStyle()
}
Formatting now works as expected, with no spotless failures and no need for suppressions or refactors.
Proposal
Please update the default bundled version of ktfmt in Spotless to 0.56, which:
• Fixes compatibility with Kotlin 2.2.0
• Avoids false-positive formatting failures
• Keeps Spotless aligned with the modern Kotlin ecosystem