5
5
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
#
7
7
# -------------------------------------------------------------------------
8
- """
9
- """
10
8
11
9
12
10
import glob
@@ -116,14 +114,14 @@ def worker_result_handler(results, metadata_tool, output_path):
116
114
117
115
118
116
# Progress reporting.
119
- progress_checked_num = None
120
- progress_actions = None
117
+ PROGRESS_CHECKED_NUM = None
118
+ PROGRESS_ACTIONS = None
121
119
122
120
123
121
def init_worker (checked_num , action_num ):
124
- global progress_checked_num , progress_actions
125
- progress_checked_num = checked_num
126
- progress_actions = action_num
122
+ global PROGRESS_CHECKED_NUM , PROGRESS_ACTIONS
123
+ PROGRESS_CHECKED_NUM = checked_num
124
+ PROGRESS_ACTIONS = action_num
127
125
128
126
129
127
def save_output (base_file_name , out , err ):
@@ -172,8 +170,7 @@ def prepare_check(action, analyzer_config, output_dir,
172
170
""" Construct the source analyzer and result handler. """
173
171
# Create a source analyzer.
174
172
source_analyzer = \
175
- analyzer_types .construct_analyzer (action ,
176
- analyzer_config )
173
+ analyzer_types .construct_analyzer (action , analyzer_config )
177
174
178
175
if disable_ctu :
179
176
# WARNING! can be called only on ClangSA
@@ -334,8 +331,8 @@ def handle_failure(
334
331
# from the standard output by this postprocess phase so we can present them
335
332
# as CodeChecker reports.
336
333
checks = source_analyzer .config_handler .checks ()
337
- state = checks .get ('clang-diagnostic-error' , (CheckerState .enabled , '' ))[0 ]
338
- if state == CheckerState .enabled :
334
+ state = checks .get ('clang-diagnostic-error' , (CheckerState .ENABLED , '' ))[0 ]
335
+ if state == CheckerState .ENABLED :
339
336
rh .postprocess_result (skip_handlers , rs_handler )
340
337
341
338
# Remove files that successfully analyzed earlier on.
@@ -507,7 +504,7 @@ def check(check_data):
507
504
result_file = ''
508
505
509
506
if analyzer_config is None :
510
- raise Exception ("Analyzer configuration is missing." )
507
+ raise ValueError ("Analyzer configuration is missing." )
511
508
512
509
source_analyzer , rh = prepare_check (action , analyzer_config ,
513
510
output_dir ,
@@ -539,7 +536,7 @@ def __create_timeout(analyzer_process):
539
536
timeout_cleanup [0 ] = setup_process_timeout (
540
537
analyzer_process , analysis_timeout )
541
538
else :
542
- def __create_timeout (analyzer_process ):
539
+ def __create_timeout (_ ):
543
540
# If no timeout is given by the client, this callback
544
541
# shouldn't do anything.
545
542
pass
@@ -555,9 +552,9 @@ def __create_timeout(analyzer_process):
555
552
"of %d seconds." , analysis_timeout )
556
553
LOG .warning ("Considering this analysis as failed..." )
557
554
rh .analyzer_returncode = - 1
558
- rh .analyzer_stderr = ( ">>> CodeChecker: Analysis timed out "
559
- " after {0} seconds. <<< \n {1}" ) \
560
- . format ( analysis_timeout , rh .analyzer_stderr )
555
+ rh .analyzer_stderr = \
556
+ ">>> CodeChecker: Analysis timed out after " \
557
+ f" { analysis_timeout } seconds. <<< \n { rh .analyzer_stderr } "
561
558
562
559
source_analyzer .post_analyze (rh )
563
560
@@ -619,7 +616,7 @@ def handle_analysis_result(success, zip_file=zip_file):
619
616
if rh .analyzer_returncode == 0 :
620
617
handle_analysis_result (success = True )
621
618
LOG .info ("[%d/%d] %s analyzed %s successfully." ,
622
- progress_checked_num .value , progress_actions .value ,
619
+ PROGRESS_CHECKED_NUM .value , PROGRESS_ACTIONS .value ,
623
620
action .analyzer_type , source_file_name )
624
621
625
622
if result_file_exists :
@@ -660,8 +657,8 @@ def handle_analysis_result(success, zip_file=zip_file):
660
657
661
658
LOG .info ("[%d/%d] %s analyzed %s without"
662
659
" CTU successfully." ,
663
- progress_checked_num .value ,
664
- progress_actions .value ,
660
+ PROGRESS_CHECKED_NUM .value ,
661
+ PROGRESS_ACTIONS .value ,
665
662
action .analyzer_type ,
666
663
source_file_name )
667
664
@@ -688,7 +685,7 @@ def handle_analysis_result(success, zip_file=zip_file):
688
685
LOG .debug_analyzer ('\n %s' , rh .analyzer_stdout )
689
686
LOG .debug_analyzer ('\n %s' , rh .analyzer_stderr )
690
687
691
- progress_checked_num .value += 1
688
+ PROGRESS_CHECKED_NUM .value += 1
692
689
693
690
return return_codes , False , reanalyzed , action .analyzer_type , \
694
691
result_file , action .source
@@ -731,10 +728,8 @@ def start_workers(actions_map, actions, analyzer_config_map,
731
728
Start the workers in the process pool.
732
729
For every build action there is worker which makes the analysis.
733
730
"""
734
- # pylint: disable=no-member multiprocess module members.
735
-
736
731
# Handle SIGINT to stop this script running.
737
- def signal_handler (signum , frame ):
732
+ def signal_handler (signum , _ ):
738
733
try :
739
734
pool .terminate ()
740
735
pool .join ()
0 commit comments