R.31 mark Example as Example, bad (closes #1651)
[CppCoreGuidelines.git] / scripts / python / cpplint_wrap.py
blobc94a7bb1a411c71420759f16bed9cdbf033c96ce
1 ## wraps local cpplint to produce verbose output without code harness
2 import cpplint
3 import sys
5 def main():
6 FILTERS=('cpplint --verbose=0 --linelength=100 --filter=-legal/copyright,-build/include_order,'
7 '-build/c++11,-build/namespaces,-build/class,-build/include,-build/include_subdir,-readability/inheritance,'
8 '-readability/function,-readability/casting,-readability/namespace,-readability/alt_tokens,'
9 '-readability/braces,-readability/fn_size,-whitespace/comments,-whitespace/braces,-whitespace/empty_loop_body,'
10 '-whitespace/indent,-whitespace/newline,-runtime/explicit,-runtime/arrays,-runtime/int,-runtime/references,'
11 '-runtime/string,-runtime/operator,-runtime/printf').split(' ')
13 result = False
14 files = sys.argv[1:]
15 for loopfile in files:
16 newargs = FILTERS + [loopfile]
17 sys.argv = newargs
19 try:
20 cpplint.main()
21 except SystemExit as e:
22 last_result = e.args[0]
23 result = result or last_result
24 if (last_result):
25 write_code_lines(loopfile)
26 sys.exit(result)
28 def write_code_lines(filename):
29 with open(filename, 'r') as f:
30 linenum = 1
31 for line in f:
32 if (not '// by md-split' in line):
33 sys.stdout.write('%3d %s' % (linenum, line))
34 linenum += 1
36 if __name__ == '__main__':
37 main()