From 40acd24e8fef2a3c46ecdb21b4be1363d48e8ec4 Mon Sep 17 00:00:00 2001 From: Cullen Rhodes Date: Sun, 22 May 2016 16:32:18 +0100 Subject: Report use statements that use {} with only one entry --- python/tidy/servo_tidy/tidy.py | 2 ++ python/tidy/servo_tidy_tests/rust_tidy.rs | 1 + python/tidy/servo_tidy_tests/test_tidy.py | 1 + 3 files changed, 4 insertions(+) (limited to 'python') diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index 6ec263b2678..fa080890eb9 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -390,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: diff --git a/python/tidy/servo_tidy_tests/rust_tidy.rs b/python/tidy/servo_tidy_tests/rust_tidy.rs index 92db863dfaa..ef0a53b4b24 100644 --- a/python/tidy/servo_tidy_tests/rust_tidy.rs +++ b/python/tidy/servo_tidy_tests/rust_tidy.rs @@ -7,6 +7,7 @@ use azure::azure_hl::{AntialiasMode, Color, ColorPattern, CompositionOp}; use euclid::size::Size2D; use azure::azure::AzIntSize; +use azure::azure::{AzIntSize}; use std; diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index 55dbb4ce21a..47c3d7780a3 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -53,6 +53,7 @@ class CheckTidiness(unittest.TestCase): self.assertEqual('use statement spans multiple lines', errors.next()[2]) self.assertEqual('missing space before }', errors.next()[2]) self.assertTrue('use statement is not in alphabetical order' in errors.next()[2]) + self.assertEqual('use statement contains braces for single import', errors.next()[2]) self.assertEqual('encountered whitespace following a use statement', errors.next()[2]) self.assertTrue('mod declaration is not in alphabetical order' in errors.next()[2]) self.assertEqual('mod declaration spans multiple lines', errors.next()[2]) -- cgit v1.2.3