Skip to content

Commit 491f3cd

Browse files
committed
Add test for extra-words and improve detection_log
Signed-off-by: Alok Kumar <[email protected]>
1 parent a4415e7 commit 491f3cd

File tree

4 files changed

+700
-1
lines changed

4 files changed

+700
-1
lines changed

src/licensedcode/detection.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class DetectionRule(Enum):
124124
These are logged in LicenseDetection.detection_log for verbosity.
125125
"""
126126
UNKNOWN_MATCH = 'unknown-match'
127+
EXTRA_WORDS = 'extra-words'
127128
LICENSE_CLUES = 'license-clues'
128129
LOW_QUALITY_MATCH_FRAGMENTS = 'low-quality-matches'
129130
FALSE_POSITIVE = 'possible-false-positive'
@@ -1071,7 +1072,7 @@ def is_correct_detection(license_matches):
10711072
]
10721073

10731074
return (
1074-
all(matcher in ("1-hash", "1-spdx-id", "2-aho") for matcher in matchers)
1075+
all(matcher in ("1-hash", "1-spdx-id") for matcher in matchers)
10751076
and all(is_match_coverage_perfect)
10761077
)
10771078

@@ -1545,6 +1546,13 @@ def get_detected_license_expression(
15451546
# in detections but ideally we should return synthetic unknowns for these
15461547
detection_log.append(DetectionRule.LOW_QUALITY_MATCH_FRAGMENTS.value)
15471548
return detection_log, combined_expression
1549+
1550+
elif analysis == DetectionCategory.EXTRA_WORDS.value:
1551+
if TRACE_ANALYSIS:
1552+
logger_debug(f'analysis {DetectionCategory.EXTRA_WORDS.value}')
1553+
# Apply filtering or handling logic if needed
1554+
matches_for_expression = license_matches
1555+
detection_log.append(DetectionRule.EXTRA_WORDS.value)
15481556

15491557
else:
15501558
if TRACE_ANALYSIS:

0 commit comments

Comments
 (0)