Repository navigation
Fix parsing and category gaps against licensedb - #41
Merged
Merged
Conversation
The SPDX idstring grammar permits them, and ScanCode emits keys such as LicenseRef-scancode-gradle-enterprise-sla-2022-11-. Closes #38
There was a problem hiding this comment.
🟡 Changes recommended
Missing license information can be misclassified as permissive, while rewriting can produce invalid expressions and repeated WITH clauses can silently overwrite exceptions.
3 open issues
What changed in this PR
This PR addresses SPDX parsing and ScanCode category gaps from #38–#40, expanding reference support while keeping strict exception validation.
Changes:
- Accepts edge punctuation in identifiers and supports exceptions on license references.
- Uses the local parser for sorted license extraction and excludes exceptions from category lookups.
- Removes category filtering from data updates, prioritizes SPDX keys, and adds regression coverage.
| File | Description |
|---|---|
spdx.go |
Adds local extraction and category-specific identifier traversal. |
rewrite.go |
Rewrites license references and their exceptions separately. |
rewrite_stream_test.go |
Updates the rewrite oracle for reference exceptions. |
README.md |
Documents the non-commercial category. |
parse.go |
Adds parsing modes, reference exceptions, and edge-punctuation support. |
parse_syntax_test.go |
Tests expanded identifier syntax and strict validation. |
parse_lax.go |
Accepts reference exceptions during normalization. |
licensedb_test.go |
Adds database-wide parsing and extraction compatibility tests. |
category.go |
Adds prioritized license indexing and exception-free category lookups. |
category_test.go |
Covers category gaps, key precedence, and WITH expressions. |
.github/workflows/update-licenses.yml |
Retains all categories in future database updates. |
Review effort: Balanced
andrew
force-pushed
the
allow-edge-hyphen-identifiers
branch
from
November 2, 2026 17:05
217e8f3 to
fce3198
Compare
ExtractLicenses now uses this package's parser instead of go-spdx, and HasCopyleft, IsFullyPermissive and ExpressionCategories ignore exceptions, so GPL-2.0-only WITH Classpath-exception-2.0 counts as copyleft. Closes #39
The SPDX grammar allows an exception after any simple expression, including license references. LicenseRef gains an Exception field.
The update workflow kept only OSS categories, so IsCommercial never matched and GetLicenseInfo returned nil for 967 licenses. SPDX keys now take precedence over ScanCode keys, which fixes BSL-1.0 resolving to the Business Source License. Closes #40
SPDX treats them as standalone values. Returning ErrInvalidSpecialValue also stops IsFullyPermissive("MIT AND NOASSERTION") from reporting true.
andrew
force-pushed
the
allow-edge-hyphen-identifiers
branch
from
November 2, 2026 17:20
fce3198 to
ae372bc
Compare
This was referenced Nov 2, 2026
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.


Running every ScanCode licensedb key through the package turned up several places where it disagreed with the SPDX grammar or with the license data.
-or., which the SPDXidstringgrammar allows, for exampleLicenseRef-scancode-gradle-enterprise-sla-2022-11-.Parse,NormalizeExpressionand the Lax variants acceptLicenseRef-*exceptions afterWITH, asParseSyntaxalready does.ParseStrictandValidstill reject them, since SPDX 2.3 requires exceptions from the exception list.ExtractLicensesuses this package's parser instead of go-spdx, so it accepts ScanCode exceptions. Results match go-spdx for every input inreal_licenses.jsonthat go-spdx accepts, and are now sorted as the doc comment describes.HasCopyleft,IsFullyPermissiveandExpressionCategoriescheck licenses and ignore exceptions. Before, anyWITHmade them return false, soHasCopyleft("GPL-2.0-only WITH Classpath-exception-2.0")was false.WITHis allowed afterLicenseRef-*andDocumentRef-*:LicenseRef-*, andLicenseRefgains anExceptionfield.IsCommercialandGetLicenseInfowork for commercial, proprietary and non-commercial licenses. This addsCategoryNonCommercial, mapsLicenseRef-alternate keys, and gives SPDX keys precedence soBSL-1.0resolves to Boost instead of ScanCode's Business Source License.Closes #38
Closes #39
Closes #40