rubocop-ast 1.30.0 → 1.31.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84c917625cddd9b79c0979e269fdd324f8119b9d2b3c6081fae0ef449669bea5
4
- data.tar.gz: 8d053cac9c670216326df54b5b7b6a8961bf89614defa16e93ad1c557a8b25a5
3
+ metadata.gz: e155ad03b7e113e566024f6e7618bd143831a7bcf238aa5d263eccd66d511bf1
4
+ data.tar.gz: ab734ac50a5888e3623b87f79824c489fe2406ae60e885092a000ecdabd52438
5
5
  SHA512:
6
- metadata.gz: c95bd42a576592153d70f61367aafacd9677021515534a487706b736cc02cfcf717fc6db39e3df7212088301383cb7d60af9b929b4ca65b7baa5a66f5eca059e
7
- data.tar.gz: f0d99d3695e651ec10709dd729696a2b137c3b11603598164b433f61583218b16807c44ea1637ebe1922b496b8472795e4d54a4dc1312908f049e6f43b242ff8
6
+ metadata.gz: a939ed43023a1cd7b408331f54d33c2ce03e3adbb6f43ee4ef1916da3455a5372c2d1560a4d88f30e64d37255656d93cfaf6d6ba08617b247e6af4c8d9a9c0d8
7
+ data.tar.gz: 697372a43782fb445340e3738ae88fd68710e85fb8dd75d8a7045056073750842339397435beb0a84a006315df99bba002bee438bc5074450b1eecf368c91eee
@@ -326,13 +326,13 @@ module RuboCop
326
326
  # what class or module is this method/constant/etc definition in?
327
327
  # returns nil if answer cannot be determined
328
328
  ancestors = each_ancestor(:class, :module, :sclass, :casgn, :block)
329
- result = ancestors.map do |ancestor|
329
+ result = ancestors.filter_map do |ancestor|
330
330
  parent_module_name_part(ancestor) do |full_name|
331
331
  return nil unless full_name
332
332
 
333
333
  full_name
334
334
  end
335
- end.compact.reverse.join('::')
335
+ end.reverse.join('::')
336
336
  result.empty? ? 'Object' : result
337
337
  end
338
338
 
@@ -2,7 +2,7 @@
2
2
  # encoding: UTF-8
3
3
  #--
4
4
  # This file is automatically generated. Do not modify it.
5
- # Generated by: oedipus_lex version 2.6.1.
5
+ # Generated by: oedipus_lex version 2.6.2.
6
6
  # Source: lib/rubocop/ast/node_pattern/lexer.rex
7
7
  #++
8
8
 
@@ -70,7 +70,6 @@ class RuboCop::AST::NodePattern::LexerRex
70
70
  yield
71
71
  end
72
72
 
73
-
74
73
  ##
75
74
  # The current scanner class. Must be overridden in subclasses.
76
75
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # DO NOT MODIFY!!!!
4
- # This file is automatically generated by Racc 1.7.1
5
- # from Racc grammar file "".
4
+ # This file is automatically generated by Racc 1.7.3
5
+ # from Racc grammar file "parser.y".
6
6
  #
7
7
 
8
8
  require 'racc/parser.rb'
@@ -15,15 +15,23 @@ module RuboCop
15
15
  INVALID_LEVELS = %i[error fatal].freeze
16
16
  private_constant :INVALID_LEVELS
17
17
 
18
+ PARSER_ENGINES = %i[parser_whitequark parser_prism].freeze
19
+ private_constant :PARSER_ENGINES
20
+
18
21
  attr_reader :path, :buffer, :ast, :comments, :tokens, :diagnostics,
19
- :parser_error, :raw_source, :ruby_version
22
+ :parser_error, :raw_source, :ruby_version, :parser_engine
20
23
 
21
- def self.from_file(path, ruby_version)
24
+ def self.from_file(path, ruby_version, parser_engine: :parser_whitequark)
22
25
  file = File.read(path, mode: 'rb')
23
- new(file, ruby_version, path)
26
+ new(file, ruby_version, path, parser_engine: parser_engine)
24
27
  end
