Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure lists of modules are in alphabetical order #7390

Closed
jdm opened this issue Aug 26, 2015 · 11 comments
Closed

Ensure lists of modules are in alphabetical order #7390

jdm opened this issue Aug 26, 2015 · 11 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Aug 26, 2015

For lists like

mod foo;
pub mod bar;
mod zap;

We should verify that they are sorted alphabetically by module name and report an error if not.

Code: python/tidy.py

@jdm jdm added E-easy A-mach labels Aug 26, 2015
@jdm
Copy link
Member Author

@jdm jdm commented Aug 26, 2015

See the code for checking sorted-ness of use statements for inspiration: http://mxr.mozilla.org/servo/source/python/tidy.py#246

@mylainos
Copy link
Contributor

@mylainos mylainos commented Aug 29, 2015

I'd like to work on this please. But if something like this happen :

mod Foo {

}
mod Bar {

}

we don't report an error because they are not sorted alphabetically, right ?

@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Aug 29, 2015

@mylainos Go ahead and take it! And, I guess we could just neglect inline modules for now :)

@mylainos
Copy link
Contributor

@mylainos mylainos commented Aug 29, 2015

I think it's done but there is a problem with this line http://mxr.mozilla.org/servo/source/components/style/lib.rs#48. For me the lint should be at the upper line but what do you think ?

@frewsxcv frewsxcv added the C-assigned label Aug 29, 2015
@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Aug 29, 2015

@mylainos Yep, you're right. That's a bit ugly, put that pub mod foo in a new line :)

@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Aug 29, 2015

I think it's cleaner in this case to keep it all on one line.

@jdm
Copy link
Member Author

@jdm jdm commented Aug 29, 2015

We should be able to strip any attributes that are used by using the same code as http://mxr.mozilla.org/servo/source/python/tidy.py#194 .

@mylainos
Copy link
Contributor

@mylainos mylainos commented Aug 29, 2015

The regex at http://mxr.mozilla.org/servo/source/python/tidy.py#195 delete the whole line. This regex line = re.sub('//.*?$|/\*.*?$|^\*.*?$|^#!?\[.*?]\s', '', line) delete just the attribute.
Now everything work except inline mod. Should I do a PR ?

@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Aug 29, 2015

@mylainos Yes, you should! (also, add a keyword referring this issue)

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Aug 29, 2015

This might be better as a compiler lint (which uses the existing parser that already knows how to deal with attributes) rather than hack it with string manipulation and regexes.

@mylainos
Copy link
Contributor

@mylainos mylainos commented Aug 30, 2015

The regex that I changed line = re.sub('//.*?$|/\*.*?$|^\*.*?$|^#!?\[.*?]\s', '', line) only report the attributes with whitespace after (due to the \s). That was for http://mxr.mozilla.org/servo/source/components/style/lib.rs#48.

But now tidy report that ./components/gfx/font.rs:104: missing space before = http://mxr.mozilla.org/servo/source/components/gfx/font.rs#104.

And this could conflict with #7460.

bors-servo pushed a commit that referenced this issue Sep 1, 2015
Making test-tidy check that = have space after them

For issue #7460. Need to ensure compatibility with #7390.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7468)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this issue Sep 18, 2015
fixes #7390 : tidy now check the order of mod declarations even whith attribute



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7680)
<!-- Reviewable:end -->
josiahdaniels added a commit to josiahdaniels/servo that referenced this issue Sep 28, 2015
josiahdaniels added a commit to josiahdaniels/servo that referenced this issue Sep 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.