Skip to content

Commit 5df2d07

Browse files
committed
[cfg] Upgrade to pylint 3.2.4
1 parent 3d1a1ab commit 5df2d07

File tree

252 files changed

+2661
-2239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+2661
-2239
lines changed

.pylintrc

+553-252
Large diffs are not rendered by default.

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ PYLINT_CMD = $(MAKE) -C $(CC_ANALYZER) pylint && \
164164
$(MAKE) -C $(CC_WEB) pylint && \
165165
pylint -j0 ./bin/** ./codechecker_common \
166166
./scripts/** ./scripts/build/** ./scripts/debug_tools/** \
167-
./scripts/gerrit_jenkins/** ./scripts/resources/** \
167+
./scripts/resources/** \
168168
./scripts/test/** ./scripts/thrift/** \
169169
--rcfile=$(ROOT)/.pylintrc
170170

analyzer/codechecker_analyzer/analysis_manager.py

+18-23
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
#
77
# -------------------------------------------------------------------------
8-
"""
9-
"""
108

119

1210
import glob
@@ -116,14 +114,14 @@ def worker_result_handler(results, metadata_tool, output_path):
116114

117115

118116
# Progress reporting.
119-
progress_checked_num = None
120-
progress_actions = None
117+
PROGRESS_CHECKED_NUM = None
118+
PROGRESS_ACTIONS = None
121119

122120

123121
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
127125

128126

129127
def save_output(base_file_name, out, err):
@@ -172,8 +170,7 @@ def prepare_check(action, analyzer_config, output_dir,
172170
""" Construct the source analyzer and result handler. """
173171
# Create a source analyzer.
174172
source_analyzer = \
175-
analyzer_types.construct_analyzer(action,
176-
analyzer_config)
173+
analyzer_types.construct_analyzer(action, analyzer_config)
177174

178175
if disable_ctu:
179176
# WARNING! can be called only on ClangSA
@@ -334,8 +331,8 @@ def handle_failure(
334331
# from the standard output by this postprocess phase so we can present them
335332
# as CodeChecker reports.
336333
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:
339336
rh.postprocess_result(skip_handlers, rs_handler)
340337

341338
# Remove files that successfully analyzed earlier on.
@@ -507,7 +504,7 @@ def check(check_data):
507504
result_file = ''
508505

509506
if analyzer_config is None:
510-
raise Exception("Analyzer configuration is missing.")
507+
raise ValueError("Analyzer configuration is missing.")
511508

512509
source_analyzer, rh = prepare_check(action, analyzer_config,
513510
output_dir,
@@ -539,7 +536,7 @@ def __create_timeout(analyzer_process):
539536
timeout_cleanup[0] = setup_process_timeout(
540537
analyzer_process, analysis_timeout)
541538
else:
542-
def __create_timeout(analyzer_process):
539+
def __create_timeout(_):
543540
# If no timeout is given by the client, this callback
544541
# shouldn't do anything.
545542
pass
@@ -555,9 +552,9 @@ def __create_timeout(analyzer_process):
555552
"of %d seconds.", analysis_timeout)
556553
LOG.warning("Considering this analysis as failed...")
557554
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}"
561558

562559
source_analyzer.post_analyze(rh)
563560

@@ -619,7 +616,7 @@ def handle_analysis_result(success, zip_file=zip_file):
619616
if rh.analyzer_returncode == 0:
620617
handle_analysis_result(success=True)
621618
LOG.info("[%d/%d] %s analyzed %s successfully.",
622-
progress_checked_num.value, progress_actions.value,
619+
PROGRESS_CHECKED_NUM.value, PROGRESS_ACTIONS.value,
623620
action.analyzer_type, source_file_name)
624621

625622
if result_file_exists:
@@ -660,8 +657,8 @@ def handle_analysis_result(success, zip_file=zip_file):
660657

661658
LOG.info("[%d/%d] %s analyzed %s without"
662659
" CTU successfully.",
663-
progress_checked_num.value,
664-
progress_actions.value,
660+
PROGRESS_CHECKED_NUM.value,
661+
PROGRESS_ACTIONS.value,
665662
action.analyzer_type,
666663
source_file_name)
667664

@@ -688,7 +685,7 @@ def handle_analysis_result(success, zip_file=zip_file):
688685
LOG.debug_analyzer('\n%s', rh.analyzer_stdout)
689686
LOG.debug_analyzer('\n%s', rh.analyzer_stderr)
690687

691-
progress_checked_num.value += 1
688+
PROGRESS_CHECKED_NUM.value += 1
692689

693690
return return_codes, False, reanalyzed, action.analyzer_type, \
694691
result_file, action.source
@@ -731,10 +728,8 @@ def start_workers(actions_map, actions, analyzer_config_map,
731728
Start the workers in the process pool.
732729
For every build action there is worker which makes the analysis.
733730
"""
734-
# pylint: disable=no-member multiprocess module members.
735-
736731
# Handle SIGINT to stop this script running.
737-
def signal_handler(signum, frame):
732+
def signal_handler(signum, _):
738733
try:
739734
pool.terminate()
740735
pool.join()

analyzer/codechecker_analyzer/analyzer.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __has_enabled_checker(ch: AnalyzerConfigHandler):
126126
Returns True if at least one checker is enabled in the given config
127127
handler.
128128
"""
129-
return any(state == CheckerState.enabled
129+
return any(state == CheckerState.ENABLED
130130
for _, (state, _) in ch.checks().items())
131131

132132

@@ -137,8 +137,6 @@ def perform_analysis(args, skip_handlers, rs_handler: ReviewStatusHandler,
137137
in the given analysis context for the supplied build actions.
138138
Additionally, insert statistical information into the metadata dict.
139139
"""
140-
# pylint: disable=no-member multiprocess module members.
141-
142140
context = analyzer_context.get_context()
143141

144142
ctu_reanalyze_on_failure = 'ctu_reanalyze_on_failure' in args and \
@@ -246,8 +244,8 @@ def perform_analysis(args, skip_handlers, rs_handler: ReviewStatusHandler,
246244
for check, data in config_map[analyzer].checks().items():
247245
state, _ = data
248246
metadata_info['checkers'].update({
249-
check: state == CheckerState.enabled})
250-
if state == CheckerState.enabled:
247+
check: state == CheckerState.ENABLED})
248+
if state == CheckerState.ENABLED:
251249
enabled_checkers[analyzer].append(check)
252250

253251
# TODO: cppcheck may require a different environment than clang.

analyzer/codechecker_analyzer/analyzer_context.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"""
1111

1212

13-
# pylint: disable=no-name-in-module
13+
# pylint: disable=deprecated-module
1414
from distutils.spawn import find_executable
1515
from argparse import ArgumentTypeError
1616

@@ -20,8 +20,8 @@
2020

2121
from pathlib import Path
2222

23-
from codechecker_common import logger
2423
from codechecker_analyzer.arg import analyzer_binary
24+
from codechecker_common import logger
2525
from codechecker_common.checker_labels import CheckerLabels
2626
from codechecker_common.singleton import Singleton
2727
from codechecker_common.util import load_json
@@ -92,7 +92,7 @@ def __init__(self):
9292
self.__populate_analyzers()
9393
self.__populate_replacer()
9494

95-
def __parse_CC_ANALYZER_BIN(self):
95+
def __parse_cc_analyzer_bin(self):
9696
env_var_bins = {}
9797
if 'CC_ANALYZER_BIN' in self.analyzer_env:
9898
had_error = False
@@ -202,7 +202,7 @@ def __populate_analyzers(self):
202202
if not analyzer_from_path:
203203
analyzer_env = self.analyzer_env
204204

205-
env_var_bin = self.__parse_CC_ANALYZER_BIN()
205+
env_var_bin = self.__parse_cc_analyzer_bin()
206206

207207
compiler_binaries = self.pckg_layout.get('analyzers')
208208
for name, value in compiler_binaries.items():

analyzer/codechecker_analyzer/analyzers/analyzer_base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ def resolve_missing_binary(cls, configured_binary, environ):
5656
"""
5757
raise NotImplementedError("Subclasses should implement this!")
5858

59+
@classmethod
5960
@abstractmethod
60-
def get_binary_version(self, environ, details=False) -> str:
61+
def get_binary_version(cls, environ, details=False) -> str:
6162
"""
6263
Return the version number of the binary that CodeChecker found, even
6364
if its incompatible. If details is true, additional version information
@@ -138,7 +139,6 @@ def post_analyze(self, result_handler):
138139
"""
139140
Run immediately after the analyze function.
140141
"""
141-
pass
142142

143143
@staticmethod
144144
def run_proc(command, cwd=None, proc_callback=None, env=None):
@@ -147,7 +147,7 @@ def run_proc(command, cwd=None, proc_callback=None, env=None):
147147
and the stdout and stderr outputs of the process.
148148
"""
149149

150-
def signal_handler(signum, frame):
150+
def signal_handler(signum, _):
151151
# Clang does not kill its child processes, so I have to.
152152
try:
153153
g_pid = proc.pid

analyzer/codechecker_analyzer/analyzers/analyzer_types.py

+11-18
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,17 @@ def check_supported_analyzers(analyzers):
209209
return enabled_analyzers, failed_analyzers
210210

211211

212-
def construct_analyzer(buildaction,
213-
analyzer_config):
214-
try:
215-
analyzer_type = buildaction.analyzer_type
216-
217-
LOG.debug_analyzer('Constructing %s analyzer.', analyzer_type)
218-
if analyzer_type in supported_analyzers:
219-
analyzer = supported_analyzers[analyzer_type](analyzer_config,
220-
buildaction)
221-
else:
222-
analyzer = None
223-
LOG.error('Unsupported analyzer type: %s', analyzer_type)
224-
return analyzer
225-
226-
except Exception:
227-
# We should've detected well before this point that something is off
228-
# with the analyzer. We can't recover here.
229-
raise
212+
def construct_analyzer(buildaction, analyzer_config):
213+
analyzer_type = buildaction.analyzer_type
214+
215+
LOG.debug_analyzer('Constructing %s analyzer.', analyzer_type)
216+
if analyzer_type in supported_analyzers:
217+
analyzer = \
218+
supported_analyzers[analyzer_type](analyzer_config, buildaction)
219+
else:
220+
analyzer = None
221+
LOG.error('Unsupported analyzer type: %s', analyzer_type)
222+
return analyzer
230223

231224

232225
def build_config_handlers(args, enabled_analyzers):

analyzer/codechecker_analyzer/analyzers/clangsa/analyzer.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class ClangSA(analyzer_base.SourceAnalyzer):
121121
__ctu_autodetection = None
122122

123123
def __init__(self, cfg_handler, buildaction):
124-
super(ClangSA, self).__init__(cfg_handler, buildaction)
124+
super().__init__(cfg_handler, buildaction)
125125
self.__disable_ctu = False
126126
self.__checker_configs = []
127127
self.__disabled_checkers = []
@@ -171,25 +171,25 @@ def __add_plugin_load_flags(cls, analyzer_cmd: List[str]):
171171
analyzer_cmd.extend(["-load", plugin])
172172

173173
@classmethod
174-
def get_binary_version(self, environ, details=False) -> str:
174+
def get_binary_version(cls, environ, details=False) -> str:
175175
# No need to LOG here, we will emit a warning later anyway.
176-
if not self.analyzer_binary():
176+
if not cls.analyzer_binary():
177177
return None
178178

179179
if details:
180-
version = [self.analyzer_binary(), '--version']
180+
ver = [cls.analyzer_binary(), '--version']
181181
else:
182-
version = [self.analyzer_binary(), '-dumpversion']
182+
ver = [cls.analyzer_binary(), '-dumpversion']
183183
try:
184-
output = subprocess.check_output(version,
184+
output = subprocess.check_output(ver,
185185
env=environ,
186186
universal_newlines=True,
187187
encoding="utf-8",
188188
errors="ignore")
189189
return output.strip()
190190
except (subprocess.CalledProcessError, OSError) as oerr:
191191
LOG.warning("Failed to get analyzer version: %s",
192-
' '.join(version))
192+
' '.join(ver))
193193
LOG.warning(oerr)
194194

195195
return None
@@ -405,9 +405,9 @@ def construct_analyzer_cmd(self, result_handler):
405405
enabled_checkers = []
406406
for checker_name, value in config.checks().items():
407407
state, _ = value
408-
if state == CheckerState.enabled:
408+
if state == CheckerState.ENABLED:
409409
enabled_checkers.append(checker_name)
410-
elif state == CheckerState.disabled:
410+
elif state == CheckerState.DISABLED:
411411
self.__disabled_checkers.append(checker_name)
412412

413413
if enabled_checkers:

analyzer/codechecker_analyzer/analyzers/clangsa/config_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ClangSAConfigHandler(config_handler.AnalyzerConfigHandler):
2121
"""
2222

2323
def __init__(self, environ):
24-
super(ClangSAConfigHandler, self).__init__()
24+
super().__init__()
2525
self.ctu_dir = ''
2626
self.ctu_on_demand = False
2727
self.enable_z3 = False

analyzer/codechecker_analyzer/analyzers/clangsa/ctu_autodetection.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,21 @@ def __init__(self, analyzer_binary, environ):
120120
LOG.debug(
121121
'Trying to detect CTU capability, but analyzer binary is not '
122122
'set!')
123-
return None
123+
return
124124

125125
analyzer_version = invoke_binary_checked(
126126
self.__analyzer_binary, ['--version'], self.environ)
127127

128128
if analyzer_version is False:
129129
LOG.debug('Failed to invoke command to get Clang version!')
130-
return None
130+
return
131131

132132
version_parser = version.ClangVersionInfoParser(self.__analyzer_binary)
133133
version_info = version_parser.parse(analyzer_version)
134134

135135
if not version_info:
136136
LOG.debug('Failed to parse Clang version information!')
137-
return None
137+
return
138138

139139
self.__analyzer_version_info = version_info
140140

analyzer/codechecker_analyzer/analyzers/clangsa/ctu_manager.py

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
LOG = get_logger('analyzer')
3131

3232

33+
# The inheritence comes from the YAML parser, we can't solve it with less
34+
# ancestors.
35+
# pylint: disable=too-many-ancestors
3336
class LLVMComatibleYamlDumper(Dumper):
3437
def check_simple_key(self):
3538
""" Mark every keys as simple keys.

analyzer/codechecker_analyzer/analyzers/clangsa/ctu_triple_arch.py

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def _find_arch_in_command(output):
6262
except ValueError:
6363
pass
6464

65+
return None
66+
6567

6668
def get_triple_arch(action, source, config):
6769
"""Returns the architecture part of the target triple for the given

analyzer/codechecker_analyzer/analyzers/clangsa/result_handler.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class ClangSAResultHandler(ResultHandler):
3232

3333
def __init__(self, *args, **kwargs):
3434
self.analyzer_info = AnalyzerInfo(name='clangsa')
35-
36-
super(ClangSAResultHandler, self).__init__(*args, **kwargs)
35+
super().__init__(*args, **kwargs)
3736

3837
def postprocess_result(
3938
self,

analyzer/codechecker_analyzer/analyzers/clangsa/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def parse(self, version_string):
5151
"""Try to parse the version string using the predefined patterns."""
5252
version_match = re.search(self.clang_version_pattern, version_string)
5353
if not version_match:
54-
return
54+
return None
5555

5656
installed_dir_match = re.search(
5757
self.clang_installed_dir_pattern, version_string)

0 commit comments

Comments
 (0)