Return declared licenses from ParseResult - #50
Conversation
andrew
left a comment
There was a problem hiding this comment.
-
internal/opam/opam.go:21discards dependency constraints and hard-codes every scope toruntime. For example,ocaml {>= "5.0"}gets an empty version anddune {build}becomes runtime. Parse the formula alongside each name and add constraint and scope tests. -
internal/pypi/pypi.go:374usesProject.Nameto decide whether to readtool.poetry.license. A valid hybrid file with[project] nameand[tool.poetry] license = "MIT"returns no license. Base the fallback on whether[project]declares license metadata. -
internal/maven/maven.go:92treats unresolved URLs such as${project.url}/LICENSEas manifest-relative files. This returns a path that cannot be read from the checkout. Reject unresolved properties or interpolate the URL before classifying it. -
internal/opam/opam.go:102fails the required lint command.opamTopLevelStringshas cognitive complexity 35, andgocriticreports twoifElseChainfindings at lines 68 and 134. Refactor the parser until the configured checks succeed.
|
Thanks for the review I’ve addressed all four points:
|
Closes #49
Summary
Add declared license metadata to
ParseResult, allowing consumers to access license information directly from supported package manifests.This introduces:
Licenses []stringfor raw declared license valuesLicenseFile stringfor a manifest-relative license filesetup.cfgand OPAM manifest supportLicense values are returned without SPDX normalization, keeping this package independent of
github.com/git-pkgs/spdx.Supported formats
License metadata is extracted from:
package.jsonandbower.jsonCargo.tomlpyproject.toml,setup.py, andsetup.cfg*.gemspec*.podspeccomposer.jsonpom.xml*.nuspec*.cabalDESCRIPTIONmix.exsopamand*.opamelm.jsonandelm-package.jsonFormats without declared license fields, such as
go.modandpubspec.yaml, continue to return empty values.For formats that allow multiple license files,
LicenseFilecontains the first declared path, matching the singular public API proposed in the issue.Validation
gofmtgit diff --checkgo build ./...go vet ./...go test ./...go test -race ./...golangci-lint— 0 issuesFollow-up hardening
A second review added coverage and fixes for:
elm.jsondependenciessetup.cfglicense values and version constraintspackage/0declarations