Kotlin detekt issues failing the build in CI
detekt ran static analysis and found issues at or above the failure threshold. This is a quality gate, not a compile error.
What this error means
The detekt task fails with Analysis failed with N issues (or a weighted threshold message), listing the rules and locations. It is deterministic given the code and config.
gradle
> Task :app:detekt FAILED
Analysis failed with 3 weighted issues.
App.kt:14:1: ComplexMethod - cyclomatic complexity 16
App.kt:30:5: MagicNumber - 86400Common causes
New code violates configured rules
Recent changes introduced findings (complexity, magic numbers, style) that push the count past the threshold.
Ruleset or baseline drift
A stricter detekt version or a changed config flags code that previously passed, or a stale baseline no longer matches the source.
How to fix it
Fix the reported findings
- Open each location and address the rule (refactor complexity, name constants).
- Re-run
./gradlew detektuntil clean. - Suppress a finding narrowly only when it is a deliberate exception.
Manage the baseline intentionally
Regenerate the detekt baseline for legacy issues so only new findings fail, and commit it.
CI step
./gradlew detektBaselineHow to prevent it
- Pin the detekt version and ruleset.
- Run detekt locally before pushing.
- Keep the baseline current and reviewed.
Related guides
Kotlin ktlint failures in CIFix Gradle ktlint check failures in CI when Kotlin source does not conform to the ktlint formatting and lint…
scalafmt check failed in CIFix sbt scalafmtCheck / scalafmtCheckAll failures in CI when source files are not formatted to the project .s…
Elixir credo issues failing the build in CIFix Elixir credo failures in CI when static-analysis issues are found and `mix credo --strict` returns a non-…