class Pronto::RailsBestPractices
Public Instance Methods
messages_for(patches, errors)
click to toggle source
# File lib/pronto/rails_best_practices.rb, line 25 def messages_for(patches, errors) errors.map do |error| patch = patch_for_error(patches, error) if patch line = patch.added_lines.find do |added_line| added_line.new_lineno == error.line_number.to_i end new_message(line, error) if line end end end
new_message(line, error)
click to toggle source
# File lib/pronto/rails_best_practices.rb, line 39 def new_message(line, error) Message.new(line.patch.delta.new_file[:path], line, :warning, error.message.capitalize, nil, self.class) end
patch_for_error(patches, error)
click to toggle source
# File lib/pronto/rails_best_practices.rb, line 44 def patch_for_error(patches, error) patches.find do |patch| patch.new_file_full_path.to_s == error.filename end end
run()
click to toggle source
# File lib/pronto/rails_best_practices.rb, line 6 def run return [] unless @patches patches_with_additions = @patches.select { |patch| patch.additions > 0 } files = patches_with_additions.map do |patch| Regexp.new(patch.new_file_full_path.to_s) end if files.any? analyzer = ::RailsBestPractices::Analyzer.new('.', 'silent' => true, 'only' => files) analyzer.analyze messages_for(patches_with_additions, analyzer.errors).compact else [] end end