detekt/detekt

RedundantVisibilityModifier false positives on "plain" detekt tasks when `explicitApi` is enabled

Open

#9 063 ouverte le 17 févr. 2026

Voir sur GitHub
 (3 commentaires) (1 réaction) (0 assignés)Kotlin (834 forks)batch import
buggradlegradle-pluginhelp wantedwaiting for feedback

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

Guide contributeur