class MetricFu::RailsBestPracticesGenerator
Public Class Methods
metric()
click to toggle source
# File lib/metric_fu/metrics/rails_best_practices/generator.rb, line 3 def self.metric :rails_best_practices end
new(options = {})
click to toggle source
Calls superclass method
MetricFu::Generator::new
# File lib/metric_fu/metrics/rails_best_practices/generator.rb, line 7 def initialize(options = {}) super(MetricFu::Utility.stringify_keys(options)) end
Public Instance Methods
analyze()
click to toggle source
# File lib/metric_fu/metrics/rails_best_practices/generator.rb, line 19 def analyze @problems = @output.collect do |problem| { file: problem.short_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
emit()
click to toggle source
# File lib/metric_fu/metrics/rails_best_practices/generator.rb, line 11 def emit mf_debug "** Rails Best Practices" path = "." analyzer = ::RailsBestPractices::Analyzer.new(path, options) analyzer.analyze @output = analyzer.errors end
per_file_info(out)
click to toggle source
# File lib/metric_fu/metrics/rails_best_practices/generator.rb, line 36 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
to_h()
click to toggle source
# File lib/metric_fu/metrics/rails_best_practices/generator.rb, line 32 def to_h { rails_best_practices: @rails_best_practices_results } end