Skip to content

Commit f9863e6

Browse files
Modify license clue/false positive heuristics
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 0432bf6 commit f9863e6

File tree

7 files changed

+35
-6
lines changed

7 files changed

+35
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
license_expression: unknown-license-reference
33
is_license_clue: yes
4-
relevance: 100
4+
relevance: 60
55
---
66

77
freeware
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
license_expression: gpl-3.0
33
is_license_reference: yes
4-
relevance: 95
4+
relevance: 60
55
---
66

77
GPL3
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
license_expression: lgpl-2.0-plus
33
is_license_reference: yes
4-
relevance: 75
4+
relevance: 60
55
---
66

77
LGPL

src/licensedcode/data/rules/public-domain_bare_words.RULE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
license_expression: public-domain
3-
is_license_reference: yes
3+
is_license_clue: yes
44
is_continuous: yes
55
relevance: 70
66
---

src/licensedcode/detection.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,25 @@ def is_false_positive(license_matches, package_license=False):
11631163
if package_license:
11641164
return False
11651165

1166+
has_copyrights = all(
1167+
True
1168+
for license_match in license_matches
1169+
if "copyright" in license_match.matched_text().lower()
1170+
)
1171+
has_full_relevance = all(
1172+
True
1173+
for license_match in license_matches
1174+
if license_match.rule.relevance == 100
1175+
)
1176+
if has_copyrights or has_full_relevance:
1177+
return False
1178+
1179+
has_low_relevance = all(
1180+
True
1181+
for license_match in license_matches
1182+
if license_match.rule.relevance < 60
1183+
)
1184+
11661185
start_line_region = min(
11671186
license_match.start_line for license_match in license_matches
11681187
)
@@ -1194,13 +1213,13 @@ def is_false_positive(license_matches, package_license=False):
11941213

11951214
is_single_match = len(license_matches) == 1
11961215

1197-
if is_single_match and is_bare_rule:
1216+
if is_single_match and is_bare_rule and has_low_relevance:
11981217
return True
11991218

12001219
if is_gpl and all_match_rule_length_one:
12011220
return True
12021221

1203-
if start_line_region > FALSE_POSITIVE_START_LINE_THRESHOLD and any(
1222+
if has_low_relevance and start_line_region > FALSE_POSITIVE_START_LINE_THRESHOLD and any(
12041223
match_rule_length_value <= FALSE_POSITIVE_RULE_LENGTH_THRESHOLD
12051224
for match_rule_length_value in match_rule_length_values
12061225
):
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
///
2+
// Confidence: High
3+
// Copyright: (C) 2010-2012 Nicolas Palix. GPLv2.
4+
// Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2.
5+
// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
6+
// URL: http://coccinelle.lip6.fr/
7+
// Comments:
8+
// Options: --no-includes --include-headers
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
license_expressions:
2+
- gpl-2.0

0 commit comments

Comments
 (0)