This cop checks for unused method arguments.
@example
def some_method(used, unused, _unused_but_allowed) puts used end
# File lib/rubocop/cop/lint/unused_method_argument.rb, line 15 def check_argument(variable) return unless variable.method_argument? super end
# File lib/rubocop/cop/lint/unused_method_argument.rb, line 20 def message(variable) message = "Unused method argument - `#{variable.name}`. " "If it's necessary, use `_` or `_#{variable.name}` " "as an argument name to indicate that it won't be used." scope = variable.scope all_arguments = scope.variables.each_value.select(&:method_argument?) if all_arguments.none?(&:referenced?) message << " You can also write as `#{scope.name}(*)` " 'if you want the method to accept any arguments ' "but don't care about them." end message end
Generated with the Darkfish Rdoc Generator 2.