rubocop 1.61.0 → 1.62.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 506b140c491cce5d643f22ac7a58396d82f19162c8bc22b2741f67a551913b07
4
- data.tar.gz: 51032873c1ce81903898c952ee828e6753a566faa204c7821f9d8a4cbbddf75d
3
+ metadata.gz: 71f9543fd4a2366245df52234cec7a2492a2e4df631fec99e466de8b82cde5d7
4
+ data.tar.gz: 99bf7b324f099186e5918469d3fd5d954e91317cb572e96f48a253c4d4ace709
5
5
  SHA512:
6
- metadata.gz: 1aa5ca182c9a0905f8b7c45408722a9885e0ac2ac104ed03e57386afa2c8323a0ce8489ed12abfcd7e169faaac428901a83d2301aa1fcaff2a84c1a2897d81f7
7
- data.tar.gz: 3f6d87ac3565d097f962bb24fa6b8c32851e622548a7b603e2c801ef27e1002ff816ec25aff8e461799fa1ee897b875409919f67120c9f9c47e0a19c881f9840
6
+ metadata.gz: a0128453654e2f6c5b5000c70931edb3dcccc2d1eb54c08b4e1af6ea393f7192ad0aeaaf9c07a136138fee6be7702caa22cdd3e0f3a46a25a6508102ac0759a1
7
+ data.tar.gz: 989aade51c2112e02b3d4e130b99d1096116fca3a8cc0d47e8c25de8eea419afb242969f9a48c7a8d04ab1b9a8563dc138b65e9b364d89758ebcdd3444147893
data/README.md CHANGED
@@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
53
53
  in your `Gemfile`:
54
54
 
55
55
  ```rb
56
- gem 'rubocop', '~> 1.61', require: false
56
+ gem 'rubocop', '~> 1.62', require: false
57
57
  ```
58
58
 
59
59
  See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
data/config/default.yml CHANGED
@@ -144,6 +144,12 @@ AllCops:
144
144
  # Ruby version is still unresolved, RuboCop will use the oldest officially
145
145
  # supported Ruby version (currently Ruby 2.7).
146
146
  TargetRubyVersion: ~
147
+ # You can specify the parser engine. There are two options available:
148
+ # - `parser_whitequark` ... https://github.com/whitequark/parser
149
+ # - `parser_prism` ... https://github.com/ruby/prism (`Prism::Translation::Parser`)
150
+ # By default, `parser` is used. For the `TargetRubyVersion` value, `parser` can be specified for versions `2.0` and above.
151
+ # `parser_prism` can be specified for versions `3.3` and above. `parser_prism` is faster but still considered experimental.
152
+ ParserEngine: parser_whitequark
147
153
  # Determines if a notification for extension libraries should be shown when
148
154
  # rubocop is run. Keys are the name of the extension, and values are an array
149
155
  # of gems in the Gemfile that the extension is suggested for, if not already
@@ -244,6 +244,10 @@ module RuboCop
244
244
  end
245
245
  end
246
246
 
247
+ def parser_engine
248
+ @parser_engine ||= for_all_cops.fetch('ParserEngine', :parser_whitequark).to_sym
249
+ end
250
+
247
251
  def target_rails_version
248
252
  @target_rails_version ||=
249
253
  if for_all_cops['TargetRailsVersion']
@@ -232,6 +232,10 @@ module RuboCop
232
232
  @config.target_ruby_version
233
233
  end
234
234
 
235
+ def parser_engine
236
+ @config.parser_engine
237
+ end
238
+
235
239
  def target_rails_version
236
240
  @config.target_rails_version
237
241
  end
@@ -254,7 +258,7 @@ module RuboCop
254
258
 
255
259
  # There should be very limited reasons for a Cop to do it's own parsing
256
260
  def parse(source, path = nil)
257
- ProcessedSource.new(source, target_ruby_version, path)
261
+ ProcessedSource.new(source, target_ruby_version, path, parser_engine: parser_engine)
258
262
  end
