From 6b95a668599988c06dca1f0360b4730a68d8f29b Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Tue, 25 Feb 2020 20:34:19 -0500 Subject: [PATCH] lint: require const field names to be in ALL_CAPS GitOrigin-RevId: 8b6c20e6d978f2756bdbf946ff860ce5cc48e3ce --- tools/scripts/lint.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/scripts/lint.py b/tools/scripts/lint.py index 5643a88..9bd054f 100644 --- a/tools/scripts/lint.py +++ b/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):