Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False negative for enum constants in UndocumentedPublic* rule group #7218

Open
TWiStErRob opened this issue Apr 23, 2024 · 2 comments
Open

Comments

@TWiStErRob
Copy link
Member

TWiStErRob commented Apr 23, 2024

Steps to Reproduce

public enum class PublicEnum {
	Foo,
	Bar,
}

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\PublicEnum.kt:21:15: PublicEnum is missing required documentation. [UndocumentedPublicClass]

Expected Behavior

Findings for each of the undocumented enum constants. They're public API as well, accessible as PublicEnum.Foo.
If

public companion object {
    public val Foo: PublicClass = ...
}

needs to be documented (The property Foo is missing documentation. [UndocumentedPublicProperty]), so does these enum constants Foo and Bar as they're essentially "just syntactic a shorthand" for the same.

Context

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

This repro might be a trivial case, but imagine an enum with 10-12 values, and no documentation.

Your Environment

  • Version of detekt used: 1.23.5
  • Version of Gradle used (if applicable): 8.7
  • Gradle scan link (add --scan option when running the gradle task): N/A
  • Operating System and version: Windows 10 / GitHub Actions Ubuntu 22.04
  • Link to your project (if it's a public repository): N/A
@atulgpt
Copy link
Contributor

atulgpt commented Apr 23, 2024

Should we make this configurable? Given documenting enum can be cumbersome

@TWiStErRob
Copy link
Member Author

Documentation alone is cumbersome :) if someone enables this rule, they probably want it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants