-
-
Notifications
You must be signed in to change notification settings - Fork 783
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
Fix false positive for CanBeNonNullable
rule
#5714
Conversation
Are these tests related with #5629? The cases are a bit difficult to follow. And I'm not sure if all of them are related with the same issue. Would it be possible to split them in different PRs? Or all of them target the same flaw? |
Hi, @BraisGabin not all follow the same flaw. Some can be grouped and split into little PRs. Is there any provision to add a disabled test in the PR? Or should I completely remove them from here and add in the other PRs? Also only see the TCs with |
I would prefer to split them up. |
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Fixed
Show fixed
Hide fixed
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Fixed
Show fixed
Hide fixed
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Fixed
Show fixed
Hide fixed
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Fixed
Show fixed
Hide fixed
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Fixed
Show fixed
Hide fixed
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Fixed
Show fixed
Hide fixed
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Fixed
Show fixed
Hide fixed
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Fixed
Show fixed
Hide fixed
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.
Hi @atulgpt which are the next steps for this PR? Is there somerhing blocking you here? Can I help you some how? I left some comments on the tests but they seem fine.
I must say that a function that only does something when a parameter is null seems like a function that should be flagged too. But probably not by this rule but by other one. But this is offtopic for this PR.
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Outdated
Show resolved
Hide resolved
} | ||
} | ||
""".trimIndent() | ||
assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) |
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.
I dont't get what this test does exactly.
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.
The name of the TC was wrong. Actually, it should report as all the branches of when
handles the non-null case. Here we are checking different types of boolean conditions. I have renamed the TC to does report when parameter is not checked for nullability in boolean conditions
...-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt
Outdated
Show resolved
Hide resolved
Hi @BraisGabin good vibes of Bali is stopping me from completing this PR 😂. I will complete back after I come back 🙂 |
Enjoy!!! |
4285945
to
c064724
Compare
Codecov Report
@@ Coverage Diff @@
## main #5714 +/- ##
============================================
+ Coverage 84.57% 84.63% +0.06%
- Complexity 3786 3788 +2
============================================
Files 546 546
Lines 12938 12943 +5
Branches 2275 2275
============================================
+ Hits 10942 10954 +12
- Misses 862 866 +4
+ Partials 1134 1123 -11
... and 19 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullable.kt
Fixed
Show fixed
Hide fixed
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullable.kt
Fixed
Show fixed
Hide fixed
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullable.kt
Outdated
Show resolved
Hide resolved
Fix violations Add PR TC
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.
I left some nit comments but LGTM
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullable.kt
Outdated
Show resolved
Hide resolved
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullable.kt
Outdated
Show resolved
Hide resolved
…/rules/style/CanBeNonNullable.kt Co-authored-by: Brais Gabín <braisgabin@gmail.com>
It seems that my code didn't compile 😅. The Github's suggestions feature is great but working without an IDE is difficult. |
Haha true 😅 I have fixed it to make it compliable. Now CI should pass |
CanBeNonNullable
ruleCanBeNonNullable
rule
Added failing TCs
Fixes #5629