From 42b011ece83406f4731a09d9fd8c1de85ff0791c Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 23 Jul 2018 12:25:25 +0200 Subject: [PATCH] WIP: DO NOT MERGE: Flake8 tests on Nodejs repos __DO NOT MERGE__: This will run the [flake8](http://flake8.pycqa.org) linter on several Nodejs repos that contain Python code to detect syntax errors and undefined names which can raise NameError at runtime. There is a discussion in https://github.com/nodejs/node-gyp/pull/1336 about the importance of using tools like Travis CI to automate the discovery of code quality issues. __E901,E999,F821,F822,F823__ are the "showstopper" flake8 issues that can halt the runtime with a SyntaxError, NameError, etc. Most other flake8 issues are merely "style violations" -- useful for readability but they do not effect runtime safety. This PR therefore demonstrates such a flake8 run these Nodejs codebases. * F821: undefined name `name` * F822: undefined name `name` in `__all__` * F823: local variable `name` referenced before assignment * E901: SyntaxError or IndentationError * E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree --- .travis.yml | 58 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 11cb2a2f12758b..de32838e72ec6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,37 @@ -language: cpp -compiler: - - clang -sudo: false -cache: ccache +group: travis_latest +dist: xenial # required for Python 3.7 +sudo: true # required for Python 3.7 +language: python +cache: pip +python: + - 2.7 + - 3.7 matrix: - include: - - os: linux - node_js: "latest" - install: - - NODE=$(which node) make lint-md-build - script: - - NODE=$(which node) make lint-ci - - os: linux - install: - - ./configure - - make -j2 V= - script: - - make -j2 test-ci -before_install: - - export CXX="ccache clang++ -Qunused-arguments" - - export CC="ccache clang -Qunused-arguments -Wno-unknown-warning-option" - - export JOBS=2 + allow_failures: + - python: 2.7 +env: + - REPO=nodejs/node + - REPO=nodejs/node-gyp + - REPO=nodejs/node-auto-test + - REPO=nodejs/node-chakracore + - REPO=nodejs/node-v8 + - REPO=nodejs/build + - REPO=nodejs/ffi + - REPO=nodejs/nan + - REPO=nodejs/testing +install: + - pip install flake8 +before_script: + - URL=https://github.com/${REPO} + - echo ; echo -n "flake8 testing of ${URL} on " ; python -V + - git clone --depth=50 ${URL} ~/${REPO} # --branch=master + - cd ~/${REPO} +script: + - echo stop the build if there are Python syntax errors or undefined names + - echo ; echo -n "flake8 testing of ${URL} on " ; python -V + - time flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics + - echo exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + - time flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +notifications: + on_success: change + on_failure: change # `always` will be the setting once code changes slow down