Skip to content

Commit

Permalink
Rename dependency attribute is_resolved
Browse files Browse the repository at this point in the history
Renaming the dependency attribute is_resolved to is_pinned to
more accurately represent this attribute accurately.
This is more relevant after the changes in aboutcode-org/scancode.io#1066

Reference: aboutcode-org/scancode.io#1066
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
  • Loading branch information
AyanSinhaMahapatra committed Aug 7, 2024
1 parent 2b09be1 commit 7c104db
Show file tree
Hide file tree
Showing 741 changed files with 13,296 additions and 13,294 deletions.
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": {
"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
6 changes: 3 additions & 3 deletions src/packagedcode/nuget.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _get_dep_packs(deps, extra_data):
scope='dependency',
is_runtime=True,
is_optional=False,
is_resolved=False,
is_pinned=False,
extra_data=extra,
)

Expand Down Expand Up @@ -196,7 +196,7 @@ def get_dependencies(cls, package_info, scope):
dependency = models.DependentPackage(
purl=str(PackageURL(type='nuget', name=name, version=version)),
extracted_requirement=version,
is_resolved=True,
is_pinned=True,
scope=scope,
is_optional=False,
is_runtime=True,
Expand Down Expand Up @@ -246,7 +246,7 @@ def parse(cls, location, package_only=False):
dependency = models.DependentPackage(
purl=str(PackageURL(type='nuget', name=package_name, version=version)),
extracted_requirement=requested or version,
is_resolved=True,
is_pinned=True,
resolved_package=resolved_package.to_dict(),
# We use the target framework as scope since there is no concept of scope in .NET
# and we may have different resolutions for different target frameworks
Expand Down
2 changes: 1 addition & 1 deletion src/packagedcode/opam.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def parse(cls, location, package_only=False):
scope='dependency',
is_runtime=True,
is_optional=False,
is_resolved=False,
is_pinned=False,
)
)

Expand Down
Loading

0 comments on commit 7c104db

Please sign in to comment.