Report use statements that use {} with only one entry

This commit is contained in:
Cullen Rhodes 2016-05-22 16:32:18 +01:00
parent 4dcb05ca4f
commit 40acd24e8f
55 changed files with 92 additions and 89 deletions

View file

@ -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:

View file

@ -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;

View file

@ -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])