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
[Fix #3936] Add new Style/MixinGrouping
cop
#3982
Conversation
include ConfigurableEnforcedStyle | ||
|
||
MIXIN_METHODS = [:extend, :include, :prepend].freeze | ||
MSG = 'Put mixins in %s.'.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the message is a bit confusing and should definitely mention include
or extend
for extra clarity.
@@ -728,6 +728,12 @@ Style/MethodName: | |||
- snake_case | |||
- camelCase | |||
|
|||
Style/MixinGrouping: | |||
EnforcedStyle: separated | |||
SupportedStyles: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some explanations about the supported styles would be useful.
A couple of points:
|
This cop checks for grouping of `mixins` in class and `module` bodies. By default, it enforces a separated style, i.e.: ``` class Foo include Bar include Qux end ``` but it can be configured to enforce a grouped style as well.
9f1e3f8
to
2341191
Compare
@bbatsov: Comments addressed. 😀
Opened a PR for this.
I was holding off on this one, because I didn't have time to deal with the visibility scopes of the |
👍 |
|
||
# good | ||
class Foo | ||
include Bar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include Bar, Qox
==
include Qox
include Bar
|
||
# good | ||
class Foo | ||
extend Bar, Qox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include Bar
include Qox
==
include Qox, Bar
This cop checks for grouping of
mixins
in class andmodule
bodies. By default, it enforces a separated style, i.e.:but it can be configured to enforce a grouped style as well.
It's currently Chinese New Year, so I didn't have time to add autocorrect. Will add it in at a later point, unless someone beats me to it. 😀
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
rake generate_cops_documentation
(required only when you've added a new cop or changed the configuration/documentation of an existing cop).