Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ disable=
unspecified-encoding,
global-statement,
protected-access,
redundant-u-string-prefix,
broad-exception-raised,
subprocess-popen-preexec-fn,
format-string-without-interpolation,
cell-var-from-loop,
logging-not-lazy,
unknown-option-value,
implicit-str-concat,
unused-wildcard-import,
pointless-statement,
wildcard-import,
unused-argument,
deprecated-module,
Expand All @@ -38,11 +33,9 @@ disable=
too-many-lines,
trailing-newlines,
missing-final-newline,
unnecessary-negation,
use-implicit-booleaness-not-len,
wrong-import-order,
use-implicit-booleaness-not-comparison,
multiple-imports,
consider-using-enumerate,
unnecessary-lambda-assignment,
consider-using-dict-items,
Expand All @@ -52,23 +45,17 @@ disable=
consider-using-with,
too-many-statements,
too-many-branches,
simplifiable-if-statement,
too-many-locals,
too-many-arguments,
too-few-public-methods,
consider-using-min-builtin,
comparison-with-itself,
too-many-return-statements,
inconsistent-return-statements,
consider-using-in,
too-many-nested-blocks,
too-many-public-methods,
consider-using-sys-exit,
chained-comparison,
too-many-instance-attributes,
consider-using-join,
too-many-boolean-expressions,
useless-object-inheritance,
use-a-generator,
too-many-positional-arguments
[REPORTS]
Expand Down
4 changes: 3 additions & 1 deletion addons/cppcheck.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

import cppcheckdata, sys, os
import cppcheckdata
import sys
import os

__checkers__ = []

Expand Down
1 change: 1 addition & 0 deletions addons/cppcheckdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ def tokAt(self, n):
for i, t in enumerate(tl):
if i == n:
return t
return None

def linkAt(self, n):
token = self.tokAt(n)
Expand Down
4 changes: 2 additions & 2 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ def remove_file_prefix(file_path, prefix):
return result


class Rule(object):
class Rule():
"""Class to keep rule text and metadata"""

MISRA_SEVERITY_LEVELS = ['Required', 'Mandatory', 'Advisory']
Expand Down Expand Up @@ -1326,7 +1326,7 @@ def __repr__(self):
return "%d.%d (%s)" % (self.num1, self.num2, self.misra_severity)


class MisraSettings(object):
class MisraSettings():
"""Hold settings for misra.py script."""

__slots__ = ["verify", "quiet", "show_summary"]
Expand Down
6 changes: 5 additions & 1 deletion addons/runaddon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import cppcheckdata, cppcheck, runpy, sys, os
import cppcheckdata
import cppcheck
import runpy
import sys
import os

if __name__ == '__main__':
addon = sys.argv[1]
Expand Down
4 changes: 2 additions & 2 deletions htmlreport/cppcheck-htmlreport
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ HTML_FOOTER = """
HTML_ERROR = "<span class=\"error2\">&lt;--- %s</span>\n"
HTML_INCONCLUSIVE = "<span class=\"inconclusive2\">&lt;--- %s</span>\n"

HTML_EXPANDABLE_ERROR = "<div class=\"verbose expandable\"><span class=\"error2\">&lt;--- %s <span class=\"marker\">[+]</span></span><div class=\"content\">%s</div></div>\n"""
HTML_EXPANDABLE_INCONCLUSIVE = "<div class=\"verbose expandable\"><span class=\"inconclusive2\">&lt;--- %s <span class=\"marker\">[+]</span></span><div class=\"content\">%s</div></div>\n"""
HTML_EXPANDABLE_ERROR = "<div class=\"verbose expandable\"><span class=\"error2\">&lt;--- %s <span class=\"marker\">[+]</span></span><div class=\"content\">%s</div></div>\n"
HTML_EXPANDABLE_INCONCLUSIVE = "<div class=\"verbose expandable\"><span class=\"inconclusive2\">&lt;--- %s <span class=\"marker\">[+]</span></span><div class=\"content\">%s</div></div>\n"