259
263
 
260
264
  # @api private
@@ -116,7 +116,7 @@ module RuboCop
116
116
 
117
117
  def incorrect_style_detected(token1, token2,
118
118
  expect_space, is_empty_braces)
119
- brace = (token1.text == '{' ? token1 : token2).pos
119
+ brace = (token1.left_brace? ? token1 : token2).pos
120
120
  range = expect_space ? brace : space_range(brace)
121
121
  detected_style = expect_space ? 'no_space' : 'space'
122
122
 
@@ -51,8 +51,13 @@ module RuboCop
51
51
  enum_conversion_call?(node) do |method_node, arguments|
52
52
  next if method_node.call_type? &&
53
53
  !method_node.method?(:__method__) && !method_node.method?(:__callee__)
54
- next if method_name?(method_node, def_node.method_name) &&
55
- arguments_match?(arguments, def_node)
54
+
55
+ valid = if method_name?(method_node, def_node.method_name)
56
+ arguments_match?(arguments, def_node)
57
+ else
58
+ def_node.arguments.empty?
59
+ end
60
+ return if valid
56
61
 
57
62
  add_offense(node)
58
63
  end
@@ -72,7 +72,7 @@ module RuboCop
72
72
  ALLOWED_STRING_TOKENS = %i[tSTRING tSTRING_CONTENT].freeze
73
73
  ARGUMENT_TYPES = %i[
74
74
  kFALSE kNIL kSELF kTRUE tCONSTANT tCVAR tFLOAT tGVAR tIDENTIFIER tINTEGER tIVAR
75
- tLBRACK tLCURLY tLPAREN_ARG tSTRING tSTRING_BEG tSYMBOL tXSTRING_BEG
75
+ tLABEL tLBRACK tLCURLY tLPAREN_ARG tSTRING tSTRING_BEG tSYMBOL tXSTRING_BEG
76
76
  ].freeze
77
77
 
78
78
  def on_new_investigation
@@ -268,7 +268,7 @@ module RuboCop
268
268
 
269
269
  # Rewrite the comment without a given token type
270
270
  def without(type)
271
- if @comment.match?(/\A#\s*#{self.class::KEYWORDS[type.to_sym]}/)
271
+ if @comment.match?(/\A#\s*#{self.class::KEYWORDS[type.to_sym]}/io)
272
272
  ''
273
273
  else
274
274
  @comment
@@ -6,7 +6,11 @@ require 'tempfile'
6
6
  module CopHelper
7
7
  extend RSpec::SharedContext
8
8
 
9
- let(:ruby_version) { RuboCop::TargetRuby::DEFAULT_VERSION }
9
+ let(:ruby_version) do
10
+ # The minimum version Prism can parse is 3.3.
11
+ ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : RuboCop::TargetRuby::DEFAULT_VERSION
12
+ end
13
+ let(:parser_engine) { ENV.fetch('PARSER_ENGINE', :parser_whitequark).to_sym }
10
14
  let(:rails_version) { false }
11
15
 
12
16
  def inspect_source(source, file = nil)
@@ -28,7 +32,9 @@ module CopHelper
28
32
  file = file.path
29
33
  end
30
34
 
31
- processed_source = RuboCop::ProcessedSource.new(source, ruby_version, file)
35
+ processed_source = RuboCop::ProcessedSource.new(
36
+ source, ruby_version, file, parser_engine: parser_engine
37
+ )
32
38
  processed_source.config = configuration
33
39
  processed_source.registry = registry
34
40
  processed_source
@@ -212,7 +212,7 @@ module RuboCop
212
212
 
213
213
  # Parsed representation of code annotated with the `^^^ Message` style
214
214
  class AnnotatedSource
215
- ANNOTATION_PATTERN = /\A\s*(\^+|\^{}) /.freeze
215
+ ANNOTATION_PATTERN = /\A\s*(\^+|\^{}) ?/.freeze
216
216
  ABBREV = "[...]\n"
217
217
 
218
218
  # @param annotated_source [String] string passed to the matchers
@@ -139,49 +139,64 @@ RSpec.shared_context 'lsp' do
139
139
  end
140
140
 
141
141
  RSpec.shared_context 'ruby 2.0' do
142
- let(:ruby_version) { 2.0 }
142
+ # Prism supports parsing Ruby 3.3+.
143
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.0 }
143
144
  end
144
145
 
145
146
  RSpec.shared_context 'ruby 2.1' do
146
- let(:ruby_version) { 2.1 }
147
+ # Prism supports parsing Ruby 3.3+.
148
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.1 }
147
149
  end
