Class: Maximus::Railsbp
Overview
Instance Attribute Summary
Attributes inherited from Lint
Instance Method Summary collapse
-
#result ⇒ Object
rails_best_practice (requires Rails).
Methods inherited from Lint
Methods included from Helper
#check_default_config_path, #edit_yaml, #file_count, #file_list, #is_rails?, #lines_added_to_range, #node_module_exists, #path_exists?, #prompt, #reporter_path, #root_dir, #truthy?
Constructor Details
This class inherits a constructor from Maximus::Lint
Instance Method Details
#result ⇒ Object
rails_best_practice (requires Rails)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/maximus/lints/railsbp.rb', line 7 def result @task = 'railsbp' @path = @settings[:root_dir] if @path.blank? return unless is_rails? && temp_config(@task) && path_exists?(@path) tmp = Tempfile.new('railsbp') `rails_best_practices #{@path} -f json --output-file #{tmp.path}` railsbp = tmp.read tmp.close tmp.unlink unless railsbp.blank? rbj = JSON.parse(railsbp).group_by { |s| s['filename'] } railsbp = {} rbj.each do |file, errors| next unless file # This crazy gsub scrubs the absolute path from the filename filename = file.gsub(Rails.root.to_s, '')[1..-1] railsbp[filename] = errors.map { |o| hash_for_railsbp(o) } end end @output[:files_inspected] ||= files_inspected('rb', ' ') refine railsbp end |