Policial :cop:

Gem Version Build Status

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.

Installation

Add this line to your application's Gemfile:

gem 'policial'

And then execute:

$ bundle

Or install it yourself as:

$ gem install policial

Usage

  1. You might need to instantiate an Octokit client with your GitHub credentials. For more information on this please check the Octokit README.
  Policial.octokit = Octokit::Client.new(access_token: 'mygithubtoken666')

Ignore this step if you want Policial to use the global Octokit configuration.

  1. Let's investigate! Start with a pull request which Policial will run an investigation against. You can setup a pull request manually:
  pull_request = Policial::PullRequest.new(
    repo: 'volmer/my_repo',
    number: 3,
    head_sha: 'headsha'
  )

Or you can extract a pull request from a GitHub pull_request webhook:

  event = Policial::PullRequestEvent.new(webhook_payload)
  pull_request = event.pull_request
  1. Now you can run the investigation:
  investigation = Policial::Investigation.new(pull_request)

  # Let's investigate this pull request...
  investigation.run

  # Want to know the violations found?
  investigation.violations
  1. Hurry, post comments about those violations on the pull request! ruby investigation.accuse The result are comments like this on each line that contains violations: image

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request