Sha256: e8d9b0b79a12c949f6557010d874e5142a346a3f48fde031c7d67a821cada547

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

class FlayHotspot
  include MetricFu::HotspotScoringStrategies

  COLUMNS = %w{flay_reason flay_matching_reason}

  def columns
    COLUMNS
  end

  def name
    :flay
  end

  def map(row)
    MetricFu::HotspotScoringStrategies.present(row)
  end

  def reduce(scores)
    MetricFu::HotspotScoringStrategies.sum(scores)
  end

  def score(metric_ranking, item)
    MetricFu::HotspotScoringStrategies.percentile(metric_ranking, item)
  end

  def generate_records(data, table)
    return if data==nil
    Array(data[:matches]).each do |match|
      problems  = match[:reason]
      matching_reason = problems.gsub(/^[0-9]+\) /,'').gsub(/\:[0-9]+/,'')
      files     = []
      locations = []
      match[:matches].each do |file_match|
        file_path = file_match[:name].sub(%r{^/},'')
        locations << "#{file_path}:#{file_match[:line]}"
        files     << file_path
      end
      files = files.uniq
      files.each do |file|
        table << {
          "metric" => self.name,
          "file_path" => file,
          "flay_reason" => problems+" files: #{locations.join(', ')}",
          "flay_matching_reason" => matching_reason
        }
      end
    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
metric_fu-4.1.0 lib/metric_fu/metrics/flay/flay_hotspot.rb
metric_fu-4.0.0 lib/metric_fu/metrics/flay/flay_hotspot.rb
metric_fu-3.0.1 lib/metric_fu/metrics/flay/flay_hotspot.rb
metric_fu-3.0.0 lib/metric_fu/metrics/flay/flay_hotspot.rb
metric_fu-2.1.4.pre5 lib/metric_fu/metrics/flay/flay_hotspot.rb
metric_fu-2.1.4.pre4 lib/metric_fu/metrics/flay/flay_hotspot.rb
metric_fu-2.1.4.pre2 lib/metric_fu/metrics/flay/flay_hotspot.rb
metric_fu-2.1.4.pre lib/metric_fu/metrics/flay/flay_hotspot.rb
metric_fu-2.1.3.7.18.1 lib/metrics/flay/flay_hotspot.rb
metric_fu-2.1.3.7.19 lib/metrics/flay/flay_hotspot.rb
metric_fu-2.1.3.6 lib/metrics/flay/flay_hotspot.rb
metric_fu-2.1.3.5 lib/metrics/flay/flay_hotspot.rb