Sha256: 9a09855ee30558561a69a8877091557286901a97e0fcf53fcd08c566b846655d

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

module MetricFu
  class HotspotAnalyzedProblems
    MetricFu.metrics_require   { "hotspots/analysis/ranked_problem_location" }

    def initialize(hotspot_rankings, analyzer_tables)
      @hotspot_rankings = hotspot_rankings
      @analyzer_tables = analyzer_tables
    end

    def worst_items
      worst_items = {}
      worst_items[:files]   = worst(@hotspot_rankings.worst_files,   :file)
      worst_items[:classes] = worst(@hotspot_rankings.worst_classes, :class)
      worst_items[:methods] = worst(@hotspot_rankings.worst_methods, :method)
      worst_items
    end

    private

    # @param rankings [Array<MetricFu::HotspotRankings>]
    # @param granularity [Symbol] one of :class, :method, :file
    def worst(rankings, granularity)
      rankings.map do |ranked_item_name|
        sub_table = get_sub_table(granularity, ranked_item_name)
        MetricFu::HotspotRankedProblemLocation.new(sub_table, granularity)
      end
    end

    def get_sub_table(granularity, ranked_item_name)
      tables = @analyzer_tables.tables_for(granularity)
      tables[ranked_item_name]
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
metric_fu-4.13.0 lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb
fastruby-metric_fu-5.0.0 lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb
code_metric_fu-4.14.4 lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb
code_metric_fu-4.14.3 lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb
code_metric_fu-4.14.2 lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb
code_metric_fu-4.14.1 lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb
code_metric_fu-4.14.0 lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb
metric_fu-4.12.0 lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb
metric_fu-4.11.4 lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb