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/RedundantSelf creates false positive with parallel assignment #4197

Closed
daniel-rikowski opened this issue Mar 28, 2017 · 1 comment
Closed
Labels

Comments

@daniel-rikowski
Copy link

When using parallel assignment involving self Style/RedundantSelf thinks self is redundant.
Expanding the parallel assignment works, i.e. self is recognized as non-redundant:

With parallel assignment:

old_log_level, self.log_level = log_level, :fatal  # Redundant `self` detected

Serial assignment:

old_log_level = log_level
self.log_level = :fatal # No redundant `self` detected

Expected behavior

Rubocop should notice that self is not redundant.

Actual behavior

Rubocop thinks that self is redundant.

Steps to reproduce the problem

Check this code with Style/RedundantSelf enabled:

def parallel
  old_log_level, self.log_level = log_level, :fatal
end

def serial
  old_log_level = log_level
  self.log_level = :fatal
end

RuboCop version

$ rubocop -V
0.48.0 (using Parser 2.4.0.0, running on ruby 2.3.3 i386-mingw32)
@bbatsov
Copy link
Collaborator

bbatsov commented Mar 29, 2017

Looks like a bug indeed.

@bbatsov bbatsov added the bug label Mar 29, 2017
Drenmi added a commit to Drenmi/rubocop that referenced this issue Mar 30, 2017
…arallel assignment

This cop would incorrectly mark a `self` as redundant when used in the
lhs expression of a parallel assignment.

This change fixes that.
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