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

"Shadowing outer local variable" is not smart enough #1518

Closed
killthekitten opened this issue Dec 21, 2014 · 4 comments
Closed

"Shadowing outer local variable" is not smart enough #1518

killthekitten opened this issue Dec 21, 2014 · 4 comments

Comments

@killthekitten
Copy link

I have a case of using ruby blocks like this:

lib/export_tools/xlsx_writer.rb:13:40: W: Shadowing outer local variable - package.
      package = Axlsx::Package.new do |package|
                                       ^^^^^^^

In this case package variable is set only after block will eval and return it's value, so shadowing doesn't take place. Should we fix the behavior of rubocop here?

@jonas054
Copy link
Collaborator

RuboCop behaves the same way as ruby -w for the given code snippet. I think we should keep that behavior.

@killthekitten
Copy link
Author

@jonas054 but for similar cases it will only lead to switching off an inspection. It's useless. I don't want to use two different names for one object. Who wants?

@jonas054
Copy link
Collaborator

I think the default behavior should be the same as ruby -w, but I would be happy to discuss the possibility of a configuration option for allowing this kind of non-problematic shadowing. Not sure how difficult is is to implement. A pull request would be most welcome.

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 28, 2015

At least the RuboCop inspection can the turned off (unlike the one in MRI). :-) As @jonas054 - PR welcome. I don't think we'll be able to allocate any attention to this in the foreseeable future, so I'm closing the issue.

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

3 participants