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

Fix: AVOID_NULL_CHECKS conflicts with NO_BRACES_IN_CONDITIONALS_AND_LOOPS #1191

Merged
merged 8 commits into from
Jan 27, 2022

Conversation

kgevorkyan
Copy link
Member

@kgevorkyan kgevorkyan commented Jan 26, 2022

What's done:

  • Don't trigger on scope function, since they are already have braces

@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #1191 (c00f8f9) into master (2df05de) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1191      +/-   ##
============================================
+ Coverage     84.49%   84.51%   +0.02%     
- Complexity     2511     2518       +7     
============================================
  Files           103      103              
  Lines          7054     7065      +11     
  Branches       1902     1909       +7     
============================================
+ Hits           5960     5971      +11     
  Misses          306      306              
  Partials        788      788              
Flag Coverage Δ
unittests 84.51% <100.00%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
...rules/chapter3/BracesInConditionalsAndLoopsRule.kt 90.38% <100.00%> (+1.13%) ⬆️

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 2df05de...c00f8f9. Read the comment docs.

### What's done:
* Code style
@kgevorkyan kgevorkyan marked this pull request as ready for review January 26, 2022 14:04
@@ -90,6 +92,13 @@ class BracesInConditionalsAndLoopsRule(configRules: List<RulesConfig>) : DiktatR
}

if (elseKeyword != null && elseNode?.elementType != IF && elseNode?.elementType != BLOCK) {
val referenceExpressionChildren = elseNode?.findAllDescendantsWithSpecificType(REFERENCE_EXPRESSION)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we check only top-level children? IIRC, findAllDescendantsWithSpecificType will return even deeply nested nodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, they reason, why it can be dangerous, that in theory, we can take some wrong node, from the nested ones
Initially I can't imagine some proper case, and thought that it will worked anyway, however now I did this, add more tests and little bit changed the logic, now we looking into the direct children

if (a) {
bar()
} else b?.let {
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 it to the smoke test too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

@kgevorkyan kgevorkyan merged commit f533d9e into master Jan 27, 2022
@kgevorkyan kgevorkyan deleted the bugfix/braces_rule branch January 27, 2022 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AVOID_NULL_CHECKS conflicts with NO_BRACES_IN_CONDITIONALS_AND_LOOPS
2 participants