Class: MetricFu::SaikuroHotspot

Inherits:
Hotspot
  • Object
show all
Defined in:
lib/metric_fu/metrics/saikuro/hotspot.rb

Constant Summary collapse

COLUMNS =
%w{lines complexity}

Instance Method Summary collapse

Methods inherited from Hotspot

analyzer_for_metric, analyzers, #get_mean, #map, #mapping_strategies, metric, #not_implemented, #reduce, #score

Instance Method Details

#columnsObject



4
5
6
# File 'lib/metric_fu/metrics/saikuro/hotspot.rb', line 4

def columns
  COLUMNS
end

#generate_records(data, table) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/metric_fu/metrics/saikuro/hotspot.rb', line 24

def generate_records(data, table)
  return if data == nil
  data[:files].each do |file|
    file_name = file[:filename]
    file[:classes].each do |klass|
      location = MetricFu::Location.for(klass[:class_name])
      offending_class = location.class_name
      klass[:methods].each do |match|
        offending_method = MetricFu::Location.for(match[:name]).method_name
        table << {
          "metric" => name,
          "lines" => match[:lines],
          "complexity" => match[:complexity],
          "class_name" => offending_class,
          "method_name" => offending_method,
          "file_path" => file_name,
        }
      end
    end
  end
end

#map_strategyObject



12
13
14
# File 'lib/metric_fu/metrics/saikuro/hotspot.rb', line 12

def map_strategy
  :complexity
end

#nameObject



8
9
10
# File 'lib/metric_fu/metrics/saikuro/hotspot.rb', line 8

def name
  :saikuro
end

#present_group(group) ⇒ Object



46
47
48
49
50
# File 'lib/metric_fu/metrics/saikuro/hotspot.rb', line 46

def present_group(group)
  occurences = group.size
  complexity = get_mean(group.column("complexity"))
  "#{'average ' if occurences > 1}complexity is %.1f" % complexity
end

#reduce_strategyObject



16
17
18
# File 'lib/metric_fu/metrics/saikuro/hotspot.rb', line 16

def reduce_strategy
  :average
end

#score_strategyObject



20
21
22
# File 'lib/metric_fu/metrics/saikuro/hotspot.rb', line 20

def score_strategy
  :identity
end