Skip to content

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

Closed

Description

@jdm

I propose the following rule:

  • for each Rust source file, look at every line
  • if the whitespace-stripped line starts with use, append the path up to any { to imports
  • if the line is empty
    • let sorted be imports sorted alphabetically
    • if sorted and imports differ, report the first import that does not match
    • reset imports to the empty list

This allows us to retain our sorted lists that are separated by whitespace that currently exist today.

Code: python/tidy.py

Activity

  1. added
    E-less-complex
    on Aug 9, 2015
  2. tafia commented on Aug 18, 2015

    @tafia
    Contributor

    Tried to address it in #7265

    This is my first python, so it may not be very standard.

    I didn't search for empty line, rather checked the imports length (works if there something else than use).

    One area where may we need to reconsider: if the very last import is supposed to be at the first place, all other imports being ordered then the entire block yields warning.

    Current code has lot of new warnings, should the cleaning be in the same pull request?

  3. added a commit that references this issue on Aug 20, 2015
    a5fbb2f
  4. jdm commented on Aug 22, 2015

    @jdm
    MemberAuthor

    Thank you so much, @tafia!

  5. tafia commented on Aug 23, 2015

    @tafia
    Contributor

    You're welcome!
    On 23 Aug 2015 07:51, "Josh Matthews" [email protected] wrote:

    Thank you so much, @tafia https://github.com/tafia!

    —
    Reply to this email directly or view it on GitHub
    #7112 (comment).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-machE-less-complex

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions