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

Alias cop does auto-correction. #657

Merged
merged 1 commit into from
Dec 5, 2013

Conversation

dblock
Copy link
Contributor

@dblock dblock commented Dec 4, 2013

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling 25d1add43f3ae6dcfa71e741ca74118a1b5fdf25 on dblock:autocorrect-alias-cop into 1b0338b on bbatsov:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling 25d1add43f3ae6dcfa71e741ca74118a1b5fdf25 on dblock:autocorrect-alias-cop into 1b0338b on bbatsov:master.

@@ -13,6 +13,11 @@
.to eq(['Use alias_method instead of alias.'])
end

it 'autocorrects alias with symbol args' do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not as simple as that - alias's arguments can be:

  • symbols
  • strings
  • barewords

In case they are strings or barewords you'll have to convert them to symbols.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right about barewords, but not string:

1.9.3p448 :001 > class Foo
1.9.3p448 :002?>     def bar
1.9.3p448 :003?>         "bar"
1.9.3p448 :004?>       end
1.9.3p448 :005?>   
1.9.3p448 :006 >       alias "foo" "bar"
1.9.3p448 :007?>   end
SyntaxError: (irb):6: syntax error, unexpected tSTRING_BEG
  alias "foo" "bar"
         ^
    from /Users/dblock/.rvm/rubies/ruby-1.9.3-p448/bin/irb:16:in `<main>'
1.9.3p448 :008 > 

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems you're right. I guess the documentation here http://ruby-doc.org/docs/keywords/1.9/ is incorrect.

@dblock
Copy link
Contributor Author

dblock commented Dec 4, 2013

Updated to autocorrect barewords.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling 91a6385 on dblock:autocorrect-alias-cop into 1b0338b on bbatsov:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling 91a6385 on dblock:autocorrect-alias-cop into 1b0338b on bbatsov:master.

bbatsov added a commit that referenced this pull request Dec 5, 2013
@bbatsov bbatsov merged commit 45acf62 into rubocop:master Dec 5, 2013
@dblock dblock deleted the autocorrect-alias-cop branch December 23, 2013 23:08
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 this pull request may close these issues.

3 participants