Skip to content

Commit

Permalink
Track package_uids in make_results_summary #435
Browse files Browse the repository at this point in the history
    * Avoid checking if package_data dictionary is already in the key_files_packages list
    * Keep track of package_uids instead

Signed-off-by: Jono Yang <jyang@nexb.com>
  • Loading branch information
JonoYang committed May 13, 2022
1 parent 695eef0 commit 6580c38
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scanpipe/pipes/scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def make_results_summary(project, scan_results_location):

key_files = []
key_files_packages = []
seen_package_uids = []

for resource in key_files_qs:
resource_data = CodebaseResourceSerializer(resource).data
Expand All @@ -483,7 +484,13 @@ def make_results_summary(project, scan_results_location):
packages = resource.discovered_packages.all()
for package in packages:
package_data = DiscoveredPackageSerializer(package).data
if package_data not in key_files_packages:
package_uids = package_data.get('extra_data', {}).get("package_uids", [])
already_seen = all(
package_uid in seen_package_uids
for package_uid in package_uids
)
if not already_seen:
seen_package_uids.extend(package_uids)
key_files_packages.append(package_data)

summary["key_files"] = key_files
Expand Down

0 comments on commit 6580c38

Please sign in to comment.