-
-
Notifications
You must be signed in to change notification settings - Fork 778
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
New rule: BooleanPropertyNaming #3795
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Alina,
I don't know if you are aware of it, but there exists already a rule, which works essentially the same as your rule. The controversial rule is called NonBooleanPropertyPrefixedWithIs
. Hence, detekt disables this rule by default.
I don't think detekt needs a second rule even if minor differences exist. Therefore, I have to unfortunately declare this as won't merge. Still, you can use this rule in a custom rule set as you like. See here for more details.
But, this is different rules. NonBooleanPropertyPrefixedWithIs - for NOT boolean property and don't check boolean properties naming. BooleanPropertyPrefixedWithAllowedWords - for booleans. |
Thanks for taking the time to add a new rule 🙏 I believe we could consider this rule, but it falls a bit in the
is less readable than:
but that's debatable, so I can understand how developers might want to enforce some prefixes on their I would like to get other maintainers opinion on this. Some things that needs to be addressed/discussed:
|
Codecov Report
@@ Coverage Diff @@
## main #3795 +/- ##
============================================
+ Coverage 83.53% 83.55% +0.02%
- Complexity 3165 3179 +14
============================================
Files 458 459 +1
Lines 9053 9085 +32
Branches 1761 1765 +4
============================================
+ Hits 7562 7591 +29
Misses 564 564
- Partials 927 930 +3
Continue to review full report at Codecov.
|
...n/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyPrefixedWithAllowedWords.kt
Outdated
Show resolved
Hide resolved
...n/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyPrefixedWithAllowedWords.kt
Outdated
Show resolved
Hide resolved
...n/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyPrefixedWithAllowedWords.kt
Outdated
Show resolved
Hide resolved
...n/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyPrefixedWithAllowedWords.kt
Outdated
Show resolved
Hide resolved
...n/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyPrefixedWithAllowedWords.kt
Outdated
Show resolved
Hide resolved
...n/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyPrefixedWithAllowedWords.kt
Outdated
Show resolved
Hide resolved
...tlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyPrefixedWithAllowedWordsSpec.kt
Outdated
Show resolved
Hide resolved
...tlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyPrefixedWithAllowedWordsSpec.kt
Outdated
Show resolved
Hide resolved
The question is whether more controversial rules shall exist in detekt considering the increasing maintenance effort in this project.
I agree with this and forgot to also reference the
I don't think there exists one. This constitutes more of a common rule in many projects. |
…boolean-naming
…va/detekt into boolean-naming � Conflicts: � detekt-rules-naming/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNaming.kt
I would not add this rule if there is not a source or reference to back it. I think that, as detekt, we should not be that opinated. #3150 was closed even with references. I understand the rule and maybe I would use it in my project too, but I don't think we should have it in our default rulesets. |
Update from original repository
…boolean-naming � Conflicts: � README.md
If the user does not want to use this rule, he will not enable it in the config file |
The rule is very useful, it improves the readability and clarity of the code. It will be great if it will be available as an optional rule. |
With regards to references:
The above references apply to Java code, yet we do not have a Kotlin coding convention encouraging or discouraging the naming pattern for a boolean property. My vote would be yes as this rule is rather easy to maintain and we could document these references in the KDoc so that we keep this rule disabled in the future. |
Other thoughts? We probably want to reach a consensus on this PR before the next release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we could add this rule and have it disabled 👍 It's not as controversial as other and the maintenance cost is not as high.
...les-naming/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNaming.kt
Outdated
Show resolved
Hide resolved
...les-naming/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNaming.kt
Outdated
Show resolved
Hide resolved
...les-naming/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNaming.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
Co-authored-by: marschwar <marschwar@users.noreply.github.com>
…boolean-naming � Conflicts: � README.md
...les-naming/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNaming.kt
Outdated
Show resolved
Hide resolved
...les-naming/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNaming.kt
Outdated
Show resolved
Hide resolved
I made it |
Is there anything missing to merge this? |
Hi! All discussions were resolved |
Can I ask you to address the CI failures? |
I'll try to do it |
I think the code itself is fine (once it compiles again 😃 - The config delegate was moved to a different package.). I have an issue with its inconsistent documentation. I know that it started out to focus on variable name prefixes, but when the rule was renamed to Thank you for your contribution. I think it's really close. Sorry for the delay. |
Thanks for the contrib @AlinaRakhimova, sorry it took a bit longer than usual 🙏 |
I added a new rule to check the naming of boolean variables to improve the readability of the code.
For example,
val enabled = true
Instead of should prefer to
val isEnabled = true