Sha256: df1a1b03a2e2912585c2e31778b114a2a8436c75cf7f16ea38197e1acf084a9f

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module Kolekti
  module Metricfu
    module Parsers
      class Saikuro < Base
        def self.parse(collected_metrics_hash, metric_configuration, persistence_strategy)
          collected_metrics_hash[:files].each do |file|
            name_prefix = parse_file_name(file[:filename])
            file[:classes].each do |cls|
              # Filter duplicate methods, picking only the latest. Fortunately Hash::[] will pick the latest element
              # when receiveing an array.
              methods_by_name = cls[:methods].map { |method| [method[:name], method] }
              # FIXME: Since ruby 2.1 this can be replaced by 'methods_by_name.to_hash'
              methods = Hash[methods_by_name]
              methods.each_value do |method|
                value = method[:complexity]
                name_suffix = module_name_suffix(method[:name])
                module_name = name_prefix + name_suffix

                granularity = KalibroClient::Entities::Miscellaneous::Granularity::METHOD
                persistence_strategy.create_tree_metric_result(metric_configuration, module_name, value.to_f, granularity)
              end
            end
          end
        end

        def self.default_value
          1.0 # Just one branch
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kolekti_metricfu-5.0.0 lib/kolekti/metricfu/parsers/saikuro.rb
kolekti_metricfu-0.0.4 lib/kolekti/metricfu/parsers/saikuro.rb