Skip to content

New rule: disallow to cast to nullable type#3497

Merged
picklebento merged 6 commits into
detekt:masterfrom
t-kameyama:CastToNullableType
Mar 2, 2021
Merged

New rule: disallow to cast to nullable type#3497
picklebento merged 6 commits into
detekt:masterfrom
t-kameyama:CastToNullableType

Conversation

@t-kameyama

Copy link
Copy Markdown
Contributor

Fixes #3479

@codecov

codecov Bot commented Feb 24, 2021

Copy link
Copy Markdown

Codecov Report

Merging #3497 (53c9d49) into master (fce4177) will decrease coverage by 2.15%.
The diff coverage is 86.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3497      +/-   ##
============================================
- Coverage     79.73%   77.57%   -2.16%     
+ Complexity     2869     2808      -61     
============================================
  Files           461      462       +1     
  Lines          8668     8683      +15     
  Branches       1676     1679       +3     
============================================
- Hits           6911     6736     -175     
- Misses          845     1040     +195     
+ Partials        912      907       -5     
Impacted Files Coverage Δ Complexity Δ
...arturbosch/detekt/rules/bugs/CastToNullableType.kt 84.61% <84.61%> (ø) 4.00 <4.00> (?)
...turbosch/detekt/rules/bugs/PotentialBugProvider.kt 100.00% <100.00%> (ø) 3.00 <0.00> (ø)
...o/gitlab/arturbosch/detekt/internal/SharedTasks.kt 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
.../arturbosch/detekt/internal/DetektMultiplatform.kt 0.00% <0.00%> (-90.91%) 0.00% <0.00%> (-3.00%)
...b/arturbosch/detekt/extensions/DetektReportType.kt 0.00% <0.00%> (-83.34%) 0.00% <0.00%> (-2.00%)
...kotlin/io/gitlab/arturbosch/detekt/DetektPlugin.kt 0.00% <0.00%> (-82.23%) 0.00% <0.00%> (-10.00%)
...o/gitlab/arturbosch/detekt/internal/DetektPlain.kt 0.00% <0.00%> (-76.48%) 0.00% <0.00%> (-5.00%)
...itlab/arturbosch/detekt/extensions/DetektReport.kt 0.00% <0.00%> (-75.00%) 0.00% <0.00%> (-3.00%)
...tlab/arturbosch/detekt/DetektCreateBaselineTask.kt 0.00% <0.00%> (-43.48%) 0.00% <0.00%> (-16.00%)
...ab/arturbosch/detekt/extensions/DetektExtension.kt 0.00% <0.00%> (-42.86%) 0.00% <0.00%> (-2.00%)
... and 6 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 fce4177...53c9d49. Read the comment docs.

t-kameyama and others added 2 commits February 25, 2021 07:35
…etekt/rules/bugs/CastToNullableTypeSpec.kt

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
@BraisGabin

Copy link
Copy Markdown
Member

Sorry, but I still don't see the value of this rule. And why is OK if the initial type is not nullable. I'd like to know what the other maintainers think about it.

@cortinico cortinico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the rule is valuable. To be honest I never really wrote a cast to a nullable type (as String?) and I've always used the as? variant, but I understand that it could be useful to detect them.

t-kameyama and others added 2 commits February 27, 2021 06:52
…etekt/rules/bugs/CastToNullableTypeSpec.kt

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
…etekt/rules/bugs/CastToNullableTypeSpec.kt

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
@t-kameyama t-kameyama requested a review from picklebento March 1, 2021 03:18
This was referenced Mar 11, 2021
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.

New rule: disallow to cast to nullable type

5 participants