Skip to content

CanBeNonNullable: Check parent condition for checking if nullability info is used or not #6064

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

Merged
merged 1 commit into from
May 5, 2023

Conversation

atulgpt
Copy link
Contributor

@atulgpt atulgpt commented May 1, 2023

Fixes: #5799

@codecov
Copy link

codecov bot commented May 1, 2023

Codecov Report

Merging #6064 (226f9f5) into main (158aa2a) will decrease coverage by 0.02%.
The diff coverage is 71.42%.

@@             Coverage Diff              @@
##               main    #6064      +/-   ##
============================================
- Coverage     84.86%   84.84%   -0.02%     
  Complexity     3975     3975              
============================================
  Files           564      564              
  Lines         13300    13300              
  Branches       2325     2327       +2     
============================================
- Hits          11287    11285       -2     
  Misses          870      870              
- Partials       1143     1145       +2     
Impacted Files Coverage Δ
.../arturbosch/detekt/rules/style/CanBeNonNullable.kt 79.33% <71.42%> (-0.74%) ⬇️

@cortinico cortinico changed the title Check parent condition for checking if nullability info is used or not CanBeNonNullable: Check parent condition for checking if nullability info is used or not May 1, 2023
val code = """
fun foo(a: Int?, other: Int) {
when {
a != null || other % 2 == 0 -> println(2 + other)
Copy link
Member

Choose a reason for hiding this comment

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

I always have doubts about this. Basically it is a boolean and makes the function do something if it is true. But probably that's probably work for another rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @BraisGabin can you create an issue about the smell here?

@BraisGabin BraisGabin added this to the 1.23.0 milestone May 5, 2023
@BraisGabin BraisGabin merged commit 731c6de into detekt:main May 5, 2023
@atulgpt atulgpt deleted the fixes/5799 branch May 5, 2023 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive on CanBeNonNullable: not differentiating between && and || in some scenarios
4 participants