25
28
 
26
- def initialize(source, ruby_version, path = nil)
29
+ def initialize(source, ruby_version, path = nil, parser_engine: :parser_whitequark)
30
+ unless PARSER_ENGINES.include?(parser_engine)
31
+ raise ArgumentError, 'The keyword argument `parser_engine` accepts ' \
32
+ "`parser` or `parser_prism`, but `#{parser_engine}` was passed."
33
+ end
34
+
27
35
  # Defaults source encoding to UTF-8, regardless of the encoding it has
28
36
  # been read with, which could be non-utf8 depending on the default
29
37
  # external encoding.
@@ -33,9 +41,10 @@ module RuboCop
33
41
  @path = path
34
42
  @diagnostics = []
35
43
  @ruby_version = ruby_version
44
+ @parser_engine = parser_engine
36
45
  @parser_error = nil
37
46
 
38
- parse(source, ruby_version)
47
+ parse(source, ruby_version, parser_engine)
39
48
  end
40
49
 
41
50
  def ast_with_comments
@@ -193,7 +202,7 @@ module RuboCop
193
202
  end
194
203
  end
195
204
 
196
- def parse(source, ruby_version)
205
+ def parse(source, ruby_version, parser_engine)
197
206
  buffer_name = @path || STRING_SOURCE_NAME
198
207
  @buffer = Parser::Source::Buffer.new(buffer_name, 1)
199
208
 
@@ -207,7 +216,7 @@ module RuboCop
207
216
  return
208
217
  end
209
218
 
210
- @ast, @comments, @tokens = tokenize(create_parser(ruby_version))
219
+ @ast, @comments, @tokens = tokenize(create_parser(ruby_version, parser_engine))
211
220
  end
212
221
 
213
222
  def tokenize(parser)
@@ -227,58 +236,77 @@ module RuboCop
227
236
  end
228
237
 
229
238
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
230
- def parser_class(ruby_version)
231
- case ruby_version
232
- when 1.9
233
- require 'parser/ruby19'
234
- Parser::Ruby19
235
- when 2.0
236
- require 'parser/ruby20'
237
- Parser::Ruby20
238
- when 2.1
239
- require 'parser/ruby21'
240
- Parser::Ruby21
241
- when 2.2
242
- require 'parser/ruby22'
243
- Parser::Ruby22
244
- when 2.3
245
- require 'parser/ruby23'
246
- Parser::Ruby23
247
- when 2.4
248
- require 'parser/ruby24'
249
- Parser::Ruby24
250
- when 2.5
251
- require 'parser/ruby25'
252
- Parser::Ruby25
253
- when 2.6
254
- require 'parser/ruby26'
255
- Parser::Ruby26
256
- when 2.7
257
- require 'parser/ruby27'
258
- Parser::Ruby27
259
- when 2.8, 3.0
260
- require 'parser/ruby30'
261
- Parser::Ruby30
262
- when 3.1
263
- require 'parser/ruby31'
264
- Parser::Ruby31
265
- when 3.2
266
- require 'parser/ruby32'
267
- Parser::Ruby32
268
- when 3.3
269
- require 'parser/ruby33'
270
- Parser::Ruby33
271
- else
272
- raise ArgumentError,
273
- "RuboCop found unknown Ruby version: #{ruby_version.inspect}"
239
+ def parser_class(ruby_version, parser_engine)
240
+ case parser_engine
241
+ when :parser_whitequark
242
+ case ruby_version
243
+ when 1.9
244
+ require 'parser/ruby19'
245
+ Parser::Ruby19
246
+ when 2.0
247
+ require 'parser/ruby20'
248
+ Parser::Ruby20
249
+ when 2.1
250
+ require 'parser/ruby21'
251
+ Parser::Ruby21
252
+ when 2.2
253
+ require 'parser/ruby22'
254
+ Parser::Ruby22
255
+ when 2.3
256
+ require 'parser/ruby23'
257
+ Parser::Ruby23
258
+ when 2.4
259
+ require 'parser/ruby24'
260
+ Parser::Ruby24
261
+ when 2.5
262
+ require 'parser/ruby25'
263
+ Parser::Ruby25
264
+ when 2.6
265
+ require 'parser/ruby26'
266
+ Parser::Ruby26
267
+ when 2.7
268
+ require 'parser/ruby27'
269
+ Parser::Ruby27
270
+ when 2.8, 3.0
271
+ require 'parser/ruby30'
272
+ Parser::Ruby30
273
+ when 3.1
274
+ require 'parser/ruby31'
275
+ Parser::Ruby31
276
+ when 3.2
277
+ require 'parser/ruby32'
278
+ Parser::Ruby32
279
+ when 3.3
280
+ require 'parser/ruby33'
281
+ Parser::Ruby33
282
+ when 3.4
283
+ require 'parser/ruby34'
284
+ Parser::Ruby34
285
+ else
286
+ raise ArgumentError, "RuboCop found unknown Ruby version: #{ruby_version.inspect}"
287
+ end
288
+ when :parser_prism
289
+ require 'prism'
290
+
291
+ case ruby_version
292
+ when 3.3
293
+ require 'prism/translation/parser33'
294
+ Prism::Translation::Parser33
295
+ when 3.4
296
+ require 'prism/translation/parser34'
297
+ Prism::Translation::Parser34
298
+ else
299
+ raise ArgumentError, 'RuboCop supports target Ruby versions 3.3 and above with Prism. ' \
300
+ "Specified target Ruby version: #{ruby_version.inspect}"
301
+ end
274
302
  end
