help wantedpinnedrefactoring
Repository metrics
- Stars
- (16 stars)
- PR merge metrics
- (PR metrics pending)
Description
Hello!
I've found this gem, which is able to unify the output of multiple static code review services. I already have some contributions to the code and the maintainer was always helpful. This example shows how can a PR reviewed:
#!/bin/env ruby
require 'fileutils'
require 'pronto'
require 'rugged'
require 'pronto/rubocop'
# These two parameters can be extracted from a PR webhook payload
PR_N = 7470
BASE = 'd5b175f'.freeze
REPO = 'manageiq/manageiq'.freeze
TRGT = 'manageiq'.freeze
repo = Rugged::Repository.init_at("tmp/#{TRGT}/")
repo.remotes.create('origin', "https://github.com/#{REPO}.git")
pronto_repo = Pronto::Git::Repository.new("tmp/#{TRGT}")
rugged_repo = pronto_repo.instance_variable_get(:@repo)
rugged_repo.remotes['origin'].fetch("pull/#{PR_N}/head")
rugged_repo.checkout('FETCH_HEAD')
diff = rugged_repo.diff(BASE, rugged_repo.head.target)
patches = Pronto::Git::Patches.new(pronto_repo, BASE, diff)
result = Pronto::Runners.new.run(patches)
formatter = Pronto::Formatter::JsonFormatter.new
formatter.format(result, pronto_repo, patches)
FileUtils.rm_rf("tmp/#{TRGT}")
I know that it's not the cleanest code, but it looks way better than our current one :innocent: