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

New rule: disallow to cast to nullable type #3497

Merged
merged 6 commits into from
Mar 2, 2021

Conversation

t-kameyama
Copy link
Contributor

Fixes #3479

@codecov
Copy link

codecov bot commented Feb 24, 2021

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

Copy link
Member

@cortinico cortinico left a comment

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>
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