Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Python flake8 tests on several Nodejs repos #21942

Closed
wants to merge 1 commit into from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Jul 23, 2018

DO NOT MERGE: This PR uses Travis CI to run the flake8 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 nodejs/node-gyp#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
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

__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 nodejs/node-gyp#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
@cclauss
Copy link
Contributor Author

cclauss commented Jul 23, 2018

Closing with output at https://travis-ci.com/nodejs/node/builds/79706150

@cclauss cclauss closed this Jul 23, 2018
@cclauss cclauss deleted the patch-1 branch July 23, 2018 10:47
@cclauss cclauss changed the title WIP: DO NOT MERGE: Flake8 tests on Nodejs repos Run Python flake8 tests on several Nodejs repos Jul 23, 2018
cclauss pushed a commit to cclauss/node-chakracore that referenced this pull request Jul 23, 2018
__xrange()__ was removed in Python 3 in favor of __range()__.  This PR ensures similar functionality on both Python 2 and Python 3.

Similar to nodejs/nan#797

Discovered via https://travis-ci.com/nodejs/node/builds/79706150 (nodejs/node#21942)


flake8 testing of https://github.com/nodejs/node-chakracore on Python 3.7.0

$ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__
```
./tools/cpplint.py:1471:12: F821 undefined name 'xrange'
  for i in xrange(startpos, len(line)):
           ^
./tools/cpplint.py:1700:15: F821 undefined name 'xrange'
  for line in xrange(1, min(len(lines), 11)):
              ^
./tools/cpplint.py:1828:12: F821 undefined name 'xrange'
  for i in xrange(1, len(raw_lines) - 1):
           ^
./tools/cpplint.py:2169:14: F821 undefined name 'xrange'
    for i in xrange(linenum - 1, self.starting_linenum, -1):
             ^
./tools/cpplint.py:2950:26: F821 undefined name 'xrange'
    for start_linenum in xrange(linenum, clean_lines.NumLines()):
                         ^
./tools/cpplint.py:3437:14: F821 undefined name 'xrange'
    for i in xrange(first_line, last_line + 1, 1):
             ^
./tools/cpplint.py:3501:19: F821 undefined name 'xrange'
    for offset in xrange(endlinenum + 1,
                  ^
./tools/cpplint.py:4047:14: F821 undefined name 'xrange'
    for i in xrange(linenum + 1, end_line):
             ^
./tools/cpplint.py:4218:23: F821 undefined name 'unicode'
  if isinstance(line, unicode):
                      ^
./tools/cpplint.py:4870:12: F821 undefined name 'xrange'
  for i in xrange(linenum, max(-1, linenum - 10), -1):
           ^
./tools/cpplint.py:4891:12: F821 undefined name 'xrange'
  for i in xrange(linenum, max(-1, linenum - 10), -1):
           ^
./tools/cpplint.py:4907:12: F821 undefined name 'xrange'
  for i in xrange(linenum, 1, -1):
           ^
./tools/cpplint.py:5008:20: F821 undefined name 'xrange'
          for i in xrange(startline, linenum + 1):
                   ^
./tools/cpplint.py:5032:14: F821 undefined name 'xrange'
    for i in xrange(linenum - 1, max(0, linenum - 10), -1):
             ^
./tools/cpplint.py:5063:14: F821 undefined name 'xrange'
    for i in xrange(2):
             ^
./tools/cpplint.py:5226:14: F821 undefined name 'xrange'
    for i in xrange(linenum - 1, max(0, linenum - 5), -1):
             ^
./tools/cpplint.py:5442:18: F821 undefined name 'xrange'
  for linenum in xrange(clean_lines.NumLines()):
                 ^
./tools/cpplint.py:5573:21: F821 undefined name 'xrange'
  for start_line in xrange(linenum, min(linenum + 3, clean_lines.NumLines())):
                    ^
./tools/cpplint.py:5588:12: F821 undefined name 'xrange'
  for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())):
           ^
./tools/cpplint.py:5845:15: F821 undefined name 'xrange'
  for line in xrange(clean_lines.NumLines()):
              ^
```
cclauss pushed a commit to cclauss/node that referenced this pull request Jul 23, 2018
__xrange()__ was removed in Python 3 in favor of __range()__.  This PR ensures similar functionality on both Python 2 and Python 3.

Discovered via https://travis-ci.com/nodejs/node/builds/79706150 (nodejs#21942)
addaleax pushed a commit that referenced this pull request Jul 27, 2018
__xrange()__ was removed in Python 3 in favor of __range()__.
This PR ensures similar functionality on both Python 2 and Python 3.

Discovered via https://travis-ci.com/nodejs/node/builds/79706150
(#21942).

PR-URL: #21945
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this pull request Jul 31, 2018
__xrange()__ was removed in Python 3 in favor of __range()__.
This PR ensures similar functionality on both Python 2 and Python 3.

Discovered via https://travis-ci.com/nodejs/node/builds/79706150
(#21942).

PR-URL: #21945
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant