@@ -1256,6 +1256,16 @@ def filter_license_references(license_match_objects):
1256
1256
return filtered_matches
1257
1257
1258
1258
1259
+ def filter_license_intros_and_references (license_match_objects ):
1260
+ """
1261
+ Return a filtered ``license_matches`` list of LicenseMatch objects removing
1262
+ matches which had references to local files with licenses and spurious matches
1263
+ to license introduction statements.
1264
+ """
1265
+ filtered_license_match_objects = filter_license_intros (license_match_objects )
1266
+ return filter_license_references (filtered_license_match_objects )
1267
+
1268
+
1259
1269
def has_references_to_local_files (license_matches ):
1260
1270
"""
1261
1271
Return True if any of the matched Rule for the ``license_matches`` has a
@@ -1319,37 +1329,37 @@ def get_detected_license_expression(
1319
1329
if analysis == DetectionCategory .UNKNOWN_REFERENCE_IN_FILE_TO_PACKAGE .value :
1320
1330
if TRACE_ANALYSIS :
1321
1331
logger_debug (f'analysis { DetectionCategory .UNKNOWN_REFERENCE_IN_FILE_TO_PACKAGE .value } ' )
1322
- matches_for_expression = filter_license_references (license_matches )
1332
+ matches_for_expression = filter_license_intros_and_references (license_matches )
1323
1333
detection_log .append (DetectionRule .UNKNOWN_REFERENCE_IN_FILE_TO_PACKAGE .value )
1324
1334
1325
1335
elif analysis == DetectionCategory .UNKNOWN_REFERENCE_IN_FILE_TO_NONEXISTENT_PACKAGE .value :
1326
1336
if TRACE_ANALYSIS :
1327
1337
logger_debug (f'analysis { DetectionCategory .UNKNOWN_REFERENCE_IN_FILE_TO_NONEXISTENT_PACKAGE .value } ' )
1328
- matches_for_expression = filter_license_references (license_matches )
1338
+ matches_for_expression = filter_license_intros_and_references (license_matches )
1329
1339
detection_log .append (DetectionRule .UNKNOWN_REFERENCE_IN_FILE_TO_NONEXISTENT_PACKAGE .value )
1330
1340
1331
1341
elif analysis == DetectionCategory .UNKNOWN_FILE_REFERENCE_LOCAL .value :
1332
1342
if TRACE_ANALYSIS :
1333
1343
logger_debug (f'analysis { DetectionCategory .UNKNOWN_FILE_REFERENCE_LOCAL .value } ' )
1334
- matches_for_expression = filter_license_references (license_matches )
1344
+ matches_for_expression = filter_license_intros_and_references (license_matches )
1335
1345
detection_log .append (DetectionRule .UNKNOWN_REFERENCE_TO_LOCAL_FILE .value )
1336
1346
1337
1347
elif analysis == DetectionCategory .PACKAGE_UNKNOWN_FILE_REFERENCE_LOCAL .value :
1338
1348
if TRACE_ANALYSIS :
1339
1349
logger_debug (f'analysis { DetectionCategory .PACKAGE_UNKNOWN_FILE_REFERENCE_LOCAL .value } ' )
1340
- matches_for_expression = filter_license_references (license_matches )
1350
+ matches_for_expression = filter_license_intros_and_references (license_matches )
1341
1351
detection_log .append (DetectionRule .PACKAGE_UNKNOWN_REFERENCE_TO_LOCAL_FILE .value )
1342
1352
1343
1353
elif analysis == DetectionCategory .PACKAGE_ADD_FROM_SIBLING_FILE .value :
1344
1354
if TRACE_ANALYSIS :
1345
1355
logger_debug (f'analysis { DetectionCategory .PACKAGE_ADD_FROM_SIBLING_FILE .value } ' )
1346
- matches_for_expression = filter_license_references (license_matches )
1356
+ matches_for_expression = filter_license_intros_and_references (license_matches )
1347
1357
detection_log .append (DetectionRule .PACKAGE_ADD_FROM_SIBLING_FILE .value )
1348
1358
1349
1359
elif analysis == DetectionCategory .PACKAGE_ADD_FROM_FILE .value :
1350
1360
if TRACE_ANALYSIS :
1351
1361
logger_debug (f'analysis { DetectionCategory .PACKAGE_ADD_FROM_FILE .value } ' )
1352
- matches_for_expression = filter_license_references (license_matches )
1362
+ matches_for_expression = filter_license_intros_and_references (license_matches )
1353
1363
detection_log .append (DetectionRule .PACKAGE_ADD_FROM_FILE .value )
1354
1364
1355
1365
elif analysis == DetectionCategory .UNKNOWN_MATCH .value :
@@ -1495,6 +1505,9 @@ def get_ambiguous_license_detections_by_type(unique_license_detections):
1495
1505
1496
1506
elif is_undetected_license_matches (license_matches = detection .matches ):
1497
1507
ambi_license_detections [DetectionCategory .UNDETECTED_LICENSE .value ] = detection
1508
+
1509
+ elif has_correct_license_clue_matches (license_matches = detection .matches ):
1510
+ ambi_license_detections [DetectionCategory .LICENSE_CLUES .value ] = detection
1498
1511
1499
1512
elif "unknown" in detection .license_expression :
1500
1513
if has_unknown_matches (license_matches = detection .matches ):
0 commit comments