class RuboCop::Cop::Lint::UnderscorePrefixedVariableName


end
{_id: _id, profit: revenue - cost}
query(:sales) do |_id:, revenue:, cost:|
# good
@example AllowKeywordBlockArguments: true
end
do_something # not using ‘_num`
[1, 2, 3].each do |_num|
end
do_something(num)
[1, 2, 3].each do |num|
# good
end
{_id: _id, profit: revenue - cost}
query(:sales) do |_id:, revenue:, cost:|
end
do_something(_num)
[1, 2, 3].each do |_num|
# bad
@example AllowKeywordBlockArguments: false (default)
prefixed block keyword arguments.
sites, the `AllowKeywordBlockArguments` will allow use of underscore-
Since block keyword arguments cannot be arbitrarily named at call
used.
Checks for underscore-prefixed variables that are actually

def self.joining_forces

def self.joining_forces
  VariableForce
end

def after_leaving_scope(scope, _variable_table)

def after_leaving_scope(scope, _variable_table)
  scope.variables.each_value { |variable| check_variable(variable) }
end

def allowed_keyword_block_argument?(variable)

def allowed_keyword_block_argument?(variable)
  variable.block_argument? &&
    variable.keyword_argument? &&
    cop_config['AllowKeywordBlockArguments']
end

def check_variable(variable)

def check_variable(variable)
  return unless variable.should_be_unused?
  return if variable.references.none?(&:explicit?)
  return if allowed_keyword_block_argument?(variable)
  node = variable.declaration_node
  location = if node.match_with_lvasgn_type?
               node.children.first.source_range
             else
               node.loc.name
             end
  add_offense(location)
end