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

BooleanPropertyNaming highlight only the name of the variable #5431

Merged
merged 2 commits into from Oct 21, 2022

Conversation

TWiStErRob
Copy link
Member

@TWiStErRob TWiStErRob commented Oct 17, 2022

... the usual, the warning hides too much, but also deeplinking is broken, e.g. clicking on the this code location:

BooleanPropertyNaming - [Boolean property name should match a ^(is|has|are) pattern. Actual name is email(...)] at P:\projects\workspace\net.twisterrob.cinema\Heroku\backend\endpoint\src\main\kotlin\net\twisterrob\cinema\cineworld\backend\endpoint\auth\data\UserInfoOpenID.kt:31:2

brings me to (before)
image

(expected)
image

@github-actions github-actions bot added the rules label Oct 17, 2022
@@ -79,7 +79,7 @@ class BooleanPropertyNaming(config: Config = Config.empty) : Rule(config) {
val description = "Boolean property name should match a $allowedPattern pattern."
return CodeSmell(
issue,
Entity.from(declaration),
Entity.from(declaration.nameIdentifier ?: declaration),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be statically checked in the new ruleset as a best practice? e.g. if the "thing" passed into Entity.from has a "name" (e.g. inherits from PsiNameIdentifierOwner), then report("use '.nameIdentifier' instead")?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this could apply to all the cases. But that seems like a doable rule so anyone can implement it and check if my statment is true.

@@ -79,7 +79,7 @@ class BooleanPropertyNaming(config: Config = Config.empty) : Rule(config) {
val description = "Boolean property name should match a $allowedPattern pattern."
return CodeSmell(
issue,
Entity.from(declaration),
Entity.from(declaration.nameIdentifier ?: declaration),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this could apply to all the cases. But that seems like a doable rule so anyone can implement it and check if my statment is true.

Co-authored-by: Brais Gabín <braisgabin@gmail.com>
@cortinico cortinico merged commit fe3d11b into detekt:main Oct 21, 2022
@TWiStErRob TWiStErRob deleted the BooleanPropertyNaming_highlight branch October 24, 2022 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants