Giter Club home page Giter Club logo

face_control's Introduction

Face Control

Gem Version Travis CI Coveralls

Run static analysis of pull requests in Bitbucket Server (formerly Stash) and comment on problems in added lines.

Currently supports RuboCop and CoffeeLint and also checks for TODOs and FIXMEs.

Inspired by Hound.

Installation

gem install face_control

You also need to have CoffeeLint installed and available in PATH.

Usage

face-control <project> <repository> <pull_request_id>

It's natural to run this on a continuous integration server (see “Example” below).

If you don't want to receive RuboCop comments with certain severity level, pass the severity in the --skip-severity option like so:

face-control --skip-severity convention <project> <repository> <pull_request_id>

Instead of --skip-severity you can use just -S.

You can also pass multiple severity levels as a comma-separated list:

face-control -S convention,refactor <project> <repository> <pull_request_id>

face-control uses the same configuration file (~/.stashconfig.yml) as the official Bitbucket Server Command Line Tools to connect to your Stash instance.

Example

Here's a Jenkins project setup as an example:

Source Code Management → Git → Repositories → Refspec:

+refs/pull-requests/*:refs/remotes/origin/pull-requests/*

It makes Jenkins fetch otherwise ignored Stash-created branches.

Source Code Management → Git → Branches to build → Branch Specifier:

origin/pull-requests/*/merge

Merge results of open non-conflicting pull requests.

Build → Execute shell → Command:

export PULL_REQUEST_ID=`echo $GIT_BRANCH | cut -d / -f 3`

gem install rubocop face_control
npm install -g coffeelint

face-control <project> <repository> $PULL_REQUEST_ID

Etymology

Face control in Wikipedia.

Sponsored by FunBox

face_control's People

Contributors

igoradamenko avatar snthpr1d3 avatar texpert avatar vassilevsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

face_control's Issues

Exception on authentication failure

When wrong credentials are provided in ~/.stashconfig.yml, face-control is throwing an exception:

+ face-control FRNT app 939
/var/lib/jenkins/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/face_control-0.9.0/lib/stash/pull_request/diff.rb:21:in `diffs_with_added_lines': private method `select' called for nil:NilClass (NoMethodError)
	from /var/lib/jenkins/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/face_control-0.9.0/lib/stash/pull_request/diff.rb:9:in `filenames_with_added_lines'
	from /var/lib/jenkins/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/face_control-0.9.0/lib/stash/pull_request.rb:13:in `filenames_with_added_lines'
	from /var/lib/jenkins/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/face_control-0.9.0/lib/face_control/cli.rb:27:in `check'
	from /var/lib/jenkins/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/face_control-0.9.0/lib/face_control/cli.rb:15:in `run'
	from /var/lib/jenkins/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/face_control-0.9.0/exe/face-control:5:in `<top (required)>'
	from /var/lib/jenkins/.rbenv/versions/2.3.4/bin/face-control:22:in `load'
	from /var/lib/jenkins/.rbenv/versions/2.3.4/bin/face-control:22:in `<main>'
I, [2017-09-05T12:23:23.242628 #29730]  INFO -- : Running checkers...
D, [2017-09-05T12:23:23.269745 #29730] DEBUG -- : [HTTParty] [2017-09-05 12:23:23 +0000] 401 "GET https://www.server.net/rest/api/1.0/projects/app/repos/fapp/pull-requests/939/diff?withComments=false" - 
D, [2017-09-05T12:23:23.269782 #29730] DEBUG -- : Response:
{"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]}
+ exit 0

Add Rails.env check

Suggest using environment-specific configuration files instead of checking for Rails.env

Affected_extensions returning nil

Currently trying with the latest version which is 0.5.0 and i am getting the following error

/Users/administrator/.rvm/gems/ruby-2.2.2/gems/face_control-0.5.0/lib/face_control/inputs/rubocop_json.rb:20:in `block (2 levels) in comments': undefined method `include?' for nil:NilClass (NoMethodError)
    from /Users/administrator/.rvm/gems/ruby-2.2.2/gems/face_control-0.5.0/lib/face_control/inputs/rubocop_json.rb:19:in `reject'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/gems/face_control-0.5.0/lib/face_control/inputs/rubocop_json.rb:19:in `block in comments'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/gems/face_control-0.5.0/lib/face_control/inputs/rubocop_json.rb:18:in `map'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/gems/face_control-0.5.0/lib/face_control/inputs/rubocop_json.rb:18:in `comments'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/gems/face_control-0.5.0/exe/face-control:30:in `block in <top (required)>'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/gems/face_control-0.5.0/exe/face-control:29:in `each'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/gems/face_control-0.5.0/exe/face-control:29:in `<top (required)>'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/bin/face-control:23:in `load'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/bin/face-control:23:in `<main>'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/administrator/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'

it looks like the affected_extensions method is not being called correctly as i can't call it from irb using a proper pull_request object, and is returning nil when being called by the gem.

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.