Module: RuboCop::Cop::Betterment::Utils::MethodReturnTable
- Defined in:
- lib/rubocop/cop/betterment/utils/method_return_table.rb
Class Method Summary collapse
- .get_method(method_name) ⇒ Object
- .has_method?(method_name) ⇒ Boolean
- .indexed_methods ⇒ Object
- .populate_index(node) ⇒ Object
Class Method Details
.get_method(method_name) ⇒ Object
28 29 30 |
# File 'lib/rubocop/cop/betterment/utils/method_return_table.rb', line 28 def get_method(method_name) indexed_methods[method_name] end |
.has_method?(method_name) ⇒ Boolean
32 33 34 |
# File 'lib/rubocop/cop/betterment/utils/method_return_table.rb', line 32 def has_method?(method_name) indexed_methods.include?(method_name) end |
.indexed_methods ⇒ Object
24 25 26 |
# File 'lib/rubocop/cop/betterment/utils/method_return_table.rb', line 24 def indexed_methods @indexed_methods ||= {} end |
.populate_index(node) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rubocop/cop/betterment/utils/method_return_table.rb', line 9 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 |