-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Don't define #autocorrect
in mixins
#3558
Comments
I agree. We should change this. On Friday, 30 September 2016, Ted Johansson notifications@github.com
|
I'm a fan of refactoring and these are great points. After working on bug reports from the new release, I'd be happy to tackle this. |
@garettarrowood: I've been thinking about this quite a bit. Since the |
So, if I understand correctly, this would mean a new set of modules called Example:
Is this what you had in mind? |
@garettarrowood: Pretty much. Except I see no reason to mix the corrector methods into the cop. The |
I want to argue that we shouldn't define the
#autocorrect
method in mixins used by cops.What's wrong with it?
#autocorrect
definition to the cop. This is pretty icky.#autocorrect
in a cop, which method is finally defined depends on the order of the mixins. This is very fragile.#autocorrect
that makes sense for a mixin, depending on the context it is being used.Cop
body.What should we do instead?
We already have a suitable abstraction in the callable objects that
#autocorrect
return. A mixin could simply make any number ofcorrector
s available for theCop
to return from it's own#autocorrect
method.Another option could be to have the mixin provide lower level methods that the cop can use to assemble it's own
#autocorrect
. TheParentheses
mixin could provide#remove_parentheses
and#add_parentheses
, for example.Which mixins are currently implementing it?
AutocorrectAlignment
EmptyLinesAroundBody
FirstElementLineBreak
MultilineLiteralBraceLayout
Parentheses
SpaceAfterPunctuation
SpaceBeforePunctuation
SpaceInside
StringLiteralsHelp
TrailingComma
UnusedArgument
The text was updated successfully, but these errors were encountered: