Handle escaped strings in rust linting, tidy.py

tidy.py now strips strings even if they have escapes before linting.

Use raw strings for regex with lots of backslashes

Handle ALL escape sequences in strings for tidy, not just escaped string terminators
This commit is contained in:
Mike Fairhurst 2016-03-06 15:26:22 -08:00
parent 743e0c9c87
commit 9b91c7afeb

View file

@ -290,7 +290,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)
@ -346,6 +346,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