-
Notifications
You must be signed in to change notification settings - Fork 39
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
Recommendation 6.1.10 no tivial getters or setters are allowed #499
Conversation
### What's done: * Added rule logic * Added warn tests * Added fix tests
### What's done: * Fixed bugs
### What's done: * Tags added
### What's done: * Fixed bugs
Codecov Report
@@ Coverage Diff @@
## master #499 +/- ##
============================================
+ Coverage 81.77% 81.80% +0.03%
- Complexity 1528 1543 +15
============================================
Files 72 73 +1
Lines 3862 3891 +29
Branches 1234 1242 +8
============================================
+ Hits 3158 3183 +25
Misses 210 210
- Partials 494 498 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
You should also handle expression-body setters (yes, they exists! :) ) and comments inside accessors (at least if accessor is trivial but has comments warning should still be raised).
Edit: seems like expression-body setters can't be trivial. But they still exist and your current code may throw an exception when it encounters one.
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/TrivialPropertyAccessors.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/TrivialPropertyAccessors.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/TrivialPropertyAccessors.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/TrivialPropertyAccessors.kt
Outdated
Show resolved
Hide resolved
### What's done: * Fixed bugs
### What's done: * Fixed bugs
### What's done: * Fixed bugs
@@ -37,6 +42,7 @@ class TrivialPropertyAccessors(private val configRules: List<RulesConfig>) : Rul | |||
|
|||
if (node.elementType == PROPERTY_ACCESSOR) { | |||
handlePropertyAccessors(node) | |||
print(node.prettyPrint()) |
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.
?
} | ||
|
||
@Suppress("UnsafeCallOnNullableType") | ||
private fun handleGetAccessor(node: ASTNode) { |
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.
Please add a comment that this handles both = field
and { return field }
### What's done: * Fixed bugs
This pull request closes #445
Actions checklist