Skip to content

Bump ktfmt default version to the latest one #2536

@polyoxidonium

Description

@polyoxidonium

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions