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
classApi::SubstancesController < Api::BaseController
...
defdestroysuper([:pharmaceut])do |substance|
substance.destroyable?endend
...
end
Rubocop wants to autocorrect this to:
> rubocop -a app/controllers/api/substances_controller.rb
Inspecting 1 file
E
Offenses:
app/controllers/api/substances_controller.rb:20:5: C: [Corrected] Pass &:destroyable? as an argument to instead of a block.
super([:pharmaceut]) do |substance|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/api/substances_controller.rb:20:25: E: unexpected token tLPAREN2
super([:pharmaceut])(&:destroyable?)
^
app/controllers/api/substances_controller.rb:42:1: E: unexpected token $end
1 file inspected, 3 offenses detected, 1 offense corrected
Rubocop even detects two Errors - all due to the code it generated on its own.
The final result:
defdestroysuper([:pharmaceut])(&:destroyable?)end
As you can see this is clearly erroneous syntax.
Version
> rubocop -v
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.6-compliant syntax, but you are running 2.1.5.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
0.33.0
I have tried to add 'super' to ignored methods in config (seeing this cop inspects this configuration attribute) but that did not help
Style/BlockDelimiters:
IgnoredMethods:
- super
- lambda
- proc
- it
The text was updated successfully, but these errors were encountered:
I have a piece of controller code like this:
Rubocop wants to autocorrect this to:
Rubocop even detects two Errors - all due to the code it generated on its own.
The final result:
As you can see this is clearly erroneous syntax.
Version
I have tried to add 'super' to ignored methods in config (seeing this cop inspects this configuration attribute) but that did not help
The text was updated successfully, but these errors were encountered: