Class: CodeIssue
Overview
DelegateClass(Ruport::Data::Record)
Constant Summary
collapse
- EXCLUDED_COLUMNS =
TODO: Yuck! ‘stat_value’ is a column for StatAnalyzer
FlogAnalyzer::COLUMNS + SaikuroAnalyzer::COLUMNS + ['stat_value'] + ChurnAnalyzer::COLUMNS + ReekAnalyzer.new.columns.extend(CarefulArray).carefully_remove(['reek__type_name', 'reek__comparable_message']) + FlayAnalyzer.new.columns.extend(CarefulArray).carefully_remove(['flay_matching_reason'])
Instance Attribute Summary
#data
Instance Method Summary
collapse
#[], #[]=, #attributes, #has_key?, #initialize, #keys, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class MetricFu::Record
Instance Method Details
#<=>(other) ⇒ Object
28
29
30
|
# File 'lib/base/code_issue.rb', line 28
def <=>(other)
spaceship_for_columns(self.attributes, other)
end
|
#===(other) ⇒ Object
32
33
34
|
# File 'lib/base/code_issue.rb', line 32
def ===(other)
self.hash_for(included_columns_hash, included_columns) == other.hash_for(included_columns_hash, included_columns)
end
|
#find_counterpart_index_in(collection) ⇒ Object
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/base/code_issue.rb', line 65
def find_counterpart_index_in(collection)
index = 0
collection.each do |issue|
return index if self === issue
index += 1
end
return nil
end
|
#hash_for(column_hash, columns) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/base/code_issue.rb', line 44
def hash_for(column_hash, columns)
@hashes ||= {}
if @hashes.has_key?(column_hash)
@hashes[column_hash]
else
values = columns.map {|column| self[column]}
hash_for_columns = values.join('').hash
@hashes[column_hash]=hash_for_columns
hash_for_columns
end
end
|
#included_columns ⇒ Object
61
62
63
|
# File 'lib/base/code_issue.rb', line 61
def included_columns
@included_columns ||= self.attributes.extend(CarefulArray).carefully_remove(EXCLUDED_COLUMNS)
end
|
#included_columns_hash ⇒ Object
57
58
59
|
# File 'lib/base/code_issue.rb', line 57
def included_columns_hash
@included_columns_hash ||= included_columns.hash
end
|
#modifies?(other) ⇒ Boolean
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/base/code_issue.rb', line 76
def modifies?(other)
case self.metric
when :reek
return false if self.reek__type_name != other.reek__type_name
self.reek__value != other.reek__value
when :flog
self.score != other.score
when :saikuro
self.complexity != other.complexity
when :stats
self.stat_value != other.stat_value
when :churn
self.times_changed != other.times_changed
when :flay
when :roodi, :stats
else
raise ArgumentError, "Invalid metric type #{self.metric}"
end
end
|
#spaceship_for_columns(columns, other) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/base/code_issue.rb', line 36
def spaceship_for_columns(columns, other)
columns.each do |column|
equality = self[column].to_s <=> other[column].to_s
return equality if equality!=0
end
return 0
end
|