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 dependency is_resolved to is_pinned #3888

Merged
merged 5 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ v33.0.0 (next next, roadmap)
of these in other summary plugins.
See https://github.com/nexB/scancode-toolkit/issues/1745

Major API/other changes:

- Output Format Version updated to 4.2.0 (major version bump)
- Dependency attribute rename: ``is_resolved`` renamed to ``is_pinned``
See https://github.com/nexB/scancode-toolkit/pull/3888 for more details.

Changes in Output Data Structure:

- The data structure of the JSON output has changed for
dependencies at file level package_data, and at top-level.
Note that the change is a modification to the JSON output,
so we have a major version bump ``3.2.0`` to ``4.2.0``:
AyanSinhaMahapatra marked this conversation as resolved.
Show resolved Hide resolved

- Dependency attribute ``is_resolved`` renamed to ``is_pinned``

v32.2.1 - 2024-07-02
---------------------
Expand Down
6 changes: 4 additions & 2 deletions docs/source/cli-reference/basic-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@
"scope": "dependencies",
"is_runtime": true,
"is_optional": false,
"is_resolved": false,
"is_pinned": false,
"is_direct": true,
"resolved_package": {},
"extra_data": {},
"dependency_uid": "pkg:bower/get-size?uuid=fixed-uid-done-for-testing-5642512d1758",
Expand Down Expand Up @@ -341,7 +342,8 @@
"scope": "dependencies",
"is_runtime": true,
"is_optional": false,
"is_resolved": false,
"is_pinned": false,
"is_direct": true,
"resolved_package": {},
"extra_data": {}
}
Expand Down
6 changes: 3 additions & 3 deletions etc/scripts/sch2js/doc/DependentPackage-json-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
}
]
},
"is_resolved": {
"is_pinned": {
AyanSinhaMahapatra marked this conversation as resolved.
Show resolved Hide resolved
"oneOf": [
{
"type": "boolean",
"title": "is resolved flag",
"description": "True if this dependency version requirement has been resolved and this dependency url points to an exact version."
"title": "is pinned flag",
"description": "True if this dependency version requirement has been pinned and this dependency points to an exact version."
},
{
"type": "null"
Expand Down
2 changes: 1 addition & 1 deletion etc/scripts/sch2js/doc/Package-json-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
}
]
},
"is_resolved": {
"is_pinned": {
"oneOf": [
{
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion src/formattedcode/output_cyclonedx.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def from_package(cls, package, components_by_purl):
for dependency in package.get('dependencies', []):
dpurl = dependency['purl']

if dependency['is_resolved']:
if dependency['is_pinned']:
dependencies_by_dependent[purl].add(dpurl)
else:
existing = components_by_purl.get(dpurl)
Expand Down
6 changes: 3 additions & 3 deletions src/packagedcode/alpine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ def D_dependencies_handler(value, dependencies=None, **kwargs):

requirement = None
version = None
is_resolved = False
is_pinned = False
segments = split_name_and_requirement(dep)
if len(segments) == 1:
# we have no requirement...just a plain name
Expand All @@ -1027,7 +1027,7 @@ def D_dependencies_handler(value, dependencies=None, **kwargs):
operator = ''.join(sorted(operator))
if operator == '=':
version = ver
is_resolved = True
is_pinned = True

requirement = operator + ver

Expand All @@ -1042,7 +1042,7 @@ def D_dependencies_handler(value, dependencies=None, **kwargs):
purl=purl,
scope=scope,
extracted_requirement=requirement,
is_resolved=is_resolved,
is_pinned=is_pinned,
)
if dependency not in dependencies:
dependencies.append(dependency.to_dict())
Expand Down
2 changes: 1 addition & 1 deletion src/packagedcode/build_gradle.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def build_package(cls, dependencies, package_only=False):
extracted_requirement=version,
is_runtime=is_runtime,
is_optional=is_optional,
is_resolved=bool(version),
is_pinned=bool(version),
)
)

Expand Down
4 changes: 2 additions & 2 deletions src/packagedcode/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def parse(cls, location, package_only=False):
scope='dependencies',
is_runtime=True,
is_optional=False,
is_resolved=True,
is_pinned=True,
)
)

Expand Down Expand Up @@ -346,7 +346,7 @@ def dependency_mapper(dependencies, scope='dependencies'):
scope=scope,
is_runtime=is_runtime,
is_optional=is_optional,
is_resolved=False,
is_pinned=False,
extra_data=extra_data,
)

