aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy
diff options
context:
space:
mode:
authorUK992 <urbankrajnc92@gmail.com>2016-09-08 16:08:38 +0200
committerUK992 <urbankrajnc92@gmail.com>2016-09-09 04:42:30 +0200
commit875981ece592b03bcf06f16b6613ddabfa11133f (patch)
tree7827403e0f1ca3e17d1d5eb18d603596f32cef6e /python/tidy
parent5a5a76cc5db830d2e622d4e0924837383b64dfa2 (diff)
downloadservo-875981ece592b03bcf06f16b6613ddabfa11133f.tar.gz
servo-875981ece592b03bcf06f16b6613ddabfa11133f.zip
Fix ordering `use` statements with braces
Diffstat (limited to 'python/tidy')
-rw-r--r--python/tidy/servo_tidy/tidy.py11
-rw-r--r--python/tidy/servo_tidy_tests/test_tidy.py1
2 files changed, 8 insertions, 4 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py
index 340a3cd1a83..081352f8a43 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/servo_tidy/tidy.py
@@ -516,10 +516,13 @@ def check_rust(file_name, lines):
yield (idx + 1, "use statement spans multiple lines")
# strip "use" from the begin and ";" from the end
current_use = line[4:-1]
- if indent == current_indent and prev_use and current_use < prev_use:
- yield(idx + 1, decl_message.format("use statement")
- + decl_expected.format(prev_use)
- + decl_found.format(current_use))
+ if prev_use:
+ current_use_cut = current_use.replace("{self,", ".").replace("{", ".")
+ prev_use_cut = prev_use.replace("{self,", ".").replace("{", ".")
+ if indent == current_indent and current_use_cut < prev_use_cut:
+ yield(idx + 1, decl_message.format("use statement")
+ + decl_expected.format(prev_use)
+ + decl_found.format(current_use))
prev_use = current_use
current_indent = indent
diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py
index c35e4b533d1..998967c617f 100644
--- a/python/tidy/servo_tidy_tests/test_tidy.py
+++ b/python/tidy/servo_tidy_tests/test_tidy.py
@@ -85,6 +85,7 @@ class CheckTidiness(unittest.TestCase):
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.assertTrue('use statement is not in alphabetical order' in 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])