Skip to content

BooleanPropertyNaming highlight only the name of the variable#5431

Merged
cortinico merged 2 commits into
detekt:mainfrom
TWiStErRob:BooleanPropertyNaming_highlight
Oct 21, 2022
Merged

BooleanPropertyNaming highlight only the name of the variable#5431
cortinico merged 2 commits into
detekt:mainfrom
TWiStErRob:BooleanPropertyNaming_highlight

Conversation

@TWiStErRob

@TWiStErRob TWiStErRob commented Oct 17, 2022

Copy link
Copy Markdown
Member

... 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
return CodeSmell(
issue,
Entity.from(declaration),
Entity.from(declaration.nameIdentifier ?: declaration),

@TWiStErRob TWiStErRob Oct 17, 2022

Copy link
Copy Markdown
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
Copy Markdown
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.

return CodeSmell(
issue,
Entity.from(declaration),
Entity.from(declaration.nameIdentifier ?: declaration),

Copy link
Copy Markdown
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.

4 participants