Skip to content

Commit 61d88dd

Browse files
0xc0170hugueskamba
authored andcommitted
scancode: fix SPDX check - only warning
SPDX are not yet done in our codebase. We suggest them to be present but 3rd party drivers have not yet been updated. The check as it was causes problems when updating 3rd party drivers (red flags in the PR). Proper fix will be to clean up SPDX id in the codebase.
1 parent e439ad9 commit 61d88dd

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

tools/test/travis-ci/scancode-evaluate.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def license_check(scancode_output_path):
8989
ReturnCode.ERROR.value if any error in file licenses found
9090
"""
9191

92-
offenders = []
92+
license_offenders = []
93+
spdx_offenders = []
9394
try:
9495
with open(scancode_output_path, 'r') as read_file:
9596
scancode_output_data = json.load(read_file)
@@ -107,13 +108,13 @@ def license_check(scancode_output_path):
107108

108109
if not scancode_output_data_file['licenses']:
109110
scancode_output_data_file['fail_reason'] = MISSING_LICENSE_TEXT
110-
offenders.append(scancode_output_data_file)
111+
license_offenders.append(scancode_output_data_file)
111112
# check the next file in the scancode output
112113
continue
113114

114115
if not has_permissive_text_in_scancode_output(scancode_output_data_file['licenses']):
115116
scancode_output_data_file['fail_reason'] = MISSING_PERMISSIVE_LICENSE_TEXT
116-
offenders.append(scancode_output_data_file)
117+
license_offenders.append(scancode_output_data_file)
117118

118119
if not has_spdx_text_in_scancode_output(scancode_output_data_file['licenses']):
119120
# Scancode does not recognize license notice in Python file headers.
@@ -131,13 +132,17 @@ def license_check(scancode_output_path):
131132

132133
if not has_spdx_text_in_analysed_file(scanned_file_content):
133134
scancode_output_data_file['fail_reason'] = MISSING_SPDX_TEXT
134-
offenders.append(scancode_output_data_file)
135+
spdx_offenders.append(scancode_output_data_file)
135136

136-
if offenders:
137+
if license_offenders:
137138
userlog.warning("Found files with missing license details, please review and fix")
138-
for offender in offenders:
139+
for offender in license_offenders:
139140
userlog.warning("File: %s reason: %s" % (path_leaf(offender['path']), offender['fail_reason']))
140-
return len(offenders)
141+
if spdx_offenders:
142+
userlog.warning("Found files with missing SPDX identifier, please review and fix")
143+
for offender in spdx_offenders:
144+
userlog.warning("File: %s reason: %s" % (path_leaf(offender['path']), offender['fail_reason']))
145+
return len(license_offenders)
141146

142147

143148
def parse_args():

tools/test/travis-ci/scancode_evaluate_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ def test_various_combinations_permissive_license_with_spdx(self):
7878
def test_missing_license_permissive_license_and_spdx(self, create_scanned_files):
7979
""" Test four files scanned with various issues.
8080
test.h: Missing license text (error count += 1)
81-
test3.h: Missing `Permissive` license text and `spdx` in match.identifier and not in file tested by ScanCode (error count += 2)
81+
test3.h: Missing `Permissive` license text and `spdx` in match.identifier and not in file tested by ScanCode (error count += 1)
8282
test4.h: Missing `Permissive` license text and `spdx` in match.identifier but found in file tested by ScanCode (error count += 1)
8383
test5.h: Missing `spdx` in match.identifier but found in file tested by ScanCode. (error count += 0)
8484
@inputs scancode_test/scancode_test_2.json
85-
@output 4
85+
@output 3
8686
"""
87-
assert license_check(os.path.join(STUBS_PATH, "scancode_test_3.json")) == 4
87+
assert license_check(os.path.join(STUBS_PATH, "scancode_test_3.json")) == 3
8888

8989
def test_permissive_license_no_spdx(self, create_scanned_files):
9090
""" Multiple `Permissive` licenses in one file but none with `spdx` in
91-
match.identifier and not in file tested by ScanCode (error count += 1)
91+
match.identifier and not in file tested by ScanCode (error count += 0)
9292
@inputs scancode_test/scancode_test_2.json
93-
@outputs 1
93+
@outputs 0
9494
"""
95-
assert license_check(os.path.join(STUBS_PATH, "scancode_test_4.json")) == 1
95+
assert license_check(os.path.join(STUBS_PATH, "scancode_test_4.json")) == 0

0 commit comments

Comments
 (0)