-
-
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/ConditionalAssigment fails to autocorrect #2608
Comments
Challenge accepted. Starting my clock... NOW. |
Hahahaha, hurry up I've invested a lot of money in this. 😉 |
Hmm. I see that @rrosenblum specifically designed this cop to flag the code you've shown. It wants to see this instead: key =~ (value.boolean? ? /#{abbr}/ : /#{shortcut}/) ...Which does make sense. Do you agree? The |
Sure, makes sense. And the comment about the name too. The autocorrection needs to be fixed though. |
OK, I blew the 10 minutes here because of misunderstanding the problem. Now let me see why autocorrection is failing. |
(And because you fixed another issue in between) |
OK. |
Here's the problem code: condition, if_branch, else_branch = *node
_if_assignment, if_variable = *if_branch
_else_assignment, else_variable = *else_branch
condition = condition.source
if_variable = if_variable.source
|
Close to nailing this one, but there is still the issue of operator priority. It needs to be smart enough to add parens if necessary. |
Don't worry, you still have 4 minutes. :) |
Issue of operator precedence solved, now writing specs. |
Wrote specs, now committing and pushing. |
Pushed fix, waiting to see if CI passes. |
Thanks for the testing... please find us some more bugs! I'm sure there are plenty left to find and fix. |
That was pretty amazing. Thanks so much! |
@alexdowad thanks for fixing this. I added on support for ternary operators at the very end. It didn't get quite as much attention as all of the other features.
I agree, this cop has diverged a bit from its name. The original intention was for it cover
Agreed, I am all for finding and fixing bugs. |
Hi! I just tried RuboCop's master branch. It's as awesome as it looks. I found this problem:
example.rb
Running RuboCop on it
Trying to autocorrect
My bet is that it'll take @alexdowad aproximately 10 minutes to fix it. 😂
Thanks!
The text was updated successfully, but these errors were encountered: