GithubHelp home page GithubHelp logo

prontolabs / pronto Goto Github PK

View Code? Open in Web Editor NEW
2.6K 38.0 245.0 5.43 MB

Quick automated code review of your changes

License: MIT License

Ruby 100.00%
review automated-review automated-analysis linters gitlab bitbucket formatter

pronto's Introduction

Pronto

Build Status Coverage Status Code Climate Gem Version Inline docs

Pronto runs analysis quickly by checking only the relevant changes. Created to be used on GitHub pull requests, but also works locally and integrates with GitLab and Bitbucket. Perfect if you want to find out quickly if a branch introduces changes that conform to your styleguide, are DRY, don't introduce security holes and more.

Pronto demo

This README might be ahead of the latest release. Find the README for v0.9.2 here.

Installation

Pronto's installation is standard for a Ruby gem:

$ gem install pronto

You'll also want to install some runners to go along with the main gem:

$ gem install pronto-rubocop
$ gem install pronto-flay

If you'd rather install Pronto using bundler, you don't need to require it, unless you're gonna run it from Ruby (via Rake task, for example):

gem 'pronto'
gem 'pronto-rubocop', require: false
gem 'pronto-flay', require: false

Usage

Pronto runs the checks on a diff between the current HEAD and the provided commit-ish (default is master).

Local Changes

Navigate to the repository you want to run Pronto on, and:

git checkout feature/branch

# Analyze diff of committed changes on current branch and master:
pronto run

# Analyze changes in git staging area
pronto run --staged

# Analyze diff of uncommitted changes and master:
pronto run --unstaged

# Analyze *all* changes since the *initial* commit (may take some time):
pronto run --commit=$(git log --pretty=format:%H | tail -1)

Just run pronto without any arguments to see what Pronto is capable of.

Available Options

Command flag Description
--exit-code Exits with non-zero code if there were any warnings/errors.
-c/--commit Commit for the diff.
--staged Analyze changes in git staging area
--unstaged Analyze changes made, but not in git staging area
-r/--runner Run only the passed runners.
-f/--formatters Pick output formatters.

GitHub Integration

You can run Pronto as a step of your CI builds and get the results as comments on GitHub commits using GithubFormatter or GithubPullRequestFormatter.

Add Pronto runners you want to use to your Gemfile:

Set the PRONTO_GITHUB_ACCESS_TOKEN environment variable or value in .pronto.yml to OAuth token that has access to the repository.

Then just run it:

$ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github -c origin/master

If you want comments to appear on pull request diff, instead of commit:

$ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github_pr -c origin/master

If you want review to appear on pull request diff, instead of separate comments:

$ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github_pr_review -c origin/master

All the N pending comments will be now separated into X number of PR reviews. The number of the PR reviews will be controlled by an additional environment variable or with the help of a config setting. This way, by a single pronto run, all the comments will be published to the PR, but divided into small reviews in order to avoid the rate limit of the providers.

X = N / {PRONTO_WARNINGS_PER_REVIEW || warnings_per_review || 30})

Note: In case no environment variable or config setting is specified in .pronto.yml, a default value of 30 will be used.

$ PRONTO_WARNINGS_PER_REVIEW=30 PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github_pr_review -c origin/master

Use GithubStatusFormatter to submit commit status:

$ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github_status -c origin/master

If you want to show a one single status for all runners, instead of status per runner:

$ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github_combined_status -c origin/master

It's possible to combine multiple formatters. To get both pull request comments and commit status summary use:

$ PRONTO_GITHUB_ACCESS_TOKEN=token PRONTO_PULL_REQUEST_ID=id pronto run -f github_status github_pr -c origin/master

As an alternative, you can also set up a rake task:

Pronto::GemNames.new.to_a.each { |gem_name| require "pronto/#{gem_name}" }

formatter = Pronto::Formatter::GithubFormatter.new # also possible: GithubPullRequestFormatter, GithubPullRequestReviewFormatter
status_formatter = Pronto::Formatter::GithubStatusFormatter.new
formatters = [formatter, status_formatter]
Pronto.run('origin/master', '.', formatters)

GitHub Actions Integration

You can also run Pronto as a GitHub action.

Here's an example .github/workflows/pronto.yml workflow file using the github_status and github_pr formatters and running on each GitHub PR, with pronto-rubocop as the runner:

name: Pronto
on: [pull_request]

