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

Style/Alias doesn't allow any use of alias #1460

Closed
marxarelli opened this issue Nov 24, 2014 · 8 comments
Closed

Style/Alias doesn't allow any use of alias #1460

marxarelli opened this issue Nov 24, 2014 · 8 comments

Comments

@marxarelli
Copy link
Contributor

According to comments in rubocop/ruby-style-guide#377 alias is not strictly forbidden by the style guide and in fact can be more appropriate than alias_method in some cases—usually those involving lexical scope and a clear indirection to methods within the same scope. The Style/Alias cop needs refactoring to allow the use of alias in cases such as the following.

class Westerner
  def first_name
    @names.first
  end

  alias given_name first_name
end
marxarelli added a commit to marxarelli/rubocop that referenced this issue Nov 25, 2014
Fixed `Style/Alias` cop to allow the use of `alias` in lexical class and
module scope, as the style guide does not forbid it.
@bf4
Copy link
Contributor

bf4 commented Dec 8, 2015

I see the PR wasn't merged.

In 0.35.1 I'm still getting that annoying Style/Alias: Use alias_method instead of alias. (https://github.com/bbatsov/ruby-style-guide#alias-method) even though https://github.com/bbatsov/ruby-style-guide#alias-method-lexically it should be permitted. And the only option is Enabled.

I don't really understand cop internals, so I can't tell what it's doing wrong.

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 9, 2015

@marxarelli disappeared and I didn't have time to work on this myself. Someone else will have to drive the work here to completion.

Basically, now the cop reflects an older version of the style guide.

@bf4
Copy link
Contributor

bf4 commented Dec 9, 2015

I'm happy to help with some guidance.. I understand the ruby and the parser, but would need some help getting that into a tested coo

B mobile phone

On Dec 9, 2015, at 4:00 AM, Bozhidar Batsov notifications@github.com wrote:

@marxarelli disappeared and I didn't have time to work on this myself. Someone else will have to drive the work here to completion.

Basically, now the cop reflects an older version of the style guide.


Reply to this email directly or view it on GitHub.

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 19, 2015

Sure. You can start work on this and we'll lend you all the help you need.

@bf4
Copy link
Contributor

bf4 commented Dec 24, 2015

@alexdowad Yay! 🌈 ❤️ ✨ 💯

@marxarelli
Copy link
Contributor Author

Sorry about being a total flake on this one. I'm glad it got done by @alexdowad !

@matrinox
Copy link

matrinox commented Feb 7, 2016

I think the default should be prefer_alias_method. That was the behaviour before and upgrading a minor release should not break that expectation.

@bbatsov
Copy link
Collaborator

bbatsov commented Feb 7, 2016

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

4 participants