148
150
 
149
151
  RSpec.shared_context 'ruby 2.2' do
150
- let(:ruby_version) { 2.2 }
152
+ # Prism supports parsing Ruby 3.3+.
153
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.2 }
151
154
  end
152
155
 
153
156
  RSpec.shared_context 'ruby 2.3' do
154
- let(:ruby_version) { 2.3 }
157
+ # Prism supports parsing Ruby 3.3+.
158
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.3 }
155
159
  end
156
160
 
157
161
  RSpec.shared_context 'ruby 2.4' do
158
- let(:ruby_version) { 2.4 }
162
+ # Prism supports parsing Ruby 3.3+.
163
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.4 }
159
164
  end
160
165
 
161
166
  RSpec.shared_context 'ruby 2.5' do
162
- let(:ruby_version) { 2.5 }
167
+ # Prism supports parsing Ruby 3.3+.
168
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.5 }
163
169
  end
164
170
 
165
171
  RSpec.shared_context 'ruby 2.6' do
166
- let(:ruby_version) { 2.6 }
172
+ # Prism supports parsing Ruby 3.3+.
173
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.6 }
167
174
  end
168
175
 
169
176
  RSpec.shared_context 'ruby 2.7' do
170
- let(:ruby_version) { 2.7 }
177
+ # Prism supports parsing Ruby 3.3+.
178
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.7 }
171
179
  end
172
180
 
173
181
  RSpec.shared_context 'ruby 3.0' do
174
- let(:ruby_version) { 3.0 }
182
+ # Prism supports parsing Ruby 3.3+.
183
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 3.0 }
175
184
  end
176
185
 
177
186
  RSpec.shared_context 'ruby 3.1' do
178
- let(:ruby_version) { 3.1 }
187
+ # Prism supports parsing Ruby 3.3+.
188
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 3.1 }
179
189
  end
180
190
 
181
191
  RSpec.shared_context 'ruby 3.2' do
182
- let(:ruby_version) { 3.2 }
192
+ # Prism supports parsing Ruby 3.3+.
193
+ let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 3.2 }
183
194
  end
184
195
 
185
196
  RSpec.shared_context 'ruby 3.3' do
186
197
  let(:ruby_version) { 3.3 }
187
198
  end
199
+
200
+ RSpec.shared_context 'ruby 3.4' do
201
+ let(:ruby_version) { 3.4 }
202
+ end
@@ -27,4 +27,5 @@ RSpec.configure do |config|
27
27
  config.include_context 'ruby 3.1', :ruby31
28
28
  config.include_context 'ruby 3.2', :ruby32
29
29
  config.include_context 'ruby 3.3', :ruby33
30
+ config.include_context 'ruby 3.4', :ruby34
30
31
  end
@@ -467,15 +467,21 @@ module RuboCop
467
467
  end
468
468
  end
469
469
 
470
+ # rubocop:disable Metrics/MethodLength
470
471
  def get_processed_source(file)
471
472
  config = @config_store.for_file(file)
472
473
  ruby_version = config.target_ruby_version
474
+ parser_engine = config.parser_engine
473
475
 
474
476
  processed_source = if @options[:stdin]
475
- ProcessedSource.new(@options[:stdin], ruby_version, file)
477
+ ProcessedSource.new(
478
+ @options[:stdin], ruby_version, file, parser_engine: parser_engine
479
+ )
476
480
  else
477
481
  begin
478
- ProcessedSource.from_file(file, ruby_version)
482
+ ProcessedSource.from_file(
483
+ file, ruby_version, parser_engine: parser_engine
484
+ )
479
485
  rescue Errno::ENOENT
480
486
  raise RuboCop::Error, "No such file or directory: #{file}"
481
487
  end
@@ -484,6 +490,7 @@ module RuboCop
484
490
  processed_source.registry = mobilized_cop_classes(config)
485
491
  processed_source
486
492
  end
493
+ # rubocop:enable Metrics/MethodLength
487
494
 
488
495
  # A Cop::Team instance is stateful and may change when inspecting.
489
496
  # The "standby" team for a given config is an initialized but
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RuboCop
4
- # This class finds target files to inspect by scanning the directory tree
5
- # and picking ruby files.
4
+ # This class finds target files to inspect by scanning the directory tree and picking ruby files.
6
5
  # @api private
7
6
  class TargetFinder
8
7
  HIDDEN_PATH_SUBSTRING = "#{File::SEPARATOR}."
@@ -12,21 +11,8 @@ module RuboCop
12
11
  @options = options
13
12
  end
14
13
 
15
- def force_exclusion?
16
- @options[:force_exclusion]
17
- end
18
-
19
- def debug?
20
- @options[:debug]
21
- end
22
-
23
- def fail_fast?
24
- @options[:fail_fast]
25
- end
26
-
27
- # Generate a list of target files by expanding globbing patterns
28
- # (if any). If args is empty, recursively find all Ruby source
29
- # files under the current directory
14
+ # Generate a list of target files by expanding globbing patterns (if any). If args is empty,
15
+ # recursively find all Ruby source files under the current directory
30
16
  # @return [Array] array of file paths
31
17
  def find(args, mode)
32
18
  return target_files_in_dir if args.empty?
@@ -44,12 +30,11 @@ module RuboCop
44
30
  files.map { |f| File.expand_path(f) }.uniq
45
31
  end
46
32
 
47
- # Finds all Ruby source files under the current or other supplied
48
- # directory. A Ruby source file is defined as a file with the `.rb`
49
- # extension or a file with no extension that has a ruby shebang line
50
- # as its first line.
51
- # It is possible to specify includes and excludes using the config file,
52
- # so you can include other Ruby files like Rakefiles and gemspecs.
33
+ # Finds all Ruby source files under the current or other supplied directory. A Ruby source file
34
+ # is defined as a file with the `.rb` extension or a file with no extension that has a ruby
35
+ # shebang line as its first line.
36
+ # It is possible to specify includes and excludes using the config file, so you can include
37
+ # other Ruby files like Rakefiles and gemspecs.
53
38
  # @param base_dir Root directory under which to search for
54
39
  # ruby source files
55
40
  # @return [Array] Array of filenames
@@ -66,20 +51,10 @@ module RuboCop
66
51
  target_files.sort_by!(&order)
67
52
  end
68
53
 
69
- def to_inspect?(file, hidden_files, base_dir_config)
70
- return false if base_dir_config.file_to_exclude?(file)
71
- return true if !hidden_files.bsearch do |hidden_file|
72
- file <=> hidden_file
73
- end && ruby_file?(file)
74
-
75
- base_dir_config.file_to_include?(file)
76
- end
77
-
78
- # Search for files recursively starting at the given base directory using
79
- # the given flags that determine how the match is made. Excluded files will
80
- # be removed later by the caller, but as an optimization find_files removes
81
- # the top level directories that are excluded in configuration in the
82
- # normal way (dir/**/*).
54
+ # Search for files recursively starting at the given base directory using the given flags that
55
+ # determine how the match is made. Excluded files will be removed later by the caller, but as an
56
+ # optimization find_files removes the top level directories that are excluded in configuration
57
+ # in the normal way (dir/**/*).
83
58
  def find_files(base_dir, flags)
