class RuboCop::Cop::Lint::UnderscorePrefixedVariableName

end
do_something # not using ‘_num`
[1, 2, 3].each do |_num|
# good
@example
end
do_something(num)
[1, 2, 3].each do |num|
# good
@example
end
do_something(_num)
[1, 2, 3].each do |_num|
# bad
@example
used.
This cop checks for underscore-prefixed variables that are actually

def after_leaving_scope(scope, _variable_table)

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

def check_variable(variable)

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

def join_force?(force_class)

def join_force?(force_class)
  force_class == VariableForce
end