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

double alias problem #70

Closed
zeroed opened this issue Apr 18, 2013 · 5 comments
Closed

double alias problem #70

zeroed opened this issue Apr 18, 2013 · 5 comments

Comments

@zeroed
Copy link

zeroed commented Apr 18, 2013

Maybe I've found a bug (?)... it seems that rubocop (version 0.5.0) doesn't like so much a snippet of code like this one:

alias has_foo? foo?
alias has_bar? bar?

I will do a PR...

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 18, 2013

What exactly is the problem? I assume you got two warnings to use alias_method instead.

@zeroed
Copy link
Author

zeroed commented Apr 18, 2013

I saw something a little less polite:

/usr/local/lib/ruby/gems/2.0.0/gems/rubocop-0.5.0/lib/rubocop/cop/alias.rb:10:in `block in inspect': undefined method `lineno' for "c":String (NoMethodError)
    from /usr/local/lib/ruby/gems/2.0.0/gems/rubocop-0.5.0/lib/rubocop/cop/cop.rb:82:in `block (2 levels) in each'
    from /usr/local/lib/ruby/gems/2.0.0/gems/rubocop-0.5.0/lib/rubocop/cop/cop.rb:82:in `block (2 levels) in each'
...

@zeroed
Copy link
Author

zeroed commented Apr 18, 2013

This is the spec without the check in alias.rb:

Failures:

  1) Rubocop::Cop::Alias does not mess with double alias
     Failure/Error: inspect_source(a,
     NoMethodError:
       undefined method `lineno' for "s":String
     # ./lib/rubocop/cop/alias.rb:11:in `block in inspect'
     # ./lib/rubocop/cop/cop.rb:82:in `block (2 levels) in each'
     # ./lib/rubocop/cop/cop.rb:82:in `block (2 levels) in each'
     # ./lib/rubocop/cop/cop.rb:80:in `each'
     # ./lib/rubocop/cop/cop.rb:82:in `block in each'
     # ./lib/rubocop/cop/cop.rb:81:in `each'
     # ./lib/rubocop/cop/cop.rb:81:in `each'
     # ./lib/rubocop/cop/cop.rb:82:in `block in each'
     # ./lib/rubocop/cop/cop.rb:81:in `each'
     # ./lib/rubocop/cop/cop.rb:81:in `each'
     # ./lib/rubocop/cop/alias.rb:9:in `inspect'
     # ./spec/rubocop/cops/alias_spec.rb:24:in `block (2 levels) in <module:Cop>'

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 19, 2013

The actual problem here is not that there are two alias keywords, but the use of barewords with them. Since I generally always use symbols I forgot to support that case. Thanks for reporting that!

@zeroed
Copy link
Author

zeroed commented Apr 19, 2013

You're welcome @bbatsov ... reading the rubocop code is always a pleasure!
^_^

Yup...

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

2 participants