rubocop-ast 1.44.1 → 1.47.1
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 +4 -4
- data/README.md +0 -2
- data/lib/rubocop/ast/builder.rb +1 -0
- data/lib/rubocop/ast/node/complex_node.rb +13 -0
- data/lib/rubocop/ast/node/mixin/basic_literal_node.rb +1 -1
- data/lib/rubocop/ast/node/mixin/numeric_node.rb +2 -2
- data/lib/rubocop/ast/node/mixin/parameterized_node.rb +1 -0
- data/lib/rubocop/ast/node.rb +24 -2
- data/lib/rubocop/ast/node_pattern/compiler/debug.rb +2 -0
- data/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb +1 -1
- data/lib/rubocop/ast/node_pattern/compiler.rb +1 -0
- data/lib/rubocop/ast/node_pattern/lexer.rex +1 -1
- data/lib/rubocop/ast/node_pattern/lexer.rex.rb +1 -1
- data/lib/rubocop/ast/node_pattern/node.rb +1 -1
- data/lib/rubocop/ast/node_pattern.rb +1 -0
- data/lib/rubocop/ast/processed_source.rb +4 -2
- data/lib/rubocop/ast/traversal.rb +1 -0
- data/lib/rubocop/ast/version.rb +1 -1
- data/lib/rubocop/ast.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bffbd470297f3e2a3ef1db00d3259258c7ced492c848913d5df487c7283b395
|
4
|
+
data.tar.gz: 39db744fd59f6a5f326ffa22516194f2b2c0666ebf3d8fc9211caed06aeacfd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 693ddec9b2ab60ded1ab59f4a344d92dab3d72d9c14fdf7ea6222bc1ae5ce58066ed504946095d6b770d3bfb0bdd4cbb0212f51889f2713b347097887b13b63d
|
7
|
+
data.tar.gz: c19c8995d2de5c654ae169ac036d501042b808a487aa767ff93bdd3e4f2b5b452e79e80c7f57be92e9957e47a39149fcae5c932feb1dc1e001b1a6a2fce96836
|
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/rubocop-ast)
|
4
4
|
[](https://github.com/rubocop/rubocop-ast/actions/workflows/rubocop.yml)
|
5
|
-
[](https://codeclimate.com/github/rubocop/rubocop-ast/test_coverage)
|
6
|
-
[](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
|
|
data/lib/rubocop/ast/builder.rb
CHANGED
@@ -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
|
@@ -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
|
data/lib/rubocop/ast/node.rb
CHANGED
@@ -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
|
|
@@ -116,7 +123,10 @@ module RuboCop
|
|
116
123
|
|
117
124
|
block: :any_block,
|
118
125
|
numblock: :any_block,
|
119
|
-
itblock: :any_block
|
126
|
+
itblock: :any_block,
|
127
|
+
|
128
|
+
match_pattern: :any_match_pattern,
|
129
|
+
match_pattern_p: :any_match_pattern
|
120
130
|
}.freeze
|
121
131
|
private_constant :GROUP_FOR_TYPE
|
122
132
|
|
@@ -269,7 +279,7 @@ module RuboCop
|
|
269
279
|
def right_siblings
|
270
280
|
return [].freeze unless parent
|
271
281
|
|
272
|
-
parent.children[sibling_index + 1..].freeze
|
282
|
+
parent.children[(sibling_index + 1)..].freeze
|
273
283
|
end
|
274
284
|
|
275
285
|
# Common destructuring method. This can be used to normalize
|
@@ -540,6 +550,18 @@ module RuboCop
|
|
540
550
|
GROUP_FOR_TYPE[type] == :any_block
|
541
551
|
end
|
542
552
|
|
553
|
+
def any_match_pattern_type?
|
554
|
+
GROUP_FOR_TYPE[type] == :any_match_pattern
|
555
|
+
end
|
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
|
+
|
543
565
|
def guard_clause?
|
544
566
|
node = operator_keyword? ? rhs : self
|
545
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
|
@@ -122,7 +122,7 @@ class RuboCop::AST::NodePattern::LexerRex
|
|
122
122
|
# do nothing
|
123
123
|
when ss.skip(/:(#{SYMBOL_NAME})/o) then
|
124
124
|
action { emit :tSYMBOL, &:to_sym }
|
125
|
-
when ss.skip(/"(
|
125
|
+
when ss.skip(/"(.*?)"/) then
|
126
126
|
action { emit :tSTRING }
|
127
127
|
when ss.skip(/[-+]?\d+\.\d+/) then
|
128
128
|
action { emit :tNUMBER, &:to_f }
|
@@ -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
|
@@ -256,7 +256,8 @@ module RuboCop
|
|
256
256
|
[ast, comments, tokens]
|
257
257
|
end
|
258
258
|
|
259
|
-
|
259
|
+
# rubocop:disable Lint/FloatComparison, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
260
|
+
def parser_class(ruby_version, parser_engine)
|
260
261
|
case parser_engine
|
261
262
|
when :parser_whitequark
|
262
263
|
case ruby_version
|
@@ -323,6 +324,7 @@ module RuboCop
|
|
323
324
|
end
|
324
325
|
end
|
325
326
|
end
|
327
|
+
# rubocop:enable Lint/FloatComparison, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
326
328
|
|
327
329
|
def builder_class(parser_engine)
|
328
330
|
case parser_engine
|
@@ -339,7 +341,7 @@ module RuboCop
|
|
339
341
|
|
340
342
|
parser_class = parser_class(ruby_version, parser_engine)
|
341
343
|
|
342
|
-
parser_instance = if prism_result
|
344
|
+
parser_instance = if parser_engine == :parser_prism && prism_result
|
343
345
|
# NOTE: Since it is intended for use with Ruby LSP, it targets only Prism.
|
344
346
|
# If there is no reuse of a pre-parsed result, such as in Ruby LSP,
|
345
347
|
# regular parsing with Prism occurs, and `else` branch will be executed.
|
data/lib/rubocop/ast/version.rb
CHANGED
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.
|
4
|
+
version: 1.47.1
|
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-
|
13
|
+
date: 2025-09-22 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
|