rubocop_challenger 2.0.0.pre10 → 2.3.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.
data/Gemfile.lock CHANGED
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop_challenger (2.0.0.pre10)
5
- pr_comet (>= 0.2, < 0.4)
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.0)
19
- byebug (11.0.1)
20
- coderay (1.1.2)
21
- diff-lcs (1.3)
22
- docile (1.3.2)
23
- faraday (0.17.0)
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
- jaro_winkler (1.5.3)
26
- json (2.2.0)
27
- method_source (0.9.2)
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.14.0)
42
+ octokit (4.20.0)
43
+ faraday (>= 0.9)
30
44
  sawyer (~> 0.8.0, >= 0.5.3)
31
- parallel (1.18.0)
32
- parser (2.6.5.0)
33
- ast (~> 2.4.0)
34
- pr_comet (0.3.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.12.2)
38
- coderay (~> 1.1.0)
39
- method_source (~> 0.9.0)
40
- pry-byebug (3.7.0)
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.10)
43
- public_suffix (4.0.1)
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.0)
46
- rspec (3.9.0)
47
- rspec-core (~> 3.9.0)
48
- rspec-expectations (~> 3.9.0)
49
- rspec-mocks (~> 3.9.0)
50
- rspec-core (3.9.0)
51
- rspec-support (~> 3.9.0)
52
- rspec-expectations (3.9.0)
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.9.0)
55
- rspec-mocks (3.9.0)
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.9.0)
58
- rspec-support (3.9.0)
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 (0.75.1)
62
- jaro_winkler (~> 1.5.1)
78
+ rubocop (1.10.0)
63
79
  parallel (~> 1.10)
64
- parser (>= 2.6)
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, < 1.7)
68
- rubocop-performance (1.5.0)
69
- rubocop (>= 0.71.0)
70
- rubocop-rspec (1.36.0)
71
- rubocop (>= 0.68.1)
72
- ruby-progressbar (1.10.1)
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.17.1)
106
+ simplecov (0.21.2)
77
107
  docile (~> 1.1)
78
- json (>= 1.8, < 3)
79
- simplecov-html (~> 0.10.0)
80
- simplecov-html (0.10.2)
81
- thor (0.20.3)
82
- unicode-display_width (1.6.0)
83
- yard (0.9.20)
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 (~> 1.16)
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
- 1.17.3
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:2.6-node-browsers
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 # The Pull Request committer email
121
- --name=NAME # The Pull Request committer name
122
- f, [--file-path=FILE_PATH] # Set your ".rubocop_todo.yml" path
123
- # Default: .rubocop_todo.yml
124
- 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.
125
- [--mode=MODE] # Mode to select deletion target. You can choice "most_occurrence", "least_occurrence", or "random"
126
- # Default: most_occurrence
127
- b, [--base-branch=BASE_BRANCH] # The Branch to merge into
128
- # Default: master
129
- l, [--labels=one two three] # Label to give to Pull Request
130
- # Default: ["rubocop challenge"]
131
- [--project-column-name=PROJECT_COLUMN_NAME] # A project column name. You can add the created PR to the GitHub project
132
- [--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.
133
- [--no-create-pr] # No create a pull request (for testing)
134
- [--exclude-limit=N] # For how many exclude properties when creating the .rubocop_todo.yml
135
- [--auto-gen-timestamp], [--no-auto-gen-timestamp] # Include the date and time when creating the .rubocop_todo.yml
136
- # Default: true
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.4 or higher
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.add_runtime_dependency 'pr_comet', '>= 0.2', '< 0.4'
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', '~> 1.16'
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
@@ -24,6 +24,7 @@ module RubocopChallenger
24
24
  rubocop
25
25
  rubocop-performance
26
26
  rubocop-rails
27
+ rubocop-rake
27
28
  rubocop-rspec
28
29
  ].freeze
29
30
  end
@@ -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(&method(:installed?)))
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
@@ -53,6 +53,10 @@ module RubocopChallenger
53
53
  yardoc.examples
54
54
  end
55
55
 
56
+ def safe_autocorrect?
57
+ yardoc.safe_autocorrect?
58
+ end
59
+
56
60
  def yardoc
57
61
  @yardoc ||= Rubocop::Yardoc.new(title)
58
62
  end
@@ -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, :pull_request, :exclude_limit, :auto_gen_timestamp
50
+ attr_reader :options
49
51
 
50
- # Extracts options for the PullRequest class
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(options[:file_path], options[:mode]).tap do |rule|
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