class Pronto::GoodcheckRunner
Public Instance Methods
goodcheck_home_path()
click to toggle source
# File lib/pronto/goodcheck.rb, line 71 def goodcheck_home_path if (path = ENV["GOODCHECK_HOME"]) Pathname(path) else Pathname(Dir.home) + ".goodcheck" end end
messages_for(issues)
click to toggle source
# File lib/pronto/goodcheck.rb, line 38 def messages_for(issues) issues.map do |issue| patch = patch_for_issue(issue) next if patch.nil? line = patch.added_lines.find do |added_line| issue["location"]["start_line"] == added_line.new_lineno end new_message(line, issue) if line end end
new_message(line, issue)
click to toggle source
# File lib/pronto/goodcheck.rb, line 57 def new_message(line, issue) path = issue["path"] message = "#{issue["message"]}" if issue["justifications"].any? justifications = "" issue["justifications"].each do |justification| justifications << "\n* #{justification}" end message << "\n\nJustifications:\n#{justifications}" end Message.new(path, line, :info, message, nil, self.class) end
patch_for_issue(issue)
click to toggle source
# File lib/pronto/goodcheck.rb, line 51 def patch_for_issue(issue) patches_with_changes.find do |patch| patch.delta.new_file[:path].to_s == issue["path"] end end
patches_with_changes()
click to toggle source
# File lib/pronto/goodcheck.rb, line 32 def patches_with_changes return [] unless @patches @patches_with_changes ||= @patches.select { |patch| patch.additions > 0 } end
project_relative_path(patch)
click to toggle source
# File lib/pronto/goodcheck.rb, line 79 def project_relative_path(patch) Pathname(patch.delta.new_file[:path]) end
run()
click to toggle source
# File lib/pronto/goodcheck.rb, line 9 def run files = patches_with_changes .map { |patch| project_relative_path(patch) } stdout = StringIO.new stderr = StringIO.new reporter = ::Goodcheck::Reporters::JSON.new( stdout: stdout, stderr: stderr, ) runner = ::Goodcheck::Commands::Check.new( config_path: Pathname("goodcheck.yml"), rules: [], targets: files, reporter: reporter, stderr: stderr, home_path: goodcheck_home_path, force_download: false, ) runner.run analysis = JSON.load(stdout.string) messages_for(Array(analysis)) end