275
303
  end
276
304
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
277
305
 
278
- def create_parser(ruby_version)
306
+ def create_parser(ruby_version, parser_engine)
279
307
  builder = RuboCop::AST::Builder.new
280
308
 
281
- parser_class(ruby_version).new(builder).tap do |parser|
309
+ parser_class(ruby_version, parser_engine).new(builder).tap do |parser|
282
310
  # On JRuby there's a risk that we hang in tokenize() if we
283
311
  # don't set the all errors as fatal flag. The problem is caused by a bug
284
312
  # in Racc that is discussed in issue #93 of the whitequark/parser
@@ -83,7 +83,7 @@ module RuboCop
83
83
  end
84
84
 
85
85
  def left_curly_brace?
86
- type == :tLCURLY
86
+ type == :tLCURLY || type == :tLAMBEG
87
87
  end
88
88
 
89
89
  def right_curly_brace?
@@ -45,7 +45,7 @@ module RuboCop
45
45
  end # end
46
46
  RUBY
47
47
  aliases.each do |m|
48
- alias_method "on_#{m}", "on_#{type}"
48
+ alias_method :"on_#{m}", :"on_#{type}"
49
49
  end
50
50
  end
51
51
 
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module AST
5
5
  module Version
6
- STRING = '1.30.0'
6
+ STRING = '1.31.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-ast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.30.0
4
+ version: 1.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-10-26 00:00:00.000000000 Z
13
+ date: 2024-02-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser
@@ -18,14 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 3.2.1.0
21
+ version: 3.3.0.4
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 3.2.1.0
28
+ version: 3.3.0.4
29
+ - !ruby/object:Gem::Dependency
30
+ name: prism
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 0.24.0
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.24.0
29
43
  description: " RuboCop's Node and NodePattern classes.\n"
30
44
  email: rubocop@googlegroups.com
31
45
  executables: []
@@ -149,14 +163,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - ">="
151
165
  - !ruby/object:Gem::Version
152
- version: 2.6.0
166
+ version: 2.7.0
153
167
  required_rubygems_version: !ruby/object:Gem::Requirement
154
168
  requirements:
155
169
  - - ">="
156
170
  - !ruby/object:Gem::Version
157
171
  version: '0'
158
172
  requirements: []
159
- rubygems_version: 3.4.10
173
+ rubygems_version: 3.3.7
160
174
  signing_key:
161
175
  specification_version: 4
162
176
  summary: RuboCop tools to deal with Ruby code AST.