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

Incorrect “redundant self” after inner method definition #3383

Closed
noniq opened this issue Aug 9, 2016 · 0 comments
Closed

Incorrect “redundant self” after inner method definition #3383

noniq opened this issue Aug 9, 2016 · 0 comments

Comments

@noniq
Copy link

noniq commented Aug 9, 2016

Given a method with a method parameter shadowing an instance method, RuboCop produces an incorrect “Redundant self detected” warning if (and only if) the method also contains an inner method definition:

class Foo
  attr_reader :bar

  def method(bar)
    def inner_method; end
    puts bar, self.bar # `bar` and `self.bar` are different!
  end
end

Without the inner method definition everything works correctly (i.e. no “redundant self” warning is produced).


Expected behavior

No warning about “redundant self” because in fact it is not redundant at this place.

Actual behavior

Warning “Redundant self detected”.

Steps to reproduce the problem

Run RuboCop on the example program given above.

RuboCop version

$ rubocop -V
0.42.0 (using Parser 2.3.1.2, running on ruby 2.1.6 x86_64-darwin14.0)
$ (cd rubocop && git rev-parse HEAD)
78de463f33992bce5b1ecf40e311958ad773bad5
bankair pushed a commit to bankair/rubocop that referenced this issue Aug 31, 2016
That commit add failing test for issue rubocop#3383, and
fix the problem by adding a scoped local vars
management.
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
…ubocop#3459)

That commit adds failing test for issue rubocop#3383, and
fixes the problem by adding scoped local vars
management.
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

No branches or pull requests

1 participant