rubocop-ast 1.33.1 → 1.34.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e18e1861fce6c7270825ae9878eb90e0e7fff0ade7e152dbb1930420ea443f6e
|
4
|
+
data.tar.gz: d5c24a9c7ff60efed99bd0f30d0debdb828b6ab7833dfc267d9743a9fd110a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee36477fed091f324d3259d528e0dbbec67267364cbd201e551d04f62d982058def295a487d27a549f02729327097bf0d6241d22642c20c8f199aa3ce3eb0541
|
7
|
+
data.tar.gz: 2961fdad4fb442fc09eb7ec0ad234331ddff49e28851444d8befc18b2e7c4e8aa41f9c534461445aed856a6eebf16aa692d6f7d2c2d498fee27b48e1fbe9e121
|
@@ -12,6 +12,7 @@ module RuboCop
|
|
12
12
|
def name
|
13
13
|
node_parts[0]
|
14
14
|
end
|
15
|
+
alias lhs name
|
15
16
|
|
16
17
|
# The expression being assigned to the variable.
|
17
18
|
#
|
@@ -19,6 +20,7 @@ module RuboCop
|
|
19
20
|
def expression
|
20
21
|
node_parts[1]
|
21
22
|
end
|
23
|
+
alias rhs expression
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
@@ -9,6 +9,7 @@ module RuboCop
|
|
9
9
|
include ConstantNode
|
10
10
|
|
11
11
|
alias name short_name
|
12
|
+
alias lhs short_name
|
12
13
|
|
13
14
|
# The expression being assigned to the variable.
|
14
15
|
#
|
@@ -16,6 +17,7 @@ module RuboCop
|
|
16
17
|
def expression
|
17
18
|
node_parts[2]
|
18
19
|
end
|
20
|
+
alias rhs expression
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -10,12 +10,13 @@ module RuboCop
|
|
10
10
|
def assignment_node
|
11
11
|
node_parts[0]
|
12
12
|
end
|
13
|
+
alias lhs assignment_node
|
13
14
|
|
14
15
|
# The name of the variable being assigned as a symbol.
|
15
16
|
#
|
16
17
|
# @return [Symbol] the name of the variable being assigned
|
17
18
|
def name
|
18
|
-
assignment_node.name
|
19
|
+
assignment_node.call_type? ? assignment_node.method_name : assignment_node.name
|
19
20
|
end
|
20
21
|
|
21
22
|
# The operator being used for assignment as a symbol.
|
@@ -31,6 +32,7 @@ module RuboCop
|
|
31
32
|
def expression
|
32
33
|
node_parts.last
|
33
34
|
end
|
35
|
+
alias rhs expression
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
data/lib/rubocop/ast/node.rb
CHANGED
@@ -88,6 +88,34 @@ module RuboCop
|
|
88
88
|
EMPTY_PROPERTIES = {}.freeze
|
89
89
|
private_constant :EMPTY_CHILDREN, :EMPTY_PROPERTIES
|
90
90
|
|
91
|
+
# @api private
|
92
|
+
GROUP_FOR_TYPE = {
|
93
|
+
arg: :argument,
|
94
|
+
optarg: :argument,
|
95
|
+
restarg: :argument,
|
96
|
+
kwarg: :argument,
|
97
|
+
kwoptarg: :argument,
|
98
|
+
kwrestarg: :argument,
|
99
|
+
blockarg: :argument,
|
100
|
+
forward_arg: :argument,
|
101
|
+
shardowarg: :argument,
|
102
|
+
|
103
|
+
true: :boolean,
|
104
|
+
false: :boolean,
|
105
|
+
|
106
|
+
int: :numeric,
|
107
|
+
float: :numeric,
|
108
|
+
rational: :numeric,
|
109
|
+
complex: :numeric,
|
110
|
+
|
111
|
+
irange: :range,
|
112
|
+
erange: :range,
|
113
|
+
|
114
|
+
send: :call,
|
115
|
+
csend: :call
|
116
|
+
}.freeze
|
117
|
+
private_constant :GROUP_FOR_TYPE
|
118
|
+
|
91
119
|
# Define a +recursive_?+ predicate method for the given node kind.
|
92
120
|
private_class_method def self.def_recursive_literal_predicate(kind) # rubocop:disable Metrics/MethodLength
|
93
121
|
recursive_kind = "recursive_#{kind}?"
|
@@ -126,6 +154,16 @@ module RuboCop
|
|
126
154
|
end
|
127
155
|
end
|
128
156
|
|
157
|
+
# Determine if the node is one of several node types in a single query
|
158
|
+
# Allows specific single node types, as well as "grouped" types
|
159
|
+
# (e.g. `:boolean` for `:true` or `:false`)
|
160
|
+
def type?(*types)
|
161
|
+
return true if types.include?(type)
|
162
|
+
|
163
|
+
group_type = GROUP_FOR_TYPE[type]
|
164
|
+
!group_type.nil? && types.include?(group_type)
|
165
|
+
end
|
166
|
+
|
129
167
|
(Parser::Meta::NODE_TYPES - [:send]).each do |node_type|
|
130
168
|
method_name = "#{node_type.to_s.gsub(/\W/, '')}_type?"
|
131
169
|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
@@ -312,13 +350,12 @@ module RuboCop
|
|
312
350
|
def_node_matcher :str_content, '(str $_)'
|
313
351
|
|
314
352
|
def const_name
|
315
|
-
return unless const_type?
|
353
|
+
return unless const_type? || casgn_type?
|
316
354
|
|
317
|
-
namespace, name = *self
|
318
355
|
if namespace && !namespace.cbase_type?
|
319
|
-
"#{namespace.const_name}::#{
|
356
|
+
"#{namespace.const_name}::#{short_name}"
|
320
357
|
else
|
321
|
-
|
358
|
+
short_name.to_s
|
322
359
|
end
|
323
360
|
end
|
324
361
|
|
@@ -464,7 +501,7 @@ module RuboCop
|
|
464
501
|
end
|
465
502
|
|
466
503
|
def call_type?
|
467
|
-
|
504
|
+
GROUP_FOR_TYPE[type] == :call
|
468
505
|
end
|
469
506
|
|
470
507
|
def chained?
|
@@ -476,19 +513,19 @@ module RuboCop
|
|
476
513
|
end
|
477
514
|
|
478
515
|
def argument_type?
|
479
|
-
|
516
|
+
GROUP_FOR_TYPE[type] == :argument
|
480
517
|
end
|
481
518
|
|
482
519
|
def boolean_type?
|
483
|
-
|
520
|
+
GROUP_FOR_TYPE[type] == :boolean
|
484
521
|
end
|
485
522
|
|
486
523
|
def numeric_type?
|
487
|
-
|
524
|
+
GROUP_FOR_TYPE[type] == :numeric
|
488
525
|
end
|
489
526
|
|
490
527
|
def range_type?
|
491
|
-
|
528
|
+
GROUP_FOR_TYPE[type] == :range
|
492
529
|
end
|
493
530
|
|
494
531
|
def guard_clause?
|
data/lib/rubocop/ast/version.rb
CHANGED
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.34.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: 2024-11-
|
13
|
+
date: 2024-11-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parser
|