rubocop-ast 1.45.1 → 1.47.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: 521d7e1613b1073ddff48a0cbe4b9845082cbe146ec4526d7b3ffbea9682a289
4
- data.tar.gz: 53f870c81fb23413c05b2d51968b2c5eef0160b0ff6dc0a5ce50b00a694f4629
3
+ metadata.gz: 69fa84f885de90b4390fd20fffacdc680cce5bb621cf036ceeb1372df1b4cf98
4
+ data.tar.gz: 204d7ca5706f7fcea3ee5747dc08cc89376447384f39da3ca759bf1830112b01
5
5
  SHA512:
6
- metadata.gz: fcea8269fce5fa28c1b99a176cf80c81899c929e6d8d195359a8d2841edf07a20920282aa54e0f37ad4fc606fccc8a6ffcd9769c47a14d737390456713581291
7
- data.tar.gz: 7061c378e6de7e7e8fdbb9b95d986a0e5447ce52e717c70e588add642360cf95ae6aafb0a67f6c580e2a498e06d46cc4d0480a207d5c7e8465b7a3570329dd85
6
+ metadata.gz: c38ada82f862b5688956f91a069ad36dd8c7f9dec831b51510de1d0653d75e9ab1c363a0c7fed0876aafc0a75cd64ed8f469d7f87b30cacccc25342bd85745fb
7
+ data.tar.gz: f977594d3f9e8b486ca1ac98c19406742e4f0153ca43695ae4ab9645cc2667c44599ce3ae55c4caade8f7353873a1eeefd82f8181f876b35f2e09784e5f4a9a5
data/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/rubocop-ast.svg)](https://badge.fury.io/rb/rubocop-ast)
4
4
  [![CI](https://github.com/rubocop/rubocop-ast/actions/workflows/rubocop.yml/badge.svg)](https://github.com/rubocop/rubocop-ast/actions/workflows/rubocop.yml)
5
- [![Test Coverage](https://api.codeclimate.com/v1/badges/a29666e6373bc41bc0a9/test_coverage)](https://codeclimate.com/github/rubocop/rubocop-ast/test_coverage)
6
- [![Maintainability](https://api.codeclimate.com/v1/badges/a29666e6373bc41bc0a9/maintainability)](https://codeclimate.com/github/rubocop/rubocop-ast/maintainability)
7
5
 
8
6
  Contains the classes needed by [RuboCop](https://github.com/rubocop/rubocop) to deal with Ruby's AST, in particular:
9
7
 
@@ -38,6 +38,7 @@ module RuboCop
38
38
  casgn: CasgnNode,
39
39
  case: CaseNode,
40
40
  class: ClassNode,
41
+ complex: ComplexNode,
41
42
  const: ConstNode,
42
43
  def: DefNode,
43
44
  defined?: DefinedNode,
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `complex` nodes. This will be used in place of a plain
6
+ # node when the builder constructs the AST, making its methods available to
7
+ # all `complex` nodes within RuboCop.
8
+ class ComplexNode < Node
9
+ include BasicLiteralNode
10
+ include NumericNode
11
+ end
12
+ end
13
+ end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module AST
5
5
  # Common functionality for primitive literal nodes: `sym`, `str`,
6
- # `int`, `float`, `rational`...
6
+ # `int`, `float`, `rational`, `complex`...
7
7
  module BasicLiteralNode
8
8
  # Returns the value of the literal.
9
9
  #
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module AST
5
- # Common functionality for primitive numeric nodes: `int`, `float`, `rational`...
5
+ # Common functionality for primitive numeric nodes: `int`, `float`, `rational`, `complex`...
6
6
  module NumericNode
7
7
  SIGN_REGEX = /\A[+-]/.freeze
8
8
  private_constant :SIGN_REGEX
@@ -15,7 +15,7 @@ module RuboCop
15
15
  #
16
16
  # @return [Boolean] whether this literal has a sign.
17
17
  def sign?
18
- source.match(SIGN_REGEX)
18
+ source.match?(SIGN_REGEX)
19
19
  end
20
20
  end
21
21
  end
@@ -65,6 +65,7 @@ module RuboCop
65
65
  # arguments
66
66
  module WrappedArguments
67
67
  include ParameterizedNode
68
+
68
69
  # @return [Array] The arguments of the node.
69
70
  def arguments
70
71
  first = children.first
@@ -108,6 +108,13 @@ module RuboCop
108
108
  rational: :numeric,
109
109
  complex: :numeric,
110
110
 
111
+ str: :any_str,
112
+ dstr: :any_str,
113
+ xstr: :any_str,
114
+
115
+ sym: :any_sym,
116
+ dsym: :any_sym,
117
+
111
118
  irange: :range,
112
119
  erange: :range,
113
120
 
@@ -272,7 +279,7 @@ module RuboCop
272
279
  def right_siblings
273
280
  return [].freeze unless parent
274
281
 
275
- parent.children[sibling_index + 1..].freeze
282
+ parent.children[(sibling_index + 1)..].freeze
276
283
  end
277
284
 
278
285
  # Common destructuring method. This can be used to normalize
@@ -547,6 +554,14 @@ module RuboCop
547
554
  GROUP_FOR_TYPE[type] == :any_match_pattern
548
555
  end
549
556
 
557
+ def any_str_type?
558
+ GROUP_FOR_TYPE[type] == :any_str
559
+ end
560
+
561
+ def any_sym_type?
562
+ GROUP_FOR_TYPE[type] == :any_sym
563
+ end
564
+
550
565
  def guard_clause?
551
566
  node = operator_keyword? ? rhs : self
552
567
 
@@ -261,7 +261,7 @@ module RuboCop
261
261
  arities = children
262
262
  .reverse
263
263
  .map(&:arity_range)
264
- .map { |r| last = last.begin + r.begin..last.max + r.max }
264
+ .map { |r| last = (last.begin + r.begin)..(last.max + r.max) }
265
265
  .reverse!
266
266
  arities.push last_arity
267
267
  end
@@ -10,6 +10,7 @@ module RuboCop
10
10
  # /docs/modules/ROOT/pages/node_pattern.adoc
11
11
  class Compiler
12
12
  extend SimpleForwardable
13
+
13
14
  attr_reader :captures, :named_parameters, :positional_parameters, :binding
14
15
 
15
16
  def initialize
@@ -179,7 +179,7 @@ module RuboCop
179
179
  class AnyOrder < Node
180
180
  include ForbidInSeqHead
181
181
 
182
- ARITIES = Hash.new { |h, k| h[k] = k - 1..Float::INFINITY }
182
+ ARITIES = Hash.new { |h, k| h[k] = (k - 1)..Float::INFINITY }
183
183
  private_constant :ARITIES
184
184
 
185
185
  def term_nodes
@@ -50,6 +50,7 @@ module RuboCop
50
50
 
51
51
  extend SimpleForwardable
52
52
  include MethodDefiner
53
+
53
54
  Invalid = Class.new(StandardError)
54
55
 
55
56
  VAR = 'node'
@@ -79,6 +79,7 @@ module RuboCop
79
79
  end
80
80
  private_constant :CallbackCompiler
81
81
  extend CallbackCompiler
82
+
82
83
  send_code = CallbackCompiler::SEND
83
84
 
84
85
  ### children count == 0
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module AST
5
5
  module Version
6
- STRING = '1.45.1'
6
+ STRING = '1.47.0'
7
7
  end
8
8
  end
9
9
  end
data/lib/rubocop/ast.rb CHANGED
@@ -48,6 +48,7 @@ require_relative 'ast/node/case_match_node'
48
48
  require_relative 'ast/node/case_node'
49
49
  require_relative 'ast/node/casgn_node'
50
50
  require_relative 'ast/node/class_node'
51
+ require_relative 'ast/node/complex_node'
51
52
  require_relative 'ast/node/const_node'
52
53
  require_relative 'ast/node/def_node'
53
54
  require_relative 'ast/node/defined_node'
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.45.1
4
+ version: 1.47.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: 2025-06-08 00:00:00.000000000 Z
13
+ date: 2025-09-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser
@@ -69,6 +69,7 @@ files:
69
69
  - lib/rubocop/ast/node/case_node.rb
70
70
  - lib/rubocop/ast/node/casgn_node.rb
71
71
  - lib/rubocop/ast/node/class_node.rb
72
+ - lib/rubocop/ast/node/complex_node.rb
72
73
  - lib/rubocop/ast/node/const_node.rb
73
74
  - lib/rubocop/ast/node/csend_node.rb
74
75
  - lib/rubocop/ast/node/def_node.rb