Rubocop gives me the following violation
lib/daru/vector.rb:1182:5: C: Style/MethodMissing: When using method_missing, define respond_to_missing? and fall back on super.
def method_missing(name, *args, &block) ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
An invalid method is defined as:
def method_missing(name, *args, &block)
if name =~ /(.+)\=/
self[$1.to_sym] = args[0]
elsif has_index?(name)
self[name]
else
super(name, *args, &block)
end
end
I tried to fix this with the code below, in which you can see an example here
def respond_to_missing?(method_name, include_private=false)
(name =~ /(.+)\=/) || has_index?(name) || super
end
But now Rubocop gives me the following violation:
lib/daru/vector.rb:1182:5: C: Style/MethodMissing: When using method_missing, fall back on super.
def method_missing(name, *args, &block) ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I can’t understand what happened. As you can see, I return to super in the else block.
source
share