diff --git a/src/licensedcode/plugin_license.py b/src/licensedcode/plugin_license.py index d7837f4e0b..d54cf53d70 100644 --- a/src/licensedcode/plugin_license.py +++ b/src/licensedcode/plugin_license.py @@ -304,6 +304,9 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase): path=referenced_resource.path ) + if not referenced_detections: + continue + referenced_license_expression = combine_expressions( expressions=[ detection["license_expression"] @@ -314,7 +317,7 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase): referenced_license_expression=referenced_license_expression, license_detection=license_detection, ): - if TRACE_REFERENCE: + if TRACE_REFERENCE and referenced_resource: logger_debug( f'use_referenced_license_expression: False for ' f'resource: {referenced_resource.path} and ' @@ -322,7 +325,7 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase): ) continue - if TRACE_REFERENCE: + if TRACE_REFERENCE and referenced_resource: logger_debug( f'use_referenced_license_expression: True for ' f'resource: {referenced_resource.path} and ' diff --git a/src/packagedcode/licensing.py b/src/packagedcode/licensing.py index 70c34722ad..ee7178da28 100644 --- a/src/packagedcode/licensing.py +++ b/src/packagedcode/licensing.py @@ -140,6 +140,9 @@ def add_referenced_license_matches_for_package(resource, codebase): ): continue + if not (referenced_resource and referenced_resource.license_detections): + continue + modified = True detections_added.extend(referenced_resource.license_detections) matches_to_extend = get_matches_from_detection_mappings(