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

More preparations for running Detekt with type resolution #5905

Merged
merged 5 commits into from
Oct 5, 2022

Conversation

sschuberth
Copy link
Member

Please have a look at the individual commit messages for the details.

@codecov
Copy link

codecov bot commented Oct 4, 2022

Codecov Report

Base: 58.30% // Head: 58.32% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (bf0f647) compared to base (8038dee).
Patch coverage: 17.64% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5905      +/-   ##
============================================
+ Coverage     58.30%   58.32%   +0.01%     
+ Complexity     2154     2152       -2     
============================================
  Files           329      329              
  Lines         19157    19154       -3     
  Branches       3761     3764       +3     
============================================
+ Hits          11170    11171       +1     
+ Misses         6878     6875       -3     
+ Partials       1109     1108       -1     
Flag Coverage Δ
funTest-analyzer-docker 74.96% <ø> (ø)
funTest-non-analyzer 47.05% <21.42%> (+0.01%) ⬆️
test 27.99% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...l/identification/identifiedFiles/IdentifiedFile.kt 37.50% <0.00%> (ø)
...ation/markedAsIdentified/MarkedAsIdentifiedFile.kt 28.57% <0.00%> (ø)
...src/main/kotlin/config/FileStorageConfiguration.kt 30.76% <0.00%> (+5.76%) ⬆️
advisor/src/main/kotlin/advisors/Osv.kt 63.04% <50.00%> (+0.67%) ⬆️
...nts/fossid-webapp/src/main/kotlin/model/Project.kt 57.35% <0.00%> (+0.63%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

This silences Detekt violations when used with type resolution.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
`shouldBeTypeOf` applies a contract.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Avoiding sequences makes the issue disappear.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
@fviernau
Copy link
Member

fviernau commented Oct 5, 2022

Disabled auto-merge as I believe it'd be good to have another approval for the decision to ditch !!, e.g. @mnonnenmacher @MarcelBochtler .

@@ -277,7 +277,7 @@ fun <K, V : Collection<T>, T> Map<K, V>.zipWithCollections(other: Map<K, V>): Ma
zip(other) { a, b ->
when {
// When iterating over the combined key set, not both values can be null.
a == null -> b!!
a == null -> checkNotNull(b)
Copy link
Member

Choose a reason for hiding this comment

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

Java 14 improved the NullPointerExceptions to display the actual variable name which was null causing this exception.
checkNotNull() only shows Required value was null..

I'm not sure if this Java 14 feature would also work with NPEs from Kotlin, and if it would be more helpful. But it might be one thing to consider.

Copy link
Member

Choose a reason for hiding this comment

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

Aside from that, when looking at this commit, if these are the only places where it had to be changed, I would also vote for keeping this the rule to disallow !!.

Copy link
Member

@MarcelBochtler MarcelBochtler Oct 5, 2022

Choose a reason for hiding this comment

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

Additionally, this rule does not to disallow every usage of !!.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if this Java 14 feature would also work with NPEs from Kotlin, and if it would be more helpful.

That's a nice Java feature indeed, and I believe it would work with any JVM language; however, for the time being we're probably stuck with Java 11 anyway, also see #4948 😞

Aside from that, when looking at this commit, if these are the only places where it had to be changed

To be fair, there might be might more places (in non-main source sets) that would need to be changed when keeping this rule enabled and using Detekt with type resolution. I'm not yet done with looking at all the code, but I'll probably stop here for now with this preparation.

@sschuberth sschuberth merged commit 38d25fd into main Oct 5, 2022
@sschuberth sschuberth deleted the detekt-type-resolution-2 branch October 5, 2022 11:53
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.

3 participants