class MetricFu::ReekGrapher

Attributes

labels[RW]
reek_count[RW]

Public Class Methods

metric() click to toggle source
# File lib/metric_fu/metrics/reek/grapher.rb, line 6
def self.metric
  :reek
end
new() click to toggle source
Calls superclass method
# File lib/metric_fu/metrics/reek/grapher.rb, line 10
def initialize
  super
  @reek_count = {}
  @labels = {}
end

Public Instance Methods

data() click to toggle source
# File lib/metric_fu/metrics/reek/grapher.rb, line 39
def data
  @reek_count.map do |name, count|
    [name, nil_counts_to_zero(count).join(",")]
  end
end
get_metrics(metrics, date) click to toggle source
# File lib/metric_fu/metrics/reek/grapher.rb, line 16
def get_metrics(metrics, date)
  if metrics && metrics[:reek]
    counter = @labels.size
    @labels.update(@labels.size => date)

    metrics[:reek][:matches].each do |reek_chunk|
      reek_chunk[:code_smells].each do |code_smell|
        # speaking of code smell...
        @reek_count[code_smell[:type]] = [] if @reek_count[code_smell[:type]].nil?
        if @reek_count[code_smell[:type]][counter].nil?
          @reek_count[code_smell[:type]][counter] = 1
        else
          @reek_count[code_smell[:type]][counter] += 1
        end
      end
    end
  end
end
output_filename() click to toggle source
# File lib/metric_fu/metrics/reek/grapher.rb, line 45
def output_filename
  "reek.js"
end
title() click to toggle source
# File lib/metric_fu/metrics/reek/grapher.rb, line 35
def title
  "Reek: code smells"
end

Private Instance Methods

nil_counts_to_zero(counts) click to toggle source
# File lib/metric_fu/metrics/reek/grapher.rb, line 51
def nil_counts_to_zero(counts)
  counts.map { |count| count || 0 }
end