rubocop_challenger 2.7.0 → 2.8.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 +4 -4
- data/.circleci/config.yml +3 -8
- data/.rubocop.yml +4 -4
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +29 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +19 -42
- data/README.md +19 -16
- data/challenger.gemspec +2 -2
- data/images/{decrease_of_offence_codes.png → decrease_of_offense_codes.png} +0 -0
- data/lib/rubocop_challenger/bundler/command.rb +1 -1
- data/lib/rubocop_challenger/cli.rb +14 -10
- data/lib/rubocop_challenger/go.rb +20 -7
- data/lib/rubocop_challenger/rubocop/command.rb +3 -1
- data/lib/rubocop_challenger/rubocop/todo_reader.rb +6 -5
- data/lib/rubocop_challenger/rubocop/yardoc.rb +1 -9
- data/lib/rubocop_challenger/version.rb +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '069b4741c020bd27b620bcf7e5cac220bd9f80de03735751598e148d7c622a0a'
|
|
4
|
+
data.tar.gz: 0a9eedf4aed6d0154be1cd70f53ac4a573fcdc349b0be4611b60e8f3463f2c6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b87dea0df5bbb1e54e9296d71752be6d5af85dc57374da52c34431175e831e103f2c45d565e22e0b6e6c5bc4e6bdca95761a849489984699f4aa4721c306f84
|
|
7
|
+
data.tar.gz: 54357ce576a82ea8c950fc2d0ed1c21b956e04fc971659b05b3e62d43696850fb59394943ba30f761674f07462474037fdfb6ffb87780f2e5d33f588da37ea8a
|
data/.circleci/config.yml
CHANGED
|
@@ -12,7 +12,7 @@ references:
|
|
|
12
12
|
- &ruby_version
|
|
13
13
|
ruby_version:
|
|
14
14
|
type: enum
|
|
15
|
-
enum: ["2.
|
|
15
|
+
enum: ["2.7", "3.0", "3.1"]
|
|
16
16
|
default: "3.1"
|
|
17
17
|
|
|
18
18
|
executors:
|
|
@@ -77,7 +77,7 @@ commands:
|
|
|
77
77
|
bundle exec exe/rubocop_challenger go \
|
|
78
78
|
--email=ryz310@gmail.com \
|
|
79
79
|
--name=ryz310 \
|
|
80
|
-
--
|
|
80
|
+
--no-offense-counts \
|
|
81
81
|
--no-create-pr
|
|
82
82
|
integration_testing:
|
|
83
83
|
description: Integration testing for RuboCop Challenge
|
|
@@ -159,7 +159,7 @@ jobs:
|
|
|
159
159
|
- code-climate/install
|
|
160
160
|
- code-climate/sum-coverage:
|
|
161
161
|
input: codeclimate.*.json
|
|
162
|
-
parts:
|
|
162
|
+
parts: 3
|
|
163
163
|
- code-climate/upload-coverage
|
|
164
164
|
rubocop:
|
|
165
165
|
executor: default
|
|
@@ -192,9 +192,6 @@ workflows:
|
|
|
192
192
|
|
|
193
193
|
commit:
|
|
194
194
|
jobs:
|
|
195
|
-
- build:
|
|
196
|
-
name: build_on_ruby_2.6
|
|
197
|
-
ruby_version: "2.6"
|
|
198
195
|
- build:
|
|
199
196
|
name: build_on_ruby_2.7
|
|
200
197
|
ruby_version: "2.7"
|
|
@@ -209,14 +206,12 @@ workflows:
|
|
|
209
206
|
- integration_testing
|
|
210
207
|
- upload-coverage:
|
|
211
208
|
requires:
|
|
212
|
-
- build_on_ruby_2.6
|
|
213
209
|
- build_on_ruby_2.7
|
|
214
210
|
- build_on_ruby_3.0
|
|
215
211
|
- build_on_ruby_3.1
|
|
216
212
|
- release:
|
|
217
213
|
context: RubyGems API Key
|
|
218
214
|
requires:
|
|
219
|
-
- build_on_ruby_2.6
|
|
220
215
|
- build_on_ruby_2.7
|
|
221
216
|
- build_on_ruby_3.0
|
|
222
217
|
- build_on_ruby_3.1
|
data/.rubocop.yml
CHANGED
|
@@ -7,13 +7,13 @@ require:
|
|
|
7
7
|
inherit_from: .rubocop_todo.yml
|
|
8
8
|
|
|
9
9
|
AllCops:
|
|
10
|
-
TargetRubyVersion: 2.
|
|
10
|
+
TargetRubyVersion: 2.7
|
|
11
11
|
NewCops: enable
|
|
12
12
|
|
|
13
13
|
Metrics/BlockLength:
|
|
14
14
|
Exclude:
|
|
15
|
-
-
|
|
16
|
-
-
|
|
15
|
+
- "challenger.gemspec"
|
|
16
|
+
- "spec/**/*"
|
|
17
17
|
|
|
18
18
|
Naming/VariableNumber:
|
|
19
19
|
EnforcedStyle: snake_case
|
|
@@ -21,7 +21,7 @@ Naming/VariableNumber:
|
|
|
21
21
|
# For integration testing
|
|
22
22
|
RSpec/MultipleExpectations:
|
|
23
23
|
Exclude:
|
|
24
|
-
-
|
|
24
|
+
- "spec/lib/rubocop_challenger/cli_spec.rb"
|
|
25
25
|
|
|
26
26
|
RSpec/MultipleMemoizedHelpers:
|
|
27
27
|
Max: 10
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config --exclude-limit 30 --no-auto-gen-timestamp`
|
|
3
|
-
# using RuboCop version 1.
|
|
3
|
+
# using RuboCop version 1.30.0.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Change log
|
|
2
2
|
|
|
3
|
+
## v2.8.0 (May 30, 2022)
|
|
4
|
+
|
|
5
|
+
### Feature
|
|
6
|
+
|
|
7
|
+
- [#616](https://github.com/ryz310/rubocop_challenger/pull/616) Support `--no-offense-counts` option ([@ryz310](https://github.com/ryz310))
|
|
8
|
+
|
|
9
|
+
### Bugfix
|
|
10
|
+
|
|
11
|
+
- [#612](https://github.com/ryz310/rubocop_challenger/pull/612) Fix wrong usage of `Array#reject!`: this might return nil ([@r7kamura](https://github.com/r7kamura))
|
|
12
|
+
- [#625](https://github.com/ryz310/rubocop_challenger/pull/625) Use `--conservative` option on `bundle update` ([@ryz310](https://github.com/ryz310))
|
|
13
|
+
|
|
14
|
+
### Breaking Change
|
|
15
|
+
|
|
16
|
+
- [#615](https://github.com/ryz310/rubocop_challenger/pull/615) The end of ruby 2.6 support ([@ryz310](https://github.com/ryz310))
|
|
17
|
+
|
|
18
|
+
### Rubocop Challenge
|
|
19
|
+
|
|
20
|
+
- [#624](https://github.com/ryz310/rubocop_challenger/pull/624) Re-generate .rubocop_todo.yml with RuboCop v1.30.0 ([@ryz310](https://github.com/ryz310))
|
|
21
|
+
|
|
22
|
+
### Dependabot
|
|
23
|
+
|
|
24
|
+
- [#608](https://github.com/ryz310/rubocop_challenger/pull/608) Update pr_comet requirement from ~> 0.5.1 to >= 0.5.1, < 0.7.0 ([@ryz310](https://github.com/ryz310))
|
|
25
|
+
- [#610](https://github.com/ryz310/rubocop_challenger/pull/610) Bump activesupport from 6.1.5.1 to 6.1.6 ([@ryz310](https://github.com/ryz310))
|
|
26
|
+
|
|
27
|
+
### Misc
|
|
28
|
+
|
|
29
|
+
- [#614](https://github.com/ryz310/rubocop_challenger/pull/614) Tweak some words improved representation ([@ydah](https://github.com/ydah))
|
|
30
|
+
- [#619](https://github.com/ryz310/rubocop_challenger/pull/619) git mv ./images/decrease_of_offen{c,s}e_codes.png ([@r7kamura](https://github.com/r7kamura))
|
|
31
|
+
|
|
3
32
|
## v2.7.0 (May 08, 2022)
|
|
4
33
|
|
|
5
34
|
### Feature
|
data/Gemfile
CHANGED
|
@@ -4,7 +4,5 @@ source 'https://rubygems.org'
|
|
|
4
4
|
|
|
5
5
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
6
6
|
|
|
7
|
-
gem 'activesupport', '~> 6.1' # TODO: Remove this line at the end of Ruby 2.6 support
|
|
8
|
-
|
|
9
7
|
# Specify your gem's dependencies in rubocop_challenger.gemspec
|
|
10
8
|
gemspec
|
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rubocop_challenger (2.
|
|
5
|
-
pr_comet (
|
|
4
|
+
rubocop_challenger (2.8.0)
|
|
5
|
+
pr_comet (>= 0.5.1, < 0.7.0)
|
|
6
6
|
rainbow
|
|
7
7
|
rubocop (>= 0.87)
|
|
8
8
|
rubocop-performance
|
|
@@ -16,12 +16,11 @@ PATH
|
|
|
16
16
|
GEM
|
|
17
17
|
remote: https://rubygems.org/
|
|
18
18
|
specs:
|
|
19
|
-
activesupport (
|
|
19
|
+
activesupport (7.0.3)
|
|
20
20
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
21
21
|
i18n (>= 1.6, < 2)
|
|
22
22
|
minitest (>= 5.1)
|
|
23
23
|
tzinfo (~> 2.0)
|
|
24
|
-
zeitwerk (~> 2.3)
|
|
25
24
|
addressable (2.8.0)
|
|
26
25
|
public_suffix (>= 2.0.2, < 5.0)
|
|
27
26
|
ast (2.4.2)
|
|
@@ -30,41 +29,21 @@ GEM
|
|
|
30
29
|
concurrent-ruby (1.1.10)
|
|
31
30
|
diff-lcs (1.5.0)
|
|
32
31
|
docile (1.4.0)
|
|
33
|
-
faraday (
|
|
34
|
-
faraday-
|
|
35
|
-
faraday-em_synchrony (~> 1.0)
|
|
36
|
-
faraday-excon (~> 1.1)
|
|
37
|
-
faraday-httpclient (~> 1.0)
|
|
38
|
-
faraday-multipart (~> 1.0)
|
|
39
|
-
faraday-net_http (~> 1.0)
|
|
40
|
-
faraday-net_http_persistent (~> 1.0)
|
|
41
|
-
faraday-patron (~> 1.0)
|
|
42
|
-
faraday-rack (~> 1.0)
|
|
43
|
-
faraday-retry (~> 1.0)
|
|
32
|
+
faraday (2.3.0)
|
|
33
|
+
faraday-net_http (~> 2.0)
|
|
44
34
|
ruby2_keywords (>= 0.0.4)
|
|
45
|
-
faraday-
|
|
46
|
-
faraday-em_synchrony (1.0.0)
|
|
47
|
-
faraday-excon (1.1.0)
|
|
48
|
-
faraday-httpclient (1.0.1)
|
|
49
|
-
faraday-multipart (1.0.3)
|
|
50
|
-
multipart-post (>= 1.2, < 3)
|
|
51
|
-
faraday-net_http (1.0.1)
|
|
52
|
-
faraday-net_http_persistent (1.2.0)
|
|
53
|
-
faraday-patron (1.0.0)
|
|
54
|
-
faraday-rack (1.0.0)
|
|
55
|
-
faraday-retry (1.0.3)
|
|
35
|
+
faraday-net_http (2.0.3)
|
|
56
36
|
i18n (1.10.0)
|
|
57
37
|
concurrent-ruby (~> 1.0)
|
|
58
38
|
method_source (1.0.0)
|
|
59
39
|
minitest (5.15.0)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
sawyer (~> 0.8.0, >= 0.5.3)
|
|
40
|
+
octokit (4.23.0)
|
|
41
|
+
faraday (>= 1, < 3)
|
|
42
|
+
sawyer (~> 0.9)
|
|
64
43
|
parallel (1.22.1)
|
|
65
44
|
parser (3.1.2.0)
|
|
66
45
|
ast (~> 2.4.1)
|
|
67
|
-
pr_comet (0.
|
|
46
|
+
pr_comet (0.6.0)
|
|
68
47
|
octokit
|
|
69
48
|
rainbow
|
|
70
49
|
pry (0.13.1)
|
|
@@ -74,10 +53,10 @@ GEM
|
|
|
74
53
|
byebug (~> 11.0)
|
|
75
54
|
pry (~> 0.13.0)
|
|
76
55
|
public_suffix (4.0.7)
|
|
77
|
-
rack (2.2.3)
|
|
56
|
+
rack (2.2.3.1)
|
|
78
57
|
rainbow (3.1.1)
|
|
79
58
|
rake (13.0.6)
|
|
80
|
-
regexp_parser (2.
|
|
59
|
+
regexp_parser (2.5.0)
|
|
81
60
|
rexml (3.2.5)
|
|
82
61
|
rspec (3.11.0)
|
|
83
62
|
rspec-core (~> 3.11.0)
|
|
@@ -94,18 +73,18 @@ GEM
|
|
|
94
73
|
rspec-support (3.11.0)
|
|
95
74
|
rspec_junit_formatter (0.5.1)
|
|
96
75
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
97
|
-
rubocop (1.
|
|
76
|
+
rubocop (1.30.0)
|
|
98
77
|
parallel (~> 1.10)
|
|
99
78
|
parser (>= 3.1.0.0)
|
|
100
79
|
rainbow (>= 2.2.2, < 4.0)
|
|
101
80
|
regexp_parser (>= 1.8, < 3.0)
|
|
102
81
|
rexml (>= 3.2.5, < 4.0)
|
|
103
|
-
rubocop-ast (>= 1.
|
|
82
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
|
104
83
|
ruby-progressbar (~> 1.7)
|
|
105
84
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
106
|
-
rubocop-ast (1.
|
|
85
|
+
rubocop-ast (1.18.0)
|
|
107
86
|
parser (>= 3.1.1.0)
|
|
108
|
-
rubocop-performance (1.
|
|
87
|
+
rubocop-performance (1.14.0)
|
|
109
88
|
rubocop (>= 1.7.0, < 2.0)
|
|
110
89
|
rubocop-ast (>= 0.4.0)
|
|
111
90
|
rubocop-rails (2.14.2)
|
|
@@ -114,15 +93,15 @@ GEM
|
|
|
114
93
|
rubocop (>= 1.7.0, < 2.0)
|
|
115
94
|
rubocop-rake (0.6.0)
|
|
116
95
|
rubocop (~> 1.0)
|
|
117
|
-
rubocop-rspec (2.
|
|
96
|
+
rubocop-rspec (2.11.1)
|
|
118
97
|
rubocop (~> 1.19)
|
|
119
98
|
rubocop-thread_safety (0.4.4)
|
|
120
99
|
rubocop (>= 0.53.0)
|
|
121
100
|
ruby-progressbar (1.11.0)
|
|
122
101
|
ruby2_keywords (0.0.5)
|
|
123
|
-
sawyer (0.
|
|
102
|
+
sawyer (0.9.1)
|
|
124
103
|
addressable (>= 2.3.5)
|
|
125
|
-
faraday (
|
|
104
|
+
faraday (>= 0.17.3, < 3)
|
|
126
105
|
simplecov (0.21.2)
|
|
127
106
|
docile (~> 1.1)
|
|
128
107
|
simplecov-html (~> 0.11)
|
|
@@ -136,13 +115,11 @@ GEM
|
|
|
136
115
|
webrick (1.7.0)
|
|
137
116
|
yard (0.9.27)
|
|
138
117
|
webrick (~> 1.7.0)
|
|
139
|
-
zeitwerk (2.5.4)
|
|
140
118
|
|
|
141
119
|
PLATFORMS
|
|
142
120
|
ruby
|
|
143
121
|
|
|
144
122
|
DEPENDENCIES
|
|
145
|
-
activesupport (~> 6.1)
|
|
146
123
|
bundler (>= 2.0)
|
|
147
124
|
pry-byebug
|
|
148
125
|
rake (~> 13.0)
|
data/README.md
CHANGED
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
If you introduce [`rubocop`](https://github.com/rubocop-hq/rubocop) to an existing Rails project later, you will use [`$ rubocop --auto-gen-config`](https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md#automatically-generated-configuration). But it will make a huge `.rubocop_todo.yml` and make you despair.
|
|
6
6
|
On the other hand, `rubocop` has [`--auto-correct`](https://github.com/rubocop-hq/rubocop/blob/master/manual/basic_usage.md#other-useful-command-line-flags) option, it is possible to automatically repair the writing which does not conform to the rule. But since it occasionally destroys your code, it is quite dangerous to apply all at once.
|
|
7
7
|
It is ideal that to remove a disabled rule from `.rubocop_todo.yml` every day, to check whether it passes test, and can be obtained consent from the team. But it requires strong persistence and time.
|
|
8
|
-
I call such work
|
|
8
|
+
I call such work _Rubocop Challenge_. And the _RubocopChallenger_ is a gem to support this challenge!
|
|
9
9
|
|
|
10
|
-
## The history of RubocopChallenger with decrease of
|
|
10
|
+
## The history of RubocopChallenger with decrease of offense codes
|
|
11
11
|
|
|
12
|
-
The following chart shows the history of RubocopChallenger and decrease of
|
|
13
|
-
But there are many
|
|
12
|
+
The following chart shows the history of RubocopChallenger and decrease of offense codes at a `.rubocop_todo.yml`. The project was released at 5 years ago, and then it was introduced the RuboCop gem for huge source code including a lots of offense codes. Before using the RubocopChallenger, it was not maintain to reduce offense codes. One day, I felt a crisis and started maintain with manual. I made a lots of Pull Requests to reduce them but it's a load for me and reviewers. So I created a script for automation the flow, which is the predecessor of Rubocop Challenger gem. It brought reducing the offense codes continuously. After 8 months, finally it has done. There is no auto-correctable offense codes.
|
|
13
|
+
But there are many offenses which is un-auto-correctable yet. I will try to reduce it with the RubocopChallenger. The RubocopChallenger will
|
|
14
14
|
be continued to evolve.
|
|
15
15
|
|
|
16
|
-

|
|
17
17
|
|
|
18
18
|
## Rubocop Challenge Flow
|
|
19
19
|
|
|
20
|
-
1. Run
|
|
21
|
-
1. When
|
|
20
|
+
1. Run _RubocopChallenger_ periodically from CI tool etc.
|
|
21
|
+
1. When _RubocopChallenger_ starts, delete a disabled rule from `.rubocop_todo.yml` existing in your project, execute `$ rubocop --auto-correct` and create a PR which include modified results
|
|
22
22
|
1. You confirm the PR passes testing and then merge it if there is no problem
|
|
23
23
|
|
|
24
24
|
[](https://github.com/ryz310/rubocop_challenger/pull/97)
|
|
@@ -54,7 +54,7 @@ workflows:
|
|
|
54
54
|
nightly:
|
|
55
55
|
triggers:
|
|
56
56
|
- schedule:
|
|
57
|
-
cron: "30 23 * * 1,2,3" # 8:30am every Tuesday,
|
|
57
|
+
cron: "30 23 * * 1,2,3" # 8:30am every Tuesday, Wednesday and Thursday (JST)
|
|
58
58
|
filters:
|
|
59
59
|
branches:
|
|
60
60
|
only:
|
|
@@ -71,16 +71,16 @@ I have seen cases where errors occur due to compatibility issues with other gems
|
|
|
71
71
|
GitHub personal access token is required for sending pull requests to your repository.
|
|
72
72
|
|
|
73
73
|
1. Go to [your account's settings page](https://github.com/settings/tokens) and [generate a new token](https://github.com/settings/tokens/new) with "repo" scope
|
|
74
|
-
|
|
74
|
+

|
|
75
75
|
1. On [CircleCI](https://circleci.com) dashboard, go to your application's "Project Settings" -> "Environment Variables"
|
|
76
76
|
1. Add an environment variable `GITHUB_ACCESS_TOKEN` with your GitHub personal access token
|
|
77
|
-
|
|
77
|
+

|
|
78
78
|
|
|
79
79
|
### Want to use on GitHub Actions?
|
|
80
80
|
|
|
81
81
|
It's introduced in the following blog. Thank you Mr. Takuya Yamaguchi!
|
|
82
82
|
|
|
83
|
-
See: [RuboCop ChallengerをGitHub Actionsで動かす](https://zenn.dev/yamat47/articles/219e14ebcf31a1d13ff4)
|
|
83
|
+
See: [RuboCop Challenger を GitHub Actions で動かす](https://zenn.dev/yamat47/articles/219e14ebcf31a1d13ff4)
|
|
84
84
|
|
|
85
85
|
## CLI command references
|
|
86
86
|
|
|
@@ -107,7 +107,7 @@ Options:
|
|
|
107
107
|
f, [--file-path=FILE_PATH] # Set your ".rubocop_todo.yml" path
|
|
108
108
|
# Default: .rubocop_todo.yml
|
|
109
109
|
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.
|
|
110
|
-
[--mode=MODE] # Mode to select deletion target. You can choice "most_occurrence", "least_occurrence", or "random"
|
|
110
|
+
[--mode=MODE] # Mode to select deletion target. You can choice "most_occurrence", "least_occurrence", or "random". If you set --no-offense-counts, the mode to be forced to "random".
|
|
111
111
|
# Default: most_occurrence
|
|
112
112
|
b, [--base-branch=BASE_BRANCH] # The Branch to merge into
|
|
113
113
|
# Default: master
|
|
@@ -115,9 +115,12 @@ Options:
|
|
|
115
115
|
# Default: ["rubocop challenge"]
|
|
116
116
|
[--project-column-name=PROJECT_COLUMN_NAME] # A project column name. You can add the created PR to the GitHub project
|
|
117
117
|
[--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.
|
|
118
|
-
[--no-create-pr]
|
|
119
|
-
|
|
120
|
-
[--
|
|
118
|
+
[--create-pr], [--no-create-pr] # If you set --no-create-pr, no create a pull request (for testing)
|
|
119
|
+
# Default: true
|
|
120
|
+
[--exclude-limit=N] # For how many exclude properties on create .rubocop_todo.yml
|
|
121
|
+
[--auto-gen-timestamp], [--no-auto-gen-timestamp] # Include the date and time in .rubocop_todo.yml
|
|
122
|
+
# Default: true
|
|
123
|
+
[--offense-counts], [--no-offense-counts] # Include offense counts in .rubocop_todo.yml
|
|
121
124
|
# Default: true
|
|
122
125
|
[--only-safe-auto-correct], [--no-only-safe-auto-correct] # If given `true`, it executes `rubocop --auto-correct`,it means to correct safe cops only.
|
|
123
126
|
[--verbose], [--no-verbose] # Displays executing command.
|
|
@@ -127,7 +130,7 @@ Run `$ rubocop --auto-correct` and create a PR to GitHub repo
|
|
|
127
130
|
|
|
128
131
|
## Requirement
|
|
129
132
|
|
|
130
|
-
|
|
133
|
+
- Ruby 2.7 or higher
|
|
131
134
|
|
|
132
135
|
## Development
|
|
133
136
|
|
data/challenger.gemspec
CHANGED
|
@@ -22,9 +22,9 @@ 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.required_ruby_version = '>= 2.
|
|
25
|
+
spec.required_ruby_version = '>= 2.7'
|
|
26
26
|
|
|
27
|
-
spec.add_runtime_dependency 'pr_comet', '
|
|
27
|
+
spec.add_runtime_dependency 'pr_comet', '>= 0.5.1', '< 0.7.0'
|
|
28
28
|
spec.add_runtime_dependency 'rainbow'
|
|
29
29
|
spec.add_runtime_dependency 'rubocop', '>= 0.87'
|
|
30
30
|
spec.add_runtime_dependency 'rubocop-performance'
|
|
File without changes
|
|
@@ -14,7 +14,7 @@ module RubocopChallenger
|
|
|
14
14
|
#
|
|
15
15
|
# @param gem_names [Array<String>] The target gem names
|
|
16
16
|
def update(*gem_names)
|
|
17
|
-
run('update', *gem_names.select { |gem_name| installed?(gem_name) })
|
|
17
|
+
run('update', *gem_names.select { |gem_name| installed?(gem_name) }, '--conservative')
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
# Checks the gem is installed
|
|
@@ -29,7 +29,8 @@ module RubocopChallenger
|
|
|
29
29
|
type: :string,
|
|
30
30
|
default: 'most_occurrence',
|
|
31
31
|
desc: 'Mode to select deletion target. You can choice ' \
|
|
32
|
-
'"most_occurrence", "least_occurrence", or "random"'
|
|
32
|
+
'"most_occurrence", "least_occurrence", or "random". ' \
|
|
33
|
+
'If you set --no-offense-counts, the mode to be forced to "random".'
|
|
33
34
|
option :base_branch,
|
|
34
35
|
type: :string,
|
|
35
36
|
default: 'master',
|
|
@@ -49,19 +50,22 @@ module RubocopChallenger
|
|
|
49
50
|
desc: 'A target project ID. If does not supplied, this method ' \
|
|
50
51
|
'will find a project which associated the repository. When ' \
|
|
51
52
|
'the repository has multiple projects, you should supply this.'
|
|
52
|
-
option :
|
|
53
|
+
option :create_pr,
|
|
53
54
|
type: :boolean,
|
|
54
|
-
default:
|
|
55
|
-
desc: '
|
|
56
|
-
option :
|
|
55
|
+
default: true,
|
|
56
|
+
desc: 'If you set --no-create-pr, no create a pull request (for testing)'
|
|
57
|
+
option :exclude_limit,
|
|
57
58
|
type: :numeric,
|
|
58
|
-
desc: 'For how many exclude properties
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
desc: 'For how many exclude properties on create .rubocop_todo.yml'
|
|
60
|
+
option :auto_gen_timestamp,
|
|
61
|
+
type: :boolean,
|
|
62
|
+
default: true,
|
|
63
|
+
desc: 'Include the date and time in .rubocop_todo.yml'
|
|
64
|
+
option :offense_counts,
|
|
61
65
|
type: :boolean,
|
|
62
66
|
default: true,
|
|
63
|
-
desc: 'Include
|
|
64
|
-
option :
|
|
67
|
+
desc: 'Include offense counts in .rubocop_todo.yml'
|
|
68
|
+
option :only_safe_auto_correct,
|
|
65
69
|
type: :boolean,
|
|
66
70
|
default: false,
|
|
67
71
|
desc: 'If given `true`, it executes `rubocop --auto-correct`,' \
|
|
@@ -6,9 +6,11 @@ module RubocopChallenger
|
|
|
6
6
|
# @param options [Hash]
|
|
7
7
|
# Options for the rubocop challenge
|
|
8
8
|
# @option exclude-limit [Integer]
|
|
9
|
-
# For how many exclude properties
|
|
9
|
+
# For how many exclude properties on create .rubocop_todo.yml
|
|
10
10
|
# @option auto-gen-timestamp [Boolean]
|
|
11
|
-
# Include the date and time
|
|
11
|
+
# Include the date and time in .rubocop_todo.yml
|
|
12
|
+
# @option offense_counts [Boolean]
|
|
13
|
+
# Include offense counts in .rubocop_todo.yml'
|
|
12
14
|
# @option only-safe-auto-correct [Boolean]
|
|
13
15
|
# If given `true`, it executes `rubocop --auto-correct`,
|
|
14
16
|
# it means to correct safe cops only.
|
|
@@ -162,8 +164,8 @@ module RubocopChallenger
|
|
|
162
164
|
def rubocop_challenge_options
|
|
163
165
|
{
|
|
164
166
|
file_path: options[:file_path],
|
|
165
|
-
mode:
|
|
166
|
-
only_safe_auto_correct: options[:
|
|
167
|
+
mode: mode,
|
|
168
|
+
only_safe_auto_correct: options[:only_safe_auto_correct]
|
|
167
169
|
}
|
|
168
170
|
end
|
|
169
171
|
|
|
@@ -173,7 +175,7 @@ module RubocopChallenger
|
|
|
173
175
|
user_email: options[:email],
|
|
174
176
|
base_branch: options[:base_branch],
|
|
175
177
|
labels: options[:labels],
|
|
176
|
-
dry_run: options[:
|
|
178
|
+
dry_run: !options[:create_pr],
|
|
177
179
|
project_column_name: options[:project_column_name],
|
|
178
180
|
project_id: options[:project_id],
|
|
179
181
|
verbose: options[:verbose]
|
|
@@ -182,9 +184,20 @@ module RubocopChallenger
|
|
|
182
184
|
|
|
183
185
|
def auto_gen_config_options
|
|
184
186
|
{
|
|
185
|
-
exclude_limit: options[:
|
|
186
|
-
auto_gen_timestamp: options[:
|
|
187
|
+
exclude_limit: options[:exclude_limit],
|
|
188
|
+
auto_gen_timestamp: options[:auto_gen_timestamp],
|
|
189
|
+
offense_counts: options[:offense_counts]
|
|
187
190
|
}
|
|
188
191
|
end
|
|
192
|
+
|
|
193
|
+
# Mode to select deletion target.
|
|
194
|
+
# If you set --no-offense-counts, the mode to be forced to "random".
|
|
195
|
+
#
|
|
196
|
+
# @return [String] "most_occurrence", "least_occurrence", or "random"
|
|
197
|
+
def mode
|
|
198
|
+
return 'random' unless options[:offense_counts]
|
|
199
|
+
|
|
200
|
+
options[:mode]
|
|
201
|
+
end
|
|
189
202
|
end
|
|
190
203
|
end
|
|
@@ -19,10 +19,12 @@ module RubocopChallenger
|
|
|
19
19
|
#
|
|
20
20
|
# @param exclude_limit [Integer] default: nil
|
|
21
21
|
# @param auto_gen_timestamp [Boolean] default: true
|
|
22
|
-
|
|
22
|
+
# @param offense_counts [Boolean] default: true
|
|
23
|
+
def auto_gen_config(exclude_limit: nil, auto_gen_timestamp: true, offense_counts: true)
|
|
23
24
|
commands = ['--auto-gen-config']
|
|
24
25
|
commands << "--exclude-limit #{exclude_limit}" if exclude_limit
|
|
25
26
|
commands << '--no-auto-gen-timestamp' unless auto_gen_timestamp
|
|
27
|
+
commands << '--no-offense-counts' unless offense_counts
|
|
26
28
|
run(*commands)
|
|
27
29
|
end
|
|
28
30
|
|
|
@@ -22,9 +22,10 @@ module RubocopChallenger
|
|
|
22
22
|
@all_rules ||=
|
|
23
23
|
file_contents
|
|
24
24
|
.split(/\n{2,}/)
|
|
25
|
-
.
|
|
26
|
-
.
|
|
27
|
-
.
|
|
25
|
+
.drop(1) # remove header contents
|
|
26
|
+
.map { |content| Rule.new(content) }
|
|
27
|
+
.reject { |rule| ignored?(rule) }
|
|
28
|
+
.sort
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
# @return [Array<Rule>]
|
|
@@ -58,8 +59,8 @@ module RubocopChallenger
|
|
|
58
59
|
|
|
59
60
|
# @param rule [Rule] the target rule
|
|
60
61
|
# @return [Boolean]
|
|
61
|
-
def
|
|
62
|
-
|
|
62
|
+
def ignored?(rule)
|
|
63
|
+
ignored_rules.include?(rule.title)
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
# @return [Array<String>] Ignored rule titles
|
|
@@ -66,15 +66,7 @@ module RubocopChallenger
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def source_file_path
|
|
69
|
-
|
|
70
|
-
Object.const_source_location(cop_class.name).first
|
|
71
|
-
else
|
|
72
|
-
instance_methods
|
|
73
|
-
.map { |m| cop_class.instance_method(m).source_location }
|
|
74
|
-
.compact
|
|
75
|
-
.map(&:first)
|
|
76
|
-
.first
|
|
77
|
-
end
|
|
69
|
+
Object.const_source_location(cop_class.name).first
|
|
78
70
|
end
|
|
79
71
|
end
|
|
80
72
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop_challenger
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ryosuke_sato
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-05-
|
|
11
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pr_comet
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 0.5.1
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 0.7.0
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: 0.5.1
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 0.7.0
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: rainbow
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -265,7 +271,7 @@ files:
|
|
|
265
271
|
- challenger.gemspec
|
|
266
272
|
- exe/rubocop_challenger
|
|
267
273
|
- images/circleci_environment_variables.png
|
|
268
|
-
- images/
|
|
274
|
+
- images/decrease_of_offense_codes.png
|
|
269
275
|
- images/generate_token.png
|
|
270
276
|
- images/rubocop_challenge.png
|
|
271
277
|
- lib/rubocop_challenger.rb
|
|
@@ -300,7 +306,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
300
306
|
requirements:
|
|
301
307
|
- - ">="
|
|
302
308
|
- !ruby/object:Gem::Version
|
|
303
|
-
version: '2.
|
|
309
|
+
version: '2.7'
|
|
304
310
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
305
311
|
requirements:
|
|
306
312
|
- - ">="
|