-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathcpplint.py
More file actions
38 lines (27 loc) · 924 Bytes
/
cpplint.py
File metadata and controls
38 lines (27 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
"""Wrapper script for cpplint."""
import sys
from typing import List
from hooks.utils import StaticAnalyzerCmd
class CpplintCmd(StaticAnalyzerCmd):
"""Class for the cpplint command."""
command = "cpplint"
lookbehind = "cpplint "
def __init__(self, args: List[str]):
super().__init__(self.command, self.lookbehind, args)
self.parse_args(args)
self.add_if_missing(["--verbose=0"])
def run(self):
"""Run cpplint"""
error_occurred = False
for filename in self.files:
self.run_command_cpplint(self.args + [filename]) # cpplint is unique in requiring args before filename
if self.returncode != 0:
error_occurred = True
if error_occurred:
sys.exit(1)
def main(argv: List[str] = sys.argv):
cmd = CpplintCmd(argv)
cmd.run()
if __name__ == "__main__":
main()