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 for issue #415 - WHEN_WITHOUT_ELSE doesn't recognize when expression in when branch #450

Merged
merged 5 commits into from
Nov 13, 2020

Conversation

petertrr
Copy link
Member

This pull request closes #415

### What's done:
* Fixes
@codecov
Copy link

codecov bot commented Oct 23, 2020

Codecov Report

Merging #450 (b6bd7ed) into master (c30c8ed) will decrease coverage by 0.04%.
The diff coverage is 40.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #450      +/-   ##
============================================
- Coverage     81.82%   81.78%   -0.05%     
- Complexity     1551     1555       +4     
============================================
  Files            73       73              
  Lines          3896     3897       +1     
  Branches       1244     1244              
============================================
- Hits           3188     3187       -1     
  Misses          211      211              
- Partials        497      499       +2     
Flag Coverage Δ Complexity Δ
unittests 81.78% <40.00%> (-0.05%) 0.00 <0.00> (ø)

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

Impacted Files Coverage Δ Complexity Δ
.../cqfn/diktat/ruleset/rules/WhenMustHaveElseRule.kt 78.37% <40.00%> (-4.96%) 18.00 <0.00> (+4.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 c30c8ed...b6bd7ed. Read the comment docs.

@petertrr petertrr changed the title Fix for issue #415 Fix for issue #415 - WHEN_WITHOUT_ELSE doesn't recognize when expression in when branch Oct 23, 2020
| 1 -> when (x) {
| 2 -> foo()
| }
| }
Copy link
Member

Choose a reason for hiding this comment

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

2 else should be here? why no warnings?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because in this cases return value of when expression is used afterwards, and the compiler can check whether the choice is exhaustive. Since we don't have information about expression type, we don't check these cases at all.

@petertrr petertrr requested review from orchestr7 and aktsay6 October 30, 2020 15:27
Copy link
Member

@orchestr7 orchestr7 left a comment

Choose a reason for hiding this comment

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

lgtm

@petertrr petertrr merged commit babf843 into master Nov 13, 2020
@petertrr petertrr deleted the bugfix/when-wo-else#415 branch November 13, 2020 09:43
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.

WHEN_WITHOUT_ELSE doesn't recognize when expression in when branch
2 participants