Class: Moult::Report::Hotspot

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

Overview

One ranked file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, score:, complexity:, churn:, methods:, fan_in: nil, fan_out: nil, instability: nil, confidence: nil, category: nil) ⇒ Hotspot

Returns a new instance of Hotspot.

Parameters:

  • path (String)

    path relative to the analysis root

  • score (Float)

    complexity x churn

  • complexity (Float)

    aggregate ABC for the file

  • churn (Integer)

    commits touching the file in the window

  • methods (Array<Method>)

    worst methods, highest ABC first

  • fan_in (Integer, nil) (defaults to: nil)

    files depending on this file (resolved constant references); nil when no index was built

  • fan_out (Integer, nil) (defaults to: nil)

    files this file depends on; nil likewise

  • instability (Float, nil) (defaults to: nil)

    fan_out / (fan_in + fan_out); 0 when isolated, nil when no index was built



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/moult/report.rb', line 63

def initialize(path:, score:, complexity:, churn:, methods:,
  fan_in: nil, fan_out: nil, instability: nil, confidence: nil, category: nil)
  @path = path
  @score = score
  @complexity = complexity
  @churn = churn
  @methods = methods
  @fan_in = fan_in
  @fan_out = fan_out
  @instability = instability
  @confidence = confidence
  @category = category
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



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

def category
  @category
end

#churnObject (readonly)

Returns the value of attribute churn.



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

def churn
  @churn
end

#complexityObject (readonly)

Returns the value of attribute complexity.



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

def complexity
  @complexity
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



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

def confidence
  @confidence
end

#fan_inObject (readonly)

Returns the value of attribute fan_in.



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

def fan_in
  @fan_in
end

#fan_outObject (readonly)

Returns the value of attribute fan_out.



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

def fan_out
  @fan_out
end

#instabilityObject (readonly)

Returns the value of attribute instability.



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

def instability
  @instability
end

#methodsObject (readonly)

Returns the value of attribute methods.



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

def methods
  @methods
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#scoreObject (readonly)

Returns the value of attribute score.



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

def score
  @score
end

Instance Method Details

#to_hObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/moult/report.rb', line 82

def to_h
  {
    path: path,
    score: score,
    complexity: complexity,
    churn: churn,
    fan_in: fan_in,
    fan_out: fan_out,
    instability: instability,
    confidence: confidence,
    category: category,
    methods: methods.map(&:to_h)
  }
end

#worst_methodObject

The single worst method in the file, for table drill-down.



78
79
80
# File 'lib/moult/report.rb', line 78

def worst_method
  methods.first
end