You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if this is actually an issue, but I will report it the same
#912 introduced the ability to delegate to instance variables
In controllers, however, this may conflict with Rails/LexicallyScopedActionFilter, and the developer should take action.
For the moment, I'm undecided on the workaround. I can either:
disable the delegate on the offending line; or
explicitly add head :no_content to the controller (but it should be redundant, since it's an API only responding to json and the 204 is the default
Expected behavior
Can't tell
Actual behavior
Fixing the Rails/Delegate offense introduces a Rails/LexicallyScopedActionFilter that in order to be fixed should reintroduce the Rails/Delegate offense
$ rubocop app/controllers/posts_controller.rb
Inspecting 1 file
C
Offenses:
app/controllers/posts_controller.rb:6:3: C: [Correctable] Rails/Delegate: Use delegate to define delegations.
def destroy
^^^
1 file inspected, 1 offense detected, 1 offense autocorrectable
Second run (with autocorrect)
$ rubocop app/controllers/posts_controller.rb -a
Inspecting 1 file
C
Offenses:
app/controllers/posts_controller.rb:4:3: C: Rails/LexicallyScopedActionFilter: destroy is not explicitly defined on the class.
before_action :set_post, only: %i[destroy]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/posts_controller.rb:6:3: C: [Corrected] Rails/Delegate: Use delegate to define delegations.
def destroy
^^^
1 file inspected, 2 offenses detected, 1 offense corrected
Third run
$ rubocop app/controllers/posts_controller.rb
Inspecting 1 file
C
Offenses:
app/controllers/posts_controller.rb:4:3: C: Rails/LexicallyScopedActionFilter: destroy is not explicitly defined on the class.
before_action :set_post, only: %i[destroy]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected
Hello,
I don't know if this is actually an issue, but I will report it the same
#912 introduced the ability to delegate to instance variables
In controllers, however, this may conflict with
Rails/LexicallyScopedActionFilter
, and the developer should take action.For the moment, I'm undecided on the workaround. I can either:
head :no_content
to the controller (but it should be redundant, since it's an API only responding to json and the204
is the defaultExpected behavior
Can't tell
Actual behavior
Fixing the
Rails/Delegate
offense introduces aRails/LexicallyScopedActionFilter
that in order to be fixed should reintroduce theRails/Delegate
offenseSteps to reproduce the problem
Gemfile
rubocop.yml
app/controllers/posts_controller.rb
First run:
Second run (with autocorrect)
Third run
RuboCop version
The text was updated successfully, but these errors were encountered: