Skip to content

Migrate from ktlint to ktfmt [CLF-722] - #200

Merged
zach-klippenstein merged 1 commit into
mainfrom
zachklipp/radiography-ktlint-ktfmt-cfa2a9
Nov 4, 2026
Merged

zach-klippenstein merged 1 commit into
mainfrom
zachklipp/radiography-ktlint-ktfmt-cfa2a9

Conversation

@zach-klippenstein

@zach-klippenstein zach-klippenstein commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Replaces the ktlint-gradle plugin with ktfmt (Google style) via ktfmt-gradle, matching the formatter already used by market and workflow-kotlin.

The ktlint version this build was pinned to (0.38.1) can't parse modern Kotlin syntax, which is what broke main in #196 and required #198 as a workaround. ktfmt tracks current Kotlin releases and removes that class of problem.

Changes

  • Build config: swap org.jlleitschuh.gradle.ktlint for com.ncorti.ktfmt.gradle 0.26.0 in libs.versions.toml and build.gradle.kts. The plugin is applied to all projects (including the root) with googleStyle(), so *.gradle.kts files are formatted as well.
  • Reformat: ran ./gradlew ktfmtFormat across the repo. These are the bulk of the diff and are pure formatting; no functional changes.
  • .editorconfig: replaced the old ktlint indentation workaround with settings that make IntelliJ's Kotlin formatter match ktfmt's Google style.
  • ComposeUiTest.kt: dropped the now-unneeded ktlint-disable string-template comment.
  • CONTRIBUTING.md: documents ./gradlew ktfmtFormat / ktfmtCheck instead of the Square IntelliJ code style.

CI

No workflow changes needed. ./gradlew build runs check, which now includes ktfmtCheck for every module, so unformatted code fails CI the same way ktlint did.

Test plan

  • ./gradlew build passes locally (compile, unit tests, Android lint, apiCheck, ktfmtCheck)
  • ./gradlew ktfmtFormat is idempotent after this change
  • Android CI green

Linear: CLF-722

🤖 Generated with Claude Code

Replace the ktlint-gradle plugin, pinned to ktlint 0.38.1 (which cannot parse
modern Kotlin syntax and has blocked upgrades), with ktfmt via the
com.ncorti.ktfmt.gradle plugin using Google style. This matches the formatter
already used by market and workflow-kotlin.

- Apply ktfmt to all projects (including the root, so build scripts are
  formatted too) and configure googleStyle().
- Reformat all Kotlin sources and *.gradle.kts files with `./gradlew ktfmtFormat`.
  No functional changes; the build (tests + apiCheck) passes.
- Update .editorconfig so IntelliJ's Kotlin formatter matches ktfmt's Google
  style, replacing the old ktlint-specific indentation workaround.
- Remove the now-unneeded `ktlint-disable` comment in ComposeUiTest.
- Document `./gradlew ktfmtFormat` / `ktfmtCheck` in CONTRIBUTING.md.

`./gradlew build` already runs `check`, which now includes `ktfmtCheck`, so CI
enforces formatting without any workflow changes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@zach-klippenstein
zach-klippenstein merged commit 65cb023 into main Nov 4, 2026
8 checks passed
@zach-klippenstein
zach-klippenstein deleted the zachklipp/radiography-ktlint-ktfmt-cfa2a9 branch November 4, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants