Remove unreachable duplicate LGPL key in rubygems licenses mapping - #5326
Open
aishwary-dongre wants to merge 1 commit into
Open
aishwary-dongre wants to merge 1 commit into
aishwary-dongre wants to merge 1 commit into
Conversation
LICENSES_MAPPING in src/packagedcode/rubygems.py declared 'LGPL' twice on consecutive lines. A dict literal keeps only the last value for a repeated key, so 'LGPL': 'lgpl' was dead at import time and every gem declaring a bare LGPL already resolved to lgpl-2.0-plus. Remove the unreachable line rather than the effective one. 'lgpl' is not a ScanCode license key: there is no lgpl.LICENSE in the license data, active or inactive, and it is the only target in this mapping that does not resolve to a real key. Keeping lgpl-2.0-plus also matches how the mapping handles other bare family names, for example 'GPL': 'gpl-2.0'. Detection behaviour is therefore unchanged. Whether a bare LGPL declaration should imply lgpl-2.0-plus at all is a separate question about license semantics and is left out of scope here. Add a test that parses the module source with ast, since a duplicated key cannot be observed on the loaded dict. Reference: aboutcode-org#5314 Signed-off-by: Aishwary Dongre <87765118+aishwary-dongre@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5314
Brief description
LICENSES_MAPPINGinsrc/packagedcode/rubygems.pydeclared'LGPL'twice on consecutive lines:A dict literal keeps only the last value for a repeated key, so
'LGPL': 'lgpl'was dead at import time and a bareLGPLgem declaration already resolved tolgpl-2.0-plus.Why the unreachable line is the one removed
The issue notes that which of the two applies is currently decided by line order rather than intent, so I looked for evidence of which is correct rather than picking one:
lgplis not a ScanCode license key. There is nolgpl.LICENSEundersrc/licensedcode/data/licenses/orsrc/licensedcode/data/inactive/. Checking every target in this mapping against the license data,'LGPL': 'lgpl'is the only entry of the 32 that does not resolve to a real key.'GPL': 'gpl-2.0','BSD': 'bsd-new'and'Apache': 'apache-2.0'all map bare family names to a concrete license. (gplis likewise not a key.)git log -L 676,681:src/packagedcode/rubygems.pyshows both were added in b2a5a5a ("Recognize .gem archives as packages", 2019), which reads as an accidental duplicate rather than a deliberate override.So removing
'LGPL': 'lgpl'deletes a line that could never have worked, and license detection behaviour is unchanged.Whether a bare
LGPLdeclaration should implylgpl-2.0-plusat all is a separate question about license semantics, and I have deliberately left it out of scope. Happy to open a follow-up issue if you think the unversioned case warrants a different target.Test
Added
TestRubygemsLicensesMappingintests/packagedcode/test_rubygems.py. The duplicate-key check has to parse the module source withast, because a duplicated key is silently collapsed and cannot be observed on the loaded dict. I confirmed it fails before the fix (duplicated keys still present: ['LGPL']) and passes after.On local test runs
I could not run the suite locally.
requirements.txtpinsextractcode-7z==16.5.210531, but only16.5.210525is on PyPI, so./configure --devfails to resolve:That looks like a pre-existing packaging problem independent of this change; let me know if it is already tracked or if you would like a separate issue. I verified the new tests' assertions standalone against the module source instead, so I am relying on CI for the real run. Please do flag anything that comes back red.
I also left the existing
ruffandisortfindings in these two files alone, to keep a one-line fix from turning into unrelated import churn. NoCHANGELOG.rstentry since there is no user-visible change, but glad to add one if you prefer.AI generation disclosure
I used an AI assistant while investigating this. The duplicate-key detection, the license-key cross-check, and the
git log -Larchaeology were done with its help, and it drafted the test and this description. I have reviewed and verified every claim above against the repository myself and can explain and defend the change. Flagging it since ScanCode has no stated policy either way and I would rather be upfront.Tasks
extractcode-7zpin, relying on CI