rubocop-ast 1.16.0 → 1.21.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: 3042a6ea6c8061c98af6f9266c3c25753d9c6fa44da970def28268322e1a95d4
4
+ data.tar.gz: 6ca67765b5da2f93381655e0669eba37cfe9c12a81b8e29e0c3a57ce9fd98c55
5
5
  SHA512:
6
- metadata.gz: e422e89790ad586e0d26d8af780a15d14c892830c550a5f536e349ac46be76348760cf4f837be42fea912910db9ea2923c47d09d5e854b6ca2fb0fb72e3ebd8f
7
- data.tar.gz: e7c2c6af704a97d5102a96304eec899f63edc2a5d4eabe656205324a8e5aae4237851e6d16665dbc51a8023bd370d1090cee35ab0c6fdb36a48801a1719afb5d
6
+ metadata.gz: 5f2eb5ee0b03efc771f32464253980ac8bd4a583db82eb7e59f7b4784ac29cf22e63f118aff1493d215d60e4a9a25843912f72f8d11baea8554d4be1135e76b7
7
+ data.tar.gz: 2dfd094259a9585e0376034f21b8073736fa681799b16fd420511bea725878573e1e0aa3a52211dc5f3672e9812c440270727e7e4f06ffacaaa592c742ba37ae
@@ -249,7 +249,7 @@ module RuboCop
249
249
  ^{ # or the parent is...
250
250
  sclass class module class_constructor? # a class-like node
251
251
  [ { # or some "wrapper"
252
- kwbegin begin block
252
+ kwbegin begin block numblock
253
253
  (if _condition <%0 _>) # note: we're excluding the condition of `if` nodes
254
254
  }
255
255
  #in_macro_scope? # that is itself in a macro scope
@@ -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.
@@ -11,6 +11,7 @@ module RuboCop
11
11
  i: Regexp::IGNORECASE,
12
12
  m: Regexp::MULTILINE,
13
13
  n: Regexp::NOENCODING,
14
+ u: Regexp::FIXEDENCODING,
14
15
  o: 0
15
16
  }.freeze
16
17
  private_constant :OPTIONS
@@ -87,6 +88,11 @@ module RuboCop
87
88
  regopt_include?(:n)
88
89
  end
89
90
 
91
+ # @return [Bool] if regexp uses the fixed-encoding regopt
92
+ def fixed_encoding?
93
+ regopt_include?(:u)
94
+ end
95
+
90
96
  private
91
97
 
92
98
  def regopt_include?(option)
@@ -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,14 @@ module RuboCop
100
100
  type == :tCOMMA
101
101
  end
102
102
 
103
+ def dot?
104
+ type == :tDOT
105
+ end
106
+
107
+ def regexp_dots?
108
+ %i[tDOT2 tDOT3].include?(type)
109
+ end
110
+
103
111
  def rescue_modifier?
104
112
  type == :kRESCUE_MOD
105
113
  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.21.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.21.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-08-08 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
  - - ">="