Sha256: cb6ea1a628999f42b3eb9036c9ba84de42efbe817eacb64bbf3ab96df5e42af8
Contents?: true
Size: 1.1 KB
Versions: 62
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Style # This cop checks for parentheses for empty lambda parameters. Parentheses # for empty lambda parameters do not cause syntax errors, but they are # redundant. # # @example # # bad # -> () { do_something } # # # good # -> { do_something } # # # good # -> (arg) { do_something(arg) } class EmptyLambdaParameter < Cop include EmptyParameter include RangeHelp MSG = 'Omit parentheses for the empty lambda parameters.' def on_block(node) send_node = node.send_node return unless send_node.send_type? check(node) if node.send_node.lambda_literal? end def autocorrect(node) lambda do |corrector| send_node = node.parent.send_node range = range_between( send_node.loc.expression.end_pos, node.loc.expression.end_pos ) corrector.remove(range) end end end end end end
Version data entries
62 entries across 43 versions & 5 rubygems