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

CastToNullableType: allow casting null keyword #4907

Merged
merged 1 commit into from Jun 4, 2022
Merged

CastToNullableType: allow casting null keyword #4907

merged 1 commit into from Jun 4, 2022

Conversation

dzirbel
Copy link
Contributor

@dzirbel dzirbel commented Jun 4, 2022

Fix a false positive for CastToNullableType for casting a literal null to a nullable type. This can be necessary when providing null as a function argument where the incoming type is parameterized. In this case using e.g. null as? String is less meaningful and generates a compiler warning that the cast cannot succeed.

@github-actions github-actions bot added the rules label Jun 4, 2022
Fix a false positive for CastToNullableType for casting a literal `null` to a nullable type. This can be necessary when providing null as a function argument where the incoming type is parameterized. In this case using e.g. `null as? String` is less meaningful and generates a compiler warning that the cast cannot succeed.
@codecov
Copy link

codecov bot commented Jun 4, 2022

Codecov Report

Merging #4907 (7f51415) into main (5baf1f6) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##               main    #4907   +/-   ##
=========================================
  Coverage     84.83%   84.83%           
- Complexity     3511     3512    +1     
=========================================
  Files           497      497           
  Lines         11548    11549    +1     
  Branches       2138     2139    +1     
=========================================
+ Hits           9797     9798    +1     
  Misses          686      686           
  Partials       1065     1065           
Impacted Files Coverage Δ
...arturbosch/detekt/rules/bugs/CastToNullableType.kt 87.50% <100.00%> (+0.83%) ⬆️

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 5baf1f6...7f51415. Read the comment docs.

@BraisGabin
Copy link
Member

Thanks for the fix!

@BraisGabin BraisGabin merged commit 4b30c6b into detekt:main Jun 4, 2022
@BraisGabin BraisGabin added this to the 1.21.0 milestone Jun 4, 2022
@dzirbel dzirbel deleted the castNullToNullableType branch June 4, 2022 19:02
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.

None yet

3 participants