blob: 1d07b4ed377592c74b7dacb7bd25e193d48fe394 (
plain)
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
39
40
|
#!/usr/bin/env python
# A linter to warn for ASSERT macros which are separated from their argument
# list by a space, which Clang's CPP barfs on
import sys
import logging
import os
import json
import re
def setup_logging(logger):
"""
``arc lint`` makes it quite tricky to catch debug output from linters.
Log to a file to work around this.
"""
hdlr = logging.FileHandler('linter.log', 'w')
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
return logger
logger = logging.getLogger()
#setup_logging(logger)
logger.debug(sys.argv)
path = sys.argv[1]
warnings = []
if os.path.isfile(path):
with open(path) as f:
for lineno, line in enumerate(f):
if re.search('ASSERT \(', line) is not None:
warning = {
'severity': 'warning',
'message': 'CPP macros should not have a space between the macro name and their argument list',
'line': lineno+1,
}
warnings.append(warning)
logger.debug(warnings)
print(json.dumps(warnings))
|