face_control 0.8.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4f9e7ca404976809bcae27a991c816d13dc9aa99
4
- data.tar.gz: 9331fd455ba8e164ba80e48be06626474dacf3bb
2
+ SHA256:
3
+ metadata.gz: d122b35eb6eaff44afb9fa2cf73db3fc24c0ae4ee8641e0559ae51bf94f496ba
4
+ data.tar.gz: af390b2df7bc02946084829d41d76850e0b6beb2e981ae0986496b99272eb949
5
5
  SHA512:
6
- metadata.gz: 7254bcdd2024704eb2718c1a714328c7746de59eaf8f56406fe17a46ab737350a3208af98c494d1e92409d6bba17cd0c0644b894cd075cf8244d25145e82ddcf
7
- data.tar.gz: 1243c714fea6a8ea463b40d0ee17d2c51896588c50e51e345e1da0d67a58716af78a0f0df0e3f2d53ee41172219137b9e96cebe654bfe939f6bb0a18e7b08feb
6
+ metadata.gz: 7bdd454c0923cd2942f32341acfb29f6264d7f059366a32830d82b4baf1f3cb361c2d983a5b5196728102bfc81091867a69c9b1071874bb310339b1051f78f3f
7
+ data.tar.gz: 1073a7c288e5b336584c28b2e24f1abcefab827c472077d22b0845cbfb3fa49915153ca1f1b53d45cf3845b4eb3291d98441f67bd699e3a4120f45b55cd075d7
@@ -0,0 +1 @@
1
+ repo_token: 4sX7kIUmBKmdoAGw0PuaH9clgngz2zaGD
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ doc/
8
8
  pkg/
9
9
  spec/reports/
10
10
  tmp/
