Skip to content
Latchkey

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 - 86400

Common 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

  1. Open each location and address the rule (refactor complexity, name constants).
  2. Re-run ./gradlew detekt until clean.
  3. 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 detektBaseline

How to prevent it

  • Pin the detekt version and ruleset.
  • Run detekt locally before pushing.
  • Keep the baseline current and reviewed.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →