Class: Doxyparser::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/entruby.rb

Instance Method Summary collapse

Instance Method Details

#afferent(all = nil) ⇒ Object



46
47
48
# File 'lib/entruby.rb', line 46

def afferent(all = nil)
  all.to_a.empty? ? referenced_by : referenced_by.map { |ref| ref.reveal(all) }.compact
end

#coupling_metric(all = nil) ⇒ Object



58
59
60
61
62
63
# File 'lib/entruby.rb', line 58

def coupling_metric(all = nil)
  fan_out = fan_out(all).to_f
  fan_in = fan_in(all).to_f
  denominator = fan_out + fan_in
  denominator == 0 ? 0 : fan_out / (denominator)
end

#efferent(all = nil) ⇒ Object



42
43
44
# File 'lib/entruby.rb', line 42

def efferent(all = nil)
  all.to_a.empty? ? references : references.map { |ref| ref.reveal(all) }.compact
end

#fan_in(all = nil) ⇒ Object



54
55
56
# File 'lib/entruby.rb', line 54

def fan_in(all = nil)
  afferent(all).size
end

#fan_out(all = nil) ⇒ Object



50
51
52
# File 'lib/entruby.rb', line 50

def fan_out(all = nil)
  efferent(all).size
end

#global_nameObject



65
66
67
# File 'lib/entruby.rb', line 65

def global_name
  "global::#{signature}"
end

#referenced_byObject



38
39
40
# File 'lib/entruby.rb', line 38

def referenced_by
  node.css('referencedby').map { |ref| Reference.new(ref) }
end

#referencesObject



34
35
36
# File 'lib/entruby.rb', line 34

def references
  node.css('references').map { |ref| Reference.new(ref) }
end

#report(all) ⇒ Object

Returns Report.

Returns:

  • Report



78
79
80
81
82
# File 'lib/entruby.rb', line 78

def report(all)
  {id: id, name: basename, signature: signature, location: location, metric: coupling_metric(all), col: col,
   params: valid_params.map(&:as_json),
   imports: efferent(all).map(&:signature)}
end

#signatureObject



73
74
75
# File 'lib/entruby.rb', line 73

def signature
  "#{basename}(#{valid_params.map { |p| p.type.name }.join(', ')})"
end

#valid_paramsObject



69
70
71
# File 'lib/entruby.rb', line 69

def valid_params
  params.reject { |p| p.type.name == 'void' }
end