Expand Down
4 changes: 2 additions & 2 deletions src/packagedcode/cocoapods.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def get_pods_dependency_with_resolved_package(
extracted_requirement=xreq,
is_runtime=False,
is_optional=True,
is_resolved=True,
is_pinned=True,
is_direct=is_direct,
resolved_package=resolved_package,
)
Expand Down Expand Up @@ -377,7 +377,7 @@ def get_dependencies_for_resolved_package(cls, dependency_data, dep_pods):
extracted_requirement=dep_xreq,
is_runtime=False,
is_optional=True,
is_resolved=True,
is_pinned=True,
is_direct=True,
).to_dict()
dependencies_for_resolved.append(dependency_for_resolved)
Expand Down
10 changes: 5 additions & 5 deletions src/packagedcode/conan.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ def assemble(
yield resource


def is_constraint_resolved(constraint):
def is_constraint_pinned(constraint):
"""
Checks if a constraint is resolved and it specifies an exact version.
Checks if a constraint is pinned and it specifies an exact version.
"""
range_characters = {">", "<", "[", "]", ">=", "<="}
return not any(char in range_characters for char in constraint)
Expand All @@ -282,9 +282,9 @@ def get_dependencies(requires):
dependent_packages = []
for req in requires:
name, constraint = req.split("/", 1)
is_resolved = is_constraint_resolved(constraint)
is_pinned = is_constraint_pinned(constraint)
version = None
if is_resolved:
if is_pinned:
version = constraint
purl = PackageURL(type="conan", name=name, version=version)
dependent_packages.append(
Expand All @@ -293,7 +293,7 @@ def get_dependencies(requires):
scope="install",
is_runtime=True,
is_optional=False,
is_resolved=is_resolved,
is_pinned=is_pinned,
extracted_requirement=constraint,
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/packagedcode/godeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def parse(cls, location, package_only=False):
scope='Deps',
is_runtime=True,
is_optional=False,
is_resolved=False,
is_pinned=False,
)
)

Expand Down
6 changes: 3 additions & 3 deletions src/packagedcode/golang.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def parse(cls, location, package_only=False):
scope='require',
is_runtime=True,
is_optional=False,
is_resolved=False,
is_pinned=False,
)
)

Expand All @@ -75,7 +75,7 @@ def parse(cls, location, package_only=False):
scope='exclude',
is_runtime=True,
is_optional=False,
is_resolved=False,
is_pinned=False,
)
)

Expand Down Expand Up @@ -123,7 +123,7 @@ def parse(cls, location, package_only=False):
scope='dependency',
is_runtime=True,
is_optional=False,
is_resolved=True,
is_pinned=True,
)
)

Expand Down
4 changes: 2 additions & 2 deletions src/packagedcode/haxe.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ def _parse(cls, json_data, package_only=False):

for dep_name, dep_version in json_data.get('dependencies', {}).items():
dep_version = dep_version and dep_version.strip()
is_resolved = bool(dep_version)
is_pinned = bool(dep_version)
dep_purl = PackageURL(
type=cls.default_package_type,
name=dep_name,
version=dep_version
).to_string()
dep = models.DependentPackage(purl=dep_purl, is_resolved=is_resolved,)
dep = models.DependentPackage(purl=dep_purl, is_pinned=is_pinned)
package_data.dependencies.append(dep)

return package_data
Expand Down
6 changes: 3 additions & 3 deletions src/packagedcode/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ def get_dependencies(pom):
if dversion == 'latest.release':
dversion = None

is_resolved = bool(dversion and not any(c in dversion for c in '$[,]'))
is_pinned = bool(dversion and not any(c in dversion for c in '$[,]'))

dqualifiers = {}
# FIXME: this is missing from the original Pom parser
Expand All @@ -1065,7 +1065,7 @@ def get_dependencies(pom):
# if packaging and packaging != 'jar':
# qualifiers['packaging'] = packaging

if is_resolved:
if is_pinned:
dpurl = models.PackageURL(
type='maven',
namespace=dgroup_id,
Expand All @@ -1091,7 +1091,7 @@ def get_dependencies(pom):
scope=scope,
is_runtime=is_runtime,
is_optional=is_optional,
is_resolved=is_resolved,
is_pinned=is_pinned,
)
dependencies.append(dep_pack)