# escape() and unescape() takes care of &, < and >.
html_escape_table = {
Expand Down
6 changes: 3 additions & 3 deletions test/cli/samples_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_samples():

with open(os.path.join(sample_dir, 'out.txt')) as out_in:
out_txt = out_in.read()
if not sys.platform == 'win32':
if sys.platform != 'win32':
out_txt = out_txt.replace('\\', '/')

if not os.path.exists(os.path.join(sample_dir, 'good.c')):
Expand All @@ -30,12 +30,12 @@ def test_samples():

# check that good input does not produce any warnings
ret, _, stderr = cppcheck(['-q', '--enable=all', '--disable=missingInclude', '--inconclusive', '--check-level=exhaustive', '--error-exitcode=1', good_src], cwd=__root_dir)
if not ret == 0:
if ret != 0:
failures[good_src] = stderr

# check that the bad inout produces a warning
ret, _, stderr = cppcheck(['-q', '--enable=all', '--disable=missingInclude', '--inconclusive', '--check-level=exhaustive', '--error-exitcode=1', bad_src], cwd=__root_dir)
if not ret == 1:
if ret != 1:
failures[bad_src] = stderr

# check that the bad input procudes the expected output
Expand Down
11 changes: 6 additions & 5 deletions tools/MT-Unsafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def man_search(manpage):
MANPAGE = open(manpage, 'r')
except OSError as filename:
print('cannot open %s' % filename, file=sys.stderr)
return None, None
return # None, None

vprint(1, '%s opened' % (manpage))

Expand Down Expand Up @@ -95,7 +95,7 @@ def man_search(manpage):
if res:
apis.add(res.group(1))
dprint(1, 'found api %s in %s' % (res.group(1), lineread))
next
continue

if 'MT-Unsafe' in lineread:
resUnsafe = re.search("MT-Unsafe\\s+(.*)(\\n\'|$)", lineread)
Expand All @@ -114,7 +114,7 @@ def man_search(manpage):
dprint(1, 'new apis %s' % list(apis))
for api in apis:
unsafe_apis.add(api)
next
continue

# if lineread.startswith('.TE'):
if re.search('.TE', lineread):
Expand Down Expand Up @@ -147,7 +147,8 @@ def do_man_dir(directory):
"""Recursively process a directory of man-pages."""
dprint(1, 'do_man_dir(%s)' % (directory))
if os.path.isfile(directory):
return do_man_page(directory)
do_man_page(directory)
return

for path, _, files in os.walk(directory):
for file in files:
Expand All @@ -162,7 +163,7 @@ def do_man_dir(directory):
if re.match('^-+debug', arg):
debug = debug+1
dprint(1, 'debug %d' % debug)
next
continue
else:
if os.access(arg, os.R_OK):
manpages.add(arg)
Expand Down
8 changes: 7 additions & 1 deletion tools/creduce.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import argparse, contextlib, multiprocessing, os, tempfile, shutil, subprocess
import argparse
import contextlib
import multiprocessing
import os
import tempfile
import shutil
import subprocess

@contextlib.contextmanager
def mkdtemp():
Expand Down
4 changes: 2 additions & 2 deletions tools/donate-cpu-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
# changes)
SERVER_VERSION = "1.3.59"
SERVER_VERSION = "1.3.60"

OLD_VERSION = '2.15.0'

Expand Down Expand Up @@ -1585,7 +1585,7 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa

print_ts('packages_nodata: {}'.format(len(packages_nodata)))

print_ts('removing packages with no files to process'.format(len(packages_nodata)))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't the intent to print the number of packages (i.e. {} missing)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It is just c&p error - this is just to indicate the operation is taking place. There are further log message which provide all the remaining details.

print_ts('removing packages with no files to process')
packages_nodata_clean = []
for pkg_n in packages_nodata:
if pkg_n in packages:
Expand Down
6 changes: 3 additions & 3 deletions tools/donate-cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,16 @@
cppcheck_head_info = lib.get_cppcheck_info(tree_path)
capture_callstack = True

def get_client_version_head():
cmd = 'python3' + ' ' + os.path.join(tree_path, 'tools', 'donate-cpu.py') + ' ' + '--version'
def get_client_version_head(path):
cmd = 'python3' + ' ' + os.path.join(path, 'tools', 'donate-cpu.py') + ' ' + '--version'
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, universal_newlines=True)
try:
comm = p.communicate()
return comm[0].strip()
except:
return None

client_version_head = get_client_version_head()
client_version_head = get_client_version_head(tree_path)
c, errout, info, t, cppcheck_options, timing_info = lib.scan_package(tree_path, source_path, libraries, capture_callstack)
if c < 0:
if c == -101 and 'error: could not find or open any of the paths given.' in errout:
Expand Down
4 changes: 3 additions & 1 deletion tools/donate_cpu_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
# changes)
CLIENT_VERSION = "1.3.62"
CLIENT_VERSION = "1.3.63"

# Timeout for analysis with Cppcheck in seconds
CPPCHECK_TIMEOUT = 30 * 60
Expand Down Expand Up @@ -80,6 +80,7 @@ def check_requirements():


# Try and retry with exponential backoff if an exception is raised
# pylint: disable-next=inconsistent-return-statements
def try_retry(fun, fargs=(), max_tries=5, sleep_duration=5.0, sleep_factor=2.0):
for i in range(max_tries):
try:
Expand All @@ -93,6 +94,7 @@ def try_retry(fun, fargs=(), max_tries=5, sleep_duration=5.0, sleep_factor=2.0):
print("Trying {} again in {} seconds".format(fun.__name__, sleep_duration))
time.sleep(sleep_duration)
sleep_duration *= sleep_factor
# do not return - re-try
else:
print("Maximum number of tries reached for {}".format(fun.__name__))
raise e
Expand Down
20 changes: 9 additions & 11 deletions tools/matchcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def convertFile(self, srcname, destname, line_directive):
srclines = fin.readlines()
fin.close()

code = u''
code = ''

modified = False

Expand All @@ -710,20 +710,18 @@ def convertFile(self, srcname, destname, line_directive):
code += line

# Compute matchFunctions
strFunctions = u''
for function in self._rawMatchFunctions:
strFunctions += function
strFunctions = ''.join(self._rawMatchFunctions)

lineno = u''
lineno = ''
if line_directive:
lineno = u'#line 1 "' + srcname + '"\n'
lineno = '#line 1 "' + srcname + '"\n'

header = u'#include "matchcompiler.h"\n'
header += u'#include <string>\n'
header += u'#include <cstring>\n'
header = '#include "matchcompiler.h"\n'
header += '#include <string>\n'
header += '#include <cstring>\n'
if len(self._rawMatchFunctions):
header += u'#include "errorlogger.h"\n'
header += u'#include "token.h"\n'
header += '#include "errorlogger.h"\n'
header += '#include "token.h"\n'

fout = io.open(destname, 'wt', encoding="utf-8")
if modified or len(self._rawMatchFunctions):
Expand Down
8 changes: 2 additions & 6 deletions tools/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ def combinelines(self, filedata):
i1 = i
i2 = i + chunksize
i = i2
if i2 > len(lines):
i2 = len(lines)
i2 = min(i2, len(lines))

filedata2 = list(filedata)
for line in lines[i1:i2]:
Expand Down Expand Up @@ -259,10 +258,7 @@ def removeline(self, filedata):
elif stmt and '{' in strippedline and strippedline.find('}') == len(strippedline) - 1:
self.replaceandrun('remove line', filedata, i, '')

if strippedline[-1] in ';{}':
stmt = True
else:
stmt = False
stmt = strippedline[-1] in ';{}'

def set_elapsed_time(self, elapsed_time):
self.__elapsed_time = elapsed_time
Expand Down
3 changes: 2 additions & 1 deletion tools/reduce_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ def test_combinelines_chunk_2():
's,\n',
't;\n'
]
filedata_exp = filedata

filedata2 = reduce.combinelines(filedata)
assert filedata == filedata
assert filedata == filedata_exp
assert filedata2 == ['int i,j,\n',
'',
'l,\n',
Expand Down
2 changes: 1 addition & 1 deletion tools/triage_py/triage_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def sort_commit_hashes(commits):
if args.perf:
if out == "timeout":
data_str = "0.0" # TODO: how to handle these properly?
elif not ec == 0:
elif ec != 0:
continue # skip errors
else:
data_str = '{}'.format((end - start) / 1000.0 / 1000.0 / 1000.0)
Expand Down