detekt / detekt

Static code analysis for Kotlin
https://detekt.dev
Apache License 2.0
6.07k stars 751 forks source link

False negative for companion object in UndocumentedPublicClass #7217

Closed TWiStErRob closed 2 weeks ago

TWiStErRob commented 3 weeks ago

Steps to Reproduce

public object PublicObject

public class PublicClass {

    public companion object;
}

Configuration:

detekt.allRules = true
// Does not contain relevant lines, just a few rules deactivated or fine tuned.
detekt.config.from(rootProject.file("config/detekt/detekt.yml"))
dependencies { detektPlugins(libs.detekt.rules.libraries) }

Observed Behavior

src\main\kotlin\com\example\PublicTest.kt:21:15: PublicObject is missing required documentation. [UndocumentedPublicClass]
src\main\kotlin\com\example\PublicTest.kt:23:14: PublicClass is missing required documentation. [UndocumentedPublicClass]

Expected Behavior

The 2 findings are fine, but there are 3 public classes in the above code:

So the false negative is the companion object.

Context

I'm relying on detekt to ensure that all my public API surface is documented.

Your Environment