Skip to content

Make test-tidy check that = have space after them #7460

Closed

Description

@mylainos

I've found code like this #[cfg(target_os ="linux")]. It's a bit ugly and sometimes there is space after the =.

Code : python/tidy.py

Activity

  1. SimonSapin commented on Aug 30, 2015

    @SimonSapin
    Member

    Should we try and go full rustfmt instead?

  2. jdm commented on Aug 30, 2015

    @jdm
    Member

    @SimonSapin Nope; there are outstanding blockers last I checked.

  3. added
    E-less-complex
    L-python
    on Aug 30, 2015
  4. jerneyio commented on Aug 30, 2015

    @jerneyio
    Contributor

    Mind if take this one?

  5. jdm commented on Aug 30, 2015

    @jdm
    Member

    Go for it!

  6. added
    C-assigned
    on Aug 30, 2015
  7. jerneyio commented on Aug 30, 2015

    @jerneyio
    Contributor

    While it's true that the regex isn't accounting for a cases like #[cfg(target_os ="linux")], it looks like attributes in .rs files are being ignored anyway. See http://mxr.mozilla.org/servo/source/python/tidy.py#195. Is the desired behavior?

  8. jdm commented on Aug 30, 2015

    @jdm
    Member

    The answer is "kinda". The attributes get in the way of some of the tidy checks, but it would be beneficial to perform some checks (like this one) on them.

  9. jerneyio commented on Aug 31, 2015

    @jerneyio
    Contributor

    Ok, my local code now checks to make sure attributes like the one above (or any attribute with an = character) get checked for a space before and after the =. Other attributes like #[derive(Copy, Clone, PartialEq)] will be ignored.

    There are quite a few files that violate the rule. Should I change these now?

  10. jerneyio commented on Aug 31, 2015

    @jerneyio
    Contributor

    Like @mylainos warned in #7390, the code I wrote will conflict with his change for line http://mxr.mozilla.org/servo/source/python/tidy.py#195.

    # get rid of comments
    line = re.sub('//.*?$|/\*.*?$|^\*.*?$', '', line)
    
    # get rid of attributes that do not contain =
    line = re.sub('^#[A-Za-z0-9\(\)_\[\]_]*?$', '', line)
  11. jdm commented on Aug 31, 2015

    @jdm
    Member

    Yeah, I didn't think about things like #[doc="foo"]. I think I'm fine making it #[doc = "foo"] in service of the greater good.

  12. added a commit that references this issue on Sep 1, 2015
  13. jerneyio commented on Sep 3, 2015

    @jerneyio
    Contributor

    Can this be closed?

  14. jdm commented on Sep 3, 2015

    @jdm
    Member

    Yep!

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-machC-assignedE-less-complexL-python

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions