comparison contrib/check-config.py @ 32849:e9fc5550be46

check-config: look for ui.configwith We previously weren't looking for this config helper. And, surprise, profiling.py references config options without docs. If I tried hard enough, I could have combined the regexps using a positive lookbehind assertion or something. But I didn't want to make my brain explode. At some point, we should probably do this linting at the tokenizer or ast layer. I'm not willing to open that can of worms right now.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 15 Jun 2017 10:58:36 -0700
parents 485b8e87e244
children 5d8942dbe49e
comparison
equal deleted inserted replaced
32848:485b8e87e244 32849:e9fc5550be46
18 # Function call 18 # Function call
19 ui\.config(?P<ctype>|int|bool|list)\( 19 ui\.config(?P<ctype>|int|bool|list)\(
20 # First argument. 20 # First argument.
21 ['"](?P<section>\S+)['"],\s* 21 ['"](?P<section>\S+)['"],\s*
22 # Second argument 22 # Second argument
23 ['"](?P<option>\S+)['"](,\s+
24 (?:default=)?(?P<default>\S+?))?
25 \)''', re.VERBOSE | re.MULTILINE)
26
27 configwithre = re.compile('''
28 ui\.config(?P<ctype>with)\(
29 # First argument is callback function. This doesn't parse robustly
30 # if it is e.g. a function call.
31 [^,]+,\s*
32 ['"](?P<section>\S+)['"],\s*
23 ['"](?P<option>\S+)['"](,\s+ 33 ['"](?P<option>\S+)['"](,\s+
24 (?:default=)?(?P<default>\S+?))? 34 (?:default=)?(?P<default>\S+?))?
25 \)''', re.VERBOSE | re.MULTILINE) 35 \)''', re.VERBOSE | re.MULTILINE)
26 36
27 configpartialre = (r"""ui\.config""") 37 configpartialre = (r"""ui\.config""")
77 if m: 87 if m:
78 documented[m.group(1)] = 1 88 documented[m.group(1)] = 1
79 89
80 # look for code-like bits 90 # look for code-like bits
81 line = carryover + l 91 line = carryover + l
82 m = configre.search(line) 92 m = configre.search(line) or configwithre.search(line)
83 if m: 93 if m:
84 ctype = m.group('ctype') 94 ctype = m.group('ctype')
85 if not ctype: 95 if not ctype:
86 ctype = 'str' 96 ctype = 'str'
87 name = m.group('section') + "." + m.group('option') 97 name = m.group('section') + "." + m.group('option')