Class: Reek::ClassContext
Instance Attribute Summary collapse
Attributes inherited from CodeContext
#name
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from CodeContext
#matches?, #method_missing
Constructor Details
#initialize(outer, name, superclass = nil) ⇒ ClassContext
SMELL: inconsistent with other contexts (not linked to the sexp)
30
31
32
33
34
35
36
37
|
# File 'lib/reek/class_context.rb', line 30
def initialize(outer, name, superclass = nil)
super(outer, nil)
@name = name
@superclass = superclass
@parsed_methods = []
@instance_variables = Set.new
@conditionals = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Reek::CodeContext
Instance Attribute Details
#conditionals ⇒ Object
Returns the value of attribute conditionals.
27
28
29
|
# File 'lib/reek/class_context.rb', line 27
def conditionals
@conditionals
end
|
#parsed_methods ⇒ Object
Returns the value of attribute parsed_methods.
27
28
29
|
# File 'lib/reek/class_context.rb', line 27
def parsed_methods
@parsed_methods
end
|
Instance Method Details
#find_module(modname) ⇒ Object
43
44
45
46
|
# File 'lib/reek/class_context.rb', line 43
def find_module(modname)
return nil unless myself
@myself.const_or_nil(modname.to_s)
end
|
#is_overriding_method?(name) ⇒ Boolean
48
49
50
51
|
# File 'lib/reek/class_context.rb', line 48
def is_overriding_method?(name)
return false unless myself
@myself.is_overriding_method?(name.to_s)
end
|
#is_struct? ⇒ Boolean
53
54
55
|
# File 'lib/reek/class_context.rb', line 53
def is_struct?
@superclass == [:const, :Struct]
end
|
39
40
41
|
# File 'lib/reek/class_context.rb', line 39
def myself
@myself ||= @outer.find_module(@name)
end
|
#num_methods ⇒ Object
57
58
59
|
# File 'lib/reek/class_context.rb', line 57
def num_methods
@parsed_methods.length
end
|
#outer_name ⇒ Object
69
70
71
|
# File 'lib/reek/class_context.rb', line 69
def outer_name
"#{@outer.outer_name}#{@name}#"
end
|
#parameterized_methods(min_clump_size) ⇒ Object
85
86
87
|
# File 'lib/reek/class_context.rb', line 85
def parameterized_methods(min_clump_size)
parsed_methods.select {|meth| meth.parameters.length >= min_clump_size }
end
|
#record_conditional(exp) ⇒ Object
81
82
83
|
# File 'lib/reek/class_context.rb', line 81
def record_conditional(exp)
@conditionals << exp
end
|
#record_instance_variable(sym) ⇒ Object
61
62
63
|
# File 'lib/reek/class_context.rb', line 61
def record_instance_variable(sym)
@instance_variables << Name.new(sym)
end
|
#record_method(meth) ⇒ Object
65
66
67
|
# File 'lib/reek/class_context.rb', line 65
def record_method(meth)
@parsed_methods << meth
end
|
73
74
75
|
# File 'lib/reek/class_context.rb', line 73
def to_s
"#{@outer.outer_name}#{@name}"
end
|
#variable_names ⇒ Object
77
78
79
|
# File 'lib/reek/class_context.rb', line 77
def variable_names
@instance_variables
end
|