face_control 0.8.1 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3b82b2b2726396b35762b53671f25666dc1562c7
4
- data.tar.gz: b2803733c726bb02fd02931dc58cff928d59ec98
2
+ SHA256:
3
+ metadata.gz: 325aba4c4fdce156c0dae24d9c5cf10b2993b4b70e0fcf184d3645cea22f5563
4
+ data.tar.gz: 700af54ea35e67f76d9245acb0fc5e63dfaa766295b357d27d71cf5e0a7de3a2
5
5
  SHA512:
6
- metadata.gz: 4b4b10c4feceace242f85e576e020f102783f1bbf2527c14c1897ba91b93d9069a30b4adf91a1aa20956be48e9bcea2d4b428cebd77b7b7c9331fe64b90b5720
7
- data.tar.gz: 58f631ad6606b34b18f204780024d9233c2fb1a715876e4dc33123ea12b2337a7c22b1a4a6235aa1f0b0abd45a617678d1a469888cf3df012ef382dcd3f5b8ef
6
+ metadata.gz: d5df85b4788e83c52f3cb051fee19d5137794b3ae9096e2bcc626b0585783515bb1479d52bf9c1cc2fab1d0cd829cbbc69120ccdf48f95e9e686144e4a047163
7
+ data.tar.gz: 308cb4a0b3d91dc19b1da72b537ed7dbd17f327554bbbc091e7ef16cd895f4828391490843ae3e63c554e0c73d4ce7935bb86131120d176b094f2390a70c9f0f
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ doc/
8
8
  pkg/
9
9
  spec/reports/
10
10
  tmp/
11
+ .idea
data/.vexor.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  rvm:
2
- - 1.9
3
2
  - 2.0
4
3
  - 2.1
5
4
  - 2.2
