Skip to content

Commit

Permalink
enabled and fixed no-else-continue pylint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Oct 7, 2024
1 parent cad4d9c commit 1c1330a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ disable=
consider-using-min-builtin,
comparison-with-itself,
too-many-return-statements,
no-else-continue,
inconsistent-return-statements,
consider-using-in,
too-many-nested-blocks,
Expand Down
6 changes: 3 additions & 3 deletions addons/cppcheckdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ def iterconfigurations(self):
if event == 'start':
cfg = Configuration(node.get('cfg'))
continue
elif event == 'end':
if event == 'end':
cfg.setIdMap(cfg_arguments)
yield cfg
cfg = None
Expand Down Expand Up @@ -1353,7 +1353,7 @@ def iterconfigurations(self):
if event == 'start':
cfg_function = Function(node, cfg.scopes[-1])
continue
elif event == 'end':
if event == 'end':
cfg.functions.append(cfg_function)
cfg_function = None

Expand Down Expand Up @@ -1397,7 +1397,7 @@ def iterconfigurations(self):
if event == 'start':
cfg_valueflow = ValueFlow(node)
continue
elif event == 'end':
if event == 'end':
cfg.valueflow.append(cfg_valueflow)
cfg_valueflow = None

Expand Down
14 changes: 6 additions & 8 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,8 +1692,7 @@ def misra_4_1(self, rawTokens):
if (isHexEscapeSequence(sequence) or isOctalEscapeSequence(sequence) or
isSimpleEscapeSequence(sequence)):
continue
else:
self.reportError(token, 4, 1)
self.reportError(token, 4, 1)

def misra_4_2(self, rawTokens):
for token in rawTokens:
Expand Down Expand Up @@ -2809,7 +2808,7 @@ def misra_12_4(self, cfg):
while expr.str not in (";", "{", "}"):
expr = expr.next
continue
elif known_value == 0:
if known_value == 0:
expr = expr.astOperand2
self.misra_12_4_check_expr(expr)

Expand All @@ -2832,8 +2831,7 @@ def misra_13_1(self, data):
if tn and tn.next and tn.next.str == '=':
tn = tn.next.next
continue
else:
break
break
if tn.str == '.' and tn.next and tn.next.isName:
tn = tn.next
if tn.next and tn.next.str == '=':
Expand Down Expand Up @@ -4429,9 +4427,9 @@ def loadRuleTexts(self, filename):

if severity_loc < 2:
continue
else:
rule.misra_severity = ''
have_severity = True

rule.misra_severity = ''
have_severity = True

