Skip to content

Commit faf24c3

Browse files
Add low relevance case in --todo
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent d4124b2 commit faf24c3

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/licensedcode/detection.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def logger_debug(*args):
7676
# Values of match_coverage less than this are reported as `license_clues` matches
7777
CLUES_MATCH_COVERAGE_THR = 60
7878

79+
# Low Relevance threshold
80+
LOW_RELEVANCE_THRESHOLD = 70
81+
7982
# False positives to spurious and gibberish texts are found usually later in the file
8083
# and matched to relatively short rules
8184
# Threshold Value of start line after which a match to likely be a false positive
@@ -104,7 +107,8 @@ class DetectionCategory(Enum):
104107
IMPERFECT_COVERAGE = 'imperfect-match-coverage'
105108
FALSE_POSITVE = 'possible-false-positive'
106109
UNDETECTED_LICENSE = 'undetected-license'
107-
MATCH_FRAGMENTS = 'match_fragments'
110+
MATCH_FRAGMENTS = 'match-fragments'
111+
LOW_RELEVANCE = 'low-relevance'
108112

109113

110114
class DetectionRule(Enum):
@@ -924,6 +928,17 @@ def has_extra_words(license_matches):
924928
)
925929

926930

931+
def has_low_rule_relevance(license_matches):
932+
"""
933+
Return True if any on the matches in ``license_matches`` List of LicenseMatch
934+
objects has a match with low score because of low rule relevance.
935+
"""
936+
return any(
937+
license_match.rule.relevance < LOW_RELEVANCE_THRESHOLD
938+
for license_match in license_matches
939+
)
940+
941+
927942
def is_false_positive(license_matches, package_license=False):
928943
"""
929944
Return True if all of the matches in ``license_matches`` List of LicenseMatch
@@ -1373,6 +1388,9 @@ def get_ambiguous_license_detections_by_type(unique_license_detections):
13731388
elif has_extra_words(license_matches=detection.matches):
13741389
ambi_license_detections[DetectionCategory.EXTRA_WORDS.value] = detection
13751390

1391+
elif has_low_rule_relevance(license_matches=detection.matches):
1392+
ambi_license_detections[DetectionCategory.LOW_RELEVANCE.value] = detection
1393+
13761394
return ambi_license_detections
13771395

13781396

src/summarycode/todo.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ class ReviewComments(Enum):
333333
"review. scancode would likely benifit from a license rule addition "
334334
"from this case, so please report this to scancode-toolkit github issues."
335335
)
336+
LOW_RELEVANCE = (
337+
"The license detection needs more review as they have low score due to "
338+
"the relevance of the matched rules as low, even though the match coverage "
339+
"is perfect, i.e. there is an exact match."
340+
)
336341
FALSE_POSITVE = (
337342
"The license detection is inconclusive, and is unlikely to be about a "
338343
"license as a piece of code/text is detected, and this needs to be reviewed. ",
@@ -370,6 +375,9 @@ def get_review_comments(detection_log):
370375

371376
if LicenseDetectionCategory.MATCH_FRAGMENTS.value in detection_log:
372377
review_comments[LicenseDetectionCategory.MATCH_FRAGMENTS.value] = ReviewComments.MATCH_FRAGMENTS.value
378+
379+
if LicenseDetectionCategory.LOW_RELEVANCE.value in detection_log:
380+
review_comments[LicenseDetectionCategory.LOW_RELEVANCE.value] = ReviewComments.LOW_RELEVANCE.value
373381

374382
if LicenseDetectionCategory.LICENSE_CLUES.value in detection_log:
375383
review_comments[LicenseDetectionCategory.LICENSE_CLUES.value] = ReviewComments.LICENSE_CLUES.value

0 commit comments

Comments
 (0)