rubocop-ast 1.24.1 → 1.27.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: f460fee9d6682f0942b107a76c8a24e59b3992e27cdb791a8d9d3e8902596bf0
4
- data.tar.gz: 27b55278782ffad52905335f6ae6b1b1709e6156802d669158f903c4b04fecbd
3
+ metadata.gz: 9c00db0a92a2f26b37430b4ee4964afda0386070b5c57dbca1b4c296d10c0ea7
4
+ data.tar.gz: e588876c3e203652888b9471a9b2f6443bf5e38ac2320e72f0c5573029879ace
5
5
  SHA512:
6
- metadata.gz: f6302e8a65e1504fbe3a929f0e50d063ea07873c9650edc1f68f65525e57a2717f06fc87b64970cc98c06e63efa1058b16d6563aa2b2863a0a80a67b04c31e98
7
- data.tar.gz: f8c7043155b9fb25ae1509c5bc8d3efe986ae9a74e302e886c3ad4947e5c06b79fd2ede7ba54aebdd3dc8bfe8b9f813ee5b6f2209140c7fee475dc31830f3d97
6
+ metadata.gz: 6a710a3ac008e2d7331a31453ccd95bd1b2db4eab78f4f4192b5e65cd1a93ca1c736cb09b7cc8041865145f1fb8acd6a82ef905ca30065851fb7267525211c90
7
+ data.tar.gz: cb7e0a7feb55d1dca39493897eea2b143f369b69a2907b9a5d06857ebf59c812a01b14f31b172407aaad7148fb3758be6537ec2284cbfd6a44c32dc2ab0d98d2
@@ -15,8 +15,8 @@ module RuboCop
15
15
  # :bar
16
16
  # ]
17
17
  #
18
- # node.loc.begin.line_span # => 1..1
19
- # node.loc.expression.line_span(exclude_end: true) # => 1...4
18
+ # node.loc.begin.line_span # => 1..1
19
+ # node.source_range.line_span(exclude_end: true) # => 1...4
20
20
  def line_span(exclude_end: false)
21
21
  ::Range.new(first_line, last_line, exclude_end)
22
22
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  module RuboCop
4
4
  module AST
5
- # A node extension for `send` nodes. This will be used in place of a plain
5
+ # A node extension for `csend` nodes. This will be used in place of a plain
6
6
  # node when the builder constructs the AST, making its methods available
7
- # to all `send` nodes within RuboCop.
7
+ # to all `csend` nodes within RuboCop.
8
8
  class CsendNode < SendNode
9
9
  def send_type?
10
10
  false
@@ -510,8 +510,14 @@ module RuboCop
510
510
 
511
511
  # @!method class_constructor?(node = self)
512
512
  def_node_matcher :class_constructor?, <<~PATTERN
513
- { (send #global_const?({:Class :Module :Struct}) :new ...)
514
- (block (send #global_const?({:Class :Module :Struct}) :new ...) ...)}
513
+ {
514
+ (send #global_const?({:Class :Module :Struct}) :new ...)
515
+ (send #global_const?(:Data) :define ...)
516
+ ({block numblock} {
517
+ (send #global_const?({:Class :Module :Struct}) :new ...)
518
+ (send #global_const?(:Data) :define ...)
519
+ } ...)
520
+ }
515
521
  PATTERN
516
522
 
517
523
  # @deprecated Use `:class_constructor?`
@@ -47,7 +47,7 @@ module RuboCop
47
47
  # @return [String] a Rainbow colorized version of ruby
48
48
  def colorize(color_scheme = COLOR_SCHEME)
49
49
  map = color_map(color_scheme)
50
- ast.loc.expression.source_buffer.source.chars.map.with_index do |char, i|
50
+ ast.source_range.source_buffer.source.chars.map.with_index do |char, i|
51
51
  Rainbow(char).color(map[i])
52
52
  end.join
53
53
  end
@@ -75,6 +75,10 @@ module RuboCop
75
75
  self.class.new(type, children, { location: location })
76
76
  end
77
77
 
78
+ def source_range
79
+ loc.expression
80
+ end
81
+
78
82
  INT_TO_RANGE = Hash.new { |h, k| h[k] = k..k }
79
83
  private_constant :INT_TO_RANGE
80
84
 
@@ -48,12 +48,12 @@ module RuboCop
48
48
 
49
49
  def emit_unary_op(type, operator_t = nil, *children)
50
50
  children[-1] = children[-1].first if children[-1].is_a?(Array) # token?
51
- map = source_map(children.first.loc.expression, operator_t: operator_t)
51
+ map = source_map(children.first.source_range, operator_t: operator_t)
52
52
  n(type, children, map)
53
53
  end
54
54
 
55
55
  def emit_list(type, begin_t, children, end_t)
56
- expr = children.first.loc.expression.join(children.last.loc.expression)
56
+ expr = children.first.source_range.join(children.last.source_range)
57
57
  map = source_map(expr, begin_t: begin_t, end_t: end_t)
58
58
  n(type, children, map)
59
59
  end
@@ -79,8 +79,7 @@ module RuboCop
79
79
  end
80
80
 
81
81
  def join_exprs(left_expr, right_expr)
82
- left_expr.loc.expression
83
- .join(right_expr.loc.expression)
82
+ left_expr.source_range.join(right_expr.source_range)
84
83
  end
85
84
 
86
85
  def source_map(token_or_range, begin_t: nil, end_t: nil, operator_t: nil, selector_t: nil)
@@ -265,6 +265,9 @@ module RuboCop
265
265
  when 3.2
266
266
  require 'parser/ruby32'
267
267
  Parser::Ruby32
268
+ when 3.3
269
+ require 'parser/ruby33'
270
+ Parser::Ruby33
268
271
  else
269
272
  raise ArgumentError,
270
273
  "RuboCop found unknown Ruby version: #{ruby_version.inspect}"
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module AST
5
5
  module Version
6
- STRING = '1.24.1'
6
+ STRING = '1.27.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.24.1
4
+ version: 1.27.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-12-29 00:00:00.000000000 Z
13
+ date: 2023-02-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 3.1.1.0
21
+ version: 3.2.1.0
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.1.1.0
28
+ version: 3.2.1.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: bundler
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  - !ruby/object:Gem::Version
177
177
  version: '0'
178
178
  requirements: []
179
- rubygems_version: 3.3.3
179
+ rubygems_version: 3.4.1
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: RuboCop tools to deal with Ruby code AST.