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

Recommendation 6.1.10 no tivial getters or setters are allowed #499

Merged
merged 10 commits into from
Nov 9, 2020

Conversation

aktsay6
Copy link
Collaborator

@aktsay6 aktsay6 commented Nov 6, 2020

This pull request closes #445

Actions checklist

  • Implemented Rule, added Warnings
  • Added tests on checks
  • Added tests on fixers
  • Updated diktat-analysis.yml
  • Updated available-rules.md

### What's done:
  * Added rule logic
  * Added warn tests
  * Added fix tests
### What's done:
  * Fixed bugs
### What's done:
  * Tags added
@aktsay6 aktsay6 added the enhancement New feature or request label Nov 6, 2020
### What's done:
  * Fixed bugs
@codecov
Copy link

codecov bot commented Nov 6, 2020

Codecov Report

Merging #499 (3194c6a) into master (6d591d7) will increase coverage by 0.03%.
The diff coverage is 86.20%.

Impacted file tree graph

@@             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     
Flag Coverage Δ Complexity Δ
unittests 81.80% <86.20%> (+0.03%) 0.00 <15.00> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...at-rules/src/main/kotlin/generated/WarningNames.kt 0.00% <ø> (ø) 0.00 <0.00> (ø)
...n/diktat/ruleset/rules/TrivialPropertyAccessors.kt 85.18% <85.18%> (ø) 15.00 <15.00> (?)
...tlin/org/cqfn/diktat/ruleset/constants/Warnings.kt 98.24% <100.00%> (+0.01%) 10.00 <0.00> (ø)
...cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt 97.05% <100.00%> (+0.04%) 8.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d591d7...6a9fd5d. Read the comment docs.

Copy link
Member

@petertrr petertrr left a 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.

@aktsay6 aktsay6 requested a review from petertrr November 9, 2020 14:05
@@ -37,6 +42,7 @@ class TrivialPropertyAccessors(private val configRules: List<RulesConfig>) : Rul

if (node.elementType == PROPERTY_ACCESSOR) {
handlePropertyAccessors(node)
print(node.prettyPrint())
Copy link
Member

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) {
Copy link
Member

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 }

@aktsay6 aktsay6 merged commit c375a4c into master Nov 9, 2020
@aktsay6 aktsay6 deleted the feature/recommendation-6.1.10(#445) branch November 9, 2020 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recommendation 6.1.10 no trivial getters and setters are allowed in the code
2 participants