Skip to content

CastToNullableType: allow casting null keyword#4907

Merged
BraisGabin merged 1 commit into
detekt:mainfrom
dzirbel:castNullToNullableType
Jun 4, 2022
Merged

CastToNullableType: allow casting null keyword#4907
BraisGabin merged 1 commit into
detekt:mainfrom
dzirbel:castNullToNullableType

Conversation

@dzirbel

@dzirbel dzirbel commented Jun 4, 2022

Copy link
Copy Markdown
Contributor

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

codecov Bot commented Jun 4, 2022

Copy link
Copy Markdown

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
Copy Markdown
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.

4 participants