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

Misc. SPDX / license mapping related improvements #8730

Merged
merged 7 commits into from
Jun 18, 2024

Conversation

sschuberth
Copy link
Member

No description provided.

Copy link

codecov bot commented Jun 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.79%. Comparing base (631db0f) to head (7cdf3ef).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8730   +/-   ##
=========================================
  Coverage     67.79%   67.79%           
  Complexity     1164     1164           
=========================================
  Files           243      243           
  Lines          7711     7711           
  Branches        861      861           
=========================================
  Hits           5228     5228           
  Misses         2127     2127           
  Partials        356      356           
Flag Coverage Δ
funTest-docker 66.84% <ø> (ø)
funTest-non-docker 33.96% <ø> (ø)
test 38.12% <ø> (ø)

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.

@sschuberth sschuberth force-pushed the warn-invalid-license-mapping branch from 19cfe2a to 4bcff23 Compare June 6, 2024 16:48
@sschuberth
Copy link
Member Author

@oss-review-toolkit/kotlin-devs can we agree that it makes sense to merge this now independently of the outcome of the discussion in #8691?

@sschuberth sschuberth force-pushed the warn-invalid-license-mapping branch from 4bcff23 to 054d4c3 Compare June 17, 2024 10:01
@sschuberth
Copy link
Member Author

@oss-review-toolkit/kotlin-devs can we agree that it makes sense to merge this now independently of the outcome of the discussion in #8691?

I've dropped the actual warning log from the PR, but the other small refactoring commits can still be merged IMO. Please have a look @mnonnenmacher and / or @fviernau.

@sschuberth sschuberth enabled auto-merge (rebase) June 17, 2024 10:02
@sschuberth sschuberth changed the title chore(ort-utils): Warn if a mapping to an invalid license is configured Misc. SPDX / license mapping related improvements Jun 17, 2024
@sschuberth sschuberth disabled auto-merge June 17, 2024 16:52
@sschuberth sschuberth force-pushed the warn-invalid-license-mapping branch 2 times, most recently from 3498e91 to cf666d9 Compare June 17, 2024 17:06
@sschuberth sschuberth enabled auto-merge (rebase) June 17, 2024 17:07
* Parses the string as an [SpdxExpression] of the given [strictness] and returns the result on success, or null if the
* string cannot be parsed.
*/
fun String.toSpdxOrNull(strictness: Strictness = Strictness.ALLOW_ANY): SpdxExpression? =
Copy link
Member

Choose a reason for hiding this comment

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

Parses -> Parse
returns -> return
maybe: the string -> this string

runCatching {
toSpdx(strictness)
}.onFailure {
logger.debug { "Could not parse license '$this' to SPDX: ${it.collectMessages()}" }
Copy link
Member

Choose a reason for hiding this comment

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

As $this is not necessary a license, if it could not be parse, should we just drop the mention of "license" from the log message?

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've reworded the message.

* afterwards.
* Normalize all license IDs using [SpdxSimpleLicenseMapping]. If [mapDeprecated] is `true`, also deprecated IDs are
* mapped to their current counterparts. The result of this function is not guaranteed to contain only valid IDs.
* Use [validate] to check the returned [SpdxExpression] for validity afterwards.
Copy link
Member

Choose a reason for hiding this comment

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

out of scope: Should this be isValid() instead of validate(), because the latter does not return any value?

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 believe the mention of validate() better matches the normalize() context, but I've now simply mentioned isValid() as well.

@@ -15,6 +15,10 @@
# SPDX-License-Identifier: Apache-2.0
# License-Filename: LICENSE

# A mapping from license strings collected from the declared licenses of Open Source packages to SPDX expressions. This
# mapping only contains license strings which can *not* be parsed by [SpdxExpression.parse], for example because the
# license names contain white spaces. See [SpdxSimpleLicenseMapping] for a mapping of varied license names.
Copy link
Member

Choose a reason for hiding this comment

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

Should it be various instead of varied?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, "varied" is correct (and also used in the original text that I copied this from) as it's supposed to mean "variants of license names" and not "several license names".

@sschuberth sschuberth force-pushed the warn-invalid-license-mapping branch from cf666d9 to 4ee94f4 Compare June 18, 2024 09:30
…censes

Introduce an intermediate variable to separate these two steps for
clarity and to ease debugging.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
…tion

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
While at it, also mention `isValid` in addition to `validate`.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
The remark about ambiguity due to a missing version became somewhat
obsolete with e7247e0.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
…ility

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
@sschuberth sschuberth force-pushed the warn-invalid-license-mapping branch from 4ee94f4 to 7cdf3ef Compare June 18, 2024 09:30
@sschuberth sschuberth requested review from fviernau and a team June 18, 2024 09:30
@sschuberth sschuberth merged commit fc5389c into main Jun 18, 2024
20 checks passed
@sschuberth sschuberth deleted the warn-invalid-license-mapping branch June 18, 2024 10:06
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