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

Fix incorrect auto-correct of === in ConditionalAssignment #2967

Merged
merged 1 commit into from
Mar 22, 2016

Conversation

rrosenblum
Copy link
Contributor

I was working on adding support for more operators to ConditionalAssignment and coming up with a new name for it, when I came across a bug. I can't imagine that the bug would happen often, but it seemed worth while to get a fix in.

@@ -82,7 +82,7 @@ def lhs_for_send(node)
indices = node.children[2...-1].map(&:source).join(', ')
"#{receiver}[#{indices}] = "
elsif node.method_name.to_s.end_with?(EQUAL) &&
![:!=, :==].include?(node.method_name)
![:!=, :==, :===].include?(node.method_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

You should also check for >=.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. >= and <= had the same bug. I also added tests for every weird math assignment operator out there that I could find.

bbatsov added a commit that referenced this pull request Mar 22, 2016
Fix incorrect auto-correct of === in ConditionalAssignment
@bbatsov bbatsov merged commit d5a6e10 into rubocop:master Mar 22, 2016
@rrosenblum rrosenblum deleted the conditional_assignment_bug branch March 23, 2016 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants