Skip to content

Add alphabetical order check for use statements - #7265

Merged
bors-servo merged 2 commits into
servo:masterfrom
tafia:tidy-use
Aug 20, 2015
Merged

bors-servo merged 2 commits into
servo:masterfrom
tafia:tidy-use

Conversation

@tafia

@tafia tafia commented Aug 18, 2015

Copy link
Copy Markdown
Contributor

close #7112

Review on Reviewable

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 18, 2015
@highfive

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @metajack (or someone else) soon.

@Ms2ger

Ms2ger commented Aug 18, 2015

Copy link
Copy Markdown
Contributor

-S-awaiting-review +S-needs-code-changes

Thank you for your PR. Unfortunately, this can't land until we have all these failures fixed. Is that something you'd like to work on?


Reviewed 1 of 1 files at r1.
Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


python/tidy.py, line 179 [r1] (raw file):
No need for this to be defined here.


python/tidy.py, line 257 [r1] (raw file):
Maybe: use = line[4:] ...


python/tidy.py, line 258 [r1] (raw file):
if match < 0


python/tidy.py, line 266 [r1] (raw file):
There's a sorted() function you can use.


Comments from the review on Reviewable.io

@Ms2ger Ms2ger added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Aug 18, 2015
@Ms2ger Ms2ger self-assigned this Aug 18, 2015
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Aug 18, 2015
@tafia

tafia commented Aug 18, 2015

Copy link
Copy Markdown
Contributor Author

Thanks for the review!
Working on your comments + all these new failures. Should I push all fixes in this pull request?

@Ms2ger Ms2ger added the S-fails-tidy `./mach test-tidy` reported errors. label Aug 18, 2015
@Ms2ger

Ms2ger commented Aug 18, 2015

Copy link
Copy Markdown
Contributor

Doing it here makes sense to me.

@tafia

tafia commented Aug 19, 2015

Copy link
Copy Markdown
Contributor Author

Should be all good now ...
I finally sorted the {...} groups as well (it feels better).

I started doing all the fixes manually ... then used this script (my 2nd python script ever!):

import os

from tempfile import mkstemp
from shutil import move
from os import remove, close

def replace_uses(file_path):
    #Create temp file
    fh, abs_path = mkstemp()
    with open(abs_path,'w') as new_file:
        with open(file_path) as old_file:
            uses = []
            for line in old_file:
                if line.lstrip().startswith("use "):
                    uses.append(line[:len(line)-2])
                else:
                    if len(uses) > 0:
                        new_file.write("".join([u + ";\n" for u in sorted(uses)]))
                        uses = []
                    new_file.write(line)
    close(fh)
    #Remove original file
    remove(file_path)
    #Move new file
    move(abs_path, file_path)


# navigate the entire directories and replace uses
for root, subdirs, files in os.walk("./"):
    for f in files:
        if f.endswith(".rs"):
            filePath = os.path.join(root, f)
            replace_uses(filePath)

@Ms2ger let me know if I must squash everything

@Ms2ger Ms2ger removed the S-fails-tidy `./mach test-tidy` reported errors. label Aug 20, 2015
@Ms2ger

Ms2ger commented Aug 20, 2015

Copy link
Copy Markdown
Contributor

Maybe squash into two commits: first one that fixes all the .rs files, and then on top of that a commit to add the check to the python script.

@tafia

tafia commented Aug 20, 2015

Copy link
Copy Markdown
Contributor Author

Fine! I'll try to do it asap.

@tafia
tafia force-pushed the tidy-use branch 2 times, most recently from d2b6603 to cb2d3ef Compare August 20, 2015 12:39
@tafia

tafia commented Aug 20, 2015

Copy link
Copy Markdown
Contributor Author

Squashed and rebased (was failing the tests again). @Ms2ger let me know!

@Ms2ger

Ms2ger commented Aug 20, 2015

Copy link
Copy Markdown
Contributor

Thanks!

@bors-servo r+ p=1000

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 009f6f6 has been approved by Ms2ger

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Aug 20, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 009f6f6 with merge a5fbb2f...

bors-servo pushed a commit that referenced this pull request Aug 20, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux1, linux2, mac1, mac2, mac3

@tafia

tafia commented Aug 21, 2015

Copy link
Copy Markdown
Contributor Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check that consecutive use statements in Rust files are in alphabetical order

4 participants