Class/Module Index [+]

Quicksearch

Reek::Core::MethodContext

A context wrapper for any method definition found in a syntax tree.

Attributes

num_statements[R]
parameters[R]
refs[R]

Public Class Methods

new(outer, exp) click to toggle source
# File lib/reek/core/method_context.rb, line 50
def initialize(outer, exp)
  super(outer, exp)
  @parameters = exp[exp[0] == :defn ? 2 : 3]  # SMELL: SimulatedPolymorphism
  @parameters ||= []
  @parameters.extend(MethodParameters)
  @num_statements = 0
  @refs = ObjectRefs.new
end

Public Instance Methods

count_statements(num) click to toggle source
# File lib/reek/core/method_context.rb, line 59
def count_statements(num)
  @num_statements += num
end
envious_receivers() click to toggle source
# File lib/reek/core/method_context.rb, line 78
def envious_receivers
  return [] if @refs.self_is_max?
  @refs.max_keys
end
record_call_to(exp) click to toggle source
# File lib/reek/core/method_context.rb, line 63
def record_call_to(exp)
  receiver, meth = exp[1..2]
  receiver ||= [:self]
  case receiver[0]
  when :lvar
    @refs.record_ref(receiver) unless meth == :new
  when :self
    record_use_of_self
  end
end
record_use_of_self() click to toggle source
# File lib/reek/core/method_context.rb, line 74
def record_use_of_self
  @refs.record_reference_to_self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.