class ReekAnalyzer
Constants
- 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
ReekAnalyzer
- REEK_ISSUE_INFO
Public Class Methods
issue_link(issue)
click to toggle source
# File lib/base/reek_analyzer.rb, line 77 def self.issue_link(issue) REEK_ISSUE_INFO[issue] end
numeric_smell?(type)
click to toggle source
# File lib/base/reek_analyzer.rb, line 126 def self.numeric_smell?(type) ["Large Class", "Long Method", "Long Parameter List"].include?(type) end
Public Instance Methods
columns()
click to toggle source
# File lib/base/reek_analyzer.rb, line 81 def columns COLUMNS.map{|column| "#{name}__#{column}"} end
generate_records(data, table)
click to toggle source
# File lib/base/reek_analyzer.rb, line 101 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, # important "file_path" => file_path, # important # NOTE: ReekAnalyzer is currently different than other analyzers with regard # to column name. Note the COLUMNS constant and #columns method "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, # important "method_name" => location.method_name, # important } end end end
map(row)
click to toggle source
# File lib/base/reek_analyzer.rb, line 89 def map(row) ScoringStrategies.present(row) end
name()
click to toggle source
# File lib/base/reek_analyzer.rb, line 85 def name :reek end
reduce(scores)
click to toggle source
# File lib/base/reek_analyzer.rb, line 93 def reduce(scores) ScoringStrategies.sum(scores) end
score(metric_ranking, item)
click to toggle source
# File lib/base/reek_analyzer.rb, line 97 def score(metric_ranking, item) ScoringStrategies.percentile(metric_ranking, item) end
Private Instance Methods
build_value_description(type_name, message)
click to toggle source
# File lib/base/reek_analyzer.rb, line 145 def build_value_description(type_name, message) item_type = message.match(/\d+ (.*)$/) if(item_type) "number of #{item_type[1]} in #{type_name.downcase}" else nil end end
comparable_message(type_name, message)
click to toggle source
# File lib/base/reek_analyzer.rb, line 132 def comparable_message(type_name, message) if self.class.numeric_smell?(type_name) match = message.match(/\d+/) if(match) match.pre_match + match.post_match else message end else message end end
parse_value(message)
click to toggle source
# File lib/base/reek_analyzer.rb, line 154 def parse_value(message) # mf_debug "parsing #{message}" match = message.match(/\d+/) if(match) match[0].to_i else nil end end