84
59
  # get all wanted directories first to improve speed of finding all files
85
60
  exclude_pattern = combined_exclude_glob_patterns(base_dir)
@@ -93,6 +68,17 @@ module RuboCop
93
68
  Dir.glob(patterns, flags).select { |path| FileTest.file?(path) }
94
69
  end
95
70
 
71
+ private
72
+
73
+ def to_inspect?(file, hidden_files, base_dir_config)
74
+ return false if base_dir_config.file_to_exclude?(file)
75
+ return true if !hidden_files.bsearch do |hidden_file|
76
+ file <=> hidden_file
77
+ end && ruby_file?(file)
78
+
79
+ base_dir_config.file_to_include?(file)
80
+ end
81
+
96
82
  def wanted_dir_patterns(base_dir, exclude_pattern, flags)
97
83
  # Escape glob characters in base_dir to avoid unwanted behavior.
98
84
  base_dir = base_dir.gsub(/[\\\{\}\[\]\*\?]/) do |reserved_glob_character|
@@ -124,21 +110,6 @@ module RuboCop
124
110
  "#{base_dir}/{#{patterns.join(',')}}"
125
111
  end
126
112
 
127
- def ruby_extension?(file)
128
- ruby_extensions.include?(File.extname(file))
129
- end
130
-
131
- def ruby_extensions
132
- @ruby_extensions ||= begin
133
- ext_patterns = all_cops_include.select { |pattern| pattern.start_with?('**/*.') }
134
- ext_patterns.map { |pattern| pattern.sub('**/*', '') }
135
- end
136
- end
137
-
138
- def ruby_filename?(file)
139
- ruby_filenames.include?(File.basename(file))
140
- end
141
-
142
113
  def ruby_filenames
143
114
  @ruby_filenames ||= begin
144
115
  file_patterns = all_cops_include.reject { |pattern| pattern.start_with?('**/*.') }
@@ -150,53 +121,72 @@ module RuboCop
150
121
  @all_cops_include ||= @config_store.for_pwd.for_all_cops['Include'].map(&:to_s)
151
122
  end
152
123
 
153
- def ruby_executable?(file)
154
- return false unless File.extname(file).empty? && File.exist?(file)
124
+ def process_explicit_path(path, mode)
125
+ files = path.include?('*') ? Dir[path] : [path]
155
126
 
156
- first_line = File.open(file, &:readline)
157
- /#!.*(#{ruby_interpreters(file).join('|')})/.match?(first_line)
158
- rescue EOFError, ArgumentError => e
159
- warn("Unprocessable file #{file}: #{e.class}, #{e.message}") if debug?
127
+ if mode == :only_recognized_file_types || force_exclusion?
128
+ files.select! { |file| included_file?(file) }
129
+ end
160
130
 
161
- false
131
+ force_exclusion? ? without_excluded(files) : files
162
132
  end
163
133
 
164
- def ruby_interpreters(file)
165
- @config_store.for(file).for_all_cops['RubyInterpreters']
134
+ def without_excluded(files)
135
+ files.reject do |file|
136
+ # When --ignore-parent-exclusion is given, we must look at the configuration associated with
137
+ # the file, but in the default case when --ignore-parent-exclusion is not given, can safely
138
+ # look only at the configuration for the current directory, since it's only the Exclude
139
+ # parameters we're going to check.
140
+ config = @config_store.for(ignore_parent_exclusion? ? file : '.')
141
+ config.file_to_exclude?(file)
142
+ end
166
143
  end
167
144
 
168
- def stdin?
169
- @options.key?(:stdin)
145
+ def included_file?(file)
146
+ ruby_file?(file) || configured_include?(file)
170
147
  end
