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

False-positive on Rails/LexicallyScopedActionFilter #529

Closed
pyromaniac opened this issue Aug 30, 2021 · 0 comments · Fixed by #531
Closed

False-positive on Rails/LexicallyScopedActionFilter #529

pyromaniac opened this issue Aug 30, 2021 · 0 comments · Fixed by #531
Labels
bug Something isn't working

Comments

@pyromaniac
Copy link

Hello, found out that Rails/LexicallyScopedActionFilter doesn't consider method aliases.


Expected behavior

I believe that the cop should consider aliased methods as explicitly defined.

Actual behavior

The cop ignored method alias.

Steps to reproduce the problem

class FooController < ApplicationController
  before_action :authorize!, only: %i[index show]
  def index
  end
  alias_method :show, :index
  
  private

  def authorize!
  end
end

This example will produce Rails/LexicallyScopedActionFilter: show is not explicitly defined on the class.

RuboCop version

$ [bundle exec] rubocop -V
1.20.0 (using Parser 3.0.2.0, rubocop-ast 1.11.0, running on ruby 2.7.4 x86_64-darwin20)
  - rubocop-performance 1.11.5
  - rubocop-rails 2.11.3
  - rubocop-rspec 2.4.0
koic added a commit to koic/rubocop-rails that referenced this issue Sep 1, 2021
…onFilter`

Fixes rubocop#529.

This PR fixes a false positive for `Rails/LexicallyScopedActionFilter`
when action method is aliased by `alias_method`.
@koic koic added the bug Something isn't working label Sep 1, 2021
koic added a commit to koic/rubocop-rails that referenced this issue Sep 1, 2021
…onFilter`

Fixes rubocop#529.

This PR fixes a false positive for `Rails/LexicallyScopedActionFilter`
when action method is aliased by `alias_method`.
koic added a commit to koic/rubocop-rails that referenced this issue Sep 2, 2021
…onFilter`

Fixes rubocop#529.

This PR fixes a false positive for `Rails/LexicallyScopedActionFilter`
when action method is aliased by `alias_method`.
@koic koic closed this as completed in #531 Sep 2, 2021
koic added a commit that referenced this issue Sep 2, 2021
…cally_scoped_action_filter

[Fix #529] Fix a false positive for `Rails/LexicallyScopedActionFilter`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants