Class: MetricFu::RcovHotspot

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

Constant Summary collapse

COLUMNS =
%w{percentage_uncovered}

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/rcov/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
# File 'lib/metric_fu/metrics/rcov/hotspot.rb', line 24

def generate_records(data, table)
  return if data == nil
  data.each do |file_name, info|
    next if (file_name == :global_percent_run) || (info[:methods].nil?)
    info[:methods].each do |method_name, percentage_uncovered|
      location = MetricFu::Location.for(method_name)
      table << {
        "metric" => :rcov,
        "file_path" => file_name,
        "class_name" => location.class_name,
        "method_name" => location.method_name,
        "percentage_uncovered" => percentage_uncovered
      }
    end
  end
end

#map_strategyObject



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

def map_strategy
  :percentage_uncovered
end

#nameObject



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

def name
  :rcov
end

#present_group(group) ⇒ Object



41
42
43
44
45
# File 'lib/metric_fu/metrics/rcov/hotspot.rb', line 41

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

#reduce_strategyObject



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

def reduce_strategy
  :average
end

#score_strategyObject



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

def score_strategy
  :identity
end