Skip to content

Commit f14375a

Browse files
move excluding code in to create_report_file
Signed-off-by: Wonjae Park <[email protected]>
1 parent 56a7921 commit f14375a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/fosslight_source/cli.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def create_report_file(
148148
output_path: str = "", output_files: list = [],
149149
output_extensions: list = [], correct_mode: bool = True,
150150
correct_filepath: str = "", path_to_scan: str = "", path_to_exclude: list = [],
151-
formats: list = []
151+
formats: list = [], excluded_file_list = []
152152
) -> 'ScannerItem':
153153
"""
154154
Create report files for given scanned result.
@@ -220,6 +220,12 @@ def create_report_file(
220220

221221
if merged_result:
222222
sheet_list = {}
223+
# Remove results that are in excluding file list
224+
for i in range(len(merged_result) - 1, -1, -1): # Iterate from last to first
225+
item_path = merged_result[i].source_name_or_path # Assuming SourceItem has 'file_path' attribute
226+
if item_path in excluded_file_list:
227+
del merged_result[i] # Delete matching item
228+
223229
scan_item.append_file_items(merged_result, PKG_NAME)
224230

225231
if selected_scanner == 'scanoss':
@@ -262,7 +268,7 @@ def create_report_file(
262268
return scan_item
263269

264270

265-
def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}, excluded_file_list=[]) -> list:
271+
def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}) -> list:
266272

267273
"""
268274
Merge scanner results and spdx parsing result.
@@ -287,11 +293,6 @@ def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_do
287293
new_result_item.download_location = download_location
288294
scancode_result.append(new_result_item)
289295

290-
for i in range(len(scancode_result) - 1, -1, -1): # Iterate from last to first
291-
item_path = scancode_result[i].source_name_or_path # Assuming SourceItem has 'file_path' attribute
292-
if item_path in excluded_file_list:
293-
del scancode_result[i] # Delete matching item
294-
295296
for item in scancode_result:
296297
item.set_oss_item()
297298

@@ -353,10 +354,10 @@ def run_scanners(
353354
path_to_exclude)
354355
if selected_scanner in SCANNER_TYPE:
355356
spdx_downloads = get_spdx_downloads(path_to_scan, path_to_exclude)
356-
merged_result = merge_results(scancode_result, scanoss_result, spdx_downloads, excluded_file_list)
357+
merged_result = merge_results(scancode_result, scanoss_result, spdx_downloads)
357358
scan_item = create_report_file(start_time, merged_result, license_list, scanoss_result, selected_scanner,
358359
print_matched_text, output_path, output_files, output_extensions, correct_mode,
359-
correct_filepath, path_to_scan, path_to_exclude, formats)
360+
correct_filepath, path_to_scan, path_to_exclude, formats, excluded_file_list)
360361
else:
361362
print_help_msg_source_scanner()
362363
result_log[RESULT_KEY] = "Unsupported scanner"

0 commit comments

Comments
 (0)