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

New Universal.OOStructures.AlphabeticExtendsImplements sniff #55

Merged
merged 1 commit into from
May 10, 2020

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 29, 2020

New sniff to verify that the names used in a class "implements" statement or an interface "extends" statement are listed in alphabetic order.

Notes:

  • This sniff contains a public orderby property to determine the sort order to use for the statement.
    If all names used are unqualified, the sort order won't make a difference.
    However, if one or more of the names are partially or fully qualified, the chosen sort order will determine how the sorting between unqualified, partially and fully qualified names is handled.
    The sniff supports two sort order options:
    • 'name' : sort by the interface name only (default);
    • 'full' : sort by the full name as used in the statement (without leading backslash).
      In both cases, the sorting will be done using natural sort, case-insensitive.
  • The sniff has modular error codes to allow for selective inclusion/exclusion:
    • ImplementsWrongOrder - for "class implements" statements.
    • ImplementsWrongOrderWithComments - for "class implements" statements interlaced with comments. These will not be auto-fixed.
    • ExtendsWrongOrder - for "interface extends" statements.
    • ExtendsWrongOrderWithComments - for "interface extends" statements interlaced with comments. These will not be auto-fixed.
  • When fixing, the existing spacing between the names in an implements/extends statement will not be maintained.
    The fixer will separate each name with a comma and one space.
    If alternative formatting is desired, a sniff which will check and fix the formatting should be added to the ruleset.

Includes fixer.
Includes unit tests.
Includes documentation.
Includes metrics.

Fixes #54

New sniff to verify that the names used in a class "implements" statement or an interface "extends" statement are listed in alphabetic order.

Notes:
* This sniff contains a public `orderby` property to determine the sort order to use for the statement.
    If all names used are unqualified, the sort order won't make a difference.
    However, if one or more of the names are partially or fully qualified, the chosen sort order will determine how the sorting between unqualified, partially and fully qualified names is handled.
    The sniff supports two sort order options:
    - 'name' : sort by the interface name only (default);
    - 'full' : sort by the full name as used in the statement (without leading backslash).
    In both cases, the sorting will be done using natural sort, case-insensitive.
* The sniff has modular error codes to allow for selective inclusion/exclusion:
    - `ImplementsWrongOrder` - for "class implements" statements.
    - `ImplementsWrongOrderWithComments` - for "class implements" statements interlaced with comments. These will not be auto-fixed.
    - `ExtendsWrongOrder` - for "interface extends" statements.
    - `ExtendsWrongOrderWithComments` - for "interface extends" statements interlaced with comments. These will not be auto-fixed.
* When fixing, the existing spacing between the names in an `implements`/`extends` statement will not be maintained.
    The fixer will separate each name with a comma and one space.
    If an alternative formatting is desired, a sniff which will check and fix the formatting should be added to the ruleset.

Includes fixer.
Includes unit tests.
Includes documentation.
Includes metrics.

Fixes 54
Copy link

@ramsey ramsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks perfect to me. Thanks!

@jrfnl jrfnl merged commit c2c4aeb into develop May 10, 2020
@jrfnl jrfnl deleted the feature/54-new-alphabeticimplementsextends-sniff branch May 10, 2020 17:50
@jrfnl
Copy link
Member Author

jrfnl commented May 10, 2020

@ramsey Glad to hear it. Feel free to open issues for other sniff ideas you come up and I'll see what I can do ;-)

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

Successfully merging this pull request may close these issues.

New sniff: alphabetize interfaces following implements keyword
2 participants