Skip to content

Generate the detekt config in a task so it survives configuration cache reuse#10

Merged
rasros merged 1 commit into
mainfrom
fix/detekt-config-config-cache
Jun 7, 2026
Merged

Generate the detekt config in a task so it survives configuration cache reuse#10
rasros merged 1 commit into
mainfrom
fix/detekt-config-config-cache

Conversation

@rasros

@rasros rasros commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

What changed

  • The lint plugin no longer writes build/tmp/eignex-detekt.yml eagerly at configuration time. A registered task (writeEignexDetektConfig) with a declared input (the content) and output (the file) materializes it instead, and the detekt and baseline tasks depend on it.
  • Added a TestKit regression test that runs detekt with the configuration cache, clears the build dir, and runs again, asserting the second run reuses the cache and still succeeds.

Why

The config was written as a side effect during project configuration, and the detekt tasks just pointed their --config at it. When the configuration cache is reused the configuration phase is skipped, so the write never happens. On a fresh checkout that restored only the Gradle home and not build/ (a CI runner with gradle/actions/setup-gradle and a cache-encryption-key), every detekt task then failed with "Path '.../build/tmp/eignex-detekt.yml' passed to --config does not exist". Making generation a task puts it in the task graph, where it runs on every build including configuration-cache hits, and makes the output up-to-date-checkable and cacheable.

Testing

Ran the lint plugin TestKit suite (5 tests) green. Confirmed the new test fails without the plugin change (reproduces the missing-config failure) and passes with it. Verified a negative sample still fires UnnecessaryFullyQualifiedName, and that a positive sample run twice with --configuration-cache reports "Configuration cache entry stored" then "Configuration cache entry reused".

@rasros rasros merged commit cf3b52c into main Jun 7, 2026
2 checks passed
@rasros rasros deleted the fix/detekt-config-config-cache branch June 7, 2026 20:03
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.

1 participant