Class: CollectionNode
Instance Attribute Summary collapse
Attributes inherited from BaseNode
#level, #location, #name
Instance Method Summary
collapse
Methods inherited from BaseNode
#complexity_share, #complexity_smells, #file?, #folder?, #function?, #path, #private?, #quality, #smells, #tangle_smells
Constructor Details
#initialize(name, location, visibility, level) ⇒ CollectionNode
Returns a new instance of CollectionNode.
6
7
8
9
|
# File 'lib/model/collection_node.rb', line 6
def initialize(name, location, visibility, level)
super(name, location, visibility, level)
@nodes = {}
end
|
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes.
4
5
6
|
# File 'lib/model/collection_node.rb', line 4
def nodes
@nodes
end
|
Instance Method Details
#complexity ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/model/collection_node.rb', line 27
def complexity
retval = 0
dependencies.each_value do |tonode|
tonode.each_value do |dependency|
retval += 1
end
end
retval
end
|
#dependencies ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/model/collection_node.rb', line 49
def dependencies
if @cache_dependencies
@cache_dependencies
else
deps = {}
@nodes.each_value do |fromnode|
fromnode.external_dependencies.each do |todep, depvalue|
@nodes.each_value do |tonode|
tonode.functions.each do |tofunction|
to = tonode.name
from = fromnode.name
if tofunction == todep and to != from
calculate_dependency deps, to, from, depvalue
end
end
end
end
end
@cache_dependencies = deps
end
end
|
#external_dependencies ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/model/collection_node.rb', line 71
def external_dependencies
deps = {}
@nodes.each_value do |node|
deps.merge! node.external_dependencies
end
deps
end
|
#functions ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/model/collection_node.rb', line 79
def functions
if @cache_functions
@cache_functions
else
functions = []
@nodes.each_value do |node|
functions.concat node.functions
end
@cache_functions = functions
end
end
|
#pot_smell ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/model/collection_node.rb', line 11
def pot_smell
retval = 0
@nodes.each_value do |node|
retval += node.pot_smell
end
retval + size*2
end
|
#size ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/model/collection_node.rb', line 19
def size
retval = 0
@nodes.each_value do |node|
retval += node.size
end
retval
end
|
#tangle_share ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/model/collection_node.rb', line 37
def tangle_share
tangles = 0
edges = 0
dependencies.each_value do |tonode|
tonode.each_value do |dependency|
tangles += dependency[:circ] ? 1 : 0
edges += 1
end
end
edges > 0 ? tangles.to_f/edges : 0
end
|