Skip to content

Commit

Permalink
Fix ordering use statements with braces
Browse files Browse the repository at this point in the history
  • Loading branch information
UK992 committed Sep 9, 2016
1 parent 5a5a76c commit 875981e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python/tidy/servo_tidy/tidy.py
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions python/tidy/servo_tidy_tests/test_tidy.py
Expand Up @@ -85,6 +85,7 @@ def test_rust(self):
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])
Expand Down

0 comments on commit 875981e

Please sign in to comment.