Policial is a gem that investigates pull requests and accuses style guide
violations. It is based on thoughtbot's
Hound project.
Currently it only investigates ruby code. You can setup your ruby code style
rules by defining a .rubocop.yml
file in you repo. Please see
RuboCop's README.
Add this line to your application's Gemfile:
gem 'policial'
And then execute:
$ bundle
Or install it yourself as:
$ gem install policial
- First, instantiate a new Detective:
detective = Policial::Detective.new
You might need to pass an Octokit client with your GitHub credentials. For more information on this please check the Octokit README.
octokit = Octokit::Client.new(access_token: 'mygithubtoken666')
detective = Policial::Detective.new(octokit)
If you don't pass an Octokit client Policial will use the global Octokit configuration.
- Let's investigate! Start by briefing your detective about the pull request it will run an investigation against. You can setup a pull request manually:
detective.brief(
repo: 'volmer/my_repo',
number: 3,
head_sha: 'headsha'
)
Or you can brief it with a
GitHub pull_request
webhook:
event = Policial::PullRequestEvent.new(webhook_payload)
detective.brief(event)
- Now you can run the investigation:
# Let's investigate this pull request...
detective.investigate
# Want to know the violations found?
detective.violations
- Hurry, post comments about those violations on the pull request!
detective.accuse
The result are comments like this on each line that contains violations:
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request