flake8 testing of https://github.com/google/styleguide on Python 3.6.3
$ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__
```
./cpplint/cpplint.py:1526:12: F821 undefined name 'xrange'
for i in xrange(startpos, len(line)):
^
./cpplint/cpplint.py:1755:15: F821 undefined name 'xrange'
for line in xrange(1, min(len(lines), 11)):
^
./cpplint/cpplint.py:1957:12: F821 undefined name 'xrange'
for i in xrange(1, len(raw_lines) - 1):
^
./cpplint/cpplint.py:2298:14: F821 undefined name 'xrange'
for i in xrange(linenum - 1, self.starting_linenum, -1):
^
./cpplint/cpplint.py:3080:26: F821 undefined name 'xrange'
for start_linenum in xrange(linenum, clean_lines.NumLines()):
^
./cpplint/cpplint.py:3537:14: F821 undefined name 'xrange'
for i in xrange(first_line, last_line + 1, 1):
^
./cpplint/cpplint.py:3601:19: F821 undefined name 'xrange'
for offset in xrange(endlinenum + 1,
^
./cpplint/cpplint.py:4155:14: F821 undefined name 'xrange'
for i in xrange(linenum + 1, end_line):
^
./cpplint/cpplint.py:4283:23: F821 undefined name 'unicode'
if isinstance(line, unicode):
^
./cpplint/cpplint.py:4928:12: F821 undefined name 'xrange'
for i in xrange(linenum, max(-1, linenum - 10), -1):
^
./cpplint/cpplint.py:4949:12: F821 undefined name 'xrange'
for i in xrange(linenum, max(-1, linenum - 10), -1):
^
./cpplint/cpplint.py:4965:12: F821 undefined name 'xrange'
for i in xrange(linenum, 1, -1):
^
./cpplint/cpplint.py:5066:20: F821 undefined name 'xrange'
for i in xrange(startline, linenum + 1):
^
./cpplint/cpplint.py:5090:14: F821 undefined name 'xrange'
for i in xrange(linenum - 1, max(0, linenum - 10), -1):
^
./cpplint/cpplint.py:5121:14: F821 undefined name 'xrange'
for i in xrange(2):
^
./cpplint/cpplint.py:5284:14: F821 undefined name 'xrange'
for i in xrange(linenum - 1, max(0, linenum - 5), -1):
^
./cpplint/cpplint.py:5503:18: F821 undefined name 'xrange'
for linenum in xrange(clean_lines.NumLines()):
^
./cpplint/cpplint.py:5639:21: F821 undefined name 'xrange'
for start_line in xrange(linenum, min(linenum + 3, clean_lines.NumLines())):
^
./cpplint/cpplint.py:5654:12: F821 undefined name 'xrange'
for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())):
^
./cpplint/cpplint.py:5911:15: F821 undefined name 'xrange'
for line in xrange(clean_lines.NumLines()):
^
```
Example:
cpplint.py --quiet <file-names>
Will now return with an exit code of 0 and return empty output if there
were no errors. This makes it particularly useful to be driven by a build system
such as makefiles or gradle.
In particular, these messages are now suppressed:
Ignoring <filename>, excluded by CPPLINT.cfg, ...
Done processing <filename>
Total errors found: 0
If there were any errors, the above messages are printed nevertheless.
There is no behavior change if --quiet is not passed in.
Also further improve the documentation and testing around --root.
Previously the root=setting in the CFG file was treated identically
to passing --root=setting on the command line, which seems undesirable
since it depends on were cpplint.cfg was invoked from (for relative
paths).
Judging on settings such as 'exclude_files' it seems within the spirit
to make the settings 'current working directory' contextual to the
same directory that CPPLINT.cfg is in.
This also makes execution consistent (picking up the "correct" settings)
regardless of the CWD when executing cpplint.py.
Example:
echo 'root=..' >> /a/b/c/CPPLINT.cfg
cd /
cpplint.py /a/b/c/source_file.h
# expects header guard of C_SOURCE_FILE_H_
However the old behavior would use '/../' = '/'
and incorrectly think the root was 'A_B_C_SOURCE_FILE_H_'.
Using cpplint.py --root with directories at a more outer level
will now prepend the header guard with all the directories from the
root to the file.
For example given
ls /a/b/c # /a/b/c/.git /a/b/c/filename.h
cpplint.py --root=/a/b /a/b/c/filename.h # C_FILENAME_H_
# no root behavior:
cpplint.py /a/b/c/filename.h # FILENAME_H_
Also supports relative paths:
cd /a/b/c
cpplint.py --root=.. filename.h # C_FILENAME_H_
Note that the old usage is still supported:
cd /a/b/c
mkdir -p d/e/f
touch /a/b/c/d/e/f/filename.h
cpplint.py --root=d/e/f d/e/f/filename.h # FILENAME_H_
which would "strip" the prefix rather than prepend an extra prefix.
(Invalid root prefixes are as before also ignored)
Using cpplint.py --root with directories at a more outer level
than the repository would not work.
For example given
/a/b/c/.git/filename.cpp
Trying to use --root=/a/b would get ignored, and it would
ask for a headerguard of FILENAME_H_ instead of C_FILENAME_H_
as expected.
Now --root will always use the "full name" and then strip off --root
prefix, giving us the desired effect.
There are links out in the wild to the old XML style guide. An XML file that links to the new style guide location ensures that those links are not completely broken.