class RuboCop::Cop::Style::NumberedParameters

Checks for numbered parameters.

It can either restrict the use of numbered parameters to single-lined blocks, or disallow completely numbered parameters.

@example EnforcedStyle: allow_single_line (default)

# bad
collection.each do
  puts _1
end

# good
collection.each { puts _1 }

@example EnforcedStyle: disallow

# bad
collection.each { puts _1 }

# good
collection.each { |item| puts item }

Constants

MSG_DISALLOW
MSG_MULTI_LINE

Public Instance Methods

on_numblock(node) click to toggle source
# File lib/rubocop/cop/style/numbered_parameters.rb, line 36
def on_numblock(node)
  if style == :disallow
    add_offense(node, message: MSG_DISALLOW)
  elsif node.multiline?
    add_offense(node, message: MSG_MULTI_LINE)
  end
end