11
+ .idea
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.7
5
+ - 2.6
6
+ - 2.5
7
+
8
+ before_script:
9
+ # https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions
10
+ - curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
11
+ - sudo apt-get install -y nodejs
12
+ - sudo npm install -g coffeelint
@@ -0,0 +1,7 @@
1
+ # Face Control
2
+
3
+ ## Significant changes
4
+
5
+ ### 1.0.0 (2020-10-26)
6
+
7
+ * Initial release
data/README.md CHANGED
@@ -1,11 +1,9 @@
1
- [![Gem Version](https://img.shields.io/gem/v/face_control.svg)](https://rubygems.org/gems/face_control)
2
- [![Code Climate](https://img.shields.io/codeclimate/github/vassilevsky/face_control.svg)](https://codeclimate.com/github/vassilevsky/face_control/code)
3
- [![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
- [![Coveralls](https://img.shields.io/coveralls/vassilevsky/face_control.svg)](https://coveralls.io/github/vassilevsky/face_control)
5
- [![VersionEye](https://img.shields.io/versioneye/d/ruby/face_control.svg)](https://www.versioneye.com/ruby/face_control)
6
-
7
1
  # Face Control
8
2
 
3
+ [![Gem Version](https://img.shields.io/gem/v/face_control.svg)](https://rubygems.org/gems/face_control)
4
+ [![Travis CI](https://img.shields.io/travis/com/funbox/face_control)](https://travis-ci.com/github/funbox/face_control)
5
+ [![Coveralls](https://img.shields.io/coveralls/funbox/face_control.svg)](https://coveralls.io/github/funbox/face_control)
6
+
9
7
  Run static analysis of pull requests in [Bitbucket Server][] (formerly Stash)
10
8
  and comment on problems in added lines.
11
9
 
@@ -16,61 +14,75 @@ Inspired by [Hound][].
16
14
 
17
15
  ## Installation
18
16
 
19
- gem install face_control
17
+ ```bash
18
+ gem install face_control
19
+ ```
20
20
 
21
- You also need to have CoffeeLint installed and available in PATH.
21
+ You also need to have CoffeeLint installed and available in `PATH`.
22
22
 
23
23
  ## Usage
24
24
 
25
- face-control <project> <repository> <pull_request_id>
25
+ ```bash
26
+ face-control <project> <repository> <pull_request_id>
27
+ ```
28
+
29
+ It's natural to run this on a continuous integration server (see “[Example](#example)” below).
26
30
 
27
- It's natural to run this on a continuous integration server.
28
- For example, here's a [Jenkins][] project setup:
31
+ If you don't want to receive RuboCop comments with certain severity level,
32
+ pass the severity in the `--skip-severity` option like so:
33
+
34
+ ```bash
35
+ face-control --skip-severity convention <project> <repository> <pull_request_id>
36
+ ```
29
37
 
30
- * Source Code Management
31
- * Git
32
- * Repositories
33
- * Refspec:
38
+ Instead of `--skip-severity` you can use just `-S`.
39
+
40
+ You can also pass multiple severity levels as a comma-separated list:
34
41
 
35
- +refs/pull-requests/*:refs/remotes/origin/pull-requests/*
42
+ ```bash
43
+ face-control -S convention,refactor <project> <repository> <pull_request_id>
44
+ ```
36
45
 
37
- (make Jenkins fetch otherwise ignored Stash-created branches)
46
+ `face-control` uses the same configuration file (`~/.stashconfig.yml`)
47
+ as the official [Bitbucket Server Command Line Tools][]
48
+ to connect to your Stash instance.
38
49
 
39
- * Branches to build
40
- * Branch Specifier:
50
+ ## Example
41
51
 
42
- origin/pull-requests/*/merge
52
+ Here's a [Jenkins][] project setup as an example:
43
53
 
44
- (merge results of open non-conflicting pull requests)
54
+ _Source Code Management Git Repositories → Refspec:_
45
55
 
46
- * Build
47
- * Execute shell
48
- * Command
56
+ ```
57
+ +refs/pull-requests/*:refs/remotes/origin/pull-requests/*
58
+ ```
49
59
 
50
- export PULL_REQUEST_ID=`echo $GIT_BRANCH | cut -d / -f 3`
60
+ It makes Jenkins fetch otherwise ignored Stash-created branches.
51
61
 
52
- gem install rubocop face_control
53
- npm install -g coffeelint
62
+ _Source Code Management → Git → Branches to build → Branch Specifier:_
54
63
 
55
- face-control <project> <repository> $PULL_REQUEST_ID
64
+ ```
65
+ origin/pull-requests/*/merge
66
+ ```
56
67
 
57
- If you don't want to receive RuboCop comments with certain severity level,
58
- pass the severity in the `--skip-severity` option like so:
68
+ Merge results of open non-conflicting pull requests.
59
69
 
60
- face-control --skip-severity convention <project> <repository> <pull_request_id>
70
+ _Build Execute shell Command:_
61
71
 
62
- You can use just `-S`.
63
- You can also pass multiple severity levels as a comma-separated list:
72
+ ```bash
73
+ export PULL_REQUEST_ID=`echo $GIT_BRANCH | cut -d / -f 3`
64
74
 
65
- face-control -S convention,refactor <project> <repository> <pull_request_id>
75
+ gem install rubocop face_control
76
+ npm install -g coffeelint
66
77
 
67
- `face-control` uses the same configuration file (`~/.stashconfig.yml`)
68
- as the official [Bitbucket Server Command Line Tools][]
69
- to connect to your Stash instance.
78
+ face-control <project> <repository> $PULL_REQUEST_ID
79
+ ```
70
80
 
71
81
  ## Etymology
72
82
 
73
- [Face control][] in Wikipedia
83
+ [Face control][] in Wikipedia.
84
+
85
+ [![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)
74
86
 
75
87
  [Hound]: https://houndci.com
76
88
  [Bitbucket Server]: https://www.atlassian.com/software/bitbucket/server
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.4'
3
+ spec.version = '1.0.0'
4
4
  spec.authors = ['Ilya Vassilevsky']
5
5
  spec.email = ['vassilevsky@gmail.com']
6
6
 
@@ -16,10 +16,9 @@ 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
- spec.add_development_dependency 'rake', '~> 10.0'
21
- spec.add_development_dependency 'minitest', '~> 5.8'
22
- spec.add_development_dependency 'minitest-reporters', '~> 1.0'
23
- spec.add_development_dependency 'webmock', '~> 1.21'
24
- spec.add_development_dependency 'coveralls', '~> 0.8'
19
+ spec.add_development_dependency 'rake'
20
+ spec.add_development_dependency 'minitest'
21
+ spec.add_development_dependency 'minitest-reporters'
22
+ spec.add_development_dependency 'webmock'
23
+ spec.add_development_dependency 'coveralls'
25
24
  end
@@ -12,8 +12,10 @@ module FaceControl
12
12
  def relevant_globs
13
13
  %w(
14
14
  *.gemspec
15
- *.rb
15
+ *.jbuilder
16
16
  *.rake
17
+ *.rb
18
+ *.ru
17
19
  Capfile
18
20
  Gemfile
19
21
  Rakefile
@@ -22,7 +24,7 @@ module FaceControl
22
24
  end
23
25
 
24
26
  def command(filenames)
25
- "rubocop --format json #{filenames}"
27
+ "rubocop --parallel --format json #{filenames}"
26
28
  end
27
29
 
28
30
  def parse(command_output)
@@ -52,21 +54,13 @@ module FaceControl
52
54
  text << " — [Guide](#{link})"
53
55
  end
54
56
 
55
- if can_be_autocorrected?(offense)
56
- text << " (Run `rubocop -a #{file['path']}` to fix.)"
57
- end
58
-
59
- text
57
+ text << " — #{offense['cop_name']}"
60
58
  end
61
59
 
62
60
  def style_guide_url(offense)
63
61
  cop_name = offense['cop_name']
64
62
  config = ::RuboCop::ConfigLoader.default_configuration
65
- ::RuboCop::Cop::MessageAnnotator.new(config, config.for_cop(cop_name), {}).urls.first
66
- end
67
-
68
- def can_be_autocorrected?(offense)
69
- !offense['corrected'].nil?
63
+ ::RuboCop::Cop::MessageAnnotator.new(config, cop_name, config.for_cop(cop_name), {}).urls.first
70
64
  end
71
65
  end
72
66
  end
@@ -9,7 +9,7 @@ module FaceControl
9
9
  def run
10
10
  logger = Logger.new(STDOUT)
11
11
  project, repository, pull_request_id, ignored_severities = arguments
12
- pull_request = pull_request(project, repository, pull_request_id, logger)
12
+ pull_request = Stash::Config.new.server(logger).repository(project, repository).pull_request(pull_request_id)
13
13
 
14
14
  logger.info('Running checkers...')
15
15
  comments = check(pull_request, ignored_severities, logger)
@@ -60,14 +60,5 @@ module FaceControl
60
60
  puts e.message
61
61
  exit(1)
62
62
  end
63
-
64
- def pull_request(project, repository, pull_request_id, logger)
65
- @pull_request ||= begin
66
- config = Stash::Config.new
67
- server = Stash::Server.new(config.host, config.user, config.password, logger)
68
- repository = server.repository(project, repository)
69
- repository.pull_request(pull_request_id)
70
- end
71
- end
72
63
  end
73
64
  end
@@ -8,6 +8,12 @@ module Stash
8
8
  fail "#{@config_file} does not exist" unless File.exist?(@config_file)
9
9
  end
10
10
 
11
+ def server(logger = nil)
12
+ Server.new(host, user, password, logger)
13
+ end
14
+
15
+ private
16
+
11
17
  def host
12
18
  config['stash_url']
13
19
  end
@@ -20,8 +26,6 @@ module Stash
20
26
  config['password']
21
27
  end
22
28
 
23
- private
24
-
25
29
  def config
26
30
  @config ||= YAML.load_file(@config_file)
27
31
  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.4
4
+ version: 1.0.0
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: 2017-03-29 00:00:00.000000000 Z
11
+ date: 2020-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -52,91 +52,77 @@ 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
72
58
  requirements:
73
- - - "~>"
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: '10.0'
61
+ version: '0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: '10.0'
68
+ version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: minitest
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - "~>"
73
+ - - ">="
88
74
  - !ruby/object:Gem::Version
89
- version: '5.8'
75
+ version: '0'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
80
+ - - ">="
95
81
  - !ruby/object:Gem::Version
96
- version: '5.8'
82
+ version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: minitest-reporters
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - "~>"
87
+ - - ">="
102
88
  - !ruby/object:Gem::Version
103
- version: '1.0'
89
+ version: '0'
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - "~>"
94
+ - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: '1.0'
96
+ version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: webmock
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
- - - "~>"
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
- version: '1.21'
103
+ version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
- - - "~>"
108
+ - - ">="
123
109
  - !ruby/object:Gem::Version
124
- version: '1.21'
110
+ version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: coveralls
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
- - - "~>"
115
+ - - ">="
130
116
  - !ruby/object:Gem::Version
131
- version: '0.8'
117
+ version: '0'
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
- - - "~>"
122
+ - - ">="
137
123
  - !ruby/object:Gem::Version
138
- version: '0.8'
139
- description:
124
+ version: '0'
125
+ description:
140
126
  email:
141
127
  - vassilevsky@gmail.com
142
128
  executables:
@@ -144,9 +130,11 @@ executables:
144
130
  extensions: []
145
131
  extra_rdoc_files: []
146
132
  files:
133
+ - ".coveralls.yml"
147
134
  - ".gitignore"
148
135
  - ".rubocop.yml"
149
- - ".vexor.yml"
136
+ - ".travis.yml"
137
+ - CHANGELOG.md
150
138
  - CODE_OF_CONDUCT.md
151
139
  - Gemfile
152
140
  - LICENSE
@@ -174,7 +162,7 @@ files:
174
162
  homepage: https://github.com/vassilevsky/face_control
175
163
  licenses: []
176
164
  metadata: {}
177
- post_install_message:
165
+ post_install_message:
178
166
  rdoc_options: []
179
167
  require_paths:
180
168
  - lib
@@ -189,9 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
177
  - !ruby/object:Gem::Version
190
178
  version: '0'
191
179
  requirements: []
192
- rubyforge_project:
193
- rubygems_version: 2.5.1
194
- signing_key:
180
+ rubygems_version: 3.0.3
181
+ signing_key:
195
182
  specification_version: 4
196
183
  summary: Checks Atlassian Stash pull requests and comments on issues in added code
197
184
  test_files: []
data/.vexor.yml DELETED
@@ -1,8 +0,0 @@
1
- rvm:
2
- - 2.0
3
- - 2.1
4
- - 2.2
5
- - 2.3
6
-
7
- before_script:
8
- - sudo npm install -g coffeelint