Add UseIsNullOrEmpty rule#3469
Merged
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3469 +/- ##
============================================
- Coverage 80.28% 80.09% -0.19%
- Complexity 2784 2824 +40
============================================
Files 454 455 +1
Lines 8414 8490 +76
Branches 1608 1637 +29
============================================
+ Hits 6755 6800 +45
- Misses 789 793 +4
- Partials 870 897 +27
Continue to review full report at Codecov.
|
caab90d to
e2b8e62
Compare
cortinico
reviewed
Feb 13, 2021
…/rules/style/UseIsNullOrEmpty.kt Co-authored-by: Nicola Corti <corti.nico@gmail.com>
picklebento
approved these changes
Feb 14, 2021
| left.isZero() -> right.safeAs<KtDotQualifiedExpression>() to false | ||
| else -> null | ||
| } ?: return null | ||
| when { |
Member
There was a problem hiding this comment.
Given that we are having nested whens, I would recommend simplifying by extracting this when into two separate functions so that:
val (expression, isEmptyString) = when {
right.isEmptyString() -> sizeCheckedEmptyString(left as? KtSimpleNameExpression)
left.isEmptyString() -> sizeCheckedEmptyString(right as? KtSimpleNameExpression)
right.isZero() -> sizeCheckedEqualToZero(left as? KtDotQualifiedExpression)
left.isZero() -> sizeCheckedEqualToZero(right as? KtDotQualifiedExpression)
else -> null
} ?: return null
picklebento
reviewed
Feb 15, 2021
picklebento
approved these changes
Feb 15, 2021
This was referenced Mar 11, 2021
Closed
Closed
This was referenced Mar 11, 2021
This was referenced Mar 18, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3466