if rule is None:
continue
Expand Down
4 changes: 1 addition & 3 deletions htmlreport/cppcheck-htmlreport
Original file line number Diff line number Diff line change
Expand Up @@ -750,9 +750,7 @@ def main() -> None:
with io.open(source_filename, 'r', encoding=options.source_encoding) as input_file:
content = input_file.read()
except IOError:
if error['id'] == 'unmatchedSuppression':
continue # file not found, bail out
else:
if error['id'] != 'unmatchedSuppression':
sys.stderr.write("ERROR: Source file '%s' not found.\n" %
source_filename)
continue
Expand Down
40 changes: 20 additions & 20 deletions tools/donate-cpu-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def generate_package_diff_statistics(filename: str) -> None:
if line == 'diff:':
is_diff = True
continue
elif not is_diff:
if not is_diff:
continue
if not line.endswith(']'):
continue
Expand Down Expand Up @@ -783,7 +783,7 @@ def timeReport(resultPath: str, show_gt: bool, query_params: dict):
if datestr is None and line.startswith(str(current_year) + '-') or line.startswith(str(current_year - 1) + '-'):
datestr = line
continue
elif pkgs is not None and package_url is None and line.startswith('ftp://'):
if pkgs is not None and package_url is None and line.startswith('ftp://'):
package_url = line
if not line.startswith('elapsed-time:'):
continue
Expand Down Expand Up @@ -883,7 +883,7 @@ def timeReportSlow(resultPath: str) -> str:
if datestr is None and line.startswith(str(current_year) + '-') or line.startswith(str(current_year - 1) + '-'):
datestr = line
continue
elif line.startswith('count:'):
if line.startswith('count:'):
count_head = line.split()[1]
if count_head == 'TO!':
# ignore results with timeouts
Expand Down Expand Up @@ -1379,13 +1379,13 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
newThread = HttpClientThread(connection, cmd, resultPath, latestResults)
newThread.start()
continue
elif cmd == 'GetCppcheckVersions\n':
if cmd == 'GetCppcheckVersions\n':
reply = 'head ' + OLD_VERSION
print_ts('GetCppcheckVersions: ' + reply)
connection.send(reply.encode('utf-8', 'ignore'))
connection.close()
continue
elif cmd == 'get\n':
if cmd == 'get\n':
while True:
pkg = packages[packageIndex]
packageIndex += 1
Expand All @@ -1401,7 +1401,7 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
connection.send(pkg.encode('utf-8', 'ignore'))
connection.close()
continue
elif cmd.startswith('write\nftp://') or cmd.startswith('write\nhttp://'):
if cmd.startswith('write\nftp://') or cmd.startswith('write\nhttp://'):
t_start = time.perf_counter()
data = read_data(connection, cmd, pos_nl, max_data_size=1024 * 1024, check_done=True, cmd_name='write')
if data is None:
Expand Down Expand Up @@ -1462,7 +1462,7 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
generate_package_diff_statistics(filename)
print_ts('write finished for {} ({} bytes / {}s)'.format(res.group(1), len(data), (time.perf_counter() - t_start)))
continue
elif cmd.startswith('write_info\nftp://') or cmd.startswith('write_info\nhttp://'):
if cmd.startswith('write_info\nftp://') or cmd.startswith('write_info\nhttp://'):
t_start = time.perf_counter()
data = read_data(connection, cmd, pos_nl, max_data_size=7 * 1024 * 1024, check_done=True, cmd_name='write_info')
if data is None:
Expand Down Expand Up @@ -1501,13 +1501,13 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
f.write(strDateTime() + '\n' + data)
print_ts('write_info finished for {} ({} bytes / {}s)'.format(res.group(1), len(data), (time.perf_counter() - t_start)))
continue
elif cmd == 'getPackagesCount\n':
if cmd == 'getPackagesCount\n':
packages_count = str(len(packages))
connection.send(packages_count.encode('utf-8', 'ignore'))
print_ts('getPackagesCount: ' + packages_count)
connection.close()
continue
elif cmd.startswith('getPackageIdx'):
if cmd.startswith('getPackageIdx'):
request_idx = abs(int(cmd[len('getPackageIdx:'):]))
if request_idx < len(packages):
pkg = packages[request_idx]
Expand All @@ -1517,7 +1517,7 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
print_ts('getPackageIdx: index {} is out of range'.format(request_idx))
connection.close()
continue
elif cmd.startswith('write_nodata\nftp://'):
if cmd.startswith('write_nodata\nftp://'):
data = read_data(connection, cmd, pos_nl, max_data_size=8 * 1024, check_done=False, cmd_name='write_nodata')
if data is None:
continue
Expand Down Expand Up @@ -1549,17 +1549,17 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
print_ts('write_nodata:' + url + ' - package not found')
break
continue

if pos_nl < 0:
print_ts('invalid command: "' + firstLine + '"')
else:
if pos_nl < 0:
print_ts('invalid command: "' + firstLine + '"')
else:
lines = cmd.split('\n')
s = '\\n'.join(lines[:2])
if len(lines) > 2:
s += '...'
print_ts('invalid command: "' + s + '"')
connection.close()
continue
lines = cmd.split('\n')
s = '\\n'.join(lines[:2])
if len(lines) > 2:
s += '...'
print_ts('invalid command: "' + s + '"')
connection.close()
continue


if __name__ == "__main__":
Expand Down

0 comments on commit 1c1330a

Please sign in to comment.