Kotlin ktlint failures in CI
ktlint ran in check mode and found formatting or lint violations. This is a style gate that fails the build until the code conforms.
What this error means
The ktlintCheck task fails listing files, lines, and rule IDs that violate the ktlint ruleset. It is deterministic given the sources and config.
gradle
> Task :app:ktlintMainSourceSetCheck FAILED
src/main/kotlin/App.kt:12:1: Unexpected indentation (standard:indent)
src/main/kotlin/App.kt:20:80: Exceeded max line length (standard:max-line-length)Common causes
Code committed without formatting
Changes were pushed without running ktlint, so indentation, imports, or line length diverge from the ruleset.
ktlint version or rule drift
A different ktlint version or editorconfig formats differently than what produced the committed code.
How to fix it
Auto-format with ktlint
Run the format task to fix most violations, then commit.
CI step
./gradlew ktlintFormatPin the ktlint version and editorconfig
- Pin the ktlint Gradle plugin version.
- Commit a shared .editorconfig so local and CI agree.
- Add a pre-commit hook to run ktlintFormat.
How to prevent it
- Pin the ktlint plugin version.
- Share an .editorconfig across the team.
- Run ktlintFormat before pushing.
Related guides
Kotlin detekt issues failing the build in CIFix Gradle detekt failures in CI when static-analysis findings exceed the configured threshold and fail the b…
scalafmt check failed in CIFix sbt scalafmtCheck / scalafmtCheckAll failures in CI when source files are not formatted to the project .s…
Elixir "mix format --check-formatted" failed in CIFix the Elixir "mix format --check-formatted" failure in CI when source files are not formatted to the projec…