users-guide: Note multiple pattern signature change in relnotes
[ghc.git] / .arc-linters / check-cpp.py
1 #!/usr/bin/env python
2
3 # A linter to warn for ASSERT macros which are separated from their argument
4 # list by a space, which Clang's CPP barfs on
5
6 import sys
7 import logging
8 import os
9 import json
10
11 def setup_logging(logger):
12 """
13 ``arc lint`` makes it quite tricky to catch debug output from linters.
14 Log to a file to work around this.
15 """
16 hdlr = logging.FileHandler('linter.log', 'w')
17 logger.addHandler(hdlr)
18 logger.setLevel(logging.DEBUG)
19 return logger
20
21 logger = logging.getLogger()
22 #setup_logging(logger)
23 logger.debug(sys.argv)
24
25 path = sys.argv[1]
26 warnings = []
27 if os.path.isfile(path):
28 with open(path) as f:
29 for lineno, line in enumerate(f):
30 if 'ASSERT (' in line:
31 warning = {
32 'severity': 'warning',
33 'message': 'CPP macros should not have a space between the macro name and their argument list',
34 'line': lineno+1,
35 }
36 warnings.append(warning)
37
38 logger.debug(warnings)
39 print(json.dumps(warnings))