jobs:
  pronto:

    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - run: |
          git fetch --no-tags --prune --depth=10 origin +refs/heads/*:refs/remotes/origin/*
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
      - name: Setup pronto
        run: gem install pronto pronto-rubocop
      - name: Run Pronto
        run: pronto run -f github_status github_pr -c origin/${{ github.base_ref }}
        env:
          PRONTO_PULL_REQUEST_ID: ${{ github.event.pull_request.number }}
          PRONTO_GITHUB_ACCESS_TOKEN: "${{ github.token }}"

check Wiki on GitHub Actions Integration for more info.

GitLab Integration

You can run Pronto as a step of your CI builds and get the results as comments on GitLab commits using GitlabFormatter.

note: this requires at least GitLab v7.5.0

Set the PRONTO_GITLAB_API_ENDPOINT environment variable or value in .pronto.yml to your API endpoint URL. If you are using Gitlab.com's hosted service your endpoint will be set by default. Set the PRONTO_GITLAB_API_PRIVATE_TOKEN environment variable or value in .pronto.yml to your Gitlab private token which you can find in your account settings.

Then just run it:

$ PRONTO_GITLAB_API_PRIVATE_TOKEN=token pronto run -f gitlab -c origin/master

note: this requires at least Gitlab 11.6+

Merge request integration:

$ PRONTO_GITLAB_API_PRIVATE_TOKEN=token PRONTO_PULL_REQUEST_ID=id pronto run -f gitlab_mr -c origin/master

On GitLabCI, make sure to run Pronto in a merge request pipeline:

lint:
  image: ruby:3.3.0 # change to your app's ruby version
  variables:
    PRONTO_GITLAB_API_ENDPOINT: "$CI_API_V4_URL" # this already contains the correct url for your GitLab instance
    PRONTO_GITLAB_API_PRIVATE_TOKEN: $ACCESS_TOKEN # configure as a variable in Gitlab CI settings; you might use a "Project Access Token" with api scope instead of your private one

    # Without this variable, GitLab only fetches with git depth set to a fixed amount (by default 20 on newer projects, 50 on older ones).
    # This would make pronto fail with the errror "revspec 'origin/{target_branch}", because it would not know of the target Branch.
    # It would also make pronto unable to compare changes with more than that amount of commits. E.g. running on 25 new commits would just return all problems, instead of only the ones in your changes.
    GIT_DEPTH: 0
  only:
    - merge_requests
  script:
    - apt-get update && apt-get install -y cmake # Install cmake required for rugged gem (Pronto depends on it)
    - bundle install
    # Run pronto on branch of current merge request, comparing to the merge requests target branch
    - bundle exec pronto run -f gitlab_mr -c origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME

Bitbucket Integration

You can run Pronto as a step of your CI builds and get the results as comments on Bitbucket commits using BitbucketFormatter or BitbucketPullRequestFormatter.

Add Pronto runners you want to use to your Gemfile:

Set the PRONTO_BITBUCKET_USERNAME and PRONTO_BITBUCKET_PASSWORD environment variables or values in .pronto.yml.

Then just run it:

$ PRONTO_BITBUCKET_USERNAME=user PRONTO_BITBUCKET_PASSWORD=pass pronto run -f bitbucket -c origin/master

or, if you want comments to appear on pull request diff, instead of commit:

$ PRONTO_BITBUCKET_USERNAME=user PRONTO_BITBUCKET_PASSWORD=pass pronto run -f bitbucket_pr -c origin/master

Configuration

The behavior of Pronto can be controlled via the .pronto.yml configuration file. It can either be placed in the working directory (*) or specified using the environment variable PRONTO_CONFIG_FILE.

(*) The working directory is where you run the command from, which is typically your project directory.

If this file cannot be found, then the default configuration in Pronto::ConfigFile::EMPTY applies.

The file has the following format:

all:
  exclude:
    - 'spec/**/*'
# exclude files for single runner
eslint:
  exclude:
    - 'app/assets/**/*'
github:
  slug: prontolabs/pronto
  access_token: B26354
  api_endpoint: https://api.github.com/
  web_endpoint: https://github.com/
gitlab:
  slug: 1234567 # gitlab's project ID
  api_private_token: 46751
  api_endpoint: https://api.vinted.com/gitlab
bitbucket:
  slug: prontolabs/pronto
  username: user
  password: pass
  web_endpoint: https://bitbucket.org/
max_warnings: 150
warnings_per_review: 30
verbose: false
runners: [rubocop, eslint] # only listed runners will be executed
skip_runners: [reek] # all, except listed runners will be executed

All properties that can be specified via .pronto.yml, can also be specified via environment variables. Their names will be the upcased path to the property. For example: PRONTO_GITHUB_SLUG or PRONTO_GITLAB_API_PRIVATE_TOKEN. Environment variables will always take precedence over values in configuration file.

Property Description
max_warnings Limits the amount of warnings. Returns all warnings if option is skipped.
runners Runs only listed runners. Runs everything if option is skipped.
skip_runners All, except listed runners will be executed. Runs everything if option is skipped.
verbose Outputs more information when set to true.
warnings_per_review Limits the amount of warnings per review. Returns all warnings if option is skipped.

Message format

Pronto allows you to configure the format of the messages that are produced. You can set a default format that will be used by all formatters, or you can configure a separate format per formatter, if you are using several.

To change the default format:

format: "%{runner} %{level} %{msg}"

To add the title of the Runner to the GitHub Pull Request formatter only:

github_pr:
  format: "%{runner} - %{msg}"

The available values to be interpolated into the message are:

Key Description
path File path.
line Line number.
level Message level.
msg Message.
commit_sha SHA.
runner Runner name.

The following values are available only to the text formatter:

Key Description
color_level Colorized message level.
color_location Colorized location.

Runners

Pronto can run various tools and libraries, as long as there's a runner for it. Currently available:

Articles

Articles to help you to get started:

Make a Pull Request to add something you wrote or found useful.

Changelog

Pronto's changelog is available here.

Copyright

Copyright (c) 2013-2018 Mindaugas Mozūras. See LICENSE for further details.

pronto's People

Contributors

abinoam avatar aergonaut avatar ajanauskas avatar alessio-signorini avatar andyw8 avatar apiology avatar ashkulz avatar bells17 avatar carakan avatar dankohn avatar deees avatar doomspork avatar drewish avatar dsander avatar gyfis avatar jeroenj avatar jhass avatar kevinjalbert avatar matheuspolicamilo avatar micjabbour avatar mknapik avatar mmozuras avatar pftg avatar reckerswartz avatar renatolond avatar rrrene avatar seikichi avatar siebertm avatar spajus avatar starchow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pronto's Issues

Specify path for repo

Hi!

I'd like to run Pronto from another directory than the git repo to analyze, is that possible?

I thought that was what this PR was for: #52 but it doesn't seem to work. Whenever I pass options for pronto run I get errors.

pronto run tmp/repository/foobar
ERROR: "pronto run" was called with arguments ["tmp/repository/foobar"]

I'm using the github version of pronto.

CircleCI shallow clone issue

If you're getting an Object not found - no matching loose object error like the following on CircleCI or similar continuous integration servers, it may be caused by them running a shallow clone:

