2222import argparse
2323from .run_spdx_extractor import get_spdx_downloads
2424from ._scan_item import ScanItem
25+ from fosslight_util .cover import CoverItem
2526
2627SRC_SHEET_NAME = 'SRC_FL_Source'
2728SCANOSS_HEADER = {SRC_SHEET_NAME : ['ID' , 'Source Name or Path' , 'OSS Name' ,
@@ -143,25 +144,26 @@ def create_report_file(_start_time, merged_result, license_list, scanoss_result,
143144 else :
144145 output_file = f"fosslight_report_src_{ _start_time } "
145146
147+ cover = CoverItem (tool_name = _PKG_NAME ,
148+ start_time = _start_time ,
149+ input_path = path_to_scan )
150+ files_count = sum ([len (files ) for r , d , files in os .walk (path_to_scan )])
151+ cover .comment = f"Total number of files: { files_count } "
152+ if len (merged_result ) == 0 :
153+ if files_count < 1 :
154+ cover .comment += "(No file detected.)"
155+ else :
156+ cover .comment += "(No OSS detected.)"
157+
158+ sheet_list [SRC_SHEET_NAME ] = []
146159 if merged_result :
147- if selected_scanner == 'scancode' or output_extension == _json_ext :
148- sheet_list [SRC_SHEET_NAME ] = []
149- for scan_item in merged_result :
150- for row in scan_item .get_row_to_print ():
151- sheet_list [SRC_SHEET_NAME ].append (row )
152-
153- elif selected_scanner == 'scanoss' :
154- sheet_list [SRC_SHEET_NAME ] = []
155- for scan_item in merged_result :
156- for row in scan_item .get_row_to_print ():
157- sheet_list [SRC_SHEET_NAME ].append (row )
158- extended_header = SCANOSS_HEADER
160+ for scan_item in merged_result :
161+ for row in scan_item .get_row_to_print ():
162+ sheet_list [SRC_SHEET_NAME ].append (row )
159163
164+ if selected_scanner == 'scanoss' :
165+ extended_header = SCANOSS_HEADER
160166 else :
161- sheet_list [SRC_SHEET_NAME ] = []
162- for scan_item in merged_result :
163- for row in scan_item .get_row_to_print ():
164- sheet_list [SRC_SHEET_NAME ].append (row )
165167 extended_header = MERGED_HEADER
166168
167169 if need_license :
@@ -183,10 +185,11 @@ def create_report_file(_start_time, merged_result, license_list, scanoss_result,
183185
184186 output_file_without_ext = os .path .join (output_path , output_file )
185187 success_to_write , writing_msg , result_file = write_output_file (output_file_without_ext , output_extension ,
186- sheet_list , extended_header )
188+ sheet_list , extended_header , "" , cover )
187189 if success_to_write :
188190 if result_file :
189191 logger .info (f"Output file:{ result_file } " )
192+ logger .info (f'{ cover .comment } ' )
190193 else :
191194 logger .warning (f"{ writing_msg } " )
192195 else :
@@ -264,7 +267,6 @@ def run_scanners(path_to_scan, output_file_name="", write_json_file=False, num_c
264267 if selected_scanner in SCANNER_TYPE :
265268 spdx_downloads = get_spdx_downloads (path_to_scan )
266269 merged_result = merge_results (scancode_result , scanoss_result , spdx_downloads )
267-
268270 create_report_file (start_time , merged_result , license_list , scanoss_result , selected_scanner , print_matched_text ,
269271 output_path , output_file , output_extension , correct_mode , correct_filepath , path_to_scan )
270272 else :
0 commit comments