Skip to content

Update following referenced licenses and rules#5233

Open
AyanSinhaMahapatra wants to merge 2 commits into
developfrom
add-license-detection
Open

Update following referenced licenses and rules#5233
AyanSinhaMahapatra wants to merge 2 commits into
developfrom
add-license-detection

Conversation

@AyanSinhaMahapatra

Copy link
Copy Markdown
Member

In case of referenced license files, update the logic to not follow and de-reference licenses when all the license leys in the referenced files are already present in the main license detection. This preserves the license conditions in case there are extra license keys in an expression.

References:

Fixes #3523

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

AyanSinhaMahapatra and others added 2 commits July 9, 2026 20:54
In case of referenced license files, update the logic to not follow
and de-reference licenses when all the license leys in the referenced
files are already present in the main license detection. This preserves
the license conditions in case there are extra license keys in an
expression.

Reference: #3523
Signed-off-by: Ayan Sinha Mahapatra <asmahapatra@aboutcode.org>
Signed-off-by: Vincent Gao <gaobing1230@gmail.com>
# If all the license keys of the referenced license expression already
# present in the actual license expression
# note that this preserves AND/OR expressions in the original license
if referenced_license_keys.issubset(license_keys):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was the main fix btw, this adds another condition when we don't want to follow and replace by referenced license detections. In the case where the referenced license keys is a subset of the original license keys.

For example:

license_expression: (lgpl-2.1 OR mpl-1.1) AND other-permissive
referenced_license_expression: lgpl-2.1 AND mpl-1.1 (from two different files, joined)

@JonoYang JonoYang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@JonoYang

JonoYang commented Jul 9, 2026

Copy link
Copy Markdown
Member

some tests are failing, i will run them locally and see if its a ci issue or not

@JonoYang

JonoYang commented Jul 9, 2026

Copy link
Copy Markdown
Member

I run pytest -vvs --test-suite all . and I fail 3 tests. Two of them are cli tests that pass when I just run pytest -vvs --test-suite all test/scancode/test_cli.py. The other test failure is tests/licensedcode/test_detect.py::TestMatchAccuracyWithFullIndex::test_match_has_correct_line_positions_in_automake_perl_file, where some spans are different than expected. I'm not sure if this is an issue or if the expected test results need to be updated. We also fail that test on the ci here: https://dev.azure.com/nexB/scancode-toolkit/_build/results?buildId=19044&view=logs&j=e968ac97-6fe5-5e03-7848-d38fdbd63e89&t=68b960ee-accc-5f66-8291-47be569f7afb&l=11813

@AyanSinhaMahapatra

Copy link
Copy Markdown
Member Author

Thanks for the review @JonoYang Let me fix the tests, which were failing already before this

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.

OR identified as AND

3 participants