This cop checks whether the block parameters of a single-line method accepting a block match the names specified via configuration.
For instance one can configure `reduce`(`inject`) to use |a, e| as parameters.
# File lib/rubocop/cop/style/single_line_block_params.rb, line 11 def on_block(node) # we care only for single line blocks return unless Util.block_length(node) == 0 method_node, args_node, _body_node = *node receiver, method_name, _method_args = *method_node # discard other scenarios return unless receiver return unless method_names.include?(method_name) # discard cases with argument destructuring args = *args_node return true unless args.all? { |n| n.type == :arg } return if args_match?(method_name, args) add_offense(args_node, :expression, message(method_name)) end
Generated with the Darkfish Rdoc Generator 2.