This cop checks for trailing comma in parameter lists and literals.
# File lib/rubocop/cop/style/trailing_comma.rb, line 12 def on_array(node) check_literal(node, 'item of %s array') if square_brackets?(node) end
# File lib/rubocop/cop/style/trailing_comma.rb, line 16 def on_hash(node) check_literal(node, 'item of %s hash') end
# File lib/rubocop/cop/style/trailing_comma.rb, line 20 def on_send(node) _receiver, _method_name, *args = *node return if args.empty? # It's impossible for a method call without parentheses to have # a trailing comma. return unless brackets?(node) check(node, args, 'parameter of %s method call', args.last.loc.expression.end_pos, node.loc.expression.end_pos) end
Generated with the Darkfish Rdoc Generator 2.