tidy: add extra space after keyword check

This commit is contained in:
Pavel Sergeev 2017-07-16 13:26:08 +03:00
parent 17f99e2a7b
commit c225847a81
3 changed files with 14 additions and 0 deletions

View file

@ -584,6 +584,12 @@ def check_rust(file_name, lines):
# -> () is unnecessary
(r"-> \(\)", "encountered function signature with -> ()", no_filter),
]
keywords = ["if", "let", "mut", "extern", "as", "impl", "fn", "struct", "enum", "pub", "mod",
"use", "in", "ref", "type", "where", "trait"]
extra_space_after = lambda key: (r"(?<![A-Za-z0-9\-_]){key} ".format(key=key),
"extra space after {key}".format(key=key),
lambda match, line: not is_attribute)
regex_rules.extend(map(extra_space_after, keywords))
for pattern, message, filter_func in regex_rules:
for match in re.finditer(pattern, line):