bundle exec pronto run -f github -c=$(git log --pretty=format:%H | tail -1) --exit-code
/home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/pronto-0.4.3/lib/pronto/git/repository.rb:68:in `merge_base': Object not found - no matching loose object (9035627bcab7e9bd64dd47c37b7fbfd67045a106) (Rugged::OdbError)
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/pronto-0.4.3/lib/pronto/git/repository.rb:68:in `merge_base'
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/pronto-0.4.3/lib/pronto/git/repository.rb:15:in `diff'
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/pronto-0.4.3/lib/pronto.rb:33:in `run'
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/pronto-0.4.3/lib/pronto/cli.rb:52:in `run'
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/gems/pronto-0.4.3/bin/pronto:6:in `<top (required)>'
    from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/bin/pronto:23:in `load'

from /home/ubuntu/cii-best-practices-badge/vendor/bundle/ruby/2.2.0/bin/pronto:23:in `<main>' bundle exec pronto run -f github -c=$(git log --pretty=format:%H | tail -1) --exit-code returned exit code 1

The solution is do an unshallow git fetch before running pronto. For example, use the following syntax for circle.yml:

test:
  pre:
    - "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
  post:
    - bundle exec pronto run -f github -c=$(git log --pretty=format:%H | tail -1) --exit-code

pronto-poper breaks GitHub and GitLab formatters

Since poper's message have no line number attached the uniqueness check breaks on both formatters (I did not check any other formatters, but text works).

It's basically because this line of code:

messages = messages.uniq { |message| [message.msg, message.line.new_lineno] }

Because message.line is nil we get an undefined method exception for new_lineno.

Running Pronto on Pull requests coming from forked repos

I'm trying to get pronto to submit comments on a pull request coming from a forked repo, but I can't seem to get anything to work:

[tansaku@Samuels-MBP:~/Documents/Github/MakersAcademy/airport_challenge (master)]$ 
→ PULL_REQUEST_ID=133 pronto run -f github_pr
0 Pronto messages posted to GitHub

Here's the pull request that I want to get commented: makersacademy/airport_challenge#133

Having tried the above on the upstream repo (makersacademy/airport_challenge), I guessed (by repeatedly watching the animated gif) that I needed to be in the feature branch in order for things to work, so staying in my local repo that has makersacademy/airport_challenge as origin, I did the following:

$ git checkout -b tansaku/master # checkout the branch on the forked repo the pull request is coming from 
$ PULL_REQUEST_ID=133 pronto run -f github_pr

which gives this error:

/Users/tansaku/.rvm/gems/ruby-2.2.2/gems/octokit-3.8.0/lib/octokit/response/raise_error.rb:16:in `on_complete': GET https://api.github.com/pulls/133/comments: 404 - Not Found // See: https://developer.github.com/v3 (Octokit::NotFound)
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/faraday-0.9.1/lib/faraday/response.rb:9:in `block in call'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/faraday-0.9.1/lib/faraday/response.rb:57:in `on_complete'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/faraday-0.9.1/lib/faraday/response.rb:8:in `call'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:139:in `build_response'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/faraday-0.9.1/lib/faraday/connection.rb:377:in `run_request'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/faraday-0.9.1/lib/faraday/connection.rb:140:in `get'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/sawyer-0.6.0/lib/sawyer/agent.rb:94:in `call'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/octokit-3.8.0/lib/octokit/client.rb:339:in `request'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/octokit-3.8.0/lib/octokit/client.rb:200:in `paginate'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/octokit-3.8.0/lib/octokit/client/pull_requests.rb:184:in `pull_request_comments'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/pronto-0.4.2/lib/pronto/github.rb:11:in `pull_comments'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/pronto-0.4.2/lib/pronto/formatter/github_pull_request_formatter.rb:31:in `create_comment'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/pronto-0.4.2/lib/pronto/formatter/github_pull_request_formatter.rb:21:in `block in format'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/pronto-0.4.2/lib/pronto/formatter/github_pull_request_formatter.rb:8:in `map'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/pronto-0.4.2/lib/pronto/formatter/github_pull_request_formatter.rb:8:in `format'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/pronto-0.4.2/lib/pronto.rb:37:in `run'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/pronto-0.4.2/lib/pronto/cli.rb:52:in `run'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/gems/pronto-0.4.2/bin/pronto:6:in `<top (required)>'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/bin/pronto:23:in `load'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/bin/pronto:23:in `<main>'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/tansaku/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'

which makes it look like the API endpoint is not configured properly for working with forks maybe?

https://api.github.com/pulls/133/comments

since that request should be for:

https://api.github.com/repos/makersacademy/airport_challenge/pulls/133/comments

Just for confirmation I can run pronto and get output locally:

