.travis.yml: Check more Python scripts with pylint (#2019)

Use renamed pylintrc file that is only meant for Travis checks.

Check all Python scripts in 'addons', 'htmlreport' and 'tools'

Errors for `_socketobject` class are disabled, see
https://stackoverflow.com/questions/10300082/how-to-prevent-python-pylint-complaining-about-socket-class-sendall-method

Install imported modules `unittest2` and `pexpect` via pip.

Add "./addons" to search-path for modules because
"tools/compare-ast-clang-and-cppcheck.py" imports cppcheckdata.py from
addons. Pylint does not seem to evaluate
`sys.path.insert(0, '../addons')` in the script. So an `init-hook` is
necessary in pylintrc_travis.
This commit is contained in:
Sebastian 2019-07-24 21:09:53 +02:00 committed by GitHub
parent 744a94ad5a
commit 8f92c43567
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 9 deletions

View File

@ -21,6 +21,8 @@ before_install:
- travis_retry sudo apt-get install -qq python-pygments qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet - travis_retry sudo apt-get install -qq python-pygments qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet
- travis_retry sudo python2 -m pip install --upgrade pytest==4.6.4 - travis_retry sudo python2 -m pip install --upgrade pytest==4.6.4
- travis_retry python2 -m pip install --user pylint - travis_retry python2 -m pip install --user pylint
- travis_retry python2 -m pip install --user unittest2
- travis_retry python2 -m pip install --user pexpect
matrix: matrix:
# do notify immediately about it when a job of a build fails. # do notify immediately about it when a job of a build fails.
@ -86,10 +88,10 @@ matrix:
- python -m compileall ./addons - python -m compileall ./addons
- python3 -m compileall ./addons - python3 -m compileall ./addons
# run pylint # run pylint
- cd addons # - pylint --rcfile=pylintrc_travis addons/y2038/*.py ! First resolve https://trac.cppcheck.net/ticket/9210 "y2038 addon no longer working"
# - pylint *.py y2038/*.py ! First resolve https://trac.cppcheck.net/ticket/9210 "y2038 addon no longer working" - pylint --rcfile=pylintrc_travis addons/*.py
- pylint *.py - pylint --rcfile=pylintrc_travis htmlreport/*.py
- cd .. - pylint --rcfile=pylintrc_travis tools/*.py
# check python syntax by compiling some selected scripts # check python syntax by compiling some selected scripts
- python -m py_compile ./tools/donate-cpu.py - python -m py_compile ./tools/donate-cpu.py
- python3 -m py_compile ./tools/donate-cpu.py - python3 -m py_compile ./tools/donate-cpu.py

View File

@ -1,5 +0,0 @@
# Just the severe stuff...
[MESSAGES CONTROL]
disable=C,R,W
[REPORTS]
reports=no

10
pylintrc_travis Normal file
View File

@ -0,0 +1,10 @@
# Just the severe stuff...
[MESSAGES CONTROL]
disable=C,R,W
[REPORTS]
reports=no
[TYPECHECK]
# See https://stackoverflow.com/questions/10300082/how-to-prevent-python-pylint-complaining-about-socket-class-sendall-method
ignored-classes=SQLObject,_socketobject
[MASTER]
init-hook='import sys; sys.path.append("./addons")'

View File

@ -84,6 +84,7 @@ def removeAll():
shutil.rmtree(filename, onerror=handleRemoveReadonly) shutil.rmtree(filename, onerror=handleRemoveReadonly)
else: else:
os.remove(filename) os.remove(filename)
# pylint: disable=undefined-variable
except WindowsError as err: except WindowsError as err:
time.sleep(30) time.sleep(30)
if count == 0: if count == 0: