-
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
Fix for issue #415 - WHEN_WITHOUT_ELSE doesn't recognize when expression in when branch #450
Conversation
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
| 1 -> when (x) { | ||
| 2 -> foo() | ||
| } | ||
| } |
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.
2 else should be here? why no warnings?
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.
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.
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/WhenMustHaveElseRule.kt
Outdated
Show resolved
Hide resolved
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.
lgtm
This pull request closes #415