$ pronto run
lib/airport.rb:6 W: Doesn't depend on instance state (UtilityFunction)
lib/plane.rb:5 I: Style/TrivialAccessors: Use `attr_reader` to define trivial reader methods. (https://github.com/bbatsov/ruby-style-guide#attr_family)

any thoughts? Would love to be able to run pronto on pull requests from forked repos.

Skip pronto for some pull requests / commits

Sometimes, when you are importing third party code into your repo (don't ask 😄 ), you know it will be shit and pronto will be all over it. It would be nice to be able to say pronto no bueno or some other safe-word in your commit message / pull request to skip pronto.

@mmozuras

Make pronto able to run as a micro server for the GitHub integration

The idea would be to have commands like rackup (with a config.ru file) or pronto server or pronto watch. This micro server would listen to Github webhooks when PR events happen, and analyze the PR.

This would allow people to easily have their own free version of https://houndci.com by deploying it to a free Heroku dyno or any other server. This also has the advantage of being independent from a CI server and it does not require too much effort to give it a spin.

I do not know if this is in the scope of the pronto project though. This small 60-lines Sinatra server I wrote basically just wraps pronto, so I was thinking it would not be too much effort to integrate it in this project. The server works quite well, it is on a free Heroky dyno and we use it every day at my job.

If this is not in the scope of this project and these kinds of servers should be independent, please close this enhancement request. If it is, I could maybe find some time to make a PR (although I do not guarantee anything).

`gem install pronto` not installing

Any help here? Looks like a problem with Rugged.

$# gem install pronto
Fetching: rugged-0.23.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing pronto:
    ERROR: Failed to build gem native extension.

    /Users/bhardin/.rbenv/versions/2.0.0-p643/bin/ruby extconf.rb
checking for gmake... no
checking for make... yes
checking for cmake... no
ERROR: CMake is required to build Rugged.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/bhardin/.rbenv/versions/2.0.0-p643/bin/ruby
    --use-system-libraries


Gem files will remain installed in /Users/bhardin/.rbenv/versions/2.0.0-p643/lib/ruby/gems/2.0.0/gems/rugged-0.23.2 for inspection.
Results logged to /Users/bhardin/.rbenv/versions/2.0.0-p643/lib/ruby/gems/2.0.0/gems/rugged-0.23.2/ext/rugged/gem_make.out```

Wrong work with GH

╰─$ GITHUB_ACCESS_TOKEN=* PULL_REQUEST_ID=* pronto run -f github_pr

/home/sjke/.rvm/gems/ruby-2.1.5@***/gems/octokit-3.8.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/***/***/pulls/***/comments: 422 - Validation Failed (Octokit::UnprocessableEntity)
Error summary:
  resource: PullRequestReviewComment
  code: custom
  field: commit_id
  message: commit_id is not part of the pull request // See: https://developer.github.com/v3/pulls/comments/#create-a-comment
group :development do
  gem 'pronto'
  gem 'pronto-rubocop', require: false  #Ruby styleguide
  gem 'pronto-rails_best_practices', require: false  #Ruby styleguide
end

Review of pull-requests from everyone in an organization

Hello @mmozuras ,

I spent time getting to know the pronto gem and after some tests on pull-requests on github, I realized that the gem can analyze only my own pull-requests (please correct me if I'm wrong), but I was wondering why the gem does not apply in other pull-requests?

I think it would be very relevant if I could analyze a pull-request from another person that work in the same organization. I started writing a few lines of code to add this option and decided to take a break to get your opinion and if this feature would be a good contribution and avoid implementing a feature that would not come to be used for some reason.

https://github.com/fernandopso/pronto/commit/c5da797248659d79a5df9a4605829c9b442d018d

commit_id is not part of the pull request

When running Pronto via Jenkins with github_pr formatter, I often get this:

/var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/octokit-4.1.1/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/<org>/<repo>/pulls/355/comments: 422 - Validation Failed (Octokit::UnprocessableEntity)
Error summary:
  resource: PullRequestReviewComment
  code: custom
  field: commit_id
  message: commit_id is not part of the pull request // See: https://developer.github.com/v3/pulls/comments/#create-a-comment
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/response.rb:9:in `block in call'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/response.rb:57:in `on_complete'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/response.rb:8:in `call'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/octokit-4.1.1/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/octokit-4.1.1/lib/octokit/middleware/follow_redirects.rb:61:in `call'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:139:in `build_response'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/connection.rb:377:in `run_request'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/connection.rb:177:in `post'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sawyer-0.6.0/lib/sawyer/agent.rb:94:in `call'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/octokit-4.1.1/lib/octokit/connection.rb:154:in `request'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/octokit-4.1.1/lib/octokit/connection.rb:28:in `post'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/octokit-4.1.1/lib/octokit/client/pull_requests.rb:211:in `create_pull_request_comment'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.3/lib/pronto/github.rb:31:in `create_pull_comment'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.3/lib/pronto/formatter/github_pull_request_formatter.rb:33:in `create_comment'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.3/lib/pronto/formatter/github_pull_request_formatter.rb:21:in `block in format'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.3/lib/pronto/formatter/github_pull_request_formatter.rb:8:in `map'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.3/lib/pronto/formatter/github_pull_request_formatter.rb:8:in `format'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.3/lib/pronto.rb:37:in `run'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.3/lib/pronto/cli.rb:52:in `run'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.3/bin/pronto:6:in `<top (required)>'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/bin/pronto:23:in `load'
    from /var/lib/jenkins/.rbenv/versions/2.1.5/bin/pronto:23:in `<main>'

Non-zero exit code when it should be zero

I'm running pronto-rubocop with Gitlab CI. It's returning a failing exit code even when Pronto is not finding any errors. Any idea on what is happening? I can't figure out what that code status means, where does the exit code come from?

0 Pronto messages posted to GitLab

ERROR: Build failed with: exit code 36

Add exclude feature

It would be good if pronto can omit some files based on glob patterns, such as db/schema.rb in Rails project which is always a generated file and should not be a subject of any check.

Pronto does nothing silently; rubocop and rails_best_pratices report errors

I can confirm that rubocop and rails_best_practices both return a handful of errors, however running pronto results in zero comments both in its normal mode (pronto run master) and github mode (GITHUB_ACCESS_TOKEN=[....] PULL_REQUEST_ID=3147 pronto run -f github_pr)

Has anyone experienced this? Ruby 2.1.1 / Rails 4.1

pronto doesn't analyse staged changes

I've been trying to execute pronto in a pre-commit hook, and I ended up with the following issue.

Suppose I have a file with inorrect indentation: in this case it's Gemfile. I stage it with git add Gemfile and execute pronto run --index. No issues are reported.

Now, if I do git reset Gemfile, pronto run --index will report the issues correctly, e.g.:

Gemfile:166 I: Inconsistent indentation detected.
Gemfile:167 I: Tab detected.
Gemfile:167 I: Inconsistent indentation detected.
Gemfile:168 I: Tab detected.
Gemfile:168 I: Inconsistent indentation detected.

I tested a bit more, and staged changes are not being analysed with all of the following:
pronto run,
pronto run --index,
pronto run --commit=$(git log --pretty=format:%H | head -1),
pronto run --commit=HEAD.

Is there something trivial I have missed, or is this behaviour expected?

I used Ruby 2.1.5. More info:

    pronto (0.5.3)
      gitlab (~> 3.4.0)
      octokit (~> 4.1.0)
      rugged (~> 0.23.0)
      thor (~> 0.19.0)
    pronto-flay (0.5.0)
      flay (~> 2.6.0)
      pronto (~> 0.5.0)
    pronto-jshint (0.5.0)
      jshintrb (~> 0.3.0)
      pronto (~> 0.5.0)
    pronto-rails_best_practices (0.5.0)
      pronto (~> 0.5.0)
      rails_best_practices (~> 1.15.0)
    pronto-rails_schema (0.5.0)
      pronto (~> 0.5.0)
    pronto-rubocop (0.5.0)
      pronto (~> 0.5.0)
      rubocop (~> 0.35.0)

stream error (Zlib::StreamError)

When running pronto with github formatter it crashes after first comment. When GITHUB_ACCESS_TOKEN is missing, there's the same error but without comment on PR.

Installed runners as gems (i.e. not within Gemfile):

  • brakeman
  • flay
  • rails_best_practices
  • rubocop

Backtrace:

$ GITHUB_ACCESS_TOKEN='...' pronto run -f github
.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http/response.rb:350:in `initialize': stream error (Zlib::StreamError)
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http/response.rb:350:in `new'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http/response.rb:350:in `initialize'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http/response.rb:257:in `new'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http/response.rb:257:in `inflater'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http/response.rb:274:in `read_body_0'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http/response.rb:201:in `read_body'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1127:in `block in get'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1413:in `block (2 levels) in transport_request'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http/response.rb:162:in `reading_body'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1412:in `block in transport_request'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1403:in `catch'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1403:in `transport_request'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1376:in `request'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1369:in `block in request'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:852:in `start'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1367:in `request'
    from .rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1126:in `get'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:78:in `perform_request'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:39:in `call'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/faraday-0.9.0/lib/faraday/response.rb:8:in `call'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/faraday-0.9.0/lib/faraday/response.rb:8:in `call'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/faraday-0.9.0/lib/faraday/rack_builder.rb:139:in `build_response'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/faraday-0.9.0/lib/faraday/connection.rb:377:in `run_request'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/faraday-0.9.0/lib/faraday/connection.rb:140:in `get'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/sawyer-0.5.3/lib/sawyer/agent.rb:94:in `call'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/octokit-2.7.1/lib/octokit/client.rb:257:in `request'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/octokit-2.7.1/lib/octokit/client.rb:129:in `get'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/octokit-2.7.1/lib/octokit/client/commit_comments.rb:25:in `commit_comments'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/pronto-0.2.4/lib/pronto/formatter/github_formatter.rb:23:in `create_comment'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/pronto-0.2.4/lib/pronto/formatter/github_formatter.rb:14:in `block in format'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/pronto-0.2.4/lib/pronto/formatter/github_formatter.rb:7:in `map'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/pronto-0.2.4/lib/pronto/formatter/github_formatter.rb:7:in `format'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/pronto-0.2.4/lib/pronto.rb:30:in `run'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/pronto-0.2.4/lib/pronto/cli.rb:42:in `run'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
    from .rvm/gems/ruby-2.0.0-p247@gemset/gems/pronto-0.2.4/bin/pronto:6:in `<top (required)>'
    from .rvm/gems/ruby-2.0.0-p247@gemset/bin/pronto:23:in `load'
    from .rvm/gems/ruby-2.0.0-p247@gemset/bin/pronto:23:in `<main>'

Problems with rugged 0.21.0

I have just installed pronto 0.3.3 as you see

pronto (0.3.3)
      octokit (~> 3.2)
      rugged (~> 0.21.0)
      thor (~> 0.19.0)

and when I execute pronto run I'm getting

/home/ccvera/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/find.rb:43:in `block in find': undefined method `encoding' for #<Pathname:/home/ccvera/Workspace/my_app/Gemfile> (NoMethodError)
    from /home/ccvera/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/find.rb:42:in `each'
    from /home/ccvera/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/find.rb:42:in `find'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/haml-lint-0.7.0/lib/haml_lint/utils.rb:13:in `block in extract_files_from'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/haml-lint-0.7.0/lib/haml_lint/utils.rb:11:in `each'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/haml-lint-0.7.0/lib/haml_lint/utils.rb:11:in `extract_files_from'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/haml-lint-0.7.0/lib/haml_lint/runner.rb:69:in `extract_applicable_files'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/haml-lint-0.7.0/lib/haml_lint/runner.rb:12:in `run'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-haml-0.3.1/lib/pronto/haml.rb:18:in `inspect'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-haml-0.3.1/lib/pronto/haml.rb:14:in `block in run'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-haml-0.3.1/lib/pronto/haml.rb:14:in `map'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-haml-0.3.1/lib/pronto/haml.rb:14:in `run'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-0.3.3/lib/pronto.rb:57:in `block in run_all_runners'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-0.3.3/lib/pronto.rb:56:in `map'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-0.3.3/lib/pronto.rb:56:in `run_all_runners'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-0.3.3/lib/pronto.rb:30:in `run'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-0.3.3/lib/pronto/cli.rb:46:in `run'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/gems/pronto-0.3.3/bin/pronto:6:in `<top (required)>'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/bin/pronto:23:in `load'
    from /home/ccvera/.rvm/gems/ruby-2.1.1/bin/pronto:23:in `<main>'

Runner request: haml-lint

It would be nice to have runner for haml-lint.

I currenlty don't have to the time to find out how to write one, but I'll try to get to it somewhere the following weeks. Unless somebody else would like to work on it of course. :)

Pronto doesn't handle file renames well

Rugged::Blame doesn't seem to detect them or have an option to detect them. Maybe using Diff#find_similar! is an option, but will require further investigation.

fasterer runner

It might be interesting to have a runner for fasterer. I might give a shot at it but I guess you will be feaster at it. :)

Incompatible with rugged v0.21.0

It seems that rugged has changed its api causing it to break with pronto:

/Users/jeroen/.gem/ruby/2.0.0/gems/pronto-haml-0.2.0/lib/pronto/haml.rb:13:in `block in run': undefined method `additions' for #<Rugged::Patch:70093436035160> (NoMethodError)
    from /Users/jeroen/.gem/ruby/2.0.0/gems/pronto-haml-0.2.0/lib/pronto/haml.rb:13:in `each_patch'
    from /Users/jeroen/.gem/ruby/2.0.0/gems/pronto-haml-0.2.0/lib/pronto/haml.rb:13:in `select'
    from /Users/jeroen/.gem/ruby/2.0.0/gems/pronto-haml-0.2.0/lib/pronto/haml.rb:13:in `run'
    from /Users/jeroen/.gem/ruby/2.0.0/bundler/gems/pronto-772610d36858/lib/pronto.rb:54:in `block in run_all_runners'
    from /Users/jeroen/.gem/ruby/2.0.0/bundler/gems/pronto-772610d36858/lib/pronto.rb:53:in `map'
    from /Users/jeroen/.gem/ruby/2.0.0/bundler/gems/pronto-772610d36858/lib/pronto.rb:53:in `run_all_runners'
    from /Users/jeroen/.gem/ruby/2.0.0/bundler/gems/pronto-772610d36858/lib/pronto.rb:29:in `run'
    from /Users/jeroen/.gem/ruby/2.0.0/bundler/gems/pronto-772610d36858/lib/pronto/cli.rb:42:in `run'
    from /Users/jeroen/.gem/ruby/2.0.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/jeroen/.gem/ruby/2.0.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/jeroen/.gem/ruby/2.0.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/jeroen/.gem/ruby/2.0.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/jeroen/.gem/ruby/2.0.0/bundler/gems/pronto-772610d36858/bin/pronto:6:in `<top (required)>'
    from /Users/jeroen/.gem/ruby/2.0.0/bin/pronto:23:in `load'
    from /Users/jeroen/.gem/ruby/2.0.0/bin/pronto:23:in `<main>'

Clean up Runner API

With six runners, API is starting to get more stable. Time to refactor, clean up the API.

Also: high time to write a wiki entry on how to write a runner for Pronto.

Verbose output

Provide more output, for debugging and following of progress, if --verbose flag is passed.

Please issue 0.26 to work with rspec-rails

This pull request to support a newer thor, which you've already merged, is necessary to work with rspec-rails 3.0.22. #26 WIthout it, I get:

$ bundle
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "thor":
  In Gemfile:
    pronto (= 0.2.5) ruby depends on
      thor (~> 0.18.0) ruby

    rspec-rails (= 3.0.2) ruby depends on
      railties (>= 3.0) ruby depends on
        thor (0.19.1)

Could you please rev the version of pronto to 0.26 and push to Rubygems. In the meantime, pulling master works:

  gem 'pronto', github: 'mmozuras/pronto', ref: '0b6db2e'

Thanks.

Pronto throws error with rugged-0.22.2

Aurimass-MacBook-Pro:core aurimas$ pronto run
dyld: lazy symbol binding failed: Symbol not found: _SSL_load_error_strings
  Referenced from: /Users/aurimas/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/rugged-0.22.2/rugged/rugged.bundle
  Expected in: flat namespace

dyld: Symbol not found: _SSL_load_error_strings
  Referenced from: /Users/aurimas/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/rugged-0.22.2/rugged/rugged.bundle
  Expected in: flat namespace

Trace/BPT trap: 5

Uninstalling rugged-0.22.2 and using rugged-0.22.1b1 solved the issue

Provide the adequate runner class in a message

Hi!

I need to have the runner class name inside each report message for a personal project. The simplest solution is to add an extra runner argument to the constructor of the Message class, but this requires to adjust all the existing runners. An other (very ugly) solution is to somehow parse the backtrace in the Message's constructor and get the caller class from it.

Which solution sounds better for you? Would you accept a PR?

commit_id is not part of the pull request

Running pronto (installed from master at c88e2b0) causes the following error when using the github_pr formatter. This is reproducible and 0.4.3 of the gem does not have this behaviour. Curiously the 15609e8fb17fffbf2d51958bf5df6c57160fd281 commit sha below is not part of my local repository (git show 156... throws an error), but viewing it on github shows it as a merge of the last commit in my branch into master. Presumably that is why it fails, curious how it is picked up by pronto (or is travis ci to blame?).

bundle exec pronto run -f github_pr

Failed to post: #<struct Pronto::Github::Comment sha="15609e8fb17fffbf2d51958bf5df6c57160fd281", body="Unnecessary spacing detected.", path="file.rb", position=40> with POST https://api.github.com/repos/removed/removed/pulls/437/comments: 422 - Validation Failed
Error summary:
resource: PullRequestReviewComment
code: custom
field: commit_id
message: commit_id is not part of the pull request // See: https://developer.github.com/v3/pulls/comments/#create-a-comment
0 Pronto messages posted to GitHub

Problem when handling submodule changes

I have a repository with certain submodules. When I let pronto review a commit which changes a submodule, I get an error:

/home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto/runner.rb:16:in `readline': Is a directory @ io_fillbuf - fd:9 /home/gitlab-runner/tmp/builds/project-1/app/assets/javascripts/lib/edifact.js (Errno::EISDIR)
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto/runner.rb:16:in `block in ruby_executable?'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto/runner.rb:16:in `open'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto/runner.rb:16:in `ruby_executable?'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto/runner.rb:10:in `ruby_file?'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-rubocop-0.4.0/lib/pronto/rubocop.rb:16:in `block in run'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto/git/patches.rb:15:in `each'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto/git/patches.rb:15:in `each'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-rubocop-0.4.0/lib/pronto/rubocop.rb:14:in `select'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-rubocop-0.4.0/lib/pronto/rubocop.rb:14:in `run'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto.rb:60:in `block in run_all_runners'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto.rb:59:in `map'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto.rb:59:in `run_all_runners'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto.rb:34:in `run'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/lib/pronto/cli.rb:52:in `run'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pronto-0.4.1/bin/pronto:6:in `<top (required)>'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/bin/pronto:23:in `load'
    from /home/gitlab-runner/.rbenv/versions/2.1.5/bin/pronto:23:in `<main>'

What I think is happening is that pronto is not checking if the changed items are files or not (=> submodules are directories)

Pronto failing with spurious rubocop errors

I'm seeing dozens of errors like:

$ bundle exec pronto run -f text -r rubocop -c origin/master
An error occurred while RSpec/FilePath cop was inspecting /home/ubuntu/chewy/spec/alerts/admin/claim_edited_alert_spec.rb.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/FilePath cop was inspecting /home/ubuntu/chewy/spec/alerts/admin/claim_other_alert_spec.rb.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/FilePath cop was inspecting /home/ubuntu/chewy/spec/alerts/admin/doctor_referral_created_alert_spec.rb.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/FilePath cop was inspecting /home/ubuntu/chewy/spec/alerts/admin/doctor_referral_notes_alert_spec.rb.

But when I run bundle exec rubocop -d I'm not seeing any RSpec/FilePath errors.

Anything suggestions on how to debug the problem?

add option to return not 0 status code if any issues found

I am using pronto in CI and I miss one feature to mark build as failed if any issues found in pronto run.

So, it would be great to add some command, which would set status code as not zero, if any issues found, so that CI would fail the build.

pronto-brakeman & pronto-rails_best_practices run order inconsistencies

Firstly, thanks @mmozuras for pronto. I'm trialling using it to help with teaching Rails, when reviewing student projects.

The running order of pronto-brakeman and pronto-rails_best_practices can affect what issues are detected.

For a Rails 4.2.0 app I'm trying this out with, here are the total counts of issues found when the runners are run alone and together in both orders:

Command Number of issues pronto found
pronto run -r=rails_best_practices 4
pronto run -r=brakeman 1
pronto run -r=rails_best_practices brakeman 5
pronto run -r=brakeman rails_best_practices 6

Neither of the above pronto runs which ran with both runners quite found all the issues. There were missing issues and false positives in both when the running order was "1. brakeman, 2. rails_best_practices" . For more details see the full output further below.

Debugging so far shows part of the issue is due to two different gems (brakeman and code_analyzer (code_analyzer is used by rails_best_practices)) monkey-patching the same Sexp methods with different behaviours.

For example, the RemoveEmptyHelpersReview#empty_body?(module_node) is dependent on Sexp#body that behaves differently in brakeman compared to code_analyzer. As a result the RemoveEmptyHelpersReview from rails_best_practices only detects empty helpers when rails_best_practices runs before brakeman.

(I'm not sure that the Sexp monkey-patching explains the entire issue yet).

I'd like to contribute a fix for this, though I'm not sure where to go from here, so any guidance and ideas would be much appreciated.

One thought is that to help uncover these kind of issues, perhaps the installed pronto-* runners could run in a random order when they're run with pronto run (i.e. no -r= option).

$ pronto run -r=rails_best_practices

app/controllers/collaborations_controller.rb:22 W: Law of demeter
app/views/wikis/show.html.haml:10 W: Law of demeter
app/helpers/collaborations_helper.rb:1 W: Remove empty helpers
app/views/collaborations/new.html.haml:10 W: Remove trailing whitespace
$ pronto run -r=brakeman

app/controllers/collaborations_controller.rb:15 W: Possible security vulnerability: Possible unprotected redirect
$ pronto run -r=rails_best_practices brakeman

app/controllers/collaborations_controller.rb:22 W: Law of demeter
app/views/wikis/show.html.haml:10 W: Law of demeter
app/helpers/collaborations_helper.rb:1 W: Remove empty helpers
app/views/collaborations/new.html.haml:10 W: Remove trailing whitespace
app/controllers/collaborations_controller.rb:15 W: Possible security vulnerability: Possible unprotected redirect
$ pronto run -r=brakeman rails_best_practices

app/controllers/collaborations_controller.rb:15 W: Possible security vulnerability: Possible unprotected redirect
app/controllers/collaborations_controller.rb:22 W: Law of demeter
app/views/wikis/show.html.haml:10 W: Law of demeter
config/routes.rb:4 W: Restrict auto-generated routes wikis (only: [])
config/routes.rb:5 W: Restrict auto-generated routes wikis/collaborations (only: [])
app/views/collaborations/new.html.haml:10 W: Remove trailing whitespace

# MISSING ISSUE: app/helpers/collaborations_helper.rb:1 W: Remove empty helpers
# FALSE POSITIVE: config/routes.rb:4 W: Restrict auto-generated routes wikis (only: [])
# FALSE POSITIVE: config/routes.rb:5 W: Restrict auto-generated routes wikis/collaborations (only: [])

Runner Issues

Following runners dependant on older versions of pronto so cannot run them in whole package with latest pronto. Included are links to relevant files.

pronto/reek
pronto/spell
pronto/fasterer

I found this including the gems in the following format in my gemfile

gem 'pronto'
gem 'pronto-fasterer', require: false
gem 'pronto-spell', require: false 
gem 'pronto-reek', require: false 

Other runners are running just fine.

If there's anything integration-wise I'm missing just give me a holler!

GitLab formatter

Since we are using GitLab at our company it would be nice to have GitLab formatter.
I already started working on it and I've got a working formatter but it's far from completed: https://github.com/jeroenj/pronto/tree/gitlab-formatter.
I'll try to clean it up when I find the time, but I'm already putting it here for anybody who's interested to help out.
There also needs to be some work done in the GitLab API to improve this code.

pronto misfiring on wrong commit

I apologize in advance that this bug report will probably not have enough detail to enable debugging. However, last night, pronto, invoked as normal from our continuous integration machine with bundle exec rake pronto:github issued over 500 comments on a 5 month old commit, rather than the commit it was supposed to run on. Specifically, my team received over 500 emails from Github with tons of specific errors, however those errors did not appear as in-line comments when I click on the accompanying link, the way they normally do.

The only thing I can find that is different is that the commit causing the problem was a revert of a commit earlier that day. However, it had nothing to do with the 5 month old commit that was being emailed about.

Unfortunately, this is a closed source project, so I don't have a good way of showing the error. And, I don't know what's causing it enough to replicate it.

But, pronto has been very reliable for me until now, so I wanted to put this out there in case others can replicate the error.

Add option to use local .jshintrc file

Would it be possible to enable the option to run pronto-jshint against a local .jshintrc configuration
bundle exec pronto run --config .jshintrc?

Thanks,
Gabriel

Exit values

rspec, rubocop, and many other tools will run and have an exit code of 1 if anything is "wrong" with your code.

For example:
rubocop:

rubocop spec 
Inspecting 34 files
..................................

34 files inspected, no offenses detected
$ echo $?
0

fail

rubocop spec 
Inspecting 34 files
.........................C........

Offenses:

spec/mailers/batch_mailer_spec.rb:48:5: C: Use 2 (not 3) spaces for indentation.
       is_expected.to deliver_to(user.email)
    ^^^

34 files inspected, 1 offense detected
echo $?
1

This feature will help with integration of other tools into pronto that look at exit codes.

Running pronto results with segmentation fault

Hi!

I came across an issue that makes the pronto run task fail miserably - with segmentation fault.
The error message can be seen in this gist: https://gist.github.com/simicic/60f84a1f6187c0ec6e1c

Checking it in deep I saw it comes from the rugged gem - I can report an issue there as well, but let me first ask, how come that a single rename of a class (class name and file name) breaks pronto?

The task is running after the test suit on Circle CI and I could detect what actually caused the failure - or at least I like to think so. After the commit that changes the file name - things started to go wrong.
I tried to clear the cache for running the task, update both pronto and rugged to the latest version but nothing seem to be helping...
(Running Ruby 2.0.0-p353, also tried with 2.1.0-p95, Pronto: 0.4.1, Rugged: 0.21.4, Github Formatter )

I would appreciate any help - maybe I am doing something wrong?

certificate verify failed (OpenSSL::SSL::SSLError)

When i need run pronto to my own gitlab with ssl self-signed, i get:
/home/gitlab-runner/.rvm/rubies/ruby-2.1.7/lib/ruby/2.1.0/net/http.rb:923:in connect: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

How i can workaround on this?

Stack trace

$ bundle exec pronto run -f gitlab -c origin/master
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.6-compliant syntax, but you are running 2.1.7.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
/home/gitlab-runner/.rvm/rubies/ruby-2.1.7/lib/ruby/2.1.0/net/http.rb:923:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
    from /home/gitlab-runner/.rvm/rubies/ruby-2.1.7/lib/ruby/2.1.0/net/http.rb:923:in `block in connect'
    from /home/gitlab-runner/.rvm/rubies/ruby-2.1.7/lib/ruby/2.1.0/timeout.rb:75:in `timeout'
    from /home/gitlab-runner/.rvm/rubies/ruby-2.1.7/lib/ruby/2.1.0/net/http.rb:923:in `connect'
    from /home/gitlab-runner/.rvm/rubies/ruby-2.1.7/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
    from /home/gitlab-runner/.rvm/rubies/ruby-2.1.7/lib/ruby/2.1.0/net/http.rb:852:in `start'
    from /home/gitlab-runner/.rvm/rubies/ruby-2.1.7/lib/ruby/2.1.0/net/http.rb:1375:in `request'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/httparty-0.13.5/lib/httparty/request.rb:101:in `perform'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/httparty-0.13.5/lib/httparty.rb:522:in `perform_request'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/httparty-0.13.5/lib/httparty.rb:460:in `get'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/gitlab-3.4.0/lib/gitlab/request.rb:41:in `get'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/gitlab-3.4.0/lib/gitlab/client/repositories.rb:111:in `commit_comments'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/pronto-0.4.2/lib/pronto/gitlab.rb:10:in `commit_comments'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/pronto-0.4.2/lib/pronto/formatter/gitlab_formatter.rb:23:in `create_comment'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/pronto-0.4.2/lib/pronto/formatter/gitlab_formatter.rb:9:in `block in format'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/pronto-0.4.2/lib/pronto/formatter/gitlab_formatter.rb:8:in `map'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/pronto-0.4.2/lib/pronto/formatter/gitlab_formatter.rb:8:in `format'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/pronto-0.4.2/lib/pronto.rb:37:in `run'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/pronto-0.4.2/lib/pronto/cli.rb:52:in `run'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/gems/pronto-0.4.2/bin/pronto:6:in `<top (required)>'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/bin/pronto:23:in `load'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/bin/pronto:23:in `<main>'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:in `eval'
    from /home/gitlab-runner/.rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:in `<main>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.