servo: Merge #17749 - Extra space check (from SergeevPavel:extra-space-check); r=jdm
<!-- Please describe your changes on the following line: --> Add tidy check for keywords with more than one space afterwards. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #17700 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 7d95fb8e49dd0eb9fa9efb9d70008f5f9bf20a83
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user