aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy/tidy.py
diff options
context:
space:
mode:
authorPavel Sergeev <sergeev.pavel.al@gmail.com>2017-07-16 13:26:08 +0300
committerPavel Sergeev <sergeev.pavel.al@gmail.com>2017-07-20 00:44:59 +0300
commitc225847a81588f7d709f5028cb24944077b4b548 (patch)
tree49c9a369f90cb8a7660fd25c4ba47a7494b14ad3 /python/tidy/servo_tidy/tidy.py
parent17f99e2a7bb0d7eec167eac952f12a7feafd647d (diff)
downloadservo-c225847a81588f7d709f5028cb24944077b4b548.tar.gz
servo-c225847a81588f7d709f5028cb24944077b4b548.zip
tidy: add extra space after keyword check
Diffstat (limited to 'python/tidy/servo_tidy/tidy.py')
-rw-r--r--python/tidy/servo_tidy/tidy.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py
index 989b83aa505..3bf6176de44 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/servo_tidy/tidy.py
@@ -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):