Browse Source

lint: require const field names to be in ALL_CAPS

GitOrigin-RevId: 8b6c20e6d9
master
Colin McMillen 4 years ago
parent
commit
6b95a66859
  1. 10
      tools/scripts/lint.py

10
tools/scripts/lint.py

@ -32,14 +32,20 @@ def lint_csharp(filename):
if len(line) > MAX_LINE_LENGTH:
if not re.match(r'\s*// https?:', line):
emit_error(filename, line_num, 'line too long')
if re.match(r'\s*//\S', line):
emit_error(filename, line_num, 'no space between // and comment')
match = re.match(r'\s*const.* (\w+) =', line)
if match:
identifier = match.group(1)
if not re.fullmatch(r'[A-Z_]+', identifier):
emit_error(filename, line_num,
'const field %s should be in ALL_CAPS' % identifier)
if re.search(r'\t', line):
emit_error(filename, line_num, 'illegal \\t character')
if re.search(r'\r', line):
emit_error(filename, line_num, 'illegal \\r character')
if re.search(r'\s+$', line):
emit_error(filename, line_num, 'trailing whitespace')
if re.match(r'\s*//\S', line):
emit_error(filename, line_num, 'no space between // and comment')
def main(args):

Loading…
Cancel
Save