Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImport ordering tidy check confused by multiple use statements from same module #7412
Comments
nox
commented
Aug 27, 2015
|
|
|
Can this be fixed by reordering the |
|
Well, that's why I opened the issue, I don't want to reorder it like this. |
|
We could have a different sorting function, but I’m not sure that it’s worth it. |
|
Whether or not it's worth it, I'm not sure a tidy check that is wrong is a good idea. |
|
Is it wrong? |
use mod::{foo, bar};
use mod::qux;I don't see why |
It doesn't look that wrong to me. |
use dom::bindings::codegen::InheritTypes::ProcessingInstructionCast;
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, DocumentTypeCast};
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLScriptElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLFormElementDerived, NodeCast};ProcessingInstructionCast is at an unexpected place. |
|
@tafia The lint is about alphabetic order of imports, not about simplicity first or whatever. |
|
qux is after foo and bar in alphabetic order, and thus should come after them, whether there are braces or not. |
|
Mmmmh… I can't order foo and bar apparently, good thing I found a real-world example. |
|
Yeah, this is super confusing. |
|
One idea from IRC: lowercase the lines before comparing them so diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py
index fcf51db..057910e 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/servo_tidy/tidy.py
@@ -430,7 +430,7 @@ 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:
+ if indent == current_indent and prev_use and current_use.lower() < prev_use.lower():
yield(idx + 1, decl_message.format("use statement")
+ decl_expected.format(prev_use)
+ decl_found.format(current_use))This generates a bunch of tidy warnings that need to be addressed. |
|
@jdm First time I hear someone complain about this specific part. I'm more annoyed by how braces should come after not-braces. |
Tidy: Fix ordering use statements with braces This hack fixes #7412 and matches behavior with rustfmt. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13205) <!-- Reviewable:end -->
…from UK992:tidy-sort); r=Wafflespeanut This hack fixes servo/servo#7412 and matches behavior with rustfmt. Source-Repo: https://github.com/servo/servo Source-Revision: 3117787fd2a8b7748cfde1e9b8c5be3c00f2c599 UltraBlame original commit: 89bfec936a22ef359e7b65a2deae11ff8f16d7c0
…from UK992:tidy-sort); r=Wafflespeanut This hack fixes servo/servo#7412 and matches behavior with rustfmt. Source-Repo: https://github.com/servo/servo Source-Revision: 3117787fd2a8b7748cfde1e9b8c5be3c00f2c599 UltraBlame original commit: 89bfec936a22ef359e7b65a2deae11ff8f16d7c0
…from UK992:tidy-sort); r=Wafflespeanut This hack fixes servo/servo#7412 and matches behavior with rustfmt. Source-Repo: https://github.com/servo/servo Source-Revision: 3117787fd2a8b7748cfde1e9b8c5be3c00f2c599 UltraBlame original commit: 89bfec936a22ef359e7b65a2deae11ff8f16d7c0