Class: MetricFu::ReekHotspot
- Inherits:
-
Hotspot
- Object
- Hotspot
- MetricFu::ReekHotspot
show all
- Defined in:
- lib/metric_fu/metrics/reek/hotspot.rb
Constant Summary
collapse
- COLUMNS =
Note that in practice, the prefix reek__ is appended to each one This was a partially implemented idea to avoid column name collisions but it is only done in the ReekHotspot
%w{type_name message value value_description comparable_message}
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Hotspot
analyzer_for_metric, analyzers, #get_mean, #map, #mapping_strategies, metric, #not_implemented, #reduce, #score
Class Method Details
.numeric_smell?(type) ⇒ Boolean
53
54
55
|
# File 'lib/metric_fu/metrics/reek/hotspot.rb', line 53
def self.numeric_smell?(type)
["Large Class", "Long Method", "Long Parameter List"].include?(type)
end
|
Instance Method Details
#columns ⇒ Object
8
9
10
|
# File 'lib/metric_fu/metrics/reek/hotspot.rb', line 8
def columns
COLUMNS.map { |column| "#{name}__#{column}" }
end
|
#generate_records(data, table) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/metric_fu/metrics/reek/hotspot.rb', line 28
def generate_records(data, table)
return if data == nil
data[:matches].each do |match|
file_path = match[:file_path]
match[:code_smells].each do |smell|
location = MetricFu::Location.for(smell[:method])
smell_type = smell[:type]
message = smell[:message]
table << {
"metric" => name, "file_path" => file_path, "reek__message" => message,
"reek__type_name" => smell_type,
"reek__value" => parse_value(message),
"reek__value_description" => build_value_description(smell_type, message),
"reek__comparable_message" => comparable_message(smell_type, message),
"class_name" => location.class_name, "method_name" => location.method_name, }
end
end
end
|
#map_strategy ⇒ Object
16
17
18
|
# File 'lib/metric_fu/metrics/reek/hotspot.rb', line 16
def map_strategy
:present
end
|
#name ⇒ Object
12
13
14
|
# File 'lib/metric_fu/metrics/reek/hotspot.rb', line 12
def name
:reek
end
|
#present_group(group) ⇒ Object
57
58
59
60
|
# File 'lib/metric_fu/metrics/reek/hotspot.rb', line 57
def present_group(group)
occurences = group.size
"found #{occurences} code smells"
end
|
#reduce_strategy ⇒ Object
20
21
22
|
# File 'lib/metric_fu/metrics/reek/hotspot.rb', line 20
def reduce_strategy
:sum
end
|
#score_strategy ⇒ Object
24
25
26
|
# File 'lib/metric_fu/metrics/reek/hotspot.rb', line 24
def score_strategy
:percentile
end
|