rubocop-ast 1.46.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/README.md +0 -2
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +1 -1
- data/lib/rubocop/ast/node/mixin/parameterized_node.rb +1 -0
- data/lib/rubocop/ast/node.rb +15 -0
- 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/compiler.rb +1 -0
- data/lib/rubocop/ast/node_pattern/lexer.rex +1 -1
- data/lib/rubocop/ast/node_pattern/lexer.rex.rb +2 -2
- data/lib/rubocop/ast/node_pattern.rb +2 -1
- data/lib/rubocop/ast/processed_source.rb +4 -5
- data/lib/rubocop/ast/traversal.rb +2 -1
- data/lib/rubocop/ast/version.rb +1 -1
- metadata +5 -8
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
|
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/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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# encoding: UTF-8
|
|
3
3
|
#--
|
|
4
4
|
# This file is automatically generated. Do not modify it.
|
|
5
|
-
# Generated by: oedipus_lex version 2.6.
|
|
5
|
+
# Generated by: oedipus_lex version 2.6.3.
|
|
6
6
|
# Source: lib/rubocop/ast/node_pattern/lexer.rex
|
|
7
7
|
#++
|
|
8
8
|
|
|
@@ -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 }
|
|
@@ -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
|
|
@@ -50,7 +52,6 @@ module RuboCop
|
|
|
50
52
|
|
|
51
53
|
extend SimpleForwardable
|
|
52
54
|
include MethodDefiner
|
|
53
|
-
Invalid = Class.new(StandardError)
|
|
54
55
|
|
|
55
56
|
VAR = 'node'
|
|
56
57
|
|
|
@@ -310,14 +310,13 @@ module RuboCop
|
|
|
310
310
|
when :parser_prism
|
|
311
311
|
case ruby_version
|
|
312
312
|
when 3.3
|
|
313
|
-
require 'prism/translation/parser33'
|
|
314
313
|
Prism::Translation::Parser33
|
|
315
314
|
when 3.4
|
|
316
|
-
require 'prism/translation/parser34'
|
|
317
315
|
Prism::Translation::Parser34
|
|
318
|
-
when 3.5
|
|
319
|
-
|
|
320
|
-
|
|
316
|
+
when 3.5, 4.0
|
|
317
|
+
Prism::Translation::Parser40
|
|
318
|
+
when 4.1
|
|
319
|
+
Prism::Translation::Parser41
|
|
321
320
|
else
|
|
322
321
|
raise ArgumentError, 'RuboCop supports target Ruby versions 3.3 and above with Prism. ' \
|
|
323
322
|
"Specified target Ruby version: #{ruby_version.inspect}"
|
|
@@ -79,13 +79,14 @@ 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
|
|
85
86
|
no_children = %i[true false nil self cbase zsuper redo retry
|
|
86
87
|
forward_args forwarded_args match_nil_pattern
|
|
87
88
|
forward_arg forwarded_restarg forwarded_kwrestarg
|
|
88
|
-
lambda empty_else kwnilarg
|
|
89
|
+
lambda empty_else kwnilarg blocknilarg
|
|
89
90
|
__FILE__ __LINE__ __ENCODING__]
|
|
90
91
|
|
|
91
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.
|
|
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
|
|
@@ -32,14 +31,14 @@ dependencies:
|
|
|
32
31
|
requirements:
|
|
33
32
|
- - "~>"
|
|
34
33
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: '1.
|
|
34
|
+
version: '1.7'
|
|
36
35
|
type: :runtime
|
|
37
36
|
prerelease: false
|
|
38
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
39
38
|
requirements:
|
|
40
39
|
- - "~>"
|
|
41
40
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: '1.
|
|
41
|
+
version: '1.7'
|
|
43
42
|
description: " RuboCop's Node and NodePattern classes.\n"
|
|
44
43
|
email: rubocop@googlegroups.com
|
|
45
44
|
executables: []
|
|
@@ -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: []
|