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

Changing functionality for AVOID_NULL_CHECK #564

Merged
merged 8 commits into from
Nov 30, 2020

Conversation

orchestr7
Copy link
Member

What's done:

  1. Now it is not trigered on simple cases like val a = b ==null
  2. added logic for requireNotNull

### What's done:
1) Now it is not trigered on simple cases like val a = b ==null
2) added logic for requireNotNull
@orchestr7 orchestr7 linked an issue Nov 23, 2020 that may be closed by this pull request
@orchestr7 orchestr7 self-assigned this Nov 23, 2020
@codecov
Copy link

codecov bot commented Nov 23, 2020

Codecov Report

Merging #564 (3da8aa6) into master (052bd9d) will decrease coverage by 0.88%.
The diff coverage is 85.71%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #564      +/-   ##
============================================
- Coverage     81.68%   80.80%   -0.89%     
- Complexity     1641     1709      +68     
============================================
  Files            79       87       +8     
  Lines          4139     4381     +242     
  Branches       1307     1349      +42     
============================================
+ Hits           3381     3540     +159     
- Misses          229      298      +69     
- Partials        529      543      +14     
Flag Coverage Δ Complexity Δ
unittests 80.80% <85.71%> (-0.89%) 0.00 <42.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> (ø)
...fn/diktat/ruleset/rules/kdoc/CommentsFormatting.kt 69.79% <ø> (-0.21%) 76.00 <0.00> (-1.00)
...lin/org/cqfn/diktat/ruleset/rules/PackageNaming.kt 93.82% <50.00%> (-1.11%) 32.00 <0.00> (ø)
...in/org/cqfn/diktat/ruleset/rules/NullChecksRule.kt 75.00% <62.50%> (-2.78%) 22.00 <4.00> (+4.00) ⬇️
.../cqfn/diktat/ruleset/rules/BlockStructureBraces.kt 83.92% <85.71%> (+0.11%) 53.00 <0.00> (ø)
...ktat/ruleset/rules/AvoidEmptyPrimaryConstructor.kt 90.00% <90.00%> (ø) 8.00 <8.00> (?)
...iktat/ruleset/rules/ImplicitBackingPropertyRule.kt 93.75% <93.75%> (ø) 23.00 <23.00> (?)
...tlin/org/cqfn/diktat/ruleset/constants/Warnings.kt 98.34% <100.00%> (+0.02%) 10.00 <0.00> (ø)
...cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt 97.64% <100.00%> (+0.38%) 9.00 <0.00> (+1.00)
...in/org/cqfn/diktat/ruleset/rules/FunctionLength.kt 84.21% <100.00%> (-0.79%) 9.00 <0.00> (-1.00)
... and 22 more

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 3e91e26...3da8aa6. Read the comment docs.

| }
""".trimMargin(),
LintError(2, 14, ruleId, Warnings.AVOID_NULL_CHECKS.warnText() +
" use 'requireNotNull()' instead of myVar != null", false),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text can be adjusted a little: like use 'requireNotNull(myVar)' instead of 'require (myVar != null)'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting myVar is too complex logic - I would not like to make the code more complex, but the second part is easy enough, added

@orchestr7 orchestr7 merged commit fefe2fd into master Nov 30, 2020
@petertrr petertrr deleted the feature/null-check-#550 branch December 21, 2020 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comparison with null yields error in diktat 0.1.5
2 participants