diff options
Diffstat (limited to 'python/tidy/servo_tidy')
-rw-r--r-- | python/tidy/servo_tidy/tidy.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index 5baca6749ab..48f7a0705bc 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -33,7 +33,6 @@ file_patterns_to_ignore = [ # Files that are ignored for all tidy and lint checks. ignored_files = [ # Generated and upstream code combined with our own. Could use cleanup - os.path.join(".", "ports", "gonk", "src", "native_window_glue.cpp"), os.path.join(".", "ports", "geckolib", "gecko_bindings", "bindings.rs"), os.path.join(".", "ports", "geckolib", "gecko_bindings", "structs.rs"), os.path.join(".", "ports", "geckolib", "string_cache", "atom_macro.rs"), @@ -54,6 +53,7 @@ ignored_dirs = [ os.path.join(".", "tests", "wpt", "harness"), os.path.join(".", "tests", "wpt", "update"), os.path.join(".", "tests", "wpt", "web-platform-tests"), + os.path.join(".", "tests", "wpt", "mozilla", "tests", "mozilla", "referrer-policy"), os.path.join(".", "tests", "wpt", "sync"), os.path.join(".", "tests", "wpt", "sync_css"), os.path.join(".", "python", "mach"), @@ -298,6 +298,7 @@ def check_rust(file_name, lines): whitespace = False prev_use = None + prev_open_brace = False current_indent = 0 prev_crate = {} prev_mod = {} @@ -341,10 +342,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)) @@ -389,6 +390,8 @@ def check_rust(file_name, lines): # No benefit over using &str (r": &String", "use &str instead of &String", no_filter), (r"^&&", "operators should go at the end of the first line", no_filter), + (r"\{[A-Za-z0-9_]+\};", "use statement contains braces for single import", + lambda match, line: line.startswith('use ')), ] for pattern, message, filter_func in regex_rules: @@ -398,6 +401,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 |