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

Rename RootLicenseMatcher to PathLicenseMatcher #9302

Merged
merged 2 commits into from
Oct 23, 2024
Merged

Rename RootLicenseMatcher to PathLicenseMatcher #9302

merged 2 commits into from
Oct 23, 2024

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 October 18, 2024 07:53
@sschuberth sschuberth enabled auto-merge (rebase) October 18, 2024 07:53
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.49%. Comparing base (6bb98df) to head (2e98fa5).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
.../main/kotlin/commands/GetPackageLicensesCommand.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9302   +/-   ##
=========================================
  Coverage     67.49%   67.49%           
  Complexity     1198     1198           
=========================================
  Files           241      241           
  Lines          8495     8495           
  Branches        900      900           
=========================================
  Hits           5734     5734           
  Misses         2399     2399           
  Partials        362      362           
Flag Coverage Δ
funTest-docker 60.59% <ø> (ø)
funTest-non-docker 33.63% <0.00%> (ø)
test 37.49% <88.88%> (ø)

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
Copy link
Member Author

@fviernau mind having a look as I have some follow-up changes?

@@ -94,7 +94,7 @@ internal class GetPackageLicensesCommand : OrtHelperCommand(

val detectedLicense = curatedFindings.toSpdxExpression()

val rootLicense = RootLicenseMatcher().getApplicableRootLicenseFindingsForDirectories(
val rootLicense = ParentLicenseMatcher().getApplicableLicenseFindingsForDirectories(
Copy link
Member

Choose a reason for hiding this comment

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

Hm, parent only refers to the direct ancestor.
Just throwing in the idea to use MainLicenseMatcher.
But not sure if this is good, what do you think?

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 "Main" has the same notion as "Root" in that it can be interpreted to only mean the license in the top-level directory. More ideas:

  • AncestorLicenseMatcher
  • InheritedLicenseMatcher
  • ApplicableLicenseMatcher
  • PathLicenseMatcher

Out of these, probably PathLicenseMatcher is the simplest and least repetitive WRT the class method names.

Any preferences from our side, @fviernau?

Copy link
Member

Choose a reason for hiding this comment

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

Puh, I'm having a hard time deciding this (except that I would not use Applicable because also licenses in other files can be applicable). Let's maybe do a quick poll on the preferred terminology. @mnonnenmacher @tsteenbe any preferences / ideas?

Copy link
Member Author

Choose a reason for hiding this comment

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

At least @mnonnenmacher is on vacation, and I'd like to proceed with this before he's back in two weeks.

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 PathLicenseMatcher now.

Copy link
Member Author

Choose a reason for hiding this comment

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

to capture that the license is somewhat originating from special files

I believe that "License" in "PathLicenseMatcher" already makes clear enough that only special files, namely license files (which are located along the path to the root), are taken into account.

The term "main license" to me is more something that makes sense in the scope of a whole package, where you want to emphasize that some licenses are more important than others in that they refer to the whole package vs. only a few files in the package.

Copy link
Member

Choose a reason for hiding this comment

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

The term "main license" to me is more something that makes sense in the scope of a whole package, where you want to emphasize that some licenses are more important than others in that they refer to the whole package vs. only a few files in the package.

"The whole package", isn't that the only use case this matcher is about?

Copy link
Member Author

@sschuberth sschuberth Oct 24, 2024

Choose a reason for hiding this comment

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

From reading the test cases I thought that the use-case would be a more generic one: To check the licenses for any path, and the root directory (which implies the package license) only being a special case. That's also why I proposed the renaming in the first place.

So for example, if you have no licenses files in the root, but a dirA/LICENSE file, and you ask for the license of dirA/dirB, then it would be the one of dirA/LICENSE. Or am I misunderstanding something?

Copy link
Member

@fviernau fviernau Oct 24, 2024

Choose a reason for hiding this comment

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

The algorithm normally starts at the VCS path (node) of the package. Looks inside that node for license files.
If found returns, if not, go up. Repeat until the root.

The idea is: Normally the special files from the repository root apply. But in some cases, additionally such special files are placed in subdirs. And we treat this as override. Note the best, but a rather common example is a docs dir containing some Creative commons license file.

Copy link
Member

Choose a reason for hiding this comment

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

And the use case we have implemented: Detected copyright findings which do not have a nearby detected license they can be associated with, get associated with the "main" licenses of the package. And this PathLicenseMatcher is determining these main licenses, starting at the VCS path of the package.

@fviernau

This comment was marked as outdated.

The name `RootLicenseMatcher` was confusing as not necessarily license
files from the root are matched: If no license files are in the root,
but a license file is in a parent directory on the path to the root
directory, that license would be applicable. Reflect that in several
renamings that avoid the "root" term if not appropriate.

Signed-off-by: Sebastian Schuberth <[email protected]>
@sschuberth sschuberth changed the title Rename RootLicenseMatcher to ParentLicenseMatcher Rename RootLicenseMatcher to PathLicenseMatcher Oct 22, 2024
@sschuberth sschuberth merged commit 131c130 into main Oct 23, 2024
23 checks passed
@sschuberth sschuberth deleted the rlm-imps branch October 23, 2024 17:15
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