rubocop-ast 1.16.0 → 1.19.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: e65c7ca3cc4f7a4345d3584be2d2f1ed5ddb737c6c9dd9698c61ee8082041439
4
- data.tar.gz: b5c6e4a5e460af4a8c4fd5e8941f2a997b94dbffcd54b53549c9147ec7cd9dcc
3
+ metadata.gz: e2940fc0009d2a8c22394b0dfdff3d48e28dcb9b696b5eaabcac8efefcc4e479
4
+ data.tar.gz: 3a42602c36dfffbe35474ab9431dbf2437e22d5b4c3b485fce79c1e12868ff2c
5
5
  SHA512:
6
- metadata.gz: e422e89790ad586e0d26d8af780a15d14c892830c550a5f536e349ac46be76348760cf4f837be42fea912910db9ea2923c47d09d5e854b6ca2fb0fb72e3ebd8f
7
- data.tar.gz: e7c2c6af704a97d5102a96304eec899f63edc2a5d4eabe656205324a8e5aae4237851e6d16665dbc51a8023bd370d1090cee35ab0c6fdb36a48801a1719afb5d
6
+ metadata.gz: 19d3856b627d85f6636619c7517220f3882e3aecd5f7daaefd9c7ef98d773dd535e86b3754f29d33364926c2d8ce4daf6ad936542c0a185a30a7996aea18de07
7
+ data.tar.gz: 2aab89172bbca7244c06ca1950dc5c2cb5868e3454d507c6ae1c2ecf545d3a0ce77b0bedaaa69f39823a1fc066914d4fb731f4e911aa706eeff0f8aa1d790ec1
@@ -84,7 +84,7 @@ module RuboCop
84
84
  include ParameterizedNode
85
85
  # @return [Array<Node>] arguments, if any
86
86
  def arguments
87
- children[first_argument_index..-1].freeze
87
+ children[first_argument_index..].freeze
88
88
  end
89
89
 
90
90
  # A shorthand for getting the first argument of the node.
@@ -57,7 +57,7 @@ module RuboCop
57
57
  # @api private
58
58
  BASIC_CONDITIONALS = %i[if while until].to_set.freeze
59
59
  # @api private
60
- CONDITIONALS = (BASIC_CONDITIONALS + [:case]).freeze
60
+ CONDITIONALS = (BASIC_CONDITIONALS + %i[case case_match]).freeze
61
61
  # @api private
62
62
  POST_CONDITION_LOOP_TYPES = %i[while_post until_post].to_set.freeze
63
63
  # @api private
@@ -194,7 +194,7 @@ module RuboCop
194
194
  def right_siblings
195
195
  return [].freeze unless parent
196
196
 
197
- parent.children[sibling_index + 1..-1].freeze
197
+ parent.children[sibling_index + 1..].freeze
198
198
  end
199
199
 
200
200
  # Common destructuring method. This can be used to normalize
@@ -20,8 +20,8 @@ module RuboCop
20
20
  end
21
21
 
22
22
  if var == :forbidden_unification
23
- raise Invalid, "Wildcard #{name} was first seen in a subset of a" \
24
- " union and can't be used outside that union"
23
+ raise Invalid, "Wildcard #{name} was first seen in a subset of a " \
24
+ "union and can't be used outside that union"
25
25
  end
26
26
  var
27
27
  end
@@ -371,13 +371,13 @@ module RuboCop
371
371
 
372
372
  # @return [Hash] of {subcompiler => code}
373
373
  def compile_union_forks
374
- compiler.each_union(node.children).map do |child|
374
+ compiler.each_union(node.children).to_h do |child|
375
375
  subsequence_terms = child.is_a?(Node::Subsequence) ? child.children : [child]
376
376
  fork = dup
377
377
  code = fork.compile_terms(subsequence_terms, @remaining_arity)
378
378
  @in_sync = false if @cur_index != :variadic_mode
379
379
  [fork, code]
380
- end.to_h # we could avoid map if RUBY_VERSION >= 2.6...
380
+ end
381
381
  end
382
382
 
383
383
  # Modifies in place `forks` to insure that `cur_{child|index}_var` are ok
@@ -116,7 +116,7 @@ module RuboCop
116
116
 
117
117
  def initialize(type, children = [], properties = {})
118
118
  if (replace = children.first.in_sequence_head)
119
- children = [*replace, *children[1..-1]]
119
+ children = [*replace, *children[1..]]
120
120
  end
121
121
 
122
122
  super
@@ -130,7 +130,7 @@ module RuboCop
130
130
  end
131
131
 
132
132
  def arg_list
133
- children[1..-1]
133
+ children[1..]
134
134
  end
135
135
  end
136
136
  FunctionCall = Predicate
@@ -212,7 +212,7 @@ module RuboCop
212
212
 
213
213
  return unless (replace = children.first.in_sequence_head)
214
214
 
215
- [with(children: [*replace, *children[1..-1]])]
215
+ [with(children: [*replace, *children[1..]])]
216
216
  end
217
217
  end
218
218
 
@@ -226,9 +226,24 @@ module RuboCop
226
226
  [ast, comments, tokens]
227
227
  end
228
228
 
229
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
229
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
230
230
  def parser_class(ruby_version)
231
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
232
247
  when 2.4
233
248
  require 'parser/ruby24'
234
249
  Parser::Ruby24
@@ -255,7 +270,7 @@ module RuboCop
255
270
  "RuboCop found unknown Ruby version: #{ruby_version.inspect}"
256
271
  end
257
272
  end
258
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
273
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
259
274
 
260
275
  def create_parser(ruby_version)
261
276
  builder = RuboCop::AST::Builder.new
@@ -100,6 +100,10 @@ module RuboCop
100
100
  type == :tCOMMA
101
101
  end
102
102
 
103
+ def regexp_dot?
104
+ %i[tDOT2 tDOT3].include?(type)
105
+ end
106
+
103
107
  def rescue_modifier?
104
108
  type == :kRESCUE_MOD
105
109
  end
@@ -34,7 +34,7 @@ module RuboCop
34
34
 
35
35
  def def_callback(type, *signature,
36
36
  arity: signature.size..signature.size,
37
- arity_check: ENV['RUBOCOP_DEBUG'] && self.arity_check(arity),
37
+ arity_check: ENV.fetch('RUBOCOP_DEBUG', nil) && self.arity_check(arity),
38
38
  body: self.body(signature, arity_check))
39
39
  type, *aliases = type
40
40
  lineno = caller_locations(1, 1).first.lineno
@@ -162,7 +162,7 @@ module RuboCop
162
162
  ### generic processing of any other node (forward compatibility)
163
163
  defined = instance_methods(false)
164
164
  .grep(/^on_/)
165
- .map { |s| s.to_s[3..-1].to_sym } # :on_foo => :foo
165
+ .map { |s| s.to_s[3..].to_sym } # :on_foo => :foo
166
166
 
167
167
  to_define = ::Parser::Meta::NODE_TYPES.to_a
168
168
  to_define -= defined
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module AST
5
5
  module Version
6
- STRING = '1.16.0'
6
+ STRING = '1.19.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.16.0
4
+ version: 1.19.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: 2022-02-22 00:00:00.000000000 Z
13
+ date: 2022-07-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
169
  - - ">="
170
170
  - !ruby/object:Gem::Version
171
- version: 2.5.0
171
+ version: 2.6.0
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  requirements:
174
174
  - - ">="