Expand Down
6 changes: 3 additions & 3 deletions src/packagedcode/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ class DependentPackage(ModelMixin):
label='is optional flag',
help='True if this dependency is an optional dependency')

is_resolved = Boolean(
is_pinned = Boolean(
default=False,
label='is resolved flag',
label='is pinned flag',
help='True if this dependency version requirement has '
'been resolved and this dependency url points to an '
'been pinned and this dependency points to an '
'exact version.')

is_direct = Boolean(
Expand Down
24 changes: 12 additions & 12 deletions src/packagedcode/npm.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def update_dependencies_by_purl(
dependencies_by_purl,
is_runtime=False,
is_optional=False,
is_resolved=False,
is_pinned=False,
is_direct=True,
):
"""
Expand All @@ -335,7 +335,7 @@ def update_dependencies_by_purl(
scope=scope,
is_runtime=is_runtime,
is_optional=is_optional,
is_resolved=is_resolved,
is_pinned=is_pinned,
is_direct=is_direct,
)
dependencies_by_purl[dep_purl] = dep_package
Expand All @@ -359,7 +359,7 @@ def update_dependencies_by_purl(
scope=scope,
is_runtime=is_runtime,
is_optional=metadata.get("optional"),
is_resolved=is_resolved,
is_pinned=is_pinned,
is_direct=is_direct,
)
dependencies_by_purl[dep_purl] = dep_package
Expand All @@ -380,7 +380,7 @@ def update_dependencies_by_purl(
extracted_requirement=requirement,
is_runtime=is_runtime,
is_optional=is_optional,
is_resolved=is_resolved,
is_pinned=is_pinned,
is_direct=is_direct,
)
dependencies_by_purl[dep_purl] = dep_package
Expand Down Expand Up @@ -709,7 +709,7 @@ def parse(cls, location, package_only=False):
scope=scope,
is_runtime=is_runtime,
is_optional=is_optional,
is_resolved=True,
is_pinned=True,
is_direct=False,
)

Expand Down Expand Up @@ -759,7 +759,7 @@ def parse(cls, location, package_only=False):
dependencies_by_purl=sub_deps_by_purl,
is_runtime=is_runtime,
is_optional=is_optional,
is_resolved=False,
is_pinned=False,
is_direct=True,
)

Expand Down Expand Up @@ -935,7 +935,7 @@ def parse(cls, location, package_only=False):
dependency = models.DependentPackage(
purl=str(purl),
extracted_requirement=version,
is_resolved=True,
is_pinned=True,
resolved_package=resolved_package.to_dict(),
scope='dependencies',
is_optional=False,
Expand Down Expand Up @@ -1103,7 +1103,7 @@ def parse(cls, location, package_only=False):
dep = models.DependentPackage(
purl=dep_purl,
extracted_requirement=extracted_requirement,
is_resolved=True,
is_pinned=True,
# FIXME: these are NOT correct
scope='dependencies',
is_optional=False,
Expand Down Expand Up @@ -1207,7 +1207,7 @@ def parse(cls, location, package_only=False):
dependencies=dependencies,
scope='dependencies',
dependencies_by_purl=deps_for_resolved_by_purl,
is_resolved=True,
is_pinned=True,
is_direct=False,
)
cls.update_dependencies_by_purl(
Expand All @@ -1221,7 +1221,7 @@ def parse(cls, location, package_only=False):
dependencies=optional_dependencies,
scope='optionalDependencies',
dependencies_by_purl=deps_for_resolved_by_purl,
is_resolved=True,
is_pinned=True,
is_optional=True,
is_direct=False,
)
Expand Down Expand Up @@ -1270,7 +1270,7 @@ def parse(cls, location, package_only=False):
purl=purl,
is_optional=is_optional,
is_runtime=is_runtime,
is_resolved=True,
is_pinned=True,
is_direct=True,
resolved_package=resolved_package.to_dict(),
extra_data=extra_data_deps,
Expand Down Expand Up @@ -1744,7 +1744,7 @@ def deps_mapper(deps, package, field_name, is_direct=True):
'devDependencies': dict(is_runtime=False, is_optional=True),
'peerDependencies': dict(is_runtime=True, is_optional=False),
'optionalDependencies': dict(is_runtime=True, is_optional=True),
'resolutions': dict(is_runtime=True, is_optional=False, is_resolved=True),
'resolutions': dict(is_runtime=True, is_optional=False, is_pinned=True),
}
dependencies = package.dependencies

Expand Down
Loading
Loading