Class: CodeIssue
- Inherits:
-
Record
show all
- Includes:
- Comparable
- Defined in:
- lib/base/code_issue.rb
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
Attributes inherited from Record
#data
Instance Method Summary
collapse
Methods inherited from Record
#[], #[]=, #attributes, #has_key?, #initialize, #keys, #method_missing
Constructor Details
This class inherits a constructor from Record
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Record
Instance Method Details
#<=>(other) ⇒ Object
25
26
27
|
# File 'lib/base/code_issue.rb', line 25
def <=>(other)
spaceship_for_columns(self.attributes, other)
end
|
#===(other) ⇒ Object
29
30
31
|
# File 'lib/base/code_issue.rb', line 29
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
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/base/code_issue.rb', line 62
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
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/base/code_issue.rb', line 41
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
58
59
60
|
# File 'lib/base/code_issue.rb', line 58
def included_columns
@included_columns ||= self.attributes.extend(CarefulArray).carefully_remove(EXCLUDED_COLUMNS)
end
|
#included_columns_hash ⇒ Object
54
55
56
|
# File 'lib/base/code_issue.rb', line 54
def included_columns_hash
@included_columns_hash ||= included_columns.hash
end
|
#modifies?(other) ⇒ Boolean
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/base/code_issue.rb', line 73
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
33
34
35
36
37
38
39
|
# File 'lib/base/code_issue.rb', line 33
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
|