Sha256: d5c15781de717fad6021efd643ca474abbf9c8e4616db151c9147d556d1d116f

Contents?: true

Size: 1.16 KB

Versions: 15

Compression:

Stored size: 1.16 KB

Contents

module MetricFu
  class RailsBestPracticesGenerator < Generator

    def self.metric
      :rails_best_practices
    end

    def emit
      mf_debug "** Rails Best Practices"
      path = '.'
      analyzer = ::RailsBestPractices::Analyzer.new(path, { 'silent' => true })
      analyzer.analyze
      @output = analyzer.errors
    end

    def analyze
      @problems = @output.collect do |problem|
        {
          :file    => problem.filename,
          :line    => problem.line_number,
          :problem => problem.message,
          :url     => problem.url
        }
      end
      total = ["Found #{@problems.count} errors."]
      @rails_best_practices_results = {:total => total, :problems => @problems}
    end

    def to_h
      {:rails_best_practices => @rails_best_practices_results}
    end

    def per_file_info(out)
      @rails_best_practices_results[:problems].each do |problem|
        next if problem[:file] == '' || problem[:problem].nil?


        lines = problem[:line].split(/\s*,\s*/)
        lines.each do |line|
          out[problem[:file]][line] << {:type => :rails_best_practices, :description => problem[:problem]}
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
metric_fu-4.11.3 lib/metric_fu/metrics/rails_best_practices/generator.rb
metric_fu-4.11.2 lib/metric_fu/metrics/rails_best_practices/generator.rb
metric_fu-4.11.1 lib/metric_fu/metrics/rails_best_practices/generator.rb
metric_fu-4.11.0 lib/metric_fu/metrics/rails_best_practices/generator.rb
metric_fu-4.10.0 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.9.0 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.8.0 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.7.4 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.7.3 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.7.2 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.7.1 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.7.0 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.6.0 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.5.2 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb
metric_fu-4.5.1 lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb