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

Bugfix. Useless auto-fix in AVOID_NULL_CHECKS rule #848

Merged
merged 6 commits into from
Apr 27, 2021

Conversation

aktsay6
Copy link
Collaborator

@aktsay6 aktsay6 commented Apr 26, 2021

What's done:

  • Fixed bug
  • Added test

This pull request closes #840

### What's done:
  * Fixed bug
@aktsay6 aktsay6 added the enhancement New feature or request label Apr 26, 2021
@aktsay6 aktsay6 requested a review from petertrr April 26, 2021 10:46
@codecov
Copy link

codecov bot commented Apr 26, 2021

Codecov Report

Merging #848 (04a431b) into master (c04b83f) will increase coverage by 0.04%.
The diff coverage is 83.33%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #848      +/-   ##
============================================
+ Coverage     81.00%   81.05%   +0.04%     
- Complexity     2282     2284       +2     
============================================
  Files           100      100              
  Lines          5843     5847       +4     
  Branches       1814     1813       -1     
============================================
+ Hits           4733     4739       +6     
  Misses          286      286              
+ Partials        824      822       -2     
Flag Coverage Δ Complexity Δ
unittests 81.05% <83.33%> (+0.04%) 2284.00 <0.00> (+2.00)

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

Impacted Files Coverage Δ Complexity Δ
...fn/diktat/ruleset/rules/chapter4/NullChecksRule.kt 78.26% <83.33%> (+3.26%) 39.00 <0.00> (+2.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 c04b83f...04a431b. Read the comment docs.

### What's done:
  * Fixed bug
### What's done:
  * Fixed bug
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.

We can add the same logic for the opposite situation as well:

fun foo(y: Int?) {
    val x = if (y == null) {
        null
    } else {
        y + 2
    }
}

we shouldn't have useless run { null } block

### What's done:
  * Fixed bug
@petertrr petertrr merged commit 19b838d into master Apr 27, 2021
@petertrr petertrr deleted the bugfix/useless-autofix-in-null-checks(#840) branch April 27, 2021 09:46
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.

Useless auto-fix in AVOID_NULL_CHECKS rule
2 participants