-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Style/AndOr enhanced autocorrect for method a or method a,b
to method(a)||method(a,b)
#1259
Comments
The closing parenthesis is the easiest. You just need to find the node representing the last argument, which you do with receiver, method_name, *args = *node and then use The opening parenthesis is a bit trickier. You could use |
@jonas054 Thank you for the hints, I found that I can get it to work if I replace the |
If you can get it to work, I think it's fine. I thought that the method name was just a symbol, not a node, so that it would be necesary to construct a new |
Here is the code to go with it |
I am trying to get Style/AndOr cop to autocorrect on patterns like
method a,b or method c
tomethod(a,b) || method(c)
. I see that there is no change in AST between the oldmethod a,b or method c
and newmethod(a,b)||method(c)
, however I am at a loss how to implement it.I see that the
or
node's two child expressions can be checked fornode.loc.begin
if the parenthesis exists, but I dont understand what to do when it does not.The text was updated successfully, but these errors were encountered: