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

Style/ParallelAssignment: swap detection for ActiveRecord #3286

Closed
arokettu opened this issue Jul 5, 2016 · 1 comment
Closed

Style/ParallelAssignment: swap detection for ActiveRecord #3286

arokettu opened this issue Jul 5, 2016 · 1 comment
Labels

Comments

@arokettu
Copy link

arokettu commented Jul 5, 2016

Summary: The Style/ParallelAssignment should ignore self. on the left when detecting variable swap

Actual behavior:

I have a code like

self.width, self.height = self.height, self.width

It says:

C: Redundant self detected.
        self.width, self.height = self.height, self.width
                                  ^^^^^^^^^^^
C: Redundant self detected.
        self.width, self.height = self.height, self.width
                                               ^^^^^^^^^^

That is expected, ok. I fix it

self.width, self.height = height, width

Now I get

C: Do not use parallel assignment.
        self.width, self.height = height, width
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expected behavior: No Style/ParallelAssignment vioaltions should be found in the line

I guess the cop should treat vars on the left with self. like vars on the right without self.

$ rubocop -V
0.41.1 (using Parser 2.3.1.2, running on ruby 2.3.1 x86_64-linux)
@bbatsov bbatsov added the bug label Jul 25, 2016
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 25, 2016

Makes sense.

@bbatsov bbatsov closed this as completed in 00b4c90 Oct 1, 2016
bbatsov added a commit that referenced this issue Oct 1, 2016
…tters

[Fix #3286] Handle `self.a, self.b = b, a` in ParallelAssignment
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
Add `self.` when it has been left out on the right hand side,
so that we can determine that it's a swap kind of assignment,
and thus allow it.

Also fixes rubocop#3418.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants