Eliminate the pylint warnings and update the pylint configuration (#2210)
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
committed by
Dániel Bátyai
parent
88f7baa192
commit
fbc53f78b7
+2
-4
@@ -22,7 +22,8 @@ script: tools/run-tests.py $OPTS
|
||||
# All the job definitions in the matrix.
|
||||
matrix:
|
||||
include:
|
||||
- env: OPTS="--check-signed-off=travis --check-cppcheck --check-doxygen --check-vera --check-license --check-magic-strings"
|
||||
- env: OPTS="--check-signed-off=travis --check-cppcheck --check-doxygen --check-vera --check-license --check-magic-strings --check-pylint"
|
||||
install: pip install --user pylint==1.6.5
|
||||
- env: OPTS="--jerry-debugger"
|
||||
- env: OPTS="--jerry-tests --jerry-test-suite"
|
||||
- env: OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake" TIMEOUT=300
|
||||
@@ -33,8 +34,6 @@ matrix:
|
||||
- env: OPTS="--unittests --buildoptions=--cmake-param=-DFEATURE_INIT_FINI=ON"
|
||||
- env: OPTS="--test262"
|
||||
install: sudo timedatectl set-timezone America/Los_Angeles
|
||||
- env: OPTS="--check-pylint"
|
||||
install: pip install --user pylint==1.6.5
|
||||
- os: osx
|
||||
before_install: tools/brew-install-deps.sh
|
||||
env: OPTS="--jerry-tests --jerry-test-suite --unittests"
|
||||
@@ -112,7 +111,6 @@ matrix:
|
||||
install: make -f ./targets/zephyr/Makefile.travis install
|
||||
script: make -f ./targets/zephyr/Makefile.travis script
|
||||
allow_failures:
|
||||
- env: OPTS="--check-pylint"
|
||||
- env: JOBNAME="Mbed/K64F Build Test"
|
||||
fast_finish: true
|
||||
|
||||
|
||||
@@ -159,9 +159,8 @@ class JerryPendingBreakpoint(object):
|
||||
return result
|
||||
|
||||
|
||||
|
||||
class JerryFunction(object):
|
||||
|
||||
# pylint: disable=too-many-instance-attributes,too-many-arguments
|
||||
def __init__(self, is_func, byte_code_cp, source, source_name, line, column, name, lines, offsets):
|
||||
self.is_func = is_func
|
||||
self.byte_code_cp = byte_code_cp
|
||||
@@ -176,10 +175,9 @@ class JerryFunction(object):
|
||||
self.first_breakpoint_offset = offsets[0]
|
||||
|
||||
if len(self.source) > 1 and not self.source[-1]:
|
||||
self.source.pop()
|
||||
self.source.pop()
|
||||
|
||||
for i in range(len(lines)):
|
||||
line = lines[i]
|
||||
for i, line in enumerate(lines):
|
||||
offset = offsets[i]
|
||||
breakpoint = JerryBreakpoint(line, offset, self)
|
||||
self.lines[line] = breakpoint
|
||||
@@ -215,17 +213,11 @@ class DebuggerPrompt(Cmd):
|
||||
def postcmd(self, stop, line):
|
||||
return self.stop
|
||||
|
||||
def disable_args(self, args):
|
||||
if args:
|
||||
print("Error: No argument expected")
|
||||
return True
|
||||
return False
|
||||
|
||||
def do_quit(self, args):
|
||||
""" Exit JerryScript debugger """
|
||||
self.do_delete("all")
|
||||
self.do_exception("0") # disable the exception handler
|
||||
self.exec_command(args, JERRY_DEBUGGER_CONTINUE)
|
||||
self._exec_command(args, JERRY_DEBUGGER_CONTINUE)
|
||||
self.stop = True
|
||||
self.quit = True
|
||||
|
||||
@@ -247,7 +239,7 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
do_b = do_break
|
||||
|
||||
def exec_command(self, args, command_id):
|
||||
def _exec_command(self, args, command_id):
|
||||
self.stop = True
|
||||
if args != "":
|
||||
print("Error: No argument expected")
|
||||
@@ -256,7 +248,7 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
def do_continue(self, args):
|
||||
""" Continue execution """
|
||||
self.exec_command(args, JERRY_DEBUGGER_CONTINUE)
|
||||
self._exec_command(args, JERRY_DEBUGGER_CONTINUE)
|
||||
self.stop = True
|
||||
self.cont = True
|
||||
if not self.non_interactive:
|
||||
@@ -266,19 +258,19 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
def do_step(self, args):
|
||||
""" Next breakpoint, step into functions """
|
||||
self.exec_command(args, JERRY_DEBUGGER_STEP)
|
||||
self._exec_command(args, JERRY_DEBUGGER_STEP)
|
||||
self.cont = True
|
||||
|
||||
do_s = do_step
|
||||
|
||||
def do_next(self, args):
|
||||
""" Next breakpoint in the same context """
|
||||
self.exec_command(args, JERRY_DEBUGGER_NEXT)
|
||||
self._exec_command(args, JERRY_DEBUGGER_NEXT)
|
||||
self.cont = True
|
||||
|
||||
do_n = do_next
|
||||
|
||||
def do_list(self, args):
|
||||
def do_list(self, _):
|
||||
""" Lists the available breakpoints """
|
||||
if self.debugger.active_breakpoint_list:
|
||||
print("=== %sActive breakpoints %s ===" % (self.debugger.green_bg, self.debugger.nocolor))
|
||||
@@ -324,7 +316,8 @@ class DebuggerPrompt(Cmd):
|
||||
else:
|
||||
print("Error: Breakpoint %d not found" % (breakpoint_index))
|
||||
|
||||
def exec_backtrace(self, args):
|
||||
def do_backtrace(self, args):
|
||||
""" Get backtrace data from debugger """
|
||||
max_depth = 0
|
||||
|
||||
if args:
|
||||
@@ -346,10 +339,6 @@ class DebuggerPrompt(Cmd):
|
||||
self.debugger.send_message(message)
|
||||
self.stop = True
|
||||
|
||||
def do_backtrace(self, args):
|
||||
""" Get backtrace data from debugger """
|
||||
self.exec_backtrace(args)
|
||||
|
||||
do_bt = do_backtrace
|
||||
|
||||
def do_src(self, args):
|
||||
@@ -365,7 +354,7 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
do_source = do_src
|
||||
|
||||
def scroll_direction(self, args):
|
||||
def _scroll_direction(self, args):
|
||||
""" Helper function for do_scroll """
|
||||
self.debugger.src_offset_diff = int(max(math.floor(self.debugger.display / 3), 1))
|
||||
if args in "up":
|
||||
@@ -375,16 +364,16 @@ class DebuggerPrompt(Cmd):
|
||||
self.debugger.src_offset += self.debugger.src_offset_diff
|
||||
print_source(self.debugger, self.debugger.display, self.debugger.src_offset)
|
||||
|
||||
def do_scroll(self, args):
|
||||
def do_scroll(self, _):
|
||||
""" Scroll the source up or down """
|
||||
while True:
|
||||
key = sys.stdin.readline()
|
||||
if key == 'w\n':
|
||||
self.scroll_direction("up")
|
||||
self._scroll_direction("up")
|
||||
elif key == 's\n':
|
||||
self.scroll_direction("down")
|
||||
self._scroll_direction("down")
|
||||
elif key == 'q\n':
|
||||
break;
|
||||
break
|
||||
else:
|
||||
print("Invalid key")
|
||||
|
||||
@@ -403,12 +392,13 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
def do_dump(self, args):
|
||||
""" Dump all of the debugger data """
|
||||
if self.disable_args(args):
|
||||
if args:
|
||||
print("Error: No argument expected")
|
||||
return
|
||||
|
||||
pprint(self.debugger.function_list)
|
||||
|
||||
def send_string(self, args, message_type):
|
||||
def _send_string(self, args, message_type):
|
||||
size = len(args)
|
||||
if size == 0:
|
||||
return
|
||||
@@ -459,7 +449,7 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
def do_eval(self, args):
|
||||
""" Evaluate JavaScript source code """
|
||||
self.send_string(args, JERRY_DEBUGGER_EVAL)
|
||||
self._send_string(args, JERRY_DEBUGGER_EVAL)
|
||||
|
||||
do_e = do_eval
|
||||
|
||||
@@ -483,7 +473,7 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
def do_memstats(self, args):
|
||||
""" Memory statistics """
|
||||
self.exec_command(args, JERRY_DEBUGGER_MEMSTATS)
|
||||
self._exec_command(args, JERRY_DEBUGGER_MEMSTATS)
|
||||
return
|
||||
|
||||
do_ms = do_memstats
|
||||
@@ -502,12 +492,12 @@ class DebuggerPrompt(Cmd):
|
||||
sys.exit("Error: Javascript file expected!")
|
||||
return
|
||||
|
||||
with open(path, 'r') as f:
|
||||
content = path + "\0" + f.read()
|
||||
self.send_string(content, JERRY_DEBUGGER_CLIENT_SOURCE)
|
||||
with open(path, 'r') as src_file:
|
||||
content = path + "\0" + src_file.read()
|
||||
self._send_string(content, JERRY_DEBUGGER_CLIENT_SOURCE)
|
||||
|
||||
def send_no_more_source(self):
|
||||
self.exec_command("", JERRY_DEBUGGER_NO_MORE_SOURCES)
|
||||
self._exec_command("", JERRY_DEBUGGER_NO_MORE_SOURCES)
|
||||
self.cont = True
|
||||
|
||||
class Multimap(object):
|
||||
@@ -539,7 +529,7 @@ class Multimap(object):
|
||||
|
||||
|
||||
class JerryDebugger(object):
|
||||
|
||||
# pylint: disable=too-many-instance-attributes,too-many-statements
|
||||
def __init__(self, address):
|
||||
|
||||
if ":" not in address:
|
||||
@@ -768,6 +758,7 @@ class JerryDebugger(object):
|
||||
self.message_data += data
|
||||
|
||||
|
||||
# pylint: disable=too-many-branches,too-many-locals,too-many-statements
|
||||
def parse_source(debugger, data):
|
||||
source_code = ""
|
||||
source_code_name = ""
|
||||
@@ -1061,6 +1052,7 @@ def get_breakpoint(debugger, breakpoint_data):
|
||||
return (function.offsets[nearest_offset], False)
|
||||
|
||||
|
||||
# pylint: disable=too-many-branches,too-many-locals,too-many-statements
|
||||
def main():
|
||||
args = arguments_parse()
|
||||
|
||||
@@ -1260,16 +1252,12 @@ if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except socket.error as error_msg:
|
||||
try:
|
||||
errno = error_msg.errno
|
||||
msg = str(error_msg)
|
||||
except:
|
||||
errno = error_msg[0]
|
||||
msg = error_msg[1]
|
||||
ERRNO = error_msg.errno
|
||||
MSG = str(error_msg)
|
||||
|
||||
if errno == 111:
|
||||
if ERRNO == 111:
|
||||
sys.exit("Failed to connect to the JerryScript debugger.")
|
||||
elif errno == 32 or errno == 104:
|
||||
elif ERRNO == 32 or ERRNO == 104:
|
||||
sys.exit("Connection closed.")
|
||||
else:
|
||||
sys.exit("Failed to connect to the JerryScript debugger.\nError: %s" % (msg))
|
||||
sys.exit("Failed to connect to the JerryScript debugger.\nError: %s" % (MSG))
|
||||
|
||||
@@ -51,9 +51,9 @@ def get_args():
|
||||
|
||||
def check_files(opts):
|
||||
files = [JERRY_BUILDER, opts.testfile]
|
||||
for file in files:
|
||||
if not os.path.isfile(file):
|
||||
sys.exit("File not found: %s" % file)
|
||||
for _file in files:
|
||||
if not os.path.isfile(_file):
|
||||
sys.exit("File not found: %s" % _file)
|
||||
|
||||
|
||||
def build_bin(heapsize, opts):
|
||||
|
||||
@@ -59,7 +59,7 @@ confidence=
|
||||
# --enable=similarities". If you want to run only the classes checker, but have
|
||||
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||
# --disable=W"
|
||||
disable=import-star-module-level,old-octal-literal,oct-method,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,missing-docstring
|
||||
disable=import-star-module-level,old-octal-literal,oct-method,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,missing-docstring,locally-disabled
|
||||
|
||||
|
||||
[REPORTS]
|
||||
@@ -131,7 +131,7 @@ single-line-if-stmt=no
|
||||
no-space-check=trailing-comma,dict-separator
|
||||
|
||||
# Maximum number of lines in a module
|
||||
max-module-lines=1000
|
||||
max-module-lines=2000
|
||||
|
||||
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||
# tab).
|
||||
@@ -328,7 +328,7 @@ max-parents=7
|
||||
max-attributes=7
|
||||
|
||||
# Minimum number of public methods for a class (see R0903).
|
||||
min-public-methods=2
|
||||
min-public-methods=0
|
||||
|
||||
# Maximum number of public methods for a class (see R0904).
|
||||
max-public-methods=20
|
||||
|
||||
+14
-12
@@ -25,11 +25,8 @@ import settings
|
||||
|
||||
OUTPUT_DIR = os.path.join(settings.PROJECT_DIR, 'build', 'tests')
|
||||
|
||||
class Options(object):
|
||||
def __init__(self, name, build_args=None, test_args=None):
|
||||
self.name = name
|
||||
self.build_args = build_args or []
|
||||
self.test_args = test_args or []
|
||||
Options = collections.namedtuple('Options', ['name', 'build_args', 'test_args'])
|
||||
Options.__new__.__defaults__ = ([], [])
|
||||
|
||||
def get_binary_path(bin_dir_path):
|
||||
return os.path.join(bin_dir_path, 'jerry')
|
||||
@@ -37,13 +34,17 @@ def get_binary_path(bin_dir_path):
|
||||
# Test options for unittests
|
||||
JERRY_UNITTESTS_OPTIONS = [
|
||||
Options('unittests',
|
||||
['--unittests', '--jerry-cmdline=off', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset', '--mem-stats=on']),
|
||||
['--unittests', '--jerry-cmdline=off', '--error-messages=on', '--snapshot-save=on',
|
||||
'--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset', '--mem-stats=on']),
|
||||
Options('unittests-debug',
|
||||
['--unittests', '--jerry-cmdline=off', '--debug', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset', '--mem-stats=on']),
|
||||
['--unittests', '--jerry-cmdline=off', '--debug', '--error-messages=on', '--snapshot-save=on',
|
||||
'--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset', '--mem-stats=on']),
|
||||
Options('doctests',
|
||||
['--doctests', '--jerry-cmdline=off', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset']),
|
||||
['--doctests', '--jerry-cmdline=off', '--error-messages=on', '--snapshot-save=on',
|
||||
'--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset']),
|
||||
Options('doctests-debug',
|
||||
['--doctests', '--jerry-cmdline=off', '--debug', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset'])
|
||||
['--doctests', '--jerry-cmdline=off', '--debug', '--error-messages=on',
|
||||
'--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset'])
|
||||
]
|
||||
|
||||
# Test options for jerry-tests
|
||||
@@ -84,7 +85,8 @@ JERRY_TEST_SUITE_OPTIONS.extend([
|
||||
['--profile=es2015-subset', '--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on'],
|
||||
['--snapshot']),
|
||||
Options('jerry_test_suite-es2015_subset-debug-snapshot',
|
||||
['--debug', '--profile=es2015-subset', '--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on'],
|
||||
['--debug', '--profile=es2015-subset', '--snapshot-save=on', '--snapshot-exec=on',
|
||||
'--jerry-cmdline-snapshot=on'],
|
||||
['--snapshot'])
|
||||
])
|
||||
|
||||
@@ -342,9 +344,9 @@ def run_buildoption_test(options):
|
||||
|
||||
return ret
|
||||
|
||||
def main(options):
|
||||
Check = collections.namedtuple('Check', ['enabled', 'runner', 'arg'])
|
||||
Check = collections.namedtuple('Check', ['enabled', 'runner', 'arg'])
|
||||
|
||||
def main(options):
|
||||
checks = [
|
||||
Check(options.check_signed_off, run_check, [settings.SIGNED_OFF_SCRIPT]
|
||||
+ {'tolerant': ['--tolerant'], 'travis': ['--travis']}.get(options.check_signed_off, [])),
|
||||
|
||||
Reference in New Issue
Block a user