171
148
 
172
149
  def ruby_file?(file)
173
150
  stdin? || ruby_extension?(file) || ruby_filename?(file) || ruby_executable?(file)
174
151
  end
175
152
 
176
- def configured_include?(file)
177
- @config_store.for_pwd.file_to_include?(file)
153
+ def stdin?
154
+ @options.key?(:stdin)
178
155
  end
179
156
 
180
- def included_file?(file)
181
- ruby_file?(file) || configured_include?(file)
157
+ def ruby_extension?(file)
158
+ ruby_extensions.include?(File.extname(file))
182
159
  end
183
160
 
184
- def process_explicit_path(path, mode)
185
- files = path.include?('*') ? Dir[path] : [path]
186
-
187
- if mode == :only_recognized_file_types || force_exclusion?
188
- files.select! { |file| included_file?(file) }
161
+ def ruby_extensions
162
+ @ruby_extensions ||= begin
163
+ ext_patterns = all_cops_include.select { |pattern| pattern.start_with?('**/*.') }
164
+ ext_patterns.map { |pattern| pattern.sub('**/*', '') }
189
165
  end
166
+ end
190
167
 
191
- return files unless force_exclusion?
168
+ def ruby_filename?(file)
169
+ ruby_filenames.include?(File.basename(file))
170
+ end
192
171
 
193
- files.reject do |file|
194
- config = @config_store.for(file)
195
- config.file_to_exclude?(file)
196
- end
172
+ def configured_include?(file)
173
+ @config_store.for_pwd.file_to_include?(file)
197
174
  end
198
175
 
199
- private
176
+ def ruby_executable?(file)
177
+ return false unless File.extname(file).empty? && File.exist?(file)
178
+
179
+ first_line = File.open(file, &:readline)
180
+ /#!.*(#{ruby_interpreters(file).join('|')})/.match?(first_line)
181
+ rescue EOFError, ArgumentError => e
182
+ warn("Unprocessable file #{file}: #{e.class}, #{e.message}") if debug?
183
+
184
+ false
185
+ end
186
+
187
+ def ruby_interpreters(file)
188
+ @config_store.for(file).for_all_cops['RubyInterpreters']
189
+ end
200
190
 
201
191
  def order
202
192
  if fail_fast?
@@ -206,5 +196,21 @@ module RuboCop
206
196
  :itself
207
197
  end
208
198
  end
199
+
200
+ def force_exclusion?
201
+ @options[:force_exclusion]
202
+ end
203
+
204
+ def ignore_parent_exclusion?
205
+ @options[:ignore_parent_exclusion]
206
+ end
207
+
208
+ def debug?
209
+ @options[:debug]
210
+ end
211
+
212
+ def fail_fast?
213
+ @options[:fail_fast]
214
+ end
209
215
  end
210
216
  end
@@ -4,7 +4,7 @@ module RuboCop
4
4
  # The kind of Ruby that code inspected by RuboCop is written in.
5
5
  # @api private
6
6
  class TargetRuby
7
- KNOWN_RUBIES = [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3].freeze
7
+ KNOWN_RUBIES = [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4].freeze
8
8
  DEFAULT_VERSION = 2.7
9
9
 
