Sha256: c95755dab6a4b3bccbaf2e453231c3b0b6ad15800ea4d795dbeab8f102a419c1

Contents?: true

Size: 914 Bytes

Versions: 15

Compression:

Stored size: 914 Bytes

Contents

module MetricFu
  
  class Reek < Generator
    REEK_REGEX = /^(\S+) (.*) \((.*)\)$/

    def emit
      files_to_reek = MetricFu.reek[:dirs_to_reek].map{|dir| Dir[File.join(dir, "**/*.rb")] }
      @output = `reek #{files_to_reek.join(" ")}`
    end

    def analyze
      @matches = @output.chomp.split("\n\n").map{|m| m.split("\n") }
      @matches = @matches.map do |match|
        file_path = match.shift.split('--').first
        file_path = file_path.gsub('"', ' ').strip
        code_smells = match.map do |smell|
          match_object = smell.match(REEK_REGEX)
          next unless match_object
          {:method => match_object[1].strip,
           :message => match_object[2].strip,
           :type => match_object[3].strip}
        end.compact
        {:file_path => file_path, :code_smells => code_smells}
      end
    end

    def to_h
      {:reek => {:matches => @matches}}
    end

  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
edouard-metric_fu-1.0.3.3 lib/generators/reek.rb
edouard-metric_fu-1.0.3.4 lib/generators/reek.rb
edouard-metric_fu-1.0.3.5 lib/generators/reek.rb
edouard-metric_fu-1.0.3.6 lib/generators/reek.rb
edouard-metric_fu-1.0.3.7 lib/generators/reek.rb
edouard-metric_fu-1.0.3.8 lib/generators/reek.rb
edouard-metric_fu-1.0.4.1 lib/generators/reek.rb
edouard-metric_fu-1.0.4.2 lib/generators/reek.rb
edouard-metric_fu-1.0.4.3 lib/generators/reek.rb
edouard-metric_fu-1.0.4.4 lib/generators/reek.rb
edouard-metric_fu-1.0.4.5 lib/generators/reek.rb
edouard-metric_fu-1.0.4 lib/generators/reek.rb
jscruggs-metric_fu-1.0.2 lib/generators/reek.rb
khall-metric_fu-1.0.2.1 lib/generators/reek.rb
khall-metric_fu-1.0.2.2 lib/generators/reek.rb