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

fix(reporter): Only write major / minor SPDX license list version info #9607

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

sschuberth
Copy link
Member

Fixes #9606.

@sschuberth sschuberth requested a review from a team as a code owner December 13, 2024 14:22
@sschuberth sschuberth enabled auto-merge (rebase) December 13, 2024 14:22
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 68.02%. Comparing base (8bc47a4) to head (f3c6855).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...ils/spdx/src/main/kotlin/model/SpdxCreationInfo.kt 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9607      +/-   ##
============================================
- Coverage     68.03%   68.02%   -0.02%     
  Complexity     1287     1287              
============================================
  Files           249      249              
  Lines          8826     8828       +2     
  Branches        920      921       +1     
============================================
  Hits           6005     6005              
- Misses         2432     2433       +1     
- Partials        389      390       +1     
Flag Coverage Δ
funTest-docker 64.96% <ø> (ø)
funTest-non-docker 33.48% <ø> (+0.03%) ⬆️
test-ubuntu-24.04 35.80% <0.00%> (-0.01%) ⬇️
test-windows-2022 35.78% <0.00%> (-0.01%) ⬇️

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 spdx-licenseListVersion-digits branch from c360479 to f3c6855 Compare December 13, 2024 14:57
@@ -172,7 +172,7 @@ internal object SpdxDocumentModelMapper {
comment = params.creationInfoComment,
created = Instant.now().truncatedTo(ChronoUnit.SECONDS),
creators = creators,
licenseListVersion = SpdxLicense.LICENSE_LIST_VERSION.substringBefore("-")
licenseListVersion = SpdxLicense.LICENSE_LIST_VERSION.split('.').take(2).joinToString(".")

Choose a reason for hiding this comment

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

This solution works, but it may be more efficient this other implementation, saving the splitting and joining back

Suggested change
licenseListVersion = SpdxLicense.LICENSE_LIST_VERSION.split('.').take(2).joinToString(".")
val licenseList = SpdxLicense.LICENSE_LIST_VERSION
licenseListVersion = licenseList.substring(0, licenseList.lastIndexOf("_"))

I do not really know much Kotlin, so take this with a pinch of salt.

Copy link
Member Author

Choose a reason for hiding this comment

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

While lastIndexOf("_") would need to use "." instead, it would also not work for something like "1.2.3.4" as the input. Not that I'm expecting that to happen, but you never know 😉

Choose a reason for hiding this comment

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

true!

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW, otherwise I would have simply used substringBeforeLast('.').

@sschuberth sschuberth merged commit 3c62407 into main Dec 13, 2024
25 of 26 checks passed
@sschuberth sschuberth deleted the spdx-licenseListVersion-digits branch December 13, 2024 15:25
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.

SPDX 2.2 conformance (invalid licenseListVersion produced)
3 participants