module RuboCop::Cop::Utils::MethodReturnTable

Public Class Methods

get_method(method_name) click to toggle source
# File lib/rubocop/cop/betterment/utils/method_return_table.rb, line 25
def get_method(method_name)
  indexed_methods[method_name]
end
has_method?(method_name) click to toggle source
# File lib/rubocop/cop/betterment/utils/method_return_table.rb, line 29
def has_method?(method_name)
  indexed_methods.include?(method_name)
end
indexed_methods() click to toggle source
# File lib/rubocop/cop/betterment/utils/method_return_table.rb, line 21
def indexed_methods
  @indexed_methods ||= {}
end
populate_index(node) click to toggle source
# File lib/rubocop/cop/betterment/utils/method_return_table.rb, line 6
def populate_index(node)
  raise "not a class" unless node.class_type?

  get_methods_for_class(node).each do |method|
    track_method(method.method_name, Utils::Parser.get_return_values(method))
  end

  node.descendants.each do |descendant|
    lhs, rhs = *descendant
    next unless descendant.equals_asgn? && (descendant.type != :casgn) && rhs&.send_type?

    track_method(lhs, [rhs])
  end
end

Private Class Methods

get_methods_for_class(node) click to toggle source
# File lib/rubocop/cop/betterment/utils/method_return_table.rb, line 39
def get_methods_for_class(node)
  return [] unless node.children && node.class_type?

  node.descendants.select(&:def_type?)
end
track_method(method_name, returns) click to toggle source
# File lib/rubocop/cop/betterment/utils/method_return_table.rb, line 35
def track_method(method_name, returns)
  indexed_methods[method_name] = returns
end