-
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
Recommendation 4.3.1 avoid nullable types #296
Recommendation 4.3.1 avoid nullable types #296
Conversation
### What's done: Added new rule
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
### 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
…ion-4.3.1-avoid-nullable-types
### What's done: Fixed bug
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
### What's done: Added handler for non null init
### What's done: Renamed methods
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
…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
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Show resolved
Hide resolved
diktat-rules/src/test/resources/test/paragraph3/nullable/NullPrimitiveTest.kt
Show resolved
Hide resolved
### What's done: Fixed fix Simplified code
### What's done: Added suppress
### What's done: Added to all config
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.
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
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
### What's done: Handle collection factory
### What's done: Find only top level Quest
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.kt
Outdated
Show resolved
Hide resolved
### 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
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.
Please change initial value for Char, apart from this LGTM
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/NullableTypeRule.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.
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
Actions checklist
Fixme