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

Bower follow-ups #8908

Merged
merged 3 commits into from
Jul 18, 2024
Merged

Bower follow-ups #8908

merged 3 commits into from
Jul 18, 2024

Conversation

fviernau
Copy link
Member

See individual commits.

@fviernau fviernau requested a review from a team as a code owner July 18, 2024 13:28

private fun getPackageInfosWithCompleteDependencies(info: PackageInfo): Map<String, PackageInfo> {

Check warning

Code scanning / detekt

Reports consecutive blank lines Warning

Needless blank line(s)
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.63%. Comparing base (e013788) to head (fd05e38).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8908   +/-   ##
=========================================
  Coverage     67.63%   67.63%           
  Complexity     1168     1168           
=========================================
  Files           244      244           
  Lines          7781     7781           
  Branches        867      867           
=========================================
  Hits           5263     5263           
  Misses         2161     2161           
  Partials        357      357           
Flag Coverage Δ
funTest-non-docker 33.90% <ø> (ø)
test 37.91% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fviernau fviernau requested a review from sschuberth July 18, 2024 15:04
@fviernau fviernau enabled auto-merge (rebase) July 18, 2024 15:04
val alternativeNode = checkNotNull(alternativeNodes[dependencyKeyOf(info)])
return parseDependencyTree(alternativeNode, scopeName, alternativeNodes)

val alternativeInfo = alternativeInfos.getValue(info.key!!)

Check warning

Code scanning / detekt

Unsafe calls on nullable types detected. These calls will throw a NullPointerException in case the nullable value is null. Warning

Calling !! on a nullable type will throw a NullPointerException at runtime in case the value is null. It should be avoided.
Comment on lines 191 to 193
val name = pkgMeta.name.orEmpty()
val version = pkgMeta.version.orEmpty()
"$name:$version".takeUnless { name.isEmpty() || version.isEmpty() }
Copy link
Member

Choose a reason for hiding this comment

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

As you have with(pkgMeta) above, I believe this could be simplified to just

"$name:$version".takeUnless { name == null || version == null }

Copy link
Member Author

Choose a reason for hiding this comment

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

Would this be a change in behavior in case of of them is "" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Anyhow, good catch with the with(pkgMeta). This was a left over which I dropped now.

Copy link
Member

Choose a reason for hiding this comment

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

Would this be a change in behavior in case of of them is "" ?

Yes, empty names / versions would not be discarded anymore. Not sure if this would actually be any issue though.

@@ -227,7 +227,7 @@ private fun parseDependencyTree(
// about the subtree rooted at the parent from that other node containing the full dependency
// information.
// See https://github.com/bower/bower/blob/6bc778d/lib/core/Manager.js#L557 and below.
val alternativeNode = checkNotNull(alternativeNodes[info.key])
val alternativeNode = alternativeNodes.getValue(info.key!!)
Copy link
Member

@sschuberth sschuberth Jul 18, 2024

Choose a reason for hiding this comment

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

This triggers a Detekt issue about the use of !!. I wonder whether we can work around that by making key non-nullable, e.g. by ensuring to not call it on root projects?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it just me or have the warnings about !! become a bit too much.

I just wanted to make obvious what previously was a bit hidden, but this warning blocks the change right?
(If so, is it possible to go back to the previous way of flagging !! ?)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this blocks the merge. But previously !! was not flagged at all, I believe. I prefer the current way of flagging it, and if you're really sure !! is the right thing to do in a specific case, it should be whitelisted via @Suppress("UnsafeCallOnNullableType").

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we revisit the decision whether we want to flag all uses of !! really?
I've spent quite some time working around cases, where !! was perfectly fine. Huge waste of time imo.
If there is a convincing rationale why !! should be forbidden, I may change my mind. But I'm not aware of any, in particular

  1. !! seems forbidden while checkNotNull() seems fine
  2. Whether !! is ok is a case by case decision, and I'm pretty sure all approvers in our community already
    pay good attention to any ocurence of !!, so flagging is not needed as we handle it already.

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 went for the supress, because the observation that the previous checkNotNull never failed implies that no lockup with a null key has been done.

Copy link
Member

Choose a reason for hiding this comment

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

Can we revisit the decision whether we want to flag all uses of !! really?

Sure, feel free to bring it up in a Kotlin dev meeting (not in the next three weeks, though, as both @mnonnenmacher and I will be on vacation).

fviernau added 3 commits July 18, 2024 21:52
A preceding commit refactored Bower to use data classes and a model
mapper for the deserilation. So, it now operates on `PackageInfo`
instances instead of on `JsonNode`s.

Align variable names, function names and comments with that change,
to make things consistent again.

Signed-off-by: Frank Viernau <[email protected]>
@fviernau fviernau requested a review from sschuberth July 18, 2024 19:53
@fviernau fviernau merged commit e288ded into main Jul 18, 2024
22 checks passed
@fviernau fviernau deleted the bower-follow-ups branch July 18, 2024 21:08
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.

2 participants