Skip to content

Commit 570c43f

Browse files
Add rules and license detection updates
* Add new license rules from jacoco * Add updates to the license clue heuristics Reference: #3515 Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 3ac8e96 commit 570c43f

File tree

7 files changed

+85
-9
lines changed

7 files changed

+85
-9
lines changed

src/licensedcode/data/rules/ace-tao_5.RULE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
license_expression: ace-tao
3-
is_license_reference: yes
3+
is_license_clue: yes
44
is_continuous: yes
55
relevance: 100
66
minimum_coverage: 100
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
license_expression: epl-2.0
3+
is_license_notice: yes
4+
referenced_filenames:
5+
- https://www.eclipse.org/legal/epl-2.0/.
6+
ignorable_urls:
7+
- https://www.eclipse.org/legal/epl-2.0
8+
---
9+
10+
is provided to you under the terms and conditions of the {{Eclipse Public License Version 2.0 ("EPL")}}.
11+
A copy of the {{EPL}} is available at {{https://www.eclipse.org/legal/epl-2.0/}}.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
license_expression: epl-2.0
3+
is_license_notice: yes
4+
ignorable_copyrights:
5+
- Copyright Mountainminds GmbH & Co. KG and Contributors
6+
ignorable_holders:
7+
- Mountainminds GmbH & Co. KG and Contributors
8+
ignorable_urls:
9+
- https://www.eclipse.org/legal/epl-2.0
10+
- https://www.eclipse.org/legal/epl-2.0/
11+
---
12+
13+
Copyright Mountainminds GmbH & Co. KG and Contributors
14+
15+
The JaCoCo Java Code Coverage Library and all included documentation is made
16+
available by Mountainminds GmbH & Co. KG, Munich. Except indicated below, the
17+
Content is provided to you under the terms and conditions of the {{Eclipse Public
18+
License Version 2.0 ("EPL")}}. A copy of the {{EPL}} is available at
19+
[https://www.eclipse.org/legal/epl-2.0/](https://www.eclipse.org/legal/epl-2.0/).
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
license_expression: unknown-license-reference
3+
is_license_reference: yes
4+
referenced_filenames:
5+
- doc/license.html
6+
---
7+
8+
Please visit doc/license.html for the complete license information
9+
including third party licenses and trademarks.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
license_expression: unknown-license-reference
3+
is_license_reference: yes
4+
referenced_filenames:
5+
- org.jacoco.doc/docroot/doc/license.html
6+
ignorable_urls:
7+
- http://www.jacoco.org/jacoco/trunk/doc/license.html
8+
---
9+
10+
Please visit http://www.jacoco.org/jacoco/trunk/doc/license.html for the
11+
complete license information including third party licenses and trademarks.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
license_expression: unknown-license-reference
3+
is_license_reference: yes
4+
referenced_filenames:
5+
- org.jacoco.doc/docroot/doc/license.html
6+
ignorable_urls:
7+
- http://www.jacoco.org/jacoco/trunk/doc/license.html
8+
---
9+
10+
Please visit
11+
[http://www.jacoco.org/jacoco/trunk/doc/license.html](http://www.jacoco.org/jacoco/trunk/doc/license.html)
12+
for the complete license information including third party licenses and trademarks.

src/licensedcode/detection.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ def from_matches(
218218
If `post_scan` is True, this function is called outside
219219
the main license detection step.
220220
"""
221+
if TRACE:
222+
logger_debug(f"LicenseDetection: from_matches: matches: {matches}")
223+
221224
if not matches:
222225
return
223226

@@ -1620,6 +1623,14 @@ def group_matches(license_matches, lines_threshold=LINES_THRESHOLD):
16201623
yield group_of_license_matches
16211624
group_of_license_matches = [license_match]
16221625

1626+
# If the current match is a license clue, we send this as a
1627+
# seperate group
1628+
elif license_match.rule.is_license_clue:
1629+
yield group_of_license_matches
1630+
yield [license_match]
1631+
group_of_license_matches = []
1632+
continue
1633+
16231634
# If none of previous or current match has license intro then we look at line numbers
16241635
# If line number difference is within threshold, we keep the current match in the group
16251636
elif is_in_group_by_threshold:
@@ -1631,7 +1642,9 @@ def group_matches(license_matches, lines_threshold=LINES_THRESHOLD):
16311642
yield group_of_license_matches
16321643
group_of_license_matches = [license_match]
16331644

1634-
yield group_of_license_matches
1645+
# If not an empty group, this is the last group
1646+
if group_of_license_matches:
1647+
yield group_of_license_matches
16351648

16361649

16371650
def get_referenced_filenames(license_matches):
@@ -1705,16 +1718,17 @@ def process_detections(detections, licensing=Licensing()):
17051718
for detection in detections:
17061719
if detection.license_expression == None:
17071720
if has_correct_license_clue_matches(detection.matches):
1721+
yield detection
17081722
continue
17091723

17101724
license_expression = str(combine_expressions(
1711-
expressions=[
1712-
match.rule.license_expression
1713-
for match in detection.matches
1714-
],
1715-
unique=True,
1716-
licensing=licensing,
1717-
))
1725+
expressions=[
1726+
match.rule.license_expression
1727+
for match in detection.matches
1728+
],
1729+
unique=True,
1730+
licensing=licensing,
1731+
))
17181732
license_keys = licensing.license_keys(expression=license_expression)
17191733

17201734
if all(

0 commit comments

Comments
 (0)