rubocop_pr 0.2.0 → 1.1.2
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 +4 -4
- data/.rubocop.yml +5 -2
- data/.travis.yml +1 -5
- data/README.md +21 -11
- data/lib/rubocop_pr.rb +2 -0
- data/lib/rubocop_pr/cli.rb +5 -21
- data/lib/rubocop_pr/cli/process_cop.rb +54 -0
- data/lib/rubocop_pr/cop.rb +18 -0
- data/lib/rubocop_pr/options.rb +65 -23
- data/lib/rubocop_pr/repositories/github.rb +83 -20
- data/lib/rubocop_pr/rubocop.rb +18 -19
- data/lib/rubocop_pr/version.rb +1 -1
- data/rubocop_pr.gemspec +8 -9
- metadata +25 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d9556b71acd309753dbdb674136ffd61627cd8689fe32e295f937f800e452f0
|
4
|
+
data.tar.gz: a76c9b82f51dc2dbdbb08e1be30dbc677621693bc2486aadd899561dbe3ab45b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85d561f2980992818b056f8287b845896e85f5ba1ff4a4e38164b6004401d9d301104c3d1fc9bf62e8c7da3453fb042a26ee05d0ccdf70334db4b45f81bb1f0f
|
7
|
+
data.tar.gz: 03d9bb0f56ffc8fd3194cf3e87a098a32efb19274cbb2405157e9846dc0572ed9a906d64e59ee4477c41fcc567c8288fdf68f90d66cbed931a29523b2d3715b4
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.5
|
3
3
|
|
4
4
|
Metrics/LineLength:
|
5
5
|
Max: 120
|
@@ -8,4 +8,7 @@ Metrics/BlockLength:
|
|
8
8
|
ExcludedMethods: ['describe', 'context']
|
9
9
|
|
10
10
|
Metrics/AbcSize:
|
11
|
-
Max: 20
|
11
|
+
Max: 20
|
12
|
+
|
13
|
+
Metrics/ClassLength:
|
14
|
+
Max: 150
|
data/.travis.yml
CHANGED
@@ -3,14 +3,10 @@ sudo: false
|
|
3
3
|
language: ruby
|
4
4
|
cache: bundler
|
5
5
|
rvm:
|
6
|
-
- 2.1
|
7
|
-
- 2.2
|
8
|
-
- 2.3
|
9
|
-
- 2.4
|
10
6
|
- 2.5
|
11
7
|
- 2.6
|
8
|
+
- 2.7
|
12
9
|
before_install:
|
13
|
-
- gem install bundler -v 1.17.3
|
14
10
|
- sudo add-apt-repository ppa:cpick/hub -y
|
15
11
|
- sudo apt-get update
|
16
12
|
- sudo apt-get install hub
|
data/README.md
CHANGED
@@ -7,7 +7,10 @@
|
|
7
7
|
|
8
8
|
CLI Issues and PR creator for Rubocop Cops. 1 linter == 1 issue == 1 PR.
|
9
9
|
|
10
|
-
|
10
|
+
Simplify the inception or version bump of [Rubocop][rubocop_repo] on the project.
|
11
|
+
|
12
|
+
With RubocopPr you can apply [Rubocop][rubocop_repo] clean and in a few minutes,
|
13
|
+
see the [example][rubocop_pr_example].
|
11
14
|
|
12
15
|
## Requirements
|
13
16
|
|
@@ -35,26 +38,34 @@ Or install it yourself as:
|
|
35
38
|
|
36
39
|
```bash
|
37
40
|
Usage: rubocop_pr [options]
|
38
|
-
-
|
41
|
+
-k, --post-checkout [command] Running after each git checkout (default: "")
|
42
|
+
-c, --continue Continue previous session (default: false)
|
39
43
|
-b, --branch [branch] internal branch with '.rubocop_todo.yml' (default: 'rubocop_todo_branch')
|
40
44
|
-m, --master [branch] branch which will be the base for all PR's (default: 'master')
|
41
|
-
-r, --post-checkout [command] Running after each git checkout (default: "")
|
42
|
-
-l, --limit [limit] Limit the PS's for one run (default: 10)
|
43
|
-
-g, --repository [name] Set repository host (default: github)
|
44
|
-
-o, --origin [origin] origin option for 'git push' (default: 'origin')
|
45
|
-
-c, --continue Continue previous session (default: false)
|
46
45
|
-v, --version Display version
|
46
|
+
-o, --origin [origin] origin option for 'git push' (default: 'origin')
|
47
|
+
-u, --hub-version [version] Set manually minimum required version of 'hub' utility for github (default: 2.12.3)
|
48
|
+
-i, --issue-labels [labels] Labels for created issues, separated by comma (default: rubocop)
|
49
|
+
-p [labels], Labels for created pull requests, separated by comma (default: rubocop)
|
50
|
+
--pull-request-labels
|
51
|
+
-a, --issue-assignees [name] Issue assignees, separated by comma (default: "")
|
52
|
+
-t [name], Pull request assignees, separated by comma (default: "")
|
53
|
+
--pull-request-assignees
|
54
|
+
-r [name], Pull request reviewers, separated by comma (default: "")
|
55
|
+
--pull-request-reviewers
|
56
|
+
-g, --repository [name] Set repository host (default: github)
|
57
|
+
-l, --limit [limit] Limit the PS's for one run (default: 10)
|
47
58
|
-h, --help Display help
|
48
59
|
```
|
49
60
|
|
50
61
|
#### Notes
|
51
62
|
|
52
|
-
* `brach` option is useful, if you want to prepare the `.rubocop-todo.yml` manually and feed it to `rubocop_pr
|
63
|
+
* `brach` option is useful, if you want to prepare the `.rubocop-todo.yml` manually and feed it to `rubocop_pr`.
|
53
64
|
* `post-checkout` handy for old Ruby versions, when shell may "forget" Ruby version.
|
54
65
|
|
55
66
|
## Contributing
|
56
67
|
|
57
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
68
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kvokka/rubocop_pr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant][contributor_covenant_link] code of conduct.
|
58
69
|
|
59
70
|
## License
|
60
71
|
|
@@ -64,12 +75,11 @@ The gem is available as open source under the terms of the [MIT License][mit_lin
|
|
64
75
|
|
65
76
|
Everyone interacting in the RubocopPr project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct][code_of_conduct_link].
|
66
77
|
|
67
|
-
|
68
78
|
[rubocop_repo]: https://github.com/rubocop-hq/rubocop
|
69
79
|
[contributor_covenant_link]: http://contributor-covenant.org
|
70
80
|
[mit_link]: https://opensource.org/licenses/MIT
|
71
81
|
[code_of_conduct_link]: https://github.com/[USERNAME]/rubocop_pr/blob/master/CODE_OF_CONDUCT.md
|
72
|
-
|
82
|
+
[rubocop_pr_example]: https://github.com/kvokka/rubocop_pr_example
|
73
83
|
[travisci_badge]: https://travis-ci.org/kvokka/rubocop_pr.svg?branch=master
|
74
84
|
[travisci]: https://travis-ci.org/kvokka/rubocop_pr
|
75
85
|
[rubygems]: https://rubygems.org/gems/rubocop_pr
|
data/lib/rubocop_pr.rb
CHANGED
@@ -10,6 +10,8 @@ require 'pry'
|
|
10
10
|
require 'rubocop_pr/version'
|
11
11
|
require 'rubocop_pr/options'
|
12
12
|
require 'rubocop_pr/environment_checker'
|
13
|
+
require 'rubocop_pr/cli/process_cop'
|
14
|
+
require 'rubocop_pr/cop'
|
13
15
|
require 'rubocop_pr/rubocop'
|
14
16
|
require 'rubocop_pr/git'
|
15
17
|
require 'rubocop_pr/repository'
|
data/lib/rubocop_pr/cli.rb
CHANGED
@@ -15,35 +15,19 @@ module RubocopPr
|
|
15
15
|
def run!
|
16
16
|
EnvironmentChecker.call(repository, options)
|
17
17
|
run
|
18
|
+
git.checkout Rubocop::TODO_FILENAME
|
18
19
|
git.checkout(options.master_branch)
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
22
23
|
|
23
24
|
def run
|
24
|
-
rubocop.
|
25
|
-
|
26
|
-
next counter if options.continue && git.branch =~ /#{branch_suffix(cop)}\s/
|
27
|
-
next counter unless rubocop.corrected?
|
28
|
-
process_cop(cop)
|
25
|
+
rubocop.each do |cop|
|
26
|
+
break if options.limit <= 0
|
29
27
|
|
30
|
-
|
31
|
-
|
28
|
+
next unless ProcessCop.new(git: git, repository: repository, cop: cop, options: options).call
|
29
|
+
options.limit -= 1
|
32
30
|
end
|
33
31
|
end
|
34
|
-
|
35
|
-
def process_cop(cop)
|
36
|
-
git.checkout(options.master_branch)
|
37
|
-
title = "Fix Rubocop #{cop} warnings"
|
38
|
-
issue_number = repository.create_issue(title: title)
|
39
|
-
git.checkout("#{issue_number}-#{branch_suffix(cop)}")
|
40
|
-
git.commit_all(title)
|
41
|
-
git.push
|
42
|
-
repository.create_pull_request(title: title, body: "Closes ##{issue_number}")
|
43
|
-
end
|
44
|
-
|
45
|
-
def branch_suffix(cop)
|
46
|
-
"rubocop-fix-#{cop.underscore.tr('/_', '-')}"
|
47
|
-
end
|
48
32
|
end
|
49
33
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module RubocopPr
|
2
|
+
class CLI
|
3
|
+
# Cop processor
|
4
|
+
class ProcessCop
|
5
|
+
attr_reader :options, :git, :repository, :cop
|
6
|
+
|
7
|
+
def initialize(git:, repository:, cop:, options:)
|
8
|
+
@git = git
|
9
|
+
@repository = repository
|
10
|
+
@cop = cop
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
return false if exit_early?
|
16
|
+
checkout_to_target_branch_throw_master_branch
|
17
|
+
git.commit_all(issue.title)
|
18
|
+
git.push
|
19
|
+
create_pr
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def rubocop
|
25
|
+
@rubocop ||= RubocopPr::Rubocop.new(git: git)
|
26
|
+
end
|
27
|
+
|
28
|
+
def exit_early?
|
29
|
+
return true if options.continue && cop_was_processed? || git.status.blank?
|
30
|
+
Rubocop.correct!(options[:all])
|
31
|
+
|
32
|
+
git.checkout Rubocop::TODO_FILENAME
|
33
|
+
git.status.blank?
|
34
|
+
end
|
35
|
+
|
36
|
+
def cop_was_processed?
|
37
|
+
git.branch.match cop.branch
|
38
|
+
end
|
39
|
+
|
40
|
+
def issue
|
41
|
+
@issue ||= repository.issue(cop: cop, **options.to_h).create
|
42
|
+
end
|
43
|
+
|
44
|
+
def checkout_to_target_branch_throw_master_branch
|
45
|
+
git.checkout(options.master_branch)
|
46
|
+
git.checkout("#{issue.number}-#{cop.branch}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_pr
|
50
|
+
repository.pull_request(cop: cop, body: "Closes ##{issue.number}", **options.to_h).create
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RubocopPr
|
2
|
+
# Simple representation of the Cop
|
3
|
+
class Cop
|
4
|
+
attr_reader :name
|
5
|
+
|
6
|
+
def initialize(name:)
|
7
|
+
@name = name
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
name.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
def branch
|
15
|
+
"rubocop-fix-#{name.underscore.tr('/_', '-')}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/rubocop_pr/options.rb
CHANGED
@@ -17,24 +17,19 @@ module RubocopPr
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
attr_accessor :opts
|
21
|
+
|
22
|
+
# options will be printed in order, as they are declared in this file
|
23
|
+
def build_parser
|
24
|
+
@parser = OptionParser.new do |op|
|
25
|
+
self.opts = op
|
22
26
|
opts.banner = 'Usage: rubocop_pr [options]'
|
23
27
|
|
24
|
-
|
25
|
-
add_rubocop_todo_branch_option(opts)
|
26
|
-
add_master_branch_option(opts)
|
27
|
-
add_post_checkout_option(opts)
|
28
|
-
add_limit_option(opts)
|
29
|
-
add_repository_option(opts)
|
30
|
-
add_git_origin_option(opts)
|
31
|
-
add_continue_option(opts)
|
32
|
-
add_version_option(opts)
|
33
|
-
add_on_tail(opts)
|
28
|
+
private_methods(false).map(&:to_s).select { |m| m.start_with?('add_') }.each { |m| send m }
|
34
29
|
end
|
35
30
|
end
|
36
31
|
|
37
|
-
def add_limit_option
|
32
|
+
def add_limit_option
|
38
33
|
@options.limit = 10
|
39
34
|
msg = "Limit the PS's for one run (default: 10)"
|
40
35
|
opts.on('-l [limit]', '--limit [limit]', Integer, msg) do |v|
|
@@ -42,15 +37,15 @@ module RubocopPr
|
|
42
37
|
end
|
43
38
|
end
|
44
39
|
|
45
|
-
def add_post_checkout_option
|
40
|
+
def add_post_checkout_option
|
46
41
|
@options.post_checkout = ''
|
47
42
|
msg = 'Running after each git checkout (default: "")'
|
48
|
-
opts.on('-
|
43
|
+
opts.on('-k [command]', '--post-checkout [command]', String, msg) do |v|
|
49
44
|
@options.post_checkout = v
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
53
|
-
def add_rubocop_todo_branch_option
|
48
|
+
def add_rubocop_todo_branch_option
|
54
49
|
@options.rubocop_todo_branch = 'rubocop_todo_branch'
|
55
50
|
msg = "internal branch with '.rubocop_todo.yml' (default: 'rubocop_todo_branch')"
|
56
51
|
opts.on('-b [branch]', '--branch [branch]', String, msg) do |v|
|
@@ -58,7 +53,7 @@ module RubocopPr
|
|
58
53
|
end
|
59
54
|
end
|
60
55
|
|
61
|
-
def add_master_branch_option
|
56
|
+
def add_master_branch_option
|
62
57
|
@options.master_branch = 'master'
|
63
58
|
msg = "branch which will be the base for all PR's (default: 'master')"
|
64
59
|
opts.on('-m [branch]', '--master [branch]', String, msg) do |v|
|
@@ -66,7 +61,7 @@ module RubocopPr
|
|
66
61
|
end
|
67
62
|
end
|
68
63
|
|
69
|
-
def add_git_origin_option
|
64
|
+
def add_git_origin_option
|
70
65
|
@options.git_origin = 'origin'
|
71
66
|
msg = "origin option for 'git push' (default: 'origin')"
|
72
67
|
opts.on('-o [origin]', '--origin [origin]', String, msg) do |v|
|
@@ -74,7 +69,7 @@ module RubocopPr
|
|
74
69
|
end
|
75
70
|
end
|
76
71
|
|
77
|
-
def add_hub_version_option
|
72
|
+
def add_hub_version_option
|
78
73
|
@options.hub_version = HUB_VERSION
|
79
74
|
msg = "Set manually minimum required version of 'hub' utility for github (default: #{HUB_VERSION})"
|
80
75
|
opts.on('-u [version] ', '--hub-version [version]', msg) do |v|
|
@@ -82,7 +77,47 @@ module RubocopPr
|
|
82
77
|
end
|
83
78
|
end
|
84
79
|
|
85
|
-
def
|
80
|
+
def add_issue_labels_option
|
81
|
+
@options.issue_labels = ['rubocop']
|
82
|
+
msg = 'Labels for created issues, separated by comma (default: rubocop)'
|
83
|
+
opts.on('-i [labels] ', '--issue-labels [labels]', Array, msg) do |v|
|
84
|
+
@options.issue_labels = v
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def add_pull_request_labels_option
|
89
|
+
@options.pull_request_labels = ['rubocop']
|
90
|
+
msg = 'Labels for created pull requests, separated by comma (default: rubocop)'
|
91
|
+
opts.on('-p [labels] ', '--pull-request-labels [labels]', Array, msg) do |v|
|
92
|
+
@options.pull_request_labels = v
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_issue_assignees_option
|
97
|
+
@options.issue_assignees = []
|
98
|
+
msg = 'Issue assignees, separated by comma (default: "")'
|
99
|
+
opts.on('-a [name] ', '--issue-assignees [name]', Array, msg) do |v|
|
100
|
+
@options.issue_assignees = v
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def add_pull_request_assignees_option
|
105
|
+
@options.pull_request_assignees = []
|
106
|
+
msg = 'Pull request assignees, separated by comma (default: "")'
|
107
|
+
opts.on('-t [name] ', '--pull-request-assignees [name]', Array, msg) do |v|
|
108
|
+
@options.pull_request_assignees = v
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def add_pull_request_reviewers_option
|
113
|
+
@options.pull_request_reviewers = []
|
114
|
+
msg = 'Pull request reviewers, separated by comma (default: "")'
|
115
|
+
opts.on('-r [name] ', '--pull-request-reviewers [name]', Array, msg) do |v|
|
116
|
+
@options.pull_request_reviewers = v
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def add_repository_option
|
86
121
|
@options.repository = 'github'
|
87
122
|
msg = 'Set repository host (default: github)'
|
88
123
|
opts.on('-g [name] ', '--repository [name]', msg) do |v|
|
@@ -90,21 +125,28 @@ module RubocopPr
|
|
90
125
|
end
|
91
126
|
end
|
92
127
|
|
93
|
-
def
|
128
|
+
def add_all_option
|
129
|
+
@options.all = false
|
130
|
+
opts.on('-a', '--all', 'Use -A flag for rubocop command (default: false)') do |_v|
|
131
|
+
@options.all = true
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def add_continue_option
|
94
136
|
@options.continue = false
|
95
137
|
opts.on('-c', '--continue', 'Continue previous session (default: false)') do |_v|
|
96
138
|
@options.continue = true
|
97
139
|
end
|
98
140
|
end
|
99
141
|
|
100
|
-
def add_version_option
|
142
|
+
def add_version_option
|
101
143
|
opts.on('-v', '--version', 'Display version') do
|
102
144
|
puts RubocopPr::VERSION
|
103
145
|
exit
|
104
146
|
end
|
105
147
|
end
|
106
148
|
|
107
|
-
def add_on_tail
|
149
|
+
def add_on_tail
|
108
150
|
opts.on_tail('-h', '--help', 'Display help') do
|
109
151
|
puts opts
|
110
152
|
exit
|
@@ -2,18 +2,72 @@ module RubocopPr
|
|
2
2
|
module Repositories
|
3
3
|
# Github repository
|
4
4
|
class Github < RubocopPr::Repository
|
5
|
-
#
|
6
|
-
class
|
7
|
-
attr_reader :title, :body
|
5
|
+
# Base class for working with `hub` utility
|
6
|
+
class Base
|
7
|
+
attr_reader :title, :body, :cop, :number
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@
|
11
|
-
@
|
9
|
+
def initialize(cop:, **options)
|
10
|
+
@cop = cop
|
11
|
+
@options = options
|
12
|
+
@title = options.delete(:title) || default_title
|
13
|
+
@body = options.delete(:body) || default_body
|
12
14
|
end
|
13
15
|
|
14
16
|
def create
|
15
|
-
|
16
|
-
|
17
|
+
@number = `#{build_command}`.split('/').last.to_i
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def assignees
|
22
|
+
@assignees ||= Array options[:assignees]
|
23
|
+
end
|
24
|
+
|
25
|
+
def labels
|
26
|
+
@labels ||= Array options[:labels]
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_command
|
30
|
+
[command, cli_options].join ' '
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
attr_reader :options
|
36
|
+
|
37
|
+
def command
|
38
|
+
raise NotImplemented
|
39
|
+
end
|
40
|
+
|
41
|
+
def cli_options
|
42
|
+
[].tap do |opt|
|
43
|
+
opt << "-m '#{title}'"
|
44
|
+
opt << "-m '#{body}'" unless body.blank?
|
45
|
+
opt << "-a '#{assignees.join(',')}'" unless assignees.blank?
|
46
|
+
opt << "-l '#{labels.join(',')}'" unless labels.blank?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def default_title
|
51
|
+
"Fix Rubocop #{cop} warnings"
|
52
|
+
end
|
53
|
+
|
54
|
+
def default_body
|
55
|
+
''
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# The representation of the Issue
|
60
|
+
class Issue < Base
|
61
|
+
def initialize(cop:, **opt)
|
62
|
+
super
|
63
|
+
@assignees = Array opt[:issue_assignees]
|
64
|
+
@labels = Array opt[:issue_labels]
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def command
|
70
|
+
'hub issue create'
|
17
71
|
end
|
18
72
|
|
19
73
|
def default_body
|
@@ -23,17 +77,26 @@ module RubocopPr
|
|
23
77
|
end
|
24
78
|
|
25
79
|
# The representation of the PR
|
26
|
-
class PullRequest
|
27
|
-
attr_reader :
|
80
|
+
class PullRequest < Base
|
81
|
+
attr_reader :reviewers
|
28
82
|
|
29
|
-
def initialize(
|
30
|
-
|
31
|
-
@
|
83
|
+
def initialize(cop:, **opt)
|
84
|
+
super
|
85
|
+
@assignees = Array opt[:pull_request_assignees]
|
86
|
+
@labels = Array opt[:pull_request_labels]
|
87
|
+
@reviewers = Array opt[:pull_request_reviewers]
|
32
88
|
end
|
33
89
|
|
34
|
-
|
35
|
-
|
36
|
-
|
90
|
+
private
|
91
|
+
|
92
|
+
def command
|
93
|
+
'hub pull-request create'
|
94
|
+
end
|
95
|
+
|
96
|
+
def cli_options
|
97
|
+
super.tap do |opt|
|
98
|
+
opt << "-r '#{reviewers.join(',')}'" unless reviewers.blank?
|
99
|
+
end
|
37
100
|
end
|
38
101
|
end
|
39
102
|
|
@@ -42,12 +105,12 @@ module RubocopPr
|
|
42
105
|
super + [RubocopPr::Repositories::Github::Checks::VerifyHubVersion]
|
43
106
|
end
|
44
107
|
|
45
|
-
def
|
46
|
-
Issue.new(*args)
|
108
|
+
def issue(*args)
|
109
|
+
Issue.new(*args)
|
47
110
|
end
|
48
111
|
|
49
|
-
def
|
50
|
-
PullRequest.new(*args)
|
112
|
+
def pull_request(*args)
|
113
|
+
PullRequest.new(*args)
|
51
114
|
end
|
52
115
|
end
|
53
116
|
end
|
data/lib/rubocop_pr/rubocop.rb
CHANGED
@@ -5,6 +5,16 @@ module RubocopPr
|
|
5
5
|
|
6
6
|
TODO_FILENAME = '.rubocop_todo.yml'.freeze
|
7
7
|
|
8
|
+
class << self
|
9
|
+
def generate_todo
|
10
|
+
system 'bundle exec rubocop --auto-gen-config'
|
11
|
+
end
|
12
|
+
|
13
|
+
def correct!(all)
|
14
|
+
system "bundle exec rubocop -#{all ? 'A' : 'a'}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
attr_reader :branch, :git
|
9
19
|
|
10
20
|
def initialize(**options)
|
@@ -13,36 +23,25 @@ module RubocopPr
|
|
13
23
|
end
|
14
24
|
|
15
25
|
def todo
|
16
|
-
YAML.safe_load(read_or_generate_todo)
|
26
|
+
@todo ||= YAML.safe_load(read_or_generate_todo)
|
17
27
|
end
|
18
28
|
|
19
29
|
def each
|
20
|
-
|
21
|
-
todos_backup = todo
|
22
|
-
todos_backup.each_key do |cop|
|
30
|
+
todo.keys.sort.reverse_each do |cop|
|
23
31
|
git.checkout(branch)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
yield cop
|
32
|
+
File.open(TODO_FILENAME, 'w') do |f|
|
33
|
+
f.write todo.except(cop.to_s).blank? ? '' : YAML.dump(todo.except(cop.to_s))
|
34
|
+
end
|
35
|
+
yield Cop.new(name: cop)
|
28
36
|
end
|
29
37
|
end
|
30
38
|
|
31
39
|
def read_or_generate_todo
|
40
|
+
git.checkout(branch)
|
32
41
|
return File.read(TODO_FILENAME) if File.exist?(TODO_FILENAME)
|
33
|
-
generate_todo
|
42
|
+
self.class.generate_todo
|
34
43
|
git.commit_all('Generate initial Rubocop todo file')
|
35
44
|
File.read(TODO_FILENAME)
|
36
45
|
end
|
37
|
-
|
38
|
-
def generate_todo
|
39
|
-
`bundle exec rubocop --auto-gen-config`
|
40
|
-
end
|
41
|
-
|
42
|
-
def corrected?
|
43
|
-
`bundle exec rubocop -a`
|
44
|
-
git.checkout TODO_FILENAME
|
45
|
-
!git.status.blank?
|
46
|
-
end
|
47
46
|
end
|
48
47
|
end
|
data/lib/rubocop_pr/version.rb
CHANGED
data/rubocop_pr.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = 'https://github.com/kvokka/rubocop_pr'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
|
-
spec.required_ruby_version = '~> 2.
|
18
|
+
spec.required_ruby_version = '~> 2.5'
|
19
19
|
|
20
20
|
# Specify which files should be added to the gem when it is released.
|
21
21
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -26,13 +26,12 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
|
29
|
-
spec.add_dependency 'activesupport', '>= 4.2.0', '<
|
30
|
-
spec.add_dependency 'rubocop', '
|
29
|
+
spec.add_dependency 'activesupport', '>= 4.2.0', '< 7.0'
|
30
|
+
spec.add_dependency 'rubocop', '>= 1.0.0'
|
31
31
|
|
32
|
-
spec.add_development_dependency '
|
33
|
-
spec.add_development_dependency '
|
34
|
-
spec.add_development_dependency '
|
35
|
-
spec.add_development_dependency '
|
36
|
-
spec.add_development_dependency 'rspec', '~>
|
37
|
-
spec.add_development_dependency 'rubocop-rspec', '~> 1.27'
|
32
|
+
spec.add_development_dependency 'overcommit', '~> 0.57'
|
33
|
+
spec.add_development_dependency 'pry', '~> 0.13'
|
34
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
35
|
+
spec.add_development_dependency 'rspec', '>= 3.0'
|
36
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.1.0'
|
38
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop_pr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kvokka
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 4.2.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,89 +29,75 @@ dependencies:
|
|
29
29
|
version: 4.2.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rubocop
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 1.0.0
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.57.0
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: bundler
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '1.16'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
44
|
+
- - ">="
|
59
45
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
46
|
+
version: 1.0.0
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: overcommit
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
64
50
|
requirements:
|
65
51
|
- - "~>"
|
66
52
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0.
|
53
|
+
version: '0.57'
|
68
54
|
type: :development
|
69
55
|
prerelease: false
|
70
56
|
version_requirements: !ruby/object:Gem::Requirement
|
71
57
|
requirements:
|
72
58
|
- - "~>"
|
73
59
|
- !ruby/object:Gem::Version
|
74
|
-
version: '0.
|
60
|
+
version: '0.57'
|
75
61
|
- !ruby/object:Gem::Dependency
|
76
62
|
name: pry
|
77
63
|
requirement: !ruby/object:Gem::Requirement
|
78
64
|
requirements:
|
79
65
|
- - "~>"
|
80
66
|
- !ruby/object:Gem::Version
|
81
|
-
version: '0.
|
67
|
+
version: '0.13'
|
82
68
|
type: :development
|
83
69
|
prerelease: false
|
84
70
|
version_requirements: !ruby/object:Gem::Requirement
|
85
71
|
requirements:
|
86
72
|
- - "~>"
|
87
73
|
- !ruby/object:Gem::Version
|
88
|
-
version: '0.
|
74
|
+
version: '0.13'
|
89
75
|
- !ruby/object:Gem::Dependency
|
90
76
|
name: rake
|
91
77
|
requirement: !ruby/object:Gem::Requirement
|
92
78
|
requirements:
|
93
79
|
- - "~>"
|
94
80
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
81
|
+
version: '13.0'
|
96
82
|
type: :development
|
97
83
|
prerelease: false
|
98
84
|
version_requirements: !ruby/object:Gem::Requirement
|
99
85
|
requirements:
|
100
86
|
- - "~>"
|
101
87
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
88
|
+
version: '13.0'
|
103
89
|
- !ruby/object:Gem::Dependency
|
104
90
|
name: rspec
|
105
91
|
requirement: !ruby/object:Gem::Requirement
|
106
92
|
requirements:
|
107
|
-
- - "
|
93
|
+
- - ">="
|
108
94
|
- !ruby/object:Gem::Version
|
109
95
|
version: '3.0'
|
110
96
|
type: :development
|
111
97
|
prerelease: false
|
112
98
|
version_requirements: !ruby/object:Gem::Requirement
|
113
99
|
requirements:
|
114
|
-
- - "
|
100
|
+
- - ">="
|
115
101
|
- !ruby/object:Gem::Version
|
116
102
|
version: '3.0'
|
117
103
|
- !ruby/object:Gem::Dependency
|
@@ -120,14 +106,14 @@ dependencies:
|
|
120
106
|
requirements:
|
121
107
|
- - "~>"
|
122
108
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
109
|
+
version: 2.1.0
|
124
110
|
type: :development
|
125
111
|
prerelease: false
|
126
112
|
version_requirements: !ruby/object:Gem::Requirement
|
127
113
|
requirements:
|
128
114
|
- - "~>"
|
129
115
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
116
|
+
version: 2.1.0
|
131
117
|
description: Create 1 PR per 1 Rubocop linter, which allow to do review rubocop changes
|
132
118
|
smoothly.
|
133
119
|
email:
|
@@ -152,6 +138,8 @@ files:
|
|
152
138
|
- exe/rubocop_pr
|
153
139
|
- lib/rubocop_pr.rb
|
154
140
|
- lib/rubocop_pr/cli.rb
|
141
|
+
- lib/rubocop_pr/cli/process_cop.rb
|
142
|
+
- lib/rubocop_pr/cop.rb
|
155
143
|
- lib/rubocop_pr/environment_checker.rb
|
156
144
|
- lib/rubocop_pr/git.rb
|
157
145
|
- lib/rubocop_pr/options.rb
|
@@ -165,7 +153,7 @@ homepage: https://github.com/kvokka/rubocop_pr
|
|
165
153
|
licenses:
|
166
154
|
- MIT
|
167
155
|
metadata: {}
|
168
|
-
post_install_message:
|
156
|
+
post_install_message:
|
169
157
|
rdoc_options: []
|
170
158
|
require_paths:
|
171
159
|
- lib
|
@@ -173,15 +161,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
161
|
requirements:
|
174
162
|
- - "~>"
|
175
163
|
- !ruby/object:Gem::Version
|
176
|
-
version: '2.
|
164
|
+
version: '2.5'
|
177
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
166
|
requirements:
|
179
167
|
- - ">="
|
180
168
|
- !ruby/object:Gem::Version
|
181
169
|
version: '0'
|
182
170
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
184
|
-
signing_key:
|
171
|
+
rubygems_version: 3.1.4
|
172
|
+
signing_key:
|
185
173
|
specification_version: 4
|
186
174
|
summary: Quick & clean Rubocop introduction.
|
187
175
|
test_files: []
|