Sha256: 0a40a3ea0f3d1675ca205ecfcd323cff49f8647990a767d544852974e8d3bc40

Contents?: true

Size: 813 Bytes

Versions: 5

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

module RubyCritic
  class AnalysisSummary
    def self.generate(analysed_modules)
      new(analysed_modules).generate
    end

    def initialize(analysed_modules)
      @analysed_modules = analysed_modules
    end

    def generate
      %w(A B C D F).each_with_object({}) do |rating, summary|
        summary[rating] = generate_for(rating)
      end
    end

    private

    attr_reader :analysed_modules, :modules

    def generate_for(rating)
      @modules = analysed_modules.for_rating(rating)
      {
        files: modules.count,
        churns: churns,
        smells: smells
      }
    end

    def churns
      modules.inject(0) { |acc, elem| acc + elem.churn }
    end

    def smells
      modules.inject(0) { |acc, elem| acc + elem.smells.count }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubycritic-3.2.0 lib/rubycritic/analysis_summary.rb
rubycritic-3.1.3 lib/rubycritic/analysis_summary.rb
rubycritic-3.1.2 lib/rubycritic/analysis_summary.rb
rubycritic-3.1.1 lib/rubycritic/analysis_summary.rb
rubycritic-3.1.0 lib/rubycritic/analysis_summary.rb