rubocop-ast 1.49.0 → 1.49.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/lib/rubocop/ast/node_pattern/compiler/binding.rb +6 -0
- data/lib/rubocop/ast/node_pattern/compiler/node_pattern_subcompiler.rb +1 -1
- data/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb +14 -2
- data/lib/rubocop/ast/node_pattern/lexer.rex.rb +1 -1
- data/lib/rubocop/ast/node_pattern/parser.racc.rb +42 -40
- data/lib/rubocop/ast/node_pattern.rb +2 -2
- data/lib/rubocop/ast/traversal.rb +1 -1
- data/lib/rubocop/ast/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aad4bf15828f1db50f117c1a983e1f4c7f0cff233878a7f1a1686416ab21feff
|
|
4
|
+
data.tar.gz: 8ac8ad74b061c5fcd733e21420068edc69d0a9bfba532dc766e01dbb80be5c40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75f3882c819f2e10f7ef893481fbe9feddedfcdc91678c1c695d6ef36d94798dedf5667427cbfc6c022494e7e0c9581f54b4e1dcc9f05f2aea677668fe645b04
|
|
7
|
+
data.tar.gz: 94b37b0490cbf1ab81ab0c4c98a5bd8e6037b6ae5210af6ba2cbd23d4a263a3e4cfccad3f99fe621a6ab62d8356fc007fd066adb2d2379e02f5b07580ef2b2d4
|
|
@@ -26,6 +26,12 @@ module RuboCop
|
|
|
26
26
|
var
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
# Returns currently bound variable names
|
|
30
|
+
# @return [Array<String>] variable names that are currently bound
|
|
31
|
+
def bound_variables
|
|
32
|
+
@bound.values
|
|
33
|
+
end
|
|
34
|
+
|
|
29
35
|
# Yields for each branch of the given union, forbidding unification of
|
|
30
36
|
# bindings which only appear in a subset of the union.
|
|
31
37
|
def union_bind(enum) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
@@ -85,16 +85,21 @@ module RuboCop
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
def visit_any_order
|
|
88
|
+
def visit_any_order # rubocop:disable Metrics/AbcSize
|
|
89
89
|
within_loop do
|
|
90
90
|
compiler.with_temp_variables do |matched|
|
|
91
|
+
bound_before = compiler.binding.bound_variables
|
|
91
92
|
case_terms = compile_any_order_branches(matched)
|
|
92
93
|
else_code, init = compile_any_order_else
|
|
93
94
|
term = "#{compile_case(case_terms, else_code)} && #{compile_loop_advance}"
|
|
94
95
|
|
|
96
|
+
# Initialize unification variables before the loop to persist across iterations
|
|
97
|
+
newly_bound = compiler.binding.bound_variables - bound_before
|
|
98
|
+
unify_init = compile_unify_init(newly_bound)
|
|
99
|
+
|
|
95
100
|
all_matched_check = "&&\n#{matched}.size == #{node.term_nodes.size}" if node.rest_node
|
|
96
101
|
<<~RUBY
|
|
97
|
-
(#{init}#{matched} = {}; true) &&
|
|
102
|
+
(#{init}#{unify_init}#{matched} = {}; true) &&
|
|
98
103
|
#{compile_loop(term)} #{all_matched_check} \\
|
|
99
104
|
RUBY
|
|
100
105
|
end
|
|
@@ -412,6 +417,13 @@ module RuboCop
|
|
|
412
417
|
end
|
|
413
418
|
@in_sync = sub_compilers.all?(&:in_sync)
|
|
414
419
|
end
|
|
420
|
+
|
|
421
|
+
# Generate initialization code for unification variables
|
|
422
|
+
# @param newly_bound [Array<String>] variable names that were newly bound
|
|
423
|
+
# @return [String] initialization code
|
|
424
|
+
def compile_unify_init(newly_bound)
|
|
425
|
+
newly_bound.map { |var| "#{var} = nil; " }.join
|
|
426
|
+
end
|
|
415
427
|
end
|
|
416
428
|
end
|
|
417
429
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
#
|
|
3
3
|
# DO NOT MODIFY!!!!
|
|
4
|
-
# This file is automatically generated by Racc 1.
|
|
5
|
-
# from Racc grammar file "".
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
|
+
# from Racc grammar file "parser.y".
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
require 'racc/parser.rb'
|
|
@@ -14,15 +14,15 @@ module RuboCop
|
|
|
14
14
|
|
|
15
15
|
racc_action_table = [
|
|
16
16
|
14, 15, 16, 21, 18, 17, 19, 10, 11, 12,
|
|
17
|
-
60, 22, 20, 4,
|
|
18
|
-
28, 23, 56, 50,
|
|
17
|
+
60, 22, 20, 4, 24, 5, 40, 6, 7, 8,
|
|
18
|
+
28, 23, 56, 50, 40, 61, 43, 66, 51, 51,
|
|
19
19
|
58, 14, 15, 16, 21, 18, 17, 19, 10, 11,
|
|
20
20
|
12, nil, 22, 20, 4, nil, 5, nil, 6, 7,
|
|
21
21
|
8, 28, 23, nil, nil, -34, 14, 15, 16, 21,
|
|
22
22
|
18, 17, 19, 10, 11, 12, nil, 22, 20, 4,
|
|
23
23
|
nil, 5, nil, 6, 7, 8, 9, 23, 14, 15,
|
|
24
24
|
16, 21, 18, 17, 19, 10, 11, 12, nil, 22,
|
|
25
|
-
20, 4, nil, 5, nil, 6, 7, 8,
|
|
25
|
+
20, 4, nil, 5, nil, 6, 7, 8, 28, 23,
|
|
26
26
|
14, 15, 16, 21, 18, 17, 19, 10, 11, 12,
|
|
27
27
|
nil, 22, 20, 4, nil, 5, nil, 6, 7, 8,
|
|
28
28
|
9, 23, 14, 15, 16, 21, 18, 17, 19, 10,
|
|
@@ -33,7 +33,7 @@ racc_action_table = [
|
|
|
33
33
|
18, 17, 19, 10, 11, 12, nil, 22, 20, 4,
|
|
34
34
|
nil, 5, nil, 6, 7, 8, 9, 23, 14, 15,
|
|
35
35
|
16, 21, 18, 17, 19, 10, 11, 12, nil, 22,
|
|
36
|
-
20, 4, nil, 5, nil, 6, 7, 8,
|
|
36
|
+
20, 4, nil, 5, nil, 6, 7, 8, 9, 23,
|
|
37
37
|
14, 15, 16, 21, 18, 17, 19, 10, 11, 12,
|
|
38
38
|
nil, 22, 20, 4, 44, 5, nil, 6, 7, 8,
|
|
39
39
|
28, 23, 14, 15, 16, 21, 18, 17, 19, 10,
|
|
@@ -47,31 +47,31 @@ racc_action_table = [
|
|
|
47
47
|
20, 4, nil, 5, nil, 6, 7, 8, 9, 23,
|
|
48
48
|
14, 15, 16, 21, 18, 17, 19, 10, 11, 12,
|
|
49
49
|
nil, 22, 20, 4, nil, 5, nil, 6, 7, 8,
|
|
50
|
-
9, 23,
|
|
51
|
-
|
|
50
|
+
9, 23, -1, -1, -1, -2, -2, -2, 47, 48,
|
|
51
|
+
49 ]
|
|
52
52
|
|
|
53
53
|
racc_action_check = [
|
|
54
54
|
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
|
55
|
-
54, 42, 42, 42,
|
|
56
|
-
42, 42, 42, 30,
|
|
55
|
+
54, 42, 42, 42, 1, 42, 10, 42, 42, 42,
|
|
56
|
+
42, 42, 42, 30, 11, 54, 24, 62, 30, 63,
|
|
57
57
|
42, 59, 59, 59, 59, 59, 59, 59, 59, 59,
|
|
58
58
|
59, nil, 59, 59, 59, nil, 59, nil, 59, 59,
|
|
59
|
-
59, 59, 59, nil, nil, 59,
|
|
60
|
-
5, 5, 5, 5, 5, 5, nil, 5, 5, 5,
|
|
61
|
-
nil, 5, nil, 5, 5, 5, 5, 5, 6, 6,
|
|
62
|
-
6, 6, 6, 6, 6, 6, 6, 6, nil, 6,
|
|
63
|
-
6, 6, nil, 6, nil, 6, 6, 6, 6, 6,
|
|
64
|
-
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
|
65
|
-
nil, 7, 7, 7, nil, 7, nil, 7, 7, 7,
|
|
66
|
-
7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
|
|
67
|
-
8, 8, nil, 8, 8, 8, nil, 8, nil, 8,
|
|
68
|
-
8, 8, 8, 8, 9, 9, 9, 9, 9, 9,
|
|
69
|
-
9, 9, 9, 9, nil, 9, 9, 9, nil, 9,
|
|
70
|
-
nil, 9, 9, 9, 9, 9, 0, 0, 0, 0,
|
|
59
|
+
59, 59, 59, nil, nil, 59, 0, 0, 0, 0,
|
|
71
60
|
0, 0, 0, 0, 0, 0, nil, 0, 0, 0,
|
|
72
61
|
nil, 0, nil, 0, 0, 0, 0, 0, 4, 4,
|
|
73
62
|
4, 4, 4, 4, 4, 4, 4, 4, nil, 4,
|
|
74
63
|
4, 4, nil, 4, nil, 4, 4, 4, 4, 4,
|
|
64
|
+
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
|
65
|
+
nil, 5, 5, 5, nil, 5, nil, 5, 5, 5,
|
|
66
|
+
5, 5, 6, 6, 6, 6, 6, 6, 6, 6,
|
|
67
|
+
6, 6, nil, 6, 6, 6, nil, 6, nil, 6,
|
|
68
|
+
6, 6, 6, 6, 7, 7, 7, 7, 7, 7,
|
|
69
|
+
7, 7, 7, 7, nil, 7, 7, 7, nil, 7,
|
|
70
|
+
nil, 7, 7, 7, 7, 7, 8, 8, 8, 8,
|
|
71
|
+
8, 8, 8, 8, 8, 8, nil, 8, 8, 8,
|
|
72
|
+
nil, 8, nil, 8, 8, 8, 8, 8, 9, 9,
|
|
73
|
+
9, 9, 9, 9, 9, 9, 9, 9, nil, 9,
|
|
74
|
+
9, 9, nil, 9, nil, 9, 9, 9, 9, 9,
|
|
75
75
|
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
|
76
76
|
nil, 27, 27, 27, 27, 27, nil, 27, 27, 27,
|
|
77
77
|
27, 27, 28, 28, 28, 28, 28, 28, 28, 28,
|
|
@@ -85,17 +85,17 @@ racc_action_check = [
|
|
|
85
85
|
50, 50, nil, 50, nil, 50, 50, 50, 50, 50,
|
|
86
86
|
61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
|
|
87
87
|
nil, 61, 61, 61, nil, 61, nil, 61, 61, 61,
|
|
88
|
-
61, 61,
|
|
89
|
-
|
|
88
|
+
61, 61, 25, 25, 25, 26, 26, 26, 29, 29,
|
|
89
|
+
29 ]
|
|
90
90
|
|
|
91
91
|
racc_action_pointer = [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
nil, nil, nil, nil,
|
|
92
|
+
54, 14, nil, nil, 76, 98, 120, 142, 164, 186,
|
|
93
|
+
4, 12, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
94
|
+
nil, nil, nil, nil, 26, 315, 318, 208, 230, 321,
|
|
95
95
|
-2, nil, nil, 252, nil, nil, nil, nil, nil, nil,
|
|
96
96
|
274, nil, -2, nil, nil, nil, nil, nil, nil, nil,
|
|
97
97
|
296, nil, nil, nil, -6, nil, nil, nil, nil, 29,
|
|
98
|
-
nil, 318,
|
|
98
|
+
nil, 318, 1, -1, nil, nil, nil ]
|
|
99
99
|
|
|
100
100
|
racc_action_default = [
|
|
101
101
|
-47, -47, -1, -2, -31, -47, -47, -47, -47, -47,
|
|
@@ -107,26 +107,26 @@ racc_action_default = [
|
|
|
107
107
|
-37, -47, -47, -47, -35, -39, -26 ]
|
|
108
108
|
|
|
109
109
|
racc_goto_table = [
|
|
110
|
-
1, 33,
|
|
111
|
-
|
|
112
|
-
nil, nil, nil, nil, nil, nil,
|
|
113
|
-
nil, nil, nil, 53,
|
|
114
|
-
55,
|
|
110
|
+
1, 33, 27, 25, 26, 34, 35, 36, 37, 38,
|
|
111
|
+
42, 32, 39, 41, 46, 63, 62, 64, 54, nil,
|
|
112
|
+
nil, nil, nil, nil, nil, nil, 25, 26, 38, nil,
|
|
113
|
+
nil, nil, nil, 53, 45, nil, nil, nil, nil, nil,
|
|
114
|
+
55, 25, 26, nil, nil, nil, 59, nil, nil, 57,
|
|
115
115
|
34, nil, nil, nil, nil, nil, nil, nil, nil, 53,
|
|
116
116
|
nil, 65 ]
|
|
117
117
|
|
|
118
118
|
racc_goto_check = [
|
|
119
|
-
1, 5,
|
|
120
|
-
|
|
121
|
-
nil, nil, nil, nil, nil, nil,
|
|
122
|
-
nil, nil, nil, 1,
|
|
123
|
-
1,
|
|
119
|
+
1, 5, 4, 2, 3, 1, 1, 1, 1, 1,
|
|
120
|
+
8, 9, 6, 6, 10, 11, 12, 13, 14, nil,
|
|
121
|
+
nil, nil, nil, nil, nil, nil, 2, 3, 1, nil,
|
|
122
|
+
nil, nil, nil, 1, 9, nil, nil, nil, nil, nil,
|
|
123
|
+
1, 2, 3, nil, nil, nil, 5, nil, nil, 9,
|
|
124
124
|
1, nil, nil, nil, nil, nil, nil, nil, nil, 1,
|
|
125
125
|
nil, 1 ]
|
|
126
126
|
|
|
127
127
|
racc_goto_pointer = [
|
|
128
|
-
nil, 0, 0,
|
|
129
|
-
-
|
|
128
|
+
nil, 0, -1, 0, -2, -4, 2, nil, -13, 7,
|
|
129
|
+
-15, -44, -43, -42, -22 ]
|
|
130
130
|
|
|
131
131
|
racc_goto_default = [
|
|
132
132
|
nil, 29, 2, 3, nil, nil, nil, 13, nil, nil,
|
|
@@ -239,6 +239,7 @@ Racc_arg = [
|
|
|
239
239
|
racc_shift_n,
|
|
240
240
|
racc_reduce_n,
|
|
241
241
|
racc_use_result_var ]
|
|
242
|
+
Ractor.make_shareable(Racc_arg) if defined?(Ractor)
|
|
242
243
|
|
|
243
244
|
Racc_token_to_s_table = [
|
|
244
245
|
"$end",
|
|
@@ -289,6 +290,7 @@ Racc_token_to_s_table = [
|
|
|
289
290
|
"opt_rest",
|
|
290
291
|
"rest",
|
|
291
292
|
"arg_list" ]
|
|
293
|
+
Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
|
|
292
294
|
|
|
293
295
|
Racc_debug_parser = false
|
|
294
296
|
|
|
@@ -24,6 +24,8 @@ module RuboCop
|
|
|
24
24
|
# - With no block and no captures: #match returns `true`.
|
|
25
25
|
#
|
|
26
26
|
class NodePattern
|
|
27
|
+
class Invalid < StandardError; end
|
|
28
|
+
|
|
27
29
|
# Helpers for defining methods based on a pattern string
|
|
28
30
|
module Macros
|
|
29
31
|
# Define a method which applies a pattern to an AST node
|
|
@@ -51,8 +53,6 @@ module RuboCop
|
|
|
51
53
|
extend SimpleForwardable
|
|
52
54
|
include MethodDefiner
|
|
53
55
|
|
|
54
|
-
Invalid = Class.new(StandardError)
|
|
55
|
-
|
|
56
56
|
VAR = 'node'
|
|
57
57
|
|
|
58
58
|
# Yields its argument and any descendants, depth-first.
|
|
@@ -86,7 +86,7 @@ module RuboCop
|
|
|
86
86
|
no_children = %i[true false nil self cbase zsuper redo retry
|
|
87
87
|
forward_args forwarded_args match_nil_pattern
|
|
88
88
|
forward_arg forwarded_restarg forwarded_kwrestarg
|
|
89
|
-
lambda empty_else kwnilarg
|
|
89
|
+
lambda empty_else kwnilarg blocknilarg
|
|
90
90
|
__FILE__ __LINE__ __ENCODING__]
|
|
91
91
|
|
|
92
92
|
### children count == 0..1
|
data/lib/rubocop/ast/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-ast
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.49.
|
|
4
|
+
version: 1.49.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bozhidar Batsov
|
|
8
8
|
- Jonas Arvidsson
|
|
9
9
|
- Yuji Nakayama
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: parser
|
|
@@ -163,7 +162,6 @@ metadata:
|
|
|
163
162
|
documentation_uri: https://docs.rubocop.org/rubocop-ast/
|
|
164
163
|
bug_tracker_uri: https://github.com/rubocop/rubocop-ast/issues
|
|
165
164
|
rubygems_mfa_required: 'true'
|
|
166
|
-
post_install_message:
|
|
167
165
|
rdoc_options: []
|
|
168
166
|
require_paths:
|
|
169
167
|
- lib
|
|
@@ -178,8 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
178
176
|
- !ruby/object:Gem::Version
|
|
179
177
|
version: '0'
|
|
180
178
|
requirements: []
|
|
181
|
-
rubygems_version:
|
|
182
|
-
signing_key:
|
|
179
|
+
rubygems_version: 4.0.3
|
|
183
180
|
specification_version: 4
|
|
184
181
|
summary: RuboCop tools to deal with Ruby code AST.
|
|
185
182
|
test_files: []
|