10
10
  OBSOLETE_RUBIES = {
@@ -96,7 +96,9 @@ module RuboCop
96
96
  end
97
97
 
98
98
  def version_from_gemspec_file(file)
99
- processed_source = ProcessedSource.from_file(file, DEFAULT_VERSION)
99
+ processed_source = ProcessedSource.from_file(
100
+ file, DEFAULT_VERSION, parser_engine: @config.parser_engine
101
+ )
100
102
  required_ruby_version(processed_source.ast).first
101
103
  end
102
104
 
@@ -107,7 +109,7 @@ module RuboCop
107
109
  version_from_array(right_hand_side)
108
110
  elsif gem_requirement_versions
109
111
  gem_requirement_versions.map(&:value)
110
- else
112
+ elsif right_hand_side.str_type?
111
113
  right_hand_side.value
112
114
  end
113
115
  end
@@ -3,9 +3,9 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.61.0'
6
+ STRING = '1.62.0'
7
7
 
8
- MSG = '%<version>s (using Parser %<parser_version>s, ' \
8
+ MSG = '%<version>s (using %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
10
10
  'running on %<ruby_engine>s %<ruby_version>s)%<server_mode>s [%<ruby_platform>s]'
11
11
 
@@ -20,7 +20,7 @@ module RuboCop
20
20
  # @api private
21
21
  def self.version(debug: false, env: nil)
22
22
  if debug
23
- verbose_version = format(MSG, version: STRING, parser_version: Parser::VERSION,
23
+ verbose_version = format(MSG, version: STRING, parser_version: parser_version,
24
24
  rubocop_ast_version: RuboCop::AST::Version::STRING,
25
25
  ruby_engine: RUBY_ENGINE, ruby_version: RUBY_VERSION,
26
26
  server_mode: server_mode,
@@ -39,6 +39,21 @@ module RuboCop
39
39
  end
40
40
  end
41
41
 
42
+ # @api private
43
+ def self.parser_version
44
+ config_path = ConfigFinder.find_config_path(Dir.pwd)
45
+ yaml = YAML.safe_load(
46
+ File.read(config_path), permitted_classes: [Regexp, Symbol], aliases: true
47
+ )
48
+
49
+ if yaml.dig('AllCops', 'ParserEngine') == 'parser_prism'
50
+ require 'prism'
51
+ "Prism #{Prism::VERSION}"
52
+ else
53
+ "Parser #{Parser::VERSION}"
54
+ end
55
+ end
56
+
42
57
  # @api private
43
58
  def self.extension_versions(env)
44
59
  features = Util.silence_warnings do
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.61.0
4
+ version: 1.62.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  - Jonas Arvidsson
9
9
  - Yuji Nakayama
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2024-02-29 00:00:00.000000000 Z
13
+ date: 2024-03-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -134,7 +134,7 @@ dependencies:
134
134
  requirements:
135
135
  - - ">="
136
136
  - !ruby/object:Gem::Version
137
- version: 1.30.0
137
+ version: 1.31.1
138
138
  - - "<"
139
139
  - !ruby/object:Gem::Version
140
140
  version: '2.0'
@@ -144,7 +144,7 @@ dependencies:
144
144
  requirements:
145
145
  - - ">="
146
146
  - !ruby/object:Gem::Version
147
- version: 1.30.0
147
+ version: 1.31.1
148
148
  - - "<"
149
149
  - !ruby/object:Gem::Version
150
150
  version: '2.0'
@@ -1031,12 +1031,12 @@ licenses:
1031
1031
  - MIT
1032
1032
  metadata:
1033
1033
  homepage_uri: https://rubocop.org/
1034
- changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.61.0
1034
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.62.0
1035
1035
  source_code_uri: https://github.com/rubocop/rubocop/
1036
- documentation_uri: https://docs.rubocop.org/rubocop/1.61/
1036
+ documentation_uri: https://docs.rubocop.org/rubocop/1.62/
1037
1037
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
1038
1038
  rubygems_mfa_required: 'true'
1039
- post_install_message:
1039
+ post_install_message:
1040
1040
  rdoc_options: []
1041
1041
  require_paths:
1042
1042
  - lib
@@ -1051,8 +1051,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1051
1051
  - !ruby/object:Gem::Version
1052
1052
  version: '0'
1053
1053
  requirements: []
1054
- rubygems_version: 3.3.7
1055
- signing_key:
1054
+ rubygems_version: 3.4.22
1055
+ signing_key:
1056
1056
  specification_version: 4
1057
1057
  summary: Automatic Ruby code style checking tool.
1058
1058
  test_files: []