Sha256: 720276d782e02b7f8bce6e2d6be2643d1ee039e8ce684e4298aeca9f68f1a867

Contents?: true

Size: 1.37 KB

Versions: 11

Compression:

Stored size: 1.37 KB

Contents

MetricFu.metrics_require   { 'hotspots/hotspot_analyzer' }
module MetricFu

  class Hotspots < Generator

    def initialize(options={})
      super
    end

    def self.verify_dependencies!
      true
    end

    def emit
      @analyzer = MetricFu::HotspotAnalyzer.new(MetricFu.report.report_hash)
    end

    def analyze
      num = nil
      worst_items = {}
      if @analyzer
        worst_items[:files] =
          @analyzer.worst_files(num).inject([]) do |array, worst_file|
          array <<
            {:location => @analyzer.location(:file, worst_file),
            :details => @analyzer.problems_with(:file, worst_file)}
          array
        end
        worst_items[:classes] = @analyzer.worst_classes(num).inject([]) do |array, class_name|
          location = @analyzer.location(:class, class_name)
          array <<
            {:location => location,
            :details => @analyzer.problems_with(:class, class_name)}
          array
        end
        worst_items[:methods] = @analyzer.worst_methods(num).inject([]) do |array, method_name|
          location = @analyzer.location(:method, method_name)
          array <<
            {:location => location,
            :details => @analyzer.problems_with(:method, method_name)}
          array
        end
      end

      @hotspots = worst_items
    end

    def to_h
      {:hotspots => @hotspots}
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

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