data/README.md CHANGED
@@ -1,76 +1,94 @@
1
+ # Face Control
2
+
1
3
  [![Gem Version](https://img.shields.io/gem/v/face_control.svg)](https://rubygems.org/gems/face_control)
2
4
  [![Code Climate](https://img.shields.io/codeclimate/github/vassilevsky/face_control.svg)](https://codeclimate.com/github/vassilevsky/face_control/code)
3
5
  [![Vexor](https://ci.vexor.io/projects/126da196-c8e6-46f0-8bc7-b5f8f4b49732/status.svg)](https://ci.vexor.io/ui/projects/126da196-c8e6-46f0-8bc7-b5f8f4b49732/builds)
4
6
  [![Coveralls](https://img.shields.io/coveralls/vassilevsky/face_control.svg)](https://coveralls.io/github/vassilevsky/face_control)
5
7
  [![VersionEye](https://img.shields.io/versioneye/d/ruby/face_control.svg)](https://www.versioneye.com/ruby/face_control)
6
8
 
7
- # Face Control
9
+ Run static analysis of pull requests in [Bitbucket Server][] (formerly Stash)
10
+ and comment on problems in added lines.
8
11
 
9
- Comment on added lines of pull requests in [Atlassian Stash][].
10
- Take comments from static checkers reports.
11
- (Currently supports [RuboCop][] and [CoffeeLint][].)
12
+ Currently supports [RuboCop][] and [CoffeeLint][] and also checks for
13
+ TODOs and FIXMEs.
12
14
 
13
15
  Inspired by [Hound][].
14
16
 
15
17
  ## Installation
16
18
 
17
- gem install face_control
19
+ ```bash
20
+ gem install face_control
21
+ ```
22
+
23
+ You also need to have CoffeeLint installed and available in `PATH`.
18
24
 
19
25
  ## Usage
20
26
 
21
- face-control <project> <repository> <pull_request_id>
27
+ ```bash
28
+ face-control <project> <repository> <pull_request_id>
29
+ ```
30
+
31
+ It's natural to run this on a continuous integration server (see “[Example](#example)” below).
32
+
33
+ If you don't want to receive RuboCop comments with certain severity level,
34
+ pass the severity in the `--skip-severity` option like so:
35
+
36
+ ```bash
37
+ face-control --skip-severity convention <project> <repository> <pull_request_id>
38
+ ```
22
39
 
23
- It's natural to run this on a continuous integration server.
24
- For example, here's a [Jenkins][] project setup:
40
+ Instead of `--skip-severity` you can use just `-S`.
25
41
 
26
- * Source Code Management
27
- * Git
28
- * Repositories
29
- * Refspec:
42
+ You can also pass multiple severity levels as a comma-separated list:
30
43
 
31
- +refs/pull-requests/*:refs/remotes/origin/pull-requests/*
44
+ ```bash
45
+ face-control -S convention,refactor <project> <repository> <pull_request_id>
46
+ ```
32
47
 
33
- (make Jenkins fetch otherwise ignored Stash-created branches)
48
+ `face-control` uses the same configuration file (`~/.stashconfig.yml`)
49
+ as the official [Bitbucket Server Command Line Tools][]
50
+ to connect to your Stash instance.
34
51
 
35
- * Branches to build
36
- * Branch Specifier:
52
+ ## Example
37
53
 
38
- origin/pull-requests/*/merge
54
+ Here's a [Jenkins][] project setup as an example:
39
55
 
40
- (merge results of open non-conflicting pull requests)
56
+ _Source Code Management Git Repositories → Refspec:_
41
57
 
42
- * Build
43
- * Execute shell
44
- * Command
58
+ ```
59
+ +refs/pull-requests/*:refs/remotes/origin/pull-requests/*
60
+ ```
45
61
 
46
- export PULL_REQUEST_ID=`echo $GIT_BRANCH | cut -d / -f 3`
62
+ It makes Jenkins fetch otherwise ignored Stash-created branches.
47
63
 
48
- gem install rubocop face_control
49
- npm install -g coffeelint
64
+ _Source Code Management → Git → Branches to build → Branch Specifier:_
50
65
 
51
- face-control <project> <repository> $PULL_REQUEST_ID
66
+ ```
67
+ origin/pull-requests/*/merge
68
+ ```
52
69
 
53
- If you don't want to receive RuboCop comments with certain severity level,
54
- pass the severity in the `--skip-severity` option like so:
70
+ Merge results of open non-conflicting pull requests.
55
71
 
56
- face-control --skip-severity convention <project> <repository> <pull_request_id>
72
+ _Build Execute shell Command:_
57
73
 
58
- You can use just `-S`.
59
- You can also pass multiple severity levels as a comma-separated list:
74
+ ```bash
75
+ export PULL_REQUEST_ID=`echo $GIT_BRANCH | cut -d / -f 3`
60
76
 
61
- face-control -S convention,refactor <project> <repository> <pull_request_id>
77
+ gem install rubocop face_control
78
+ npm install -g coffeelint
62
79
 
63
- `face-control` uses the same configuration file (`~/.stashconfig.yml`)
64
- as the official [Atlassian Stash Command Line Tools][]
65
- to connect to your Stash instance.
80
+ face-control <project> <repository> $PULL_REQUEST_ID
81
+ ```
66
82
 
67
83
  ## Etymology
68
84
 
69
- [Face control][] in Wikipedia
85
+ [Face control][] in Wikipedia.
86
+
87
+ [![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)
70
88
 
71
89
  [Hound]: https://houndci.com
72
- [Atlassian Stash]: https://www.atlassian.com/software/stash
73
- [Atlassian Stash Command Line Tools]: https://bitbucket.org/atlassian/stash-command-line-tools
90
+ [Bitbucket Server]: https://www.atlassian.com/software/bitbucket/server
91
+ [Bitbucket Server Command Line Tools]: https://bitbucket.org/atlassian/bitbucket-server-cli
74
92
  [RuboCop]: http://batsov.com/rubocop/
75
93
  [CoffeeLint]: http://www.coffeelint.org
76
94
  [Jenkins]: http://jenkins-ci.org
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- require 'bundler/gem_tasks'
2
1
  require 'rake/testtask'
3
2
 
4
3
  Rake::TestTask.new(:test) do |t|
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'face_control'
3
- spec.version = '0.8.1'
3
+ spec.version = '0.8.6'
4
4
  spec.authors = ['Ilya Vassilevsky']
5
5
  spec.email = ['vassilevsky@gmail.com']
6
6
 
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec|
16
16
  spec.add_runtime_dependency 'rubocop'
17
17
  spec.add_runtime_dependency 'httparty'
18
18
 
19
- spec.add_development_dependency 'bundler', '~> 1.8'
20
19
  spec.add_development_dependency 'rake', '~> 10.0'
21
20
  spec.add_development_dependency 'minitest', '~> 5.8'
22
21
  spec.add_development_dependency 'minitest-reporters', '~> 1.0'
@@ -13,7 +13,7 @@ module FaceControl
13
13
  file, line_num = line.split(":", 3)
14
14
  Comment.new(
15
15
  file: file,
16
- line: line_num,
16
+ line: line_num.to_i,
17
17
  text: "Do not bury this task in code. Do it now or create a JIRA issue."
18
18
  )
19
19
  end
@@ -52,21 +52,13 @@ module FaceControl
52
52
  text << " — [Guide](#{link})"
53
53
  end
54
54
 
55
- if can_be_autocorrected?(offense)
56
- text << " (Run `rubocop -a #{file['path']}` to fix.)"
57
- end
58
-
59
- text
55
+ text << " — #{offense['cop_name']}"
60
56
  end
61
57
 
62
58
  def style_guide_url(offense)
63
59
  cop_name = offense['cop_name']
64
- cop_config = ::RuboCop::ConfigLoader.default_configuration[cop_name]
65
- cop_config['StyleGuide']
66
- end
67
-
68
- def can_be_autocorrected?(offense)
69
- !offense['corrected'].nil?
60
+ config = ::RuboCop::ConfigLoader.default_configuration
61
+ ::RuboCop::Cop::MessageAnnotator.new(config, cop_name, config.for_cop(cop_name), {}).urls.first
70
62
  end
71
63
  end
72
64
  end
@@ -20,6 +20,7 @@ module Stash
20
20
  def diffs_with_added_lines
21
21
  @diff['diffs'].select do |diff|
22
22
  diff['destination'] &&
23
+ diff['hunks'] &&
23
24
  diff['hunks'].find do |hunk|
24
25
  hunk['segments'].find do |segment|
25
26
  segment['type'] == 'ADDED'
@@ -3,6 +3,8 @@ require 'stash/repository'
3
3
 
4
4
  module Stash
5
5
  class Server
6
+ class CommunicationError < StandardError; end
7
+
6
8
  attr_accessor :root_uri, :user, :password, :logger
7
9
 
8
10
  def initialize(root_uri, user, password, logger = nil)
@@ -19,14 +21,18 @@ module Stash
19
21
  end
20
22
 
21
23
  def get(path)
22
- logged('Response') do
23
- HTTParty.get(endpoint + path, auth.merge(logging))
24
+ with_error_handling do
25
+ logged('Response') do
26
+ HTTParty.get(endpoint + path, auth.merge(logging))
27
+ end
24
28
  end
25
29
  end
26
30
 
27
31
  def post(path, data)
28
- logged('Response') do
29
- HTTParty.post(endpoint + path, auth.merge(content_type).merge(body: data.to_json).merge(logging))
32
+ with_error_handling do
33
+ logged('Response') do
34
+ HTTParty.post(endpoint + path, auth.merge(content_type).merge(body: data.to_json).merge(logging))
35
+ end
30
36
  end
31
37
  end
32
38
 
@@ -73,5 +79,13 @@ module Stash
73
79
  {}
74
80
  end
75
81
  end
82
+
83
+ def with_error_handling
84
+ yield.tap do |response|
85
+ unless response.success?
86
+ fail CommunicationError, 'Stash responded with an error'
87
+ end
88
+ end
89
+ end
76
90
  end
77
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: face_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Vassilevsky
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.8'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.8'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +122,7 @@ dependencies:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0.8'
139
- description:
125
+ description:
140
126
  email:
141
127
  - vassilevsky@gmail.com
142
128
  executables:
@@ -174,7 +160,7 @@ files:
174
160
  homepage: https://github.com/vassilevsky/face_control
175
161
  licenses: []
176
162
  metadata: {}
177
- post_install_message:
163
+ post_install_message:
178
164
  rdoc_options: []
179
165
  require_paths:
180
166
  - lib
@@ -189,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
175
  - !ruby/object:Gem::Version
190
176
  version: '0'
191
177
  requirements: []
192
- rubyforge_project:
193
- rubygems_version: 2.4.5.1
194
- signing_key:
178
+ rubygems_version: 3.0.3
179
+ signing_key:
195
180
  specification_version: 4
196
181
  summary: Checks Atlassian Stash pull requests and comments on issues in added code
197
182
  test_files: []