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 Positive: TopLevelPropertyNaming applying to extension properties #7193

Closed
drewhannay opened this issue Apr 17, 2024 · 0 comments · Fixed by #7212
Closed

False Positive: TopLevelPropertyNaming applying to extension properties #7193

drewhannay opened this issue Apr 17, 2024 · 0 comments · Fixed by #7212

Comments

@drewhannay
Copy link

Expected Behavior

I have code like this:

private val Foo.myProperty: String = "Hello"

and the TopLevelPropertyNaming rule is configured to enforce PascalCase for top level properties:

  TopLevelPropertyNaming:
    active: true
    constantPattern: '(?:[A-Z][a-z0-9]+)(?:[A-Z]+[a-z0-9]*)*'
    propertyPattern: '(?:[A-Z][a-z0-9]+)(?:[A-Z]+[a-z0-9]*)*'
    privatePropertyPattern: '_?(?:[A-Z][a-z0-9]+)(?:[A-Z]+[a-z0-9]*)*'

I would expect Foo.myProperty to not be flagged, because this is an extension property on the Foo type, not an actual top level property.

Observed Behavior

Detekt flags Foo.myProperty with the TopLevelPropertyNaming rule.

Steps to Reproduce

Configure TopLevelPropertyNaming with the above options and test against an extension property.

Context

We are trying to enforce PascalCase naming for top level properties on our project and many of these false positives are also being flagged.

Your Environment

  • Version of detekt used: 1.23.6
  • Version of Gradle used (if applicable): 8.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants