rubocop_challenger 2.0.0.pre10 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +19 -11
- data/.dependabot/config.yml +18 -0
- data/.gem_comet.yml +13 -1
- data/.rubocop.yml +10 -2
- data/.rubocop_challenge.yml +3 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +322 -4
- data/Gemfile.lock +88 -54
- data/README.md +21 -33
- data/challenger.gemspec +8 -4
- data/lib/rubocop_challenger.rb +1 -0
- data/lib/rubocop_challenger/bundler/command.rb +5 -1
- data/lib/rubocop_challenger/cli.rb +9 -0
- data/lib/rubocop_challenger/github/pr_template.rb +4 -0
- data/lib/rubocop_challenger/go.rb +39 -24
- data/lib/rubocop_challenger/pull_request.rb +6 -3
- data/lib/rubocop_challenger/rubocop/challenge.rb +6 -5
- data/lib/rubocop_challenger/rubocop/command.rb +6 -2
- data/lib/rubocop_challenger/rubocop/rule.rb +1 -1
- data/lib/rubocop_challenger/rubocop/yardoc.rb +36 -20
- data/lib/rubocop_challenger/version.rb +1 -1
- data/lib/templates/checklist.md.erb +8 -0
- data/lib/templates/default.md.erb +8 -0
- data/lib/templates/error.md.erb +1 -1
- metadata +48 -24
data/Gemfile.lock
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop_challenger (2.
|
5
|
-
pr_comet (
|
4
|
+
rubocop_challenger (2.3.0)
|
5
|
+
pr_comet (~> 0.5.1)
|
6
6
|
rainbow
|
7
|
-
rubocop
|
7
|
+
rubocop (>= 0.87)
|
8
8
|
rubocop-performance
|
9
|
+
rubocop-rails
|
10
|
+
rubocop-rake
|
9
11
|
rubocop-rspec
|
10
12
|
thor
|
11
13
|
yard
|
@@ -13,86 +15,118 @@ PATH
|
|
13
15
|
GEM
|
14
16
|
remote: https://rubygems.org/
|
15
17
|
specs:
|
18
|
+
activesupport (6.1.3)
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
+
i18n (>= 1.6, < 2)
|
21
|
+
minitest (>= 5.1)
|
22
|
+
tzinfo (~> 2.0)
|
23
|
+
zeitwerk (~> 2.3)
|
16
24
|
addressable (2.7.0)
|
17
25
|
public_suffix (>= 2.0.2, < 5.0)
|
18
|
-
ast (2.4.
|
19
|
-
byebug (11.
|
20
|
-
coderay (1.1.
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
ast (2.4.2)
|
27
|
+
byebug (11.1.3)
|
28
|
+
coderay (1.1.3)
|
29
|
+
concurrent-ruby (1.1.8)
|
30
|
+
diff-lcs (1.4.4)
|
31
|
+
docile (1.3.5)
|
32
|
+
faraday (1.3.0)
|
33
|
+
faraday-net_http (~> 1.0)
|
24
34
|
multipart-post (>= 1.2, < 3)
|
25
|
-
|
26
|
-
|
27
|
-
|
35
|
+
ruby2_keywords
|
36
|
+
faraday-net_http (1.0.1)
|
37
|
+
i18n (1.8.9)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
method_source (1.0.0)
|
40
|
+
minitest (5.14.3)
|
28
41
|
multipart-post (2.1.1)
|
29
|
-
octokit (4.
|
42
|
+
octokit (4.20.0)
|
43
|
+
faraday (>= 0.9)
|
30
44
|
sawyer (~> 0.8.0, >= 0.5.3)
|
31
|
-
parallel (1.
|
32
|
-
parser (
|
33
|
-
ast (~> 2.4.
|
34
|
-
pr_comet (0.
|
45
|
+
parallel (1.20.1)
|
46
|
+
parser (3.0.0.0)
|
47
|
+
ast (~> 2.4.1)
|
48
|
+
pr_comet (0.5.1)
|
35
49
|
octokit
|
36
50
|
rainbow
|
37
|
-
pry (0.
|
38
|
-
coderay (~> 1.1
|
39
|
-
method_source (~>
|
40
|
-
pry-byebug (3.
|
51
|
+
pry (0.13.1)
|
52
|
+
coderay (~> 1.1)
|
53
|
+
method_source (~> 1.0)
|
54
|
+
pry-byebug (3.9.0)
|
41
55
|
byebug (~> 11.0)
|
42
|
-
pry (~> 0.
|
43
|
-
public_suffix (4.0.
|
56
|
+
pry (~> 0.13.0)
|
57
|
+
public_suffix (4.0.6)
|
58
|
+
rack (2.2.3)
|
44
59
|
rainbow (3.0.0)
|
45
|
-
rake (13.0.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
rspec-
|
50
|
-
|
51
|
-
rspec-
|
52
|
-
rspec-
|
60
|
+
rake (13.0.3)
|
61
|
+
regexp_parser (2.1.0)
|
62
|
+
rexml (3.2.4)
|
63
|
+
rspec (3.10.0)
|
64
|
+
rspec-core (~> 3.10.0)
|
65
|
+
rspec-expectations (~> 3.10.0)
|
66
|
+
rspec-mocks (~> 3.10.0)
|
67
|
+
rspec-core (3.10.1)
|
68
|
+
rspec-support (~> 3.10.0)
|
69
|
+
rspec-expectations (3.10.1)
|
53
70
|
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
-
rspec-support (~> 3.
|
55
|
-
rspec-mocks (3.
|
71
|
+
rspec-support (~> 3.10.0)
|
72
|
+
rspec-mocks (3.10.2)
|
56
73
|
diff-lcs (>= 1.2.0, < 2.0)
|
57
|
-
rspec-support (~> 3.
|
58
|
-
rspec-support (3.
|
74
|
+
rspec-support (~> 3.10.0)
|
75
|
+
rspec-support (3.10.2)
|
59
76
|
rspec_junit_formatter (0.4.1)
|
60
77
|
rspec-core (>= 2, < 4, != 2.12.0)
|
61
|
-
rubocop (
|
62
|
-
jaro_winkler (~> 1.5.1)
|
78
|
+
rubocop (1.10.0)
|
63
79
|
parallel (~> 1.10)
|
64
|
-
parser (>=
|
80
|
+
parser (>= 3.0.0.0)
|
65
81
|
rainbow (>= 2.2.2, < 4.0)
|
82
|
+
regexp_parser (>= 1.8, < 3.0)
|
83
|
+
rexml
|
84
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
66
85
|
ruby-progressbar (~> 1.7)
|
67
|
-
unicode-display_width (>= 1.4.0, <
|
68
|
-
rubocop-
|
69
|
-
|
70
|
-
rubocop-
|
71
|
-
rubocop (>= 0.
|
72
|
-
|
86
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
87
|
+
rubocop-ast (1.4.1)
|
88
|
+
parser (>= 2.7.1.5)
|
89
|
+
rubocop-performance (1.9.2)
|
90
|
+
rubocop (>= 0.90.0, < 2.0)
|
91
|
+
rubocop-ast (>= 0.4.0)
|
92
|
+
rubocop-rails (2.9.1)
|
93
|
+
activesupport (>= 4.2.0)
|
94
|
+
rack (>= 1.1)
|
95
|
+
rubocop (>= 0.90.0, < 2.0)
|
96
|
+
rubocop-rake (0.5.1)
|
97
|
+
rubocop
|
98
|
+
rubocop-rspec (2.2.0)
|
99
|
+
rubocop (~> 1.0)
|
100
|
+
rubocop-ast (>= 1.1.0)
|
101
|
+
ruby-progressbar (1.11.0)
|
102
|
+
ruby2_keywords (0.0.4)
|
73
103
|
sawyer (0.8.2)
|
74
104
|
addressable (>= 2.3.5)
|
75
105
|
faraday (> 0.8, < 2.0)
|
76
|
-
simplecov (0.
|
106
|
+
simplecov (0.21.2)
|
77
107
|
docile (~> 1.1)
|
78
|
-
|
79
|
-
|
80
|
-
simplecov-html (0.
|
81
|
-
|
82
|
-
|
83
|
-
|
108
|
+
simplecov-html (~> 0.11)
|
109
|
+
simplecov_json_formatter (~> 0.1)
|
110
|
+
simplecov-html (0.12.3)
|
111
|
+
simplecov_json_formatter (0.1.2)
|
112
|
+
thor (1.1.0)
|
113
|
+
tzinfo (2.0.4)
|
114
|
+
concurrent-ruby (~> 1.0)
|
115
|
+
unicode-display_width (2.0.0)
|
116
|
+
yard (0.9.26)
|
117
|
+
zeitwerk (2.4.2)
|
84
118
|
|
85
119
|
PLATFORMS
|
86
120
|
ruby
|
87
121
|
|
88
122
|
DEPENDENCIES
|
89
|
-
bundler (
|
123
|
+
bundler (>= 2.0)
|
90
124
|
pry-byebug
|
91
125
|
rake (~> 13.0)
|
92
126
|
rspec
|
93
127
|
rspec_junit_formatter
|
94
128
|
rubocop_challenger!
|
95
|
-
simplecov
|
129
|
+
simplecov (= 0.21.2)
|
96
130
|
|
97
131
|
BUNDLED WITH
|
98
|
-
|
132
|
+
2.2.3
|
data/README.md
CHANGED
@@ -56,7 +56,7 @@ version: 2
|
|
56
56
|
jobs:
|
57
57
|
rubocop_challenge:
|
58
58
|
docker:
|
59
|
-
- image: circleci/ruby:
|
59
|
+
- image: circleci/ruby:3.0
|
60
60
|
working_directory: ~/repo
|
61
61
|
steps:
|
62
62
|
- checkout
|
@@ -83,20 +83,6 @@ workflows:
|
|
83
83
|
- rubocop_challenge
|
84
84
|
```
|
85
85
|
|
86
|
-
If you added `rubocop_challenger` gem in your Gemfile so please modify script of installing and execution as following:
|
87
|
-
|
88
|
-
```yml
|
89
|
-
steps:
|
90
|
-
- checkout
|
91
|
-
- run:
|
92
|
-
name: Rubocop Challenge
|
93
|
-
command: |
|
94
|
-
bundle install
|
95
|
-
bundle exec rubocop_challenger go \
|
96
|
-
--email=rubocop-challenger@example.com \
|
97
|
-
--name="Rubocop Challenger"
|
98
|
-
```
|
99
|
-
|
100
86
|
## CLI command references
|
101
87
|
|
102
88
|
```sh
|
@@ -117,30 +103,32 @@ Usage:
|
|
117
103
|
rubocop_challenger go --email=EMAIL --name=NAME
|
118
104
|
|
119
105
|
Options:
|
120
|
-
--email=EMAIL
|
121
|
-
--name=NAME
|
122
|
-
f, [--file-path=FILE_PATH]
|
123
|
-
|
124
|
-
t, [--template=TEMPLATE]
|
125
|
-
[--mode=MODE]
|
126
|
-
|
127
|
-
b, [--base-branch=BASE_BRANCH]
|
128
|
-
|
129
|
-
l, [--labels=one two three]
|
130
|
-
|
131
|
-
[--project-column-name=PROJECT_COLUMN_NAME]
|
132
|
-
[--project-id=N]
|
133
|
-
[--no-create-pr]
|
134
|
-
[--exclude-limit=N]
|
135
|
-
[--auto-gen-timestamp], [--no-auto-gen-timestamp]
|
136
|
-
|
106
|
+
--email=EMAIL # The Pull Request committer email
|
107
|
+
--name=NAME # The Pull Request committer name
|
108
|
+
f, [--file-path=FILE_PATH] # Set your ".rubocop_todo.yml" path
|
109
|
+
# Default: .rubocop_todo.yml
|
110
|
+
t, [--template=TEMPLATE] # A Pull Request template `erb` file path.You can use variable that `title`, `rubydoc_url`, `description` and `examples` into the erb file.
|
111
|
+
[--mode=MODE] # Mode to select deletion target. You can choice "most_occurrence", "least_occurrence", or "random"
|
112
|
+
# Default: most_occurrence
|
113
|
+
b, [--base-branch=BASE_BRANCH] # The Branch to merge into
|
114
|
+
# Default: master
|
115
|
+
l, [--labels=one two three] # Label to give to Pull Request
|
116
|
+
# Default: ["rubocop challenge"]
|
117
|
+
[--project-column-name=PROJECT_COLUMN_NAME] # A project column name. You can add the created PR to the GitHub project
|
118
|
+
[--project-id=N] # A target project ID. If does not supplied, this method will find a project which associated the repository. When the repository has multiple projects, you should supply this.
|
119
|
+
[--no-create-pr] # No create a pull request (for testing)
|
120
|
+
[--exclude-limit=N] # For how many exclude properties when creating the .rubocop_todo.yml
|
121
|
+
[--auto-gen-timestamp], [--no-auto-gen-timestamp] # Include the date and time when creating the .rubocop_todo.yml
|
122
|
+
# Default: true
|
123
|
+
[--only-safe-auto-correct], [--no-only-safe-auto-correct] # If given `true`, it executes `rubocop --auto-correct`,it means to correct safe cops only.
|
124
|
+
[--verbose], [--no-verbose] # Displays executing command.
|
137
125
|
|
138
126
|
Run `$ rubocop --auto-correct` and create a PR to GitHub repo
|
139
127
|
```
|
140
128
|
|
141
129
|
## Requirement
|
142
130
|
|
143
|
-
* Ruby 2.
|
131
|
+
* Ruby 2.5 or higher
|
144
132
|
|
145
133
|
## Development
|
146
134
|
|
data/challenger.gemspec
CHANGED
@@ -22,18 +22,22 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.
|
25
|
+
spec.required_ruby_version = '>= 2.5'
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'pr_comet', '~> 0.5.1'
|
26
28
|
spec.add_runtime_dependency 'rainbow'
|
27
|
-
spec.add_runtime_dependency 'rubocop'
|
29
|
+
spec.add_runtime_dependency 'rubocop', '>= 0.87'
|
28
30
|
spec.add_runtime_dependency 'rubocop-performance'
|
31
|
+
spec.add_runtime_dependency 'rubocop-rails'
|
32
|
+
spec.add_runtime_dependency 'rubocop-rake'
|
29
33
|
spec.add_runtime_dependency 'rubocop-rspec'
|
30
34
|
spec.add_runtime_dependency 'thor'
|
31
35
|
spec.add_runtime_dependency 'yard'
|
32
36
|
|
33
|
-
spec.add_development_dependency 'bundler', '
|
37
|
+
spec.add_development_dependency 'bundler', '>= 2.0'
|
34
38
|
spec.add_development_dependency 'pry-byebug'
|
35
39
|
spec.add_development_dependency 'rake', '~> 13.0'
|
36
40
|
spec.add_development_dependency 'rspec'
|
37
41
|
spec.add_development_dependency 'rspec_junit_formatter'
|
38
|
-
spec.add_development_dependency 'simplecov'
|
42
|
+
spec.add_development_dependency 'simplecov', '0.21.2'
|
39
43
|
end
|
data/lib/rubocop_challenger.rb
CHANGED
@@ -6,11 +6,15 @@ module RubocopChallenger
|
|
6
6
|
class Command
|
7
7
|
include PrComet::CommandLine
|
8
8
|
|
9
|
+
def initialize(verbose: false)
|
10
|
+
@verbose = verbose
|
11
|
+
end
|
12
|
+
|
9
13
|
# Executes `$ bundle update` which excludes not installed gems
|
10
14
|
#
|
11
15
|
# @param gem_names [Array<String>] The target gem names
|
12
16
|
def update(*gem_names)
|
13
|
-
run('update', *gem_names.select
|
17
|
+
run('update', *gem_names.select { |gem_name| installed?(gem_name) })
|
14
18
|
end
|
15
19
|
|
16
20
|
# Checks the gem is installed
|
@@ -61,6 +61,15 @@ module RubocopChallenger
|
|
61
61
|
type: :boolean,
|
62
62
|
default: true,
|
63
63
|
desc: 'Include the date and time when creating the .rubocop_todo.yml'
|
64
|
+
option :'only-safe-auto-correct',
|
65
|
+
type: :boolean,
|
66
|
+
default: false,
|
67
|
+
desc: 'If given `true`, it executes `rubocop --auto-correct`,' \
|
68
|
+
'it means to correct safe cops only.'
|
69
|
+
option :verbose,
|
70
|
+
type: :boolean,
|
71
|
+
default: false,
|
72
|
+
desc: 'Displays executing command.'
|
64
73
|
def go
|
65
74
|
Go.new(options).exec
|
66
75
|
rescue Errors::NoAutoCorrectableRule => e
|
@@ -9,6 +9,9 @@ module RubocopChallenger
|
|
9
9
|
# For how many exclude properties when creating the ".rubocop_todo.yml"
|
10
10
|
# @option auto-gen-timestamp [Boolean]
|
11
11
|
# Include the date and time when creating the ".rubocop_todo.yml"
|
12
|
+
# @option only-safe-auto-correct [Boolean]
|
13
|
+
# If given `true`, it executes `rubocop --auto-correct`,
|
14
|
+
# it means to correct safe cops only.
|
12
15
|
# @option name [String]
|
13
16
|
# The author name which use at the git commit
|
14
17
|
# @option email [String]
|
@@ -23,11 +26,10 @@ module RubocopChallenger
|
|
23
26
|
# A target project ID. If does not supplied, this method will find a
|
24
27
|
# project which associated the repository. When the repository has
|
25
28
|
# multiple projects, you should supply this.
|
29
|
+
# @option verbose [Boolean]
|
30
|
+
# Displays executing command.
|
26
31
|
def initialize(options)
|
27
32
|
@options = options
|
28
|
-
@exclude_limit = options[:'exclude-limit']
|
29
|
-
@auto_gen_timestamp = options[:'auto-gen-timestamp']
|
30
|
-
@pull_request = PullRequest.new(extract_pull_request_options(options))
|
31
33
|
end
|
32
34
|
|
33
35
|
# Executes Rubocop Challenge flow
|
@@ -45,27 +47,15 @@ module RubocopChallenger
|
|
45
47
|
|
46
48
|
private
|
47
49
|
|
48
|
-
attr_reader :options
|
50
|
+
attr_reader :options
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
# @param options [Hash] The target options
|
53
|
-
# @return [Hash] Options for the PullRequest class
|
54
|
-
def extract_pull_request_options(options)
|
55
|
-
{
|
56
|
-
user_name: options[:name],
|
57
|
-
user_email: options[:email],
|
58
|
-
base_branch: options[:base_branch],
|
59
|
-
labels: options[:labels],
|
60
|
-
dry_run: options[:'no-create-pr'],
|
61
|
-
project_column_name: options[:project_column_name],
|
62
|
-
project_id: options[:project_id]
|
63
|
-
}
|
52
|
+
def pull_request
|
53
|
+
@pull_request ||= PullRequest.new(**pull_request_options)
|
64
54
|
end
|
65
55
|
|
66
56
|
# Executes `$ bundle update` for the rubocop and the associated gems
|
67
57
|
def update_rubocop!
|
68
|
-
bundler = Bundler::Command.new
|
58
|
+
bundler = Bundler::Command.new(verbose: options[:verbose])
|
69
59
|
pull_request.commit! ':police_car: $ bundle update rubocop' do
|
70
60
|
bundler.update(*RSPEC_GEMS)
|
71
61
|
end
|
@@ -79,10 +69,7 @@ module RubocopChallenger
|
|
79
69
|
def regenerate_rubocop_todo!
|
80
70
|
before_version = scan_rubocop_version_in_rubocop_todo_file
|
81
71
|
pull_request.commit! ':police_car: regenerate rubocop todo' do
|
82
|
-
Rubocop::Command.new.auto_gen_config(
|
83
|
-
exclude_limit: exclude_limit,
|
84
|
-
auto_gen_timestamp: auto_gen_timestamp
|
85
|
-
)
|
72
|
+
Rubocop::Command.new.auto_gen_config(**auto_gen_config_options)
|
86
73
|
end
|
87
74
|
after_version = scan_rubocop_version_in_rubocop_todo_file
|
88
75
|
|
@@ -107,7 +94,7 @@ module RubocopChallenger
|
|
107
94
|
# @raise [Errors::NoAutoCorrectableRule]
|
108
95
|
# Raises if there is no auto correctable rule in ".rubocop_todo.yml"
|
109
96
|
def rubocop_challenge!(before_version, after_version)
|
110
|
-
Rubocop::Challenge.exec(
|
97
|
+
Rubocop::Challenge.exec(**rubocop_challenge_options).tap do |rule|
|
111
98
|
pull_request.commit! ":police_car: #{rule.title}"
|
112
99
|
end
|
113
100
|
rescue Errors::NoAutoCorrectableRule => e
|
@@ -171,5 +158,33 @@ module RubocopChallenger
|
|
171
158
|
todo_reader = Rubocop::TodoReader.new(options[:file_path])
|
172
159
|
todo_reader.all_rules.include?(rule)
|
173
160
|
end
|
161
|
+
|
162
|
+
def rubocop_challenge_options
|
163
|
+
{
|
164
|
+
file_path: options[:file_path],
|
165
|
+
mode: options[:mode],
|
166
|
+
only_safe_auto_correct: options[:'only-safe-auto-correct']
|
167
|
+
}
|
168
|
+
end
|
169
|
+
|
170
|
+
def pull_request_options
|
171
|
+
{
|
172
|
+
user_name: options[:name],
|
173
|
+
user_email: options[:email],
|
174
|
+
base_branch: options[:base_branch],
|
175
|
+
labels: options[:labels],
|
176
|
+
dry_run: options[:'no-create-pr'],
|
177
|
+
project_column_name: options[:project_column_name],
|
178
|
+
project_id: options[:project_id],
|
179
|
+
verbose: options[:verbose]
|
180
|
+
}
|
181
|
+
end
|
182
|
+
|
183
|
+
def auto_gen_config_options
|
184
|
+
{
|
185
|
+
exclude_limit: options[:'exclude-limit'],
|
186
|
+
auto_gen_timestamp: options[:'auto-gen-timestamp']
|
187
|
+
}
|
188
|
+
end
|
174
189
|
end
|
175
190
|
end
|