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

Simplify redundant SPDX choices #9641

Merged
merged 6 commits into from
Dec 18, 2024
Merged

Conversation

sschuberth
Copy link
Member

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

@sschuberth sschuberth requested a review from a team as a code owner December 18, 2024 15:28
@sschuberth sschuberth enabled auto-merge (rebase) December 18, 2024 15:28
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.05%. Comparing base (83a9a58) to head (e33e141).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9641   +/-   ##
=========================================
  Coverage     68.05%   68.05%           
  Complexity     1285     1285           
=========================================
  Files           249      249           
  Lines          8835     8835           
  Branches        921      921           
=========================================
  Hits           6013     6013           
  Misses         2433     2433           
  Partials        389      389           
Flag Coverage Δ
funTest-docker 65.14% <ø> (ø)
funTest-non-docker 33.31% <ø> (ø)
test-ubuntu-24.04 35.84% <ø> (ø)
test-windows-2022 35.82% <ø> (ø)

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 disabled auto-merge December 18, 2024 15:49
utils/spdx/src/main/kotlin/SpdxExpression.kt Outdated Show resolved Hide resolved
utils/spdx/src/main/kotlin/SpdxExpression.kt Outdated Show resolved Hide resolved
"remove redundant choices" {
val expression = "Apache-2.0 AND (Apache-2.0 OR MIT) AND MIT".toSpdx()

// Compare string representations to not rely on semantic equality.
Copy link
Member

Choose a reason for hiding this comment

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

Should this say "structural equality" instead? I'm actually not sure if I understand the comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

As this is about simplifying expressions, I want to be sure that e.g. MIT AND MIT is simplified to exactly MIT although it is "MIT AND MIT".toSpdx() == "MIT".toSpdx().

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but isn't "MIT AND MIT" semantically equal with "MIT", but not syntactically?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, exactly. The comment is meaning to say: "If we would not use string-comparison here, expressions would be compared for being semantically equal, which is not what we want."

utils/spdx/src/main/kotlin/SpdxExpression.kt Outdated Show resolved Hide resolved
With sorting applied, the string representation can be hard-coded.

Signed-off-by: Sebastian Schuberth <[email protected]>
Be extra sure that the actual string representation becomes simpler.

Signed-off-by: Sebastian Schuberth <[email protected]>
@sschuberth sschuberth force-pushed the spdx-simplify-redundant-choices branch from 551e4df to 23eba66 Compare December 18, 2024 16:23
Disambiguate the AND-operator's test name accordingly.

Signed-off-by: Sebastian Schuberth <[email protected]>
While this was partly explained in the commit message that introduced the
code, make this more visible.

Signed-off-by: Sebastian Schuberth <[email protected]>
Extract flattening to a function and reuse it to either flatten an only
choice, or the original expression.

Signed-off-by: Sebastian Schuberth <[email protected]>
If there is a "choice" between "a" or "a", that is not really a choice.

Signed-off-by: Sebastian Schuberth <[email protected]>
@sschuberth sschuberth force-pushed the spdx-simplify-redundant-choices branch from 23eba66 to e33e141 Compare December 18, 2024 16:46
@sschuberth
Copy link
Member Author

PS: It occurred to me that we probably could convert several functions, like decompose(), to lazy properties to avoid recomputation.

@sschuberth sschuberth enabled auto-merge (rebase) December 18, 2024 17:13
@sschuberth sschuberth merged commit a72d6b3 into main Dec 18, 2024
26 checks passed
@sschuberth sschuberth deleted the spdx-simplify-redundant-choices branch December 18, 2024 19:28
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