-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Conversation
Coverage increased (+0.0%) when pulling 25d1add43f3ae6dcfa71e741ca74118a1b5fdf25 on dblock:autocorrect-alias-cop into 1b0338b on bbatsov:master. |
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 >
There was a problem hiding this comment.
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.
Updated to autocorrect barewords. |
Alias cop does auto-correction.
No description provided.