diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-05-27 18:14:25 -0500 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-05-27 18:14:25 -0500 |
commit | 3ec20d9cf517c67f4d280e8958cc58c4c2b4fbb2 (patch) | |
tree | 19f434faead436e4b30da8a52c349d436d1fbe5d /python/tidy/servo_tidy/tidy.py | |
parent | 2d4941660bd3a4a91f82145a3a468fbf165eaf94 (diff) | |
parent | 3cb8af20c24ea0972220fa3fa7cbfcbd99c0848e (diff) | |
download | servo-3ec20d9cf517c67f4d280e8958cc58c4c2b4fbb2.tar.gz servo-3ec20d9cf517c67f4d280e8958cc58c4c2b4fbb2.zip |
Auto merge of #11472 - jdm:wip, r=mbrubeck
Report blank lines that follow an open brace
This automates something that I find myself frequently commenting on in PRs.
---
<!-- 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] There are tests for these changes OR
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11472)
<!-- Reviewable:end -->
Diffstat (limited to 'python/tidy/servo_tidy/tidy.py')
-rw-r--r-- | python/tidy/servo_tidy/tidy.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index fa080890eb9..8bdce255b38 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -299,6 +299,7 @@ def check_rust(file_name, lines): whitespace = False prev_use = None + prev_open_brace = False current_indent = 0 prev_crate = {} prev_mod = {} @@ -342,10 +343,10 @@ def check_rust(file_name, lines): line = re.sub(r"'(\\.|[^\\'])*?'", "''", line) # get rid of comments - line = re.sub('//.*?$|/\*.*?$|^\*.*?$', '', line) + line = re.sub('//.*?$|/\*.*?$|^\*.*?$', '//', line) # get rid of attributes that do not contain = - line = re.sub('^#[A-Za-z0-9\(\)\[\]_]*?$', '', line) + line = re.sub('^#[A-Za-z0-9\(\)\[\]_]*?$', '#[]', line) # flag this line if it matches one of the following regular expressions # tuple format: (pattern, format_message, filter_function(match, line)) @@ -401,6 +402,10 @@ def check_rust(file_name, lines): yield (idx + 1, message.format(*match.groups(), **match.groupdict())) + if prev_open_brace and not line: + yield (idx + 1, "found an empty line following a {") + prev_open_brace = line.endswith("{") + # check alphabetical order of extern crates if line.startswith("extern crate "): # strip "extern crate " from the begin and ";" from the end |