class CodeIssue
Constants
- EXCLUDED_COLUMNS
TODO: Yuck! 'stat_value' is a column for StatAnalyzer
Public Instance Methods
<=>(other)
click to toggle source
# File lib/base/code_issue.rb, line 28 def <=>(other) spaceship_for_columns(self.attributes, other) end
===(other)
click to toggle source
# 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)
click to toggle source
# File lib/base/code_issue.rb, line 65 def find_counterpart_index_in(collection) # each_with_index is cleaner, but it is slower and we # spend a lot of time in this loop index = 0 collection.each do |issue| return index if self === issue index += 1 end return nil end
hash_for(column_hash, columns)
click to toggle source
# File lib/base/code_issue.rb, line 44 def hash_for(column_hash, columns) @hashes ||= {} # fetch would be cleaner, but slower 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()
click to toggle source
# 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()
click to toggle source
# File lib/base/code_issue.rb, line 57 def included_columns_hash @included_columns_hash ||= included_columns.hash end
modifies?(other)
click to toggle source
# File lib/base/code_issue.rb, line 76 def modifies?(other) case self.metric when :reek #return false unless ["Large Class", "Long Method", "Long Parameter List"].include?(self.reek__type_name) 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 #self.flay_reason != other.flay_reason # do nothing for now when :roodi, :stats # do nothing else raise ArgumentError, "Invalid metric type #{self.metric}" end end
spaceship_for_columns(columns, other)
click to toggle source
# 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