Class: MetricFu::FlayHotspot
- Inherits:
-
Hotspot
- Object
- Hotspot
- MetricFu::FlayHotspot
show all
- Defined in:
- lib/metric_fu/metrics/flay/hotspot.rb
Constant Summary
collapse
- COLUMNS =
%w{flay_reason flay_matching_reason}
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
#columns ⇒ Object
4
5
6
|
# File 'lib/metric_fu/metrics/flay/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
45
46
|
# File 'lib/metric_fu/metrics/flay/hotspot.rb', line 24
def generate_records(data, table)
return if data == nil
Array(data[:matches]).each do |match|
problems = match[:reason]
matching_reason = problems.gsub(/^[0-9]+\) /, "").gsub(/\:[0-9]+/, "")
files = []
locations = []
match[:matches].each do |file_match|
file_path = file_match[:name].sub(%r{^/}, "")
locations << "#{file_path}:#{file_match[:line]}"
files << file_path
end
files = files.uniq
files.each do |file|
table << {
"metric" => name,
"file_path" => file,
"flay_reason" => problems + " files: #{locations.join(', ')}",
"flay_matching_reason" => matching_reason
}
end
end
end
|
#map_strategy ⇒ Object
12
13
14
|
# File 'lib/metric_fu/metrics/flay/hotspot.rb', line 12
def map_strategy
:present
end
|
#name ⇒ Object
8
9
10
|
# File 'lib/metric_fu/metrics/flay/hotspot.rb', line 8
def name
:flay
end
|
#present_group(group) ⇒ Object
48
49
50
51
|
# File 'lib/metric_fu/metrics/flay/hotspot.rb', line 48
def present_group(group)
occurences = group.size
"found #{occurences} code duplications"
end
|
#reduce_strategy ⇒ Object
16
17
18
|
# File 'lib/metric_fu/metrics/flay/hotspot.rb', line 16
def reduce_strategy
:sum
end
|
#score_strategy ⇒ Object
20
21
22
|
# File 'lib/metric_fu/metrics/flay/hotspot.rb', line 20
def score_strategy
:percentile
end
|