Skip to content

Commit 637c4dd

Browse files
Adjust unknown licenses heuristics
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent fd3f1d7 commit 637c4dd

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/licensedcode/detection.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,6 @@ def get_detected_license_expression(matches, analysis, post_scan=False):
784784
logger_debug(f'analysis {DetectionCategory.UNKNOWN_MATCH.value}')
785785
matches_for_expression = matches
786786
detection_log.append(DetectionRule.UNKNOWN_MATCH.value)
787-
return detection_log, combined_expression
788787

789788
elif analysis == DetectionCategory.LICENSE_CLUES.value:
790789
if TRACE_ANALYSIS:
@@ -970,6 +969,11 @@ def analyze_detection(license_matches, package_license=False):
970969
elif is_correct_detection(license_matches):
971970
return DetectionCategory.PERFECT_DETECTION.value
972971

972+
# Case where even though the matches have perfect coverage, they have
973+
# matches with `unknown` rule identifiers
974+
elif has_unknown_matches(license_matches):
975+
return DetectionCategory.UNKNOWN_MATCH.value
976+
973977
elif is_license_clues(license_matches):
974978
return DetectionCategory.LICENSE_CLUES.value
975979

@@ -984,11 +988,6 @@ def analyze_detection(license_matches, package_license=False):
984988
elif has_extra_words(license_matches):
985989
return DetectionCategory.EXTRA_WORDS.value
986990

987-
# Case where even though the matches have perfect coverage, they have
988-
# matches with `unknown` rule identifiers
989-
elif has_unknown_matches(license_matches):
990-
return DetectionCategory.UNKNOWN_MATCH.value
991-
992991
# Cases where Match Coverage is a perfect 100 for all matches
993992
else:
994993
return DetectionCategory.PERFECT_DETECTION.value

tests/packagedcode/data/license_detection/reference-to-package/samba.expected.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
{
196196
"license_expression": "gpl-2.0-plus AND free-unknown AND gpl-1.0-plus",
197197
"detection_log": [
198-
"not-combined"
198+
"unknown-match"
199199
],
200200
"matches": [
201201
{
@@ -966,7 +966,7 @@
966966
{
967967
"license_expression": "gpl-2.0-plus AND free-unknown AND gpl-1.0-plus",
968968
"detection_log": [
969-
"not-combined"
969+
"unknown-match"
970970
],
971971
"matches": [
972972
{
@@ -1711,7 +1711,7 @@
17111711
{
17121712
"license_expression": "gpl-2.0-plus AND free-unknown AND gpl-1.0-plus",
17131713
"detection_log": [
1714-
"not-combined"
1714+
"unknown-match"
17151715
],
17161716
"matches": [
17171717
{
@@ -2468,7 +2468,7 @@
24682468
{
24692469
"license_expression": "gpl-2.0-plus AND free-unknown AND gpl-1.0-plus",
24702470
"detection_log": [
2471-
"not-combined"
2471+
"unknown-match"
24722472
],
24732473
"matches": [
24742474
{

0 commit comments

Comments
 (0)