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

Implement a cop which tracks _-prefixed variables/params that are actually used #934

Closed
bbatsov opened this issue Mar 30, 2014 · 4 comments · Fixed by #996
Closed

Implement a cop which tracks _-prefixed variables/params that are actually used #934

bbatsov opened this issue Mar 30, 2014 · 4 comments · Fixed by #996
Assignees

Comments

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 30, 2014

This came up in #931:

node.children.each do |_node|
  do_something(_node)
end
@bbatsov
Copy link
Collaborator Author

bbatsov commented Mar 31, 2014

@yujinakayama Something else we might consider - an offense for unused block and method params:

def something(x)
  # x is not used
end

hash.each { |k, v| puts k } 

I guess such a check might be useful.

@yujinakayama
Copy link
Collaborator

@bbatsov My concern about unused arguments is that sometimes people have no control on them when overriding methods of superclass or conforming to some protocols. In that case, should we force users name the arguments with _ prefix?

@bbatsov
Copy link
Collaborator Author

bbatsov commented Apr 8, 2014

On Wednesday, April 9, 2014, Yuji Nakayama [email protected] wrote:

@bbatsov https://github.com/bbatsov My concern about unused arguments
is that sometimes people have no control on them when overriding methods of
superclass. In that case, should we force users name the arguments with _prefix?

Seems reasonable to me. Those could be two cops (one for methods and one
for block params) so people can opt out if they don't like this.


Reply to this email directly or view it on GitHubhttps://github.com//issues/934#issuecomment-39905591
.

Best Regards,
Bozhidar Batsov

http://www.batsov.com

@yujinakayama
Copy link
Collaborator

Those could be two cops (one for methods and one for block params) so people can opt out if they don't like this.

👍

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 a pull request may close this issue.

2 participants