Class: SaikuroAnalyzer

Inherits:
Object
  • Object
show all
Includes:
ScoringStrategies
Defined in:
lib/base/saikuro_analyzer.rb

Constant Summary collapse

COLUMNS =
%w{lines complexity}

Instance Method Summary collapse

Methods included from ScoringStrategies

#average, #identity, #percentile, #present, #sum

Instance Method Details

#columnsObject



6
7
8
# File 'lib/base/saikuro_analyzer.rb', line 6

def columns
  COLUMNS
end

#generate_records(data, table) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/base/saikuro_analyzer.rb', line 26

def generate_records(data, table)
  return if data == nil
  data[:files].each do |file|
    file_name = file[:filename]
    file[:classes].each do |klass|
      location = MetricFu::Location.for(klass[:class_name])
      offending_class = location.class_name
      klass[:methods].each do |match|
        offending_method = MetricFu::Location.for(match[:name]).method_name
        table << {
          "metric" => name,
          "lines" => match[:lines],
          "complexity" => match[:complexity],
          "class_name" => offending_class,
          "method_name" => offending_method,
          "file_path" => file_name,
        }
      end
    end
  end
end

#map(row) ⇒ Object



14
15
16
# File 'lib/base/saikuro_analyzer.rb', line 14

def map(row)
  row.complexity
end

#nameObject



10
11
12
# File 'lib/base/saikuro_analyzer.rb', line 10

def name
  :saikuro
end

#reduce(scores) ⇒ Object



18
19
20
# File 'lib/base/saikuro_analyzer.rb', line 18

def reduce(scores)
  ScoringStrategies.average(scores)
end

#score(metric_ranking, item) ⇒ Object



22
23
24
# File 'lib/base/saikuro_analyzer.rb', line 22

def score(metric_ranking, item)
  ScoringStrategies.identity(metric_ranking, item)
end