RedundantVisibilityModifier false positives on "plain" detekt tasks when `explicitApi` is enabled
#9 063 ouverte le 17 févr. 2026
Métriques du dépôt
- Stars
- (6 942 stars)
- Métriques de merge PR
- (Merge moyen 4j 9h) (65 PRs mergées en 30 j)
Description
Followup to https://github.com/detekt/detekt/issues/3874, where RedundantVisibilityModifier was flagging incorrectly. A fix was made for that, but the issue still persists specifically when running gradle detekt instead of gradle detektMain.
Expected Behavior
No issues to be raised
Observed Behavior
RedundantVisibilityModifier flags several issues in the main source set, with explicitApi() enabled in the Gradle config. gradle detektMain runs perfectly well, but gradle detekt fails.
Steps to Reproduce
This project is where I came across it, when I enabled allRules in my detekt config. You can replicate by cloning and removing the RedundantVisibilityModifier suppression from config/detekt.yml. For reference, here's some of the output from running gradle detekt:
> Task :blueprint-core:detekt
/home/jon/dev/blueprint/blueprint-core/src/main/kotlin/blueprint/core/BlueprintPlugin.kt:7:14: BlueprintPlugin is explicitly marked as public. Public is the default visibility for classes. The public modifier is redundant. [RedundantVisibilityModifier]
Context
I'm guessing this is caused by this bit here where the "main" sourceset is specified for the explicit API config. From a look around, it seems that this same config isn't also applied to the regular detekt task.
I guess the change in behaviour comes about because detekt v2 now uses the compiler API even in the base detekt task? Not sure honestly
Your Environment
- Version of detekt used: 2.0.0-alpha2
- Version of Gradle used (if applicable): 9.3.1
- Link to your project (if it's a public repository): https://github.com/jonapoul/blueprint