From ccb14abd12ff643b5bc140613f2fc13935cdf579 Mon Sep 17 00:00:00 2001 From: vwvww Date: Sun, 5 Feb 2017 15:49:01 +0900 Subject: Add 'use statements with extraneous spaces' tidy check Add 'use statements with extraneous spaces' tidy check I added simple check routine for 'use statements with extraneous spaces' and codes that breaks the check routine in rust_tidy.rs. * Added a code that using 'use statements with extraneous spaces' code in rust_tidy.rs * Added assertion code in test_tidy.py. * check_rust function in tidy.py now recognizes the simple case in the 'use statements with extraneous spaces'. * Ran tidy check on rust code and modified a code(tests/unit/style/parsing/inherited_text.rs) that is not passing on this new tidy check. TODO: this code has to be refactored to support more general cases. - [X] ./mach test-tidy does not report any errors - [X] These changes fix #14898 (github issue number if applicable). --- python/tidy/servo_tidy/tidy.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'python/tidy/servo_tidy/tidy.py') diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index 9b59b08e473..ae929d45c3c 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -612,6 +612,10 @@ def check_rust(file_name, lines): indent = len(original_line) - len(line) if not line.endswith(";") and '{' in line: yield (idx + 1, "use statement spans multiple lines") + if '{ ' in line: + yield (idx + 1, "extra space after {") + if ' }' in line: + yield (idx + 1, "extra space before }") # strip "use" from the begin and ";" from the end current_use = line[4:-1] if prev_use: -- cgit v1.2.3