class RuboCop::Cop::Layout::SpaceBeforeFirstArg
something ‘hello’
something y, z
something x
@good
something’hello’
something y, z
something x
@bad
@example
config parameter is true.
something on a preceding or following line, if the AllowForAlignment
Alternatively, extra spaces can be added to align the argument with
first argument for method calls without parentheses.
Checks that exactly one space is used between a method name and the
def autocorrect(range)
def autocorrect(range) ->(corrector) { corrector.replace(range, ' ') } end
def expect_params_after_method_name?(node)
def expect_params_after_method_name?(node) return false if node.parenthesized? first_arg = node.first_argument same_line?(first_arg, node) && !(allow_for_alignment? && aligned_with_something?(first_arg.source_range)) end
def on_send(node)
def on_send(node) return unless regular_method_call_with_arguments?(node) return unless expect_params_after_method_name?(node) first_arg = node.first_argument.source_range first_arg_with_space = range_with_surrounding_space(first_arg, :left) space = range_between(first_arg_with_space.begin_pos, first_arg.begin_pos) add_offense(space, space) if space.length != 1 end
def regular_method_call_with_arguments?(node)
def regular_method_call_with_arguments?(node) node.arguments? && !node.operator_method? && !node.setter_method? end