diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-03-11 05:07:43 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-03-11 05:07:43 +0530 |
commit | f1bb0b0fa3eacac718a825c103cbdd1a0365fbf9 (patch) | |
tree | 7d1ec9270cfd60a15bb4d14833dd4de917580d65 /python/tidy.py | |
parent | f3a871ec3ded9efe5dfc07f8a3a39ddd6fb05856 (diff) | |
parent | 9b91c7afebfcda5fb748868f0a2c173bf9497885 (diff) | |
download | servo-f1bb0b0fa3eacac718a825c103cbdd1a0365fbf9.tar.gz servo-f1bb0b0fa3eacac718a825c103cbdd1a0365fbf9.zip |
Auto merge of #9889 - MichaelRFairhurst:github-bug-9806-tidy-linting-string-contents, r=ecoal95
Handle escaped strings in rust linting, tidy.py
A little annoying to read since we have to escape for python (\\) and
then escape for re (\\\\) and then even at times escape for single
quotes immediately after, (\\\\\), but tidy.py now strips strings even
if they have escapes before linting.
Fixes #9806 -- basically the problem is that the PR which first revealed this had an escape in one of its strings which included an = sign. The escape meant the string wasn't escaped before it looked for spaces around spaces.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9889)
<!-- Reviewable:end -->
Diffstat (limited to 'python/tidy.py')
-rw-r--r-- | python/tidy.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/python/tidy.py b/python/tidy.py index 2841d956a18..347a884ccb3 100644 --- a/python/tidy.py +++ b/python/tidy.py @@ -291,7 +291,7 @@ def check_rust(file_name, lines): # get rid of strings and chars because cases like regex expression, keep attributes if not line_is_attribute(line): - line = re.sub('".*?"|\'.*?\'', '', line) + line = re.sub(r'"(\\.|[^\\"])*?"|' + r"'(\\.|[^\\'])*?'", '', line) # get rid of comments line = re.sub('//.*?$|/\*.*?$|^\*.*?$', '', line) @@ -347,6 +347,7 @@ def check_rust(file_name, lines): for match in re.finditer(pattern, line): if not filter_func(match, line): continue + yield (idx + 1, message.format(*match.groups(), **match.groupdict())) # check alphabetical order of extern crates |