pronto 0.7.1 → 0.8.0

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
2
  SHA1:
3
- metadata.gz: a27da5811cbcfa71ddffc5842dc3295214206496
4
- data.tar.gz: 233865c5cf619728fcd26dfbf3607feb0d5fed51
3
+ metadata.gz: a5a612afb137e615ee5e2ff77940bef61836f285
4
+ data.tar.gz: 0028f06bc680ba757b55872dadb633a38dae08e0
5
5
  SHA512:
6
- metadata.gz: b9fb4cb872bca3c99d59ffe3a931dfac4911c617363a72f3307353792e514390fe5995382f11897da40694653e8029a8d181ed7a453aef27b0a79ba318a6423b
7
- data.tar.gz: fa1ff35ec5743311ff86453f2487a14903e40c9ea00b6df04a507dc2949d696957c6067d7d4dfee9e0e6412d0fc3331394f1db247e399157d62d75fd2723c45a
6
+ metadata.gz: 8232ab1382ee1447884bf1061e58d28f8a62100c59743ac5a6a8264404c94b61966e8478b0b11b2da999eaab21a136233fc44cbc1354d4403dc6301094d88915
7
+ data.tar.gz: 8a4a1196d482efceedb8c64edced6b56fa8977fe07ce9511cd4cf6374863dd5fdfa2e4f5992d56cc93eeb6a03f669182c67de03418cffbe6774e914a773e62ad
@@ -1,14 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### New features
6
+
7
+ * [#199](https://github.com/mmozuras/pronto/pull/199): add support for Ruby 2.4.0.
8
+
9
+ ### Changes
10
+
11
+ * [#181](https://github.com/mmozuras/pronto/pull/181): add ENV variables for all configuration options.
12
+ * [#184](https://github.com/mmozuras/pronto/pull/184): prefix all ENV variables with `PRONTO_`.
13
+ * [#185](https://github.com/mmozuras/pronto/pull/185): allow excluding files to lint for single runner.
14
+
15
+ ### Bugs fixed
16
+
17
+ * [#179](https://github.com/mmozuras/pronto/pull/179): correctly select branch name for fix Bitbucket pull request formatter.
18
+ * [#187](https://github.com/mmozuras/pronto/pull/187): correctly handle nil/false with consolidate_comments config option.
19
+ * [#189](https://github.com/mmozuras/pronto/pull/189): do not post anything when all consolidated comments already exist.
20
+ * [#195](https://github.com/mmozuras/pronto/pull/195): fix warning for default formatters value.
21
+
3
22
  ## 0.7.1
4
23
 
5
24
  ### Changes
6
25
 
7
26
  * Remove support for Ruby 1.9.3.
8
27
 
9
- ## Bugs fixed
28
+ ### Bugs fixed
10
29
 
11
- * [#149](https://github.com/mmozuras/pronto/issues/149): Use patches to correctly find line position for GitHub pull request formatter.
30
+ * [#149](https://github.com/mmozuras/pronto/issues/149): use patches to correctly find line position for GitHub pull request formatter.
12
31
 
13
32
  ## 0.7.0
14
33
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2016 Mindaugas Mozūras
3
+ Copyright (c) 2017 Mindaugas Mozūras
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Inline docs](http://inch-ci.org/github/mmozuras/pronto.svg)](http://inch-ci.org/github/mmozuras/pronto)
8
8
 
9
9
  **Pronto** runs analysis quickly by checking only the relevant changes. Created to
10
- be used on [pull requests](#github-integration), but also works [locally](#local-changes) and integrates with [GitLab](#gitlab-integration) and [Bitbucket](#bitbucket-integration).
10
+ be used on [GitHub pull requests](#github-integration), but also works [locally](#local-changes) and integrates with [GitLab](#gitlab-integration) and [Bitbucket](#bitbucket-integration).
11
11
  Perfect if want to find out quickly if branch introduces changes that conform
12
12
  to your [styleguide](https://github.com/mmozuras/pronto-rubocop), [are DRY](https://github.com/mmozuras/pronto-flay), [don't introduce security holes](https://github.com/mmozuras/pronto-brakeman) and [more](#runners).
13
13
 
@@ -74,13 +74,13 @@ Just run `pronto` without any arguments to see what Pronto is capable of.
74
74
 
75
75
  Available Options
76
76
 
77
- Command flag | Description
78
- -----------------|------------------------------------------------------------
79
- `--exit-code` | Exits with non-zero code if there were any warnings/errors.
80
- `-c/--commit` | Commit for the diff.
81
- `-i/--index` | Analyze changes in git index (staging area).
82
- `-r/--runner` | Run only the passed runners.
83
- `-f/--formatters`| Pick output formatters.
77
+ | Command flag | Description |
78
+ |:------------------|:------------------------------------------------------------|
79
+ | `--exit-code` | Exits with non-zero code if there were any warnings/errors. |
80
+ | `-c/--commit` | Commit for the diff. |
81
+ | `-i/--index` | Analyze changes in git index (staging area). |
82
+ | `-r/--runner` | Run only the passed runners. |
83
+ | `-f/--formatters` | Pick output formatters. |
84
84
 
85
85
  ### GitHub Integration
86
86
 
@@ -89,32 +89,32 @@ on GitHub commits using `GithubFormatter` or `GithubPullRequestFormatter`.
89
89
 
90
90
  Add Pronto runners you want to use to your Gemfile:
91
91
 
92
- Set the GITHUB_ACCESS_TOKEN environment variable or value in `.pronto.yml` to
92
+ Set the PRONTO_GITHUB_ACCESS_TOKEN environment variable or value in `.pronto.yml` to
93
93
  [OAuth token](https://help.github.com/articles/creating-an-access-token-for-command-line-use) that has access to the repository.
94
94
 
95
95
  Then just run it:
96
96
 
97
97
  ```sh
98
- $ GITHUB_ACCESS_TOKEN=token pronto run -f github -c origin/master
98
+ $ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github -c origin/master
99
99
  ```
100
100
 
101
101
  or, if you want comments to appear on pull request diff, instead of commit:
102
102
 
103
103
  ```sh
104
- $ GITHUB_ACCESS_TOKEN=token pronto run -f github_pr -c origin/master
104
+ $ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github_pr -c origin/master
105
105
  ```
106
106
 
107
107
  Use `GithubStatusFormatter` to submit [commit status](https://github.com/blog/1227-commit-status-api):
108
108
 
109
109
  ```sh
110
- $ GITHUB_ACCESS_TOKEN=token pronto run -f github_status -c origin/master
110
+ $ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github_status -c origin/master
111
111
  ```
112
112
 
113
113
  It's possible to combine multiple formatters.
114
114
  To get both pull request comments and commit status summary use:
115
115
 
116
116
  ```sh
117
- $ GITHUB_ACCESS_TOKEN=token PULL_REQUEST_ID=id pronto run -f github_status github_pr -c origin/master
117
+ $ PRONTO_GITHUB_ACCESS_TOKEN=token PULL_REQUEST_ID=id pronto run -f github_status github_pr -c origin/master
118
118
  ```
119
119
 
120
120
  As an alternative, you can also set up a rake task:
@@ -135,16 +135,16 @@ on GitLab commits using `GitlabFormatter`.
135
135
 
136
136
  **note: this requires at least GitLab v7.5.0**
137
137
 
138
- Set the `GITLAB_API_ENDPOINT` environment variable or value in `.pronto.yml` to
138
+ Set the `PRONTO_GITLAB_API_ENDPOINT` environment variable or value in `.pronto.yml` to
139
139
  your API endpoint URL. If you are using Gitlab.com's hosted service your
140
140
  endpoint will be `https://gitlab.com/api/v3`.
141
- Set the `GITLAB_API_PRIVATE_TOKEN` environment variable or value in `.pronto.yml
141
+ Set the `PRONTO_GITLAB_API_PRIVATE_TOKEN` environment variable or value in `.pronto.yml
142
142
  to your Gitlab private token which you can find in your account settings.
143
143
 
144
144
  Then just run it:
145
145
 
146
146
  ```sh
147
- $ GITLAB_API_ENDPOINT="https://gitlab.com/api/v3" GITLAB_API_PRIVATE_TOKEN=token pronto run -f gitlab -c origin/master
147
+ $ PRONTO_GITLAB_API_ENDPOINT="https://gitlab.com/api/v3" PRONTO_GITLAB_API_PRIVATE_TOKEN=token pronto run -f gitlab -c origin/master
148
148
  ```
149
149
 
150
150
  ### Bitbucket Integration
@@ -154,19 +154,19 @@ on Bitbucket commits using `BitbucketFormatter` or `BitbucketPullRequestFormatte
154
154
 
155
155
  Add Pronto runners you want to use to your Gemfile:
156
156
 
157
- Set the BITBUCKET_USERNAME and BITBUCKET_PASSWORD environment variables or values in `.pronto.yml`.
157
+ Set the PRONTO_BITBUCKET_USERNAME and PRONTO_BITBUCKET_PASSWORD environment variables or values in `.pronto.yml`.
158
158
  .
159
159
 
160
160
  Then just run it:
161
161
 
162
162
  ```sh
163
- $ BITBUCKET_USERNAME=user BITBUCKET_PASSWORD=pass pronto run -f bitbucket -c origin/master
163
+ $ PRONTO_BITBUCKET_USERNAME=user PRONTO_BITBUCKET_PASSWORD=pass pronto run -f bitbucket -c origin/master
164
164
  ```
165
165
 
166
166
  or, if you want comments to appear on pull request diff, instead of commit:
167
167
 
168
168
  ```sh
169
- $ BITBUCKET_USERNAME=user BITBUCKET_PASSWORD=pass pronto run -f bitbucket_pr -c origin/master
169
+ $ PRONTO_BITBUCKET_USERNAME=user PRONTO_BITBUCKET_PASSWORD=pass pronto run -f bitbucket_pr -c origin/master
170
170
  ```
171
171
 
172
172
  ## Configuration
@@ -180,13 +180,17 @@ The file has the following format:
180
180
  all:
181
181
  exclude:
182
182
  - 'spec/**/*'
183
+ # exclude files for single runner
184
+ eslint:
185
+ exclude:
186
+ - 'app/assets/**/*'
183
187
  github:
184
188
  slug: mmozuras/pronto
185
189
  access_token: B26354
186
190
  api_endpoint: https://api.github.com/
187
191
  web_endpoint: https://github.com/
188
192
  gitlab:
189
- slug: mmozuras/42
193
+ slug: 1234567 # gitlab's project ID
190
194
  api_private_token: 46751
191
195
  api_endpoint: https://api.vinted.com/gitlab
192
196
  bitbucket:
@@ -200,7 +204,7 @@ verbose: false
200
204
 
201
205
  All properties that can be specified via `.pronto.yml`, can also be specified
202
206
  via environment variables. Their names will be the upcased path to the property.
203
- For example: `GITHUB_SLUG` or `GITLAB_API_PRIVATE_TOKEN`. Environment variables
207
+ For example: `PRONTO_GITHUB_SLUG` or `PRONTO_GITLAB_API_PRIVATE_TOKEN`. Environment variables
204
208
  will always take precedence over values in configuration file.
205
209
 
206
210
  ## Runners
@@ -221,14 +225,18 @@ Currently available:
221
225
  * [pronto-jshint](https://github.com/mmozuras/pronto-jshint)
222
226
  * [pronto-json](https://github.com/deees/pronto-json)
223
227
  * [pronto-luacheck](https://github.com/seikichi/pronto-luacheck)
228
+ * [pronto-phpcs](https://github.com/EllisV/pronto-phpcs)
229
+ * [pronto-phpmd](https://github.com/EllisV/pronto-phpmd)
224
230
  * [pronto-poper](https://github.com/mmozuras/pronto-poper)
225
231
  * [pronto-rails_best_practices](https://github.com/mmozuras/pronto-rails_best_practices)
226
232
  * [pronto-rails_schema](https://github.com/raimondasv/pronto-rails_schema)
227
233
  * [pronto-reek](https://github.com/mmozuras/pronto-reek)
228
234
  * [pronto-rubocop](https://github.com/mmozuras/pronto-rubocop)
229
235
  * [pronto-scss](https://github.com/mmozuras/pronto-scss)
236
+ * [pronto-shellcheck](https://github.com/pclalv/pronto-shellcheck)
230
237
  * [pronto-slim](https://github.com/nysthee/pronto-slim)
231
238
  * [pronto-spell](https://github.com/mmozuras/pronto-spell)
239
+ * [pronto-stylelint](https://github.com/kevinjalbert/pronto-stylelint)
232
240
  * [pronto-swiftlint](https://github.com/ajanauskas/pronto-swiftlint)
233
241
  * [pronto-tailor](https://github.com/ajanauskas/pronto-tailor)
234
242
 
@@ -242,6 +250,8 @@ Articles to help you to get started:
242
250
  * [Pronto and git hooks](http://elliotthilaire.net/gem-pronto-and-git-hooks/)
243
251
  * [How to end fruitless dev discussions about your project’s code style?](https://medium.com/appaloosa-store-engineering/how-to-end-fruitless-dev-discussions-about-your-project-s-code-style-245070bff6d4)
244
252
  * [Free automated code reviews using Pronto](https://hovancik.net/blog/2016/04/11/free-automated-code-reviews-using-pronto.html)
253
+ * [Automated Elixir code review with Github, Credo and Travis CI](https://medium.com/fazibear/automated-elixir-code-review-with-github-credo-and-travis-ci-986cd56b8f02)
254
+ * [Running Rubocop before git commit](https://christoph.luppri.ch/articles/2016/11/21/running-rubocop-before-git-commit/)
245
255
 
246
256
  Make a Pull Request to add something you wrote or found useful.
247
257
 
@@ -65,7 +65,9 @@ module Pronto
65
65
  @pull ||= if env_pull_id
66
66
  pull_requests.find { |pr| pr.id.to_i == env_pull_id.to_i }
67
67
  elsif @repo.branch
68
- pull_requests.find { |pr| pr.branch['name'] == @repo.branch }
68
+ pull_requests.find do |pr|
69
+ pr.source['branch']['name'] == @repo.branch
70
+ end
69
71
  end
70
72
  end
71
73
 
@@ -37,7 +37,7 @@ module Pronto
37
37
 
38
38
  method_option :formatters,
39
39
  type: :array,
40
- default: 'text',
40
+ default: ['text'],
41
41
  aliases: ['formatter', '-f'],
42
42
  desc: "Pick output formatters. Available: #{::Pronto::Formatter.names.join(', ')}"
43
43
 
@@ -7,16 +7,26 @@ module Pronto
7
7
  %w(github gitlab bitbucket).each do |service|
8
8
  ConfigFile::EMPTY[service].each do |key, _|
9
9
  name = "#{service}_#{key}"
10
- define_method(name) { ENV[name.upcase] || @config_hash[service][key] }
10
+ define_method(name) { ENV["PRONTO_#{name.upcase}"] || @config_hash[service][key] }
11
11
  end
12
12
  end
13
13
 
14
14
  def consolidate_comments?
15
- !@config_hash['consolidate_comments'].nil?
15
+ consolidated =
16
+ ENV['PRONTO_CONSOLIDATE_COMMENTS'] ||
17
+ @config_hash.fetch('consolidate_comments', false)
18
+ consolidated
16
19
  end
17
20
 
18
- def excluded_files
19
- @excluded_files ||= Array(exclude)
21
+ def excluded_files(runner)
22
+ files =
23
+ if runner == 'all'
24
+ ENV['PRONTO_EXCLUDE'] || @config_hash['all']['exclude']
25
+ else
26
+ @config_hash.fetch(runner, {})['exclude']
27
+ end
28
+
29
+ Array(files)
20
30
  .flat_map { |path| Dir[path.to_s] }
21
31
  .map { |path| File.expand_path(path) }
22
32
  end
@@ -30,19 +40,14 @@ module Pronto
30
40
  end
31
41
 
32
42
  def max_warnings
33
- @config_hash['max_warnings']
43
+ ENV['PRONTO_MAX_WARNINGS'] || @config_hash['max_warnings']
34
44
  end
35
45
 
36
46
  def logger
37
47
  @logger ||= begin
38
- @config_hash['verbose'] ? Logger.new($stdout) : Logger.silent
48
+ verbose = ENV['PRONTO_VERBOSE'] || @config_hash['verbose']
49
+ verbose ? Logger.new($stdout) : Logger.silent
39
50
  end
40
51
  end
41
-
42
- private
43
-
44
- def exclude
45
- @config_hash['all']['exclude']
46
- end
47
52
  end
48
53
  end
@@ -83,7 +83,7 @@ module Pronto
83
83
  existing = old_comments[key]
84
84
  comments = dedupe_comments(existing, comments) if existing
85
85
 
86
- if config.consolidate_comments?
86
+ if config.consolidate_comments? && !comments.empty?
87
87
  comment = consolidate_comments(comments)
88
88
  memo.push(comment)
89
89
  else
@@ -1,5 +1,4 @@
1
1
  require_relative 'sentence'
2
- require_relative 'inflector'
3
2
 
4
3
  module Pronto
5
4
  module Formatter
@@ -20,7 +19,7 @@ module Pronto
20
19
  end
21
20
 
22
21
  def context
23
- Inflector.underscore(@runner.name)
22
+ "pronto/#{@runner.title}"
24
23
  end
25
24
 
26
25
  private
@@ -11,6 +11,14 @@ module Pronto
11
11
  repository
12
12
  end
13
13
 
14
+ def self.title
15
+ @runner_name ||= begin
16
+ source_path, _line = instance_method(:run).source_location
17
+ file_name, _extension = File.basename(source_path).split('.')
18
+ file_name
19
+ end
20
+ end
21
+
14
22
  def ruby_patches
15
23
  return [] unless @patches
16
24
 
@@ -6,14 +6,18 @@ module Pronto
6
6
  end
7
7
 
8
8
  def run(patches)
9
- patches = reject_excluded(patches)
10
- return [] unless patches.any?
9
+ patches = reject_excluded(@config.excluded_files('all'), patches)
10
+ return [] if patches.none?
11
11
 
12
12
  result = []
13
13
  @runners.each do |runner|
14
14
  next if exceeds_max?(result)
15
15
  @config.logger.log("Running #{runner}")
16
- result += runner.new(patches, patches.commit).run.flatten.compact
16
+ runner_patches = reject_excluded(
17
+ @config.excluded_files(runner.title), patches
18
+ )
19
+ next if runner_patches.none?
20
+ result += runner.new(runner_patches, patches.commit).run.flatten.compact
17
21
  end
18
22
  result = result.take(@config.max_warnings) if @config.max_warnings
19
23
  result
@@ -21,14 +25,12 @@ module Pronto
21
25
 
22
26
  private
23
27
 
24
- def reject_excluded(patches)
25
- return patches unless @config.excluded_files.any?
26
- patches.reject! { |patch| excluded?(patch) }
27
- patches
28
- end
28
+ def reject_excluded(excluded_files, patches)
29
+ return patches unless excluded_files.any?
29
30
 
30
- def excluded?(patch)
31
- @config.excluded_files.include?(patch.new_file_full_path.to_s)
31
+ patches.reject do |patch|
32
+ excluded_files.include?(patch.new_file_full_path.to_s)
33
+ end
32
34
  end
33
35
 
34
36
  def exceeds_max?(warnings)
@@ -1,6 +1,6 @@
1
1
  module Pronto
2
2
  module Version
3
- STRING = '0.7.1'.freeze
3
+ STRING = '0.8.0'.freeze
4
4
 
5
5
  MSG = '%s (running on %s %s %s)'.freeze
6
6
 
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.add_runtime_dependency('thor', '~> 0.19.0')
45
45
  s.add_runtime_dependency('octokit', '~> 4.3', '>= 4.1.0')
46
46
  s.add_runtime_dependency('gitlab', '~> 3.6', '>= 3.4.0')
47
- s.add_runtime_dependency('httparty', '~> 0.13.7')
47
+ s.add_runtime_dependency('httparty', '>= 0.13.7', '< 0.15')
48
48
  s.add_runtime_dependency('rainbow', '~> 2.1')
49
49
  s.add_development_dependency('rake', '~> 11.0')
50
50
  s.add_development_dependency('rspec', '~> 3.4')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindaugas Mozūras
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-20 00:00:00.000000000 Z
11
+ date: 2017-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
@@ -88,16 +88,22 @@ dependencies:
88
88
  name: httparty
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - "~>"
91
+ - - ">="
92
92
  - !ruby/object:Gem::Version
93
93
  version: 0.13.7
94
+ - - "<"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.15'
94
97
  type: :runtime
95
98
  prerelease: false
96
99
  version_requirements: !ruby/object:Gem::Requirement
97
100
  requirements:
98
- - - "~>"
101
+ - - ">="
99
102
  - !ruby/object:Gem::Version
100
103
  version: 0.13.7
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: '0.15'
101
107
  - !ruby/object:Gem::Dependency
102
108
  name: rainbow
103
109
  requirement: !ruby/object:Gem::Requirement
@@ -259,7 +265,6 @@ files:
259
265
  - lib/pronto/formatter/github_formatter.rb
260
266
  - lib/pronto/formatter/github_pull_request_formatter.rb
261
267
  - lib/pronto/formatter/github_status_formatter.rb
262
- - lib/pronto/formatter/github_status_formatter/inflector.rb
263
268
  - lib/pronto/formatter/github_status_formatter/sentence.rb
264
269
  - lib/pronto/formatter/github_status_formatter/status_builder.rb
265
270
  - lib/pronto/formatter/gitlab_formatter.rb
@@ -303,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
308
  version: '0'
304
309
  requirements: []
305
310
  rubyforge_project:
306
- rubygems_version: 2.4.5
311
+ rubygems_version: 2.6.10
307
312
  signing_key:
308
313
  specification_version: 4
309
314
  summary: Pronto runs analysis by checking only the introduced changes
@@ -1,17 +0,0 @@
1
- module Pronto
2
- module Formatter
3
- class GithubStatusFormatter
4
- class Inflector
5
- def self.underscore(camel_cased_word)
6
- return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
7
- word = camel_cased_word.to_s.gsub(/::/, '/')
8
- word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
9
- word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
10
- word.tr!('-', '_')
11
- word.downcase!
12
- word
13
- end
14
- end
15
- end
16
- end
17
- end