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

Recommendation 4.3.1 avoid nullable types #296

Merged
merged 23 commits into from
Oct 2, 2020

Conversation

kentr0w
Copy link
Collaborator

@kentr0w kentr0w commented Sep 15, 2020

Actions checklist

Fixme

Add fix logic

### What's done:
    Added new rule
@kentr0w kentr0w added the enhancement New feature or request label Sep 15, 2020
### What's done:
    Added check for fix
    Added fix processing
    Added fix tests
### What's done:
    Changed logic for avoid complex method
### What's done:
    Added return's type
### What's done:
    Fixed bug
### What's done:
    Fixed bug
@codecov
Copy link

codecov bot commented Sep 16, 2020

Codecov Report

Merging #296 into master will decrease coverage by 0.06%.
The diff coverage is 80.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #296      +/-   ##
============================================
- Coverage     82.86%   82.79%   -0.07%     
- Complexity     1144     1182      +38     
============================================
  Files            57       58       +1     
  Lines          2865     2935      +70     
  Branches        917      930      +13     
============================================
+ Hits           2374     2430      +56     
- Misses          162      169       +7     
- Partials        329      336       +7     
Flag Coverage Δ Complexity Δ
#unittests 82.79% <80.00%> (-0.07%) 1182.00 <38.00> (+38.00) ⬇️

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

Impacted Files Coverage Δ Complexity Δ
...at-rules/src/main/kotlin/generated/WarningNames.kt 0.00% <ø> (ø) 0.00 <0.00> (ø)
.../org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt 79.41% <79.41%> (ø) 38.00 <38.00> (?)
...tlin/org/cqfn/diktat/ruleset/constants/Warnings.kt 96.93% <100.00%> (+0.03%) 9.00 <0.00> (ø)
...cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt 97.91% <100.00%> (+0.04%) 3.00 <0.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 5d3fa15...c904547. Read the comment docs.

### What's done:
    Added handler for non null init
### What's done:
    Renamed methods
@kentr0w kentr0w requested a review from petertrr September 17, 2020 09:28
…ion-4.3.1-avoid-nullable-types

# Conflicts:
#	diktat-rules/src/main/kotlin/generated/WarningNames.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	diktat-rules/src/main/resources/diktat-analysis.yml
#	info/available-rules.md
### What's done:
   Fixed small  bugs
### What's done:
   Added suppress
### What's done:
   Added suppress
### What's done:
   Fixed fix
   Simplified code
### What's done:
   Added suppress
### What's done:
   Added to all config
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.

Take a look at snapshot check:
[INFO] [ktlint] /home/runner/work/diKTat/diKTat/diktat-common/src/test/kotlin/org/cqfn/diktat/test/ConfigReaderTest.kt:10:30: [NULLABLE_PROPERTY_TYPE] try to avoid use of nullable types: don't use nullable type (cannot be auto-corrected)
You should check assigned value before issuing a warning. You absolutely shouldn't suggest to change type if right hand side expression returns nullable value.

### What's done:
   Fixed bug for call expression right side
### What's done:
   Handle collection factory
### What's done:
   Find only top level Quest
### What's done:
   Simplified code
…ion-4.3.1-avoid-nullable-types

# Conflicts:
#	diktat-analysis.yml
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	diktat-rules/src/main/resources/diktat-analysis-huawei.yml
#	info/available-rules.md
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.

Please change initial value for Char, apart from this LGTM

@petertrr petertrr self-requested a review September 29, 2020 10:54
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.

Wait, I found this:
[INFO] [ktlint] /home/runner/work/diKTat/diKTat/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt:258:29: [NULLABLE_PROPERTY_TYPE] try to avoid use of nullable types: don't use nullable type (cannot be auto-corrected)
and this:
[INFO] [ktlint] /home/runner/work/diKTat/diKTat/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/DiktatRuleSetProvider4Test.kt:20:34: [NULLABLE_PROPERTY_TYPE] try to avoid use of nullable types: don't use nullable type (cannot be auto-corrected)

Both warnings are clearly false-positive

### What's done:
    Fixed logic
@kentr0w kentr0w requested a review from petertrr October 1, 2020 17:09
@kentr0w kentr0w merged commit 74d9065 into master Oct 2, 2020
@kentr0w kentr0w deleted the feature/recommendation-4.3.1-avoid-nullable-types branch October 2, 2020 14:18
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
3 participants