rubocop-ast 1.4.1 → 1.4.2
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.rb +0 -1
- data/lib/rubocop/ast/node.rb +15 -0
- data/lib/rubocop/ast/node/mixin/descendence.rb +2 -6
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +4 -0
- data/lib/rubocop/ast/node/send_node.rb +1 -0
- data/lib/rubocop/ast/node_pattern.rb +1 -1
- data/lib/rubocop/ast/processed_source.rb +1 -1
- data/lib/rubocop/ast/version.rb +1 -1
- metadata +5 -6
- data/lib/rubocop/ast/ext/set.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2fc7baac2fa613e95c79a9de02f42586585a1aaf0821a77f25ada657e653448
|
4
|
+
data.tar.gz: d16431779a8cc2f5b795fe112de79a6e3628103b3e79fbea7213a8f9fa8da35e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d3cb6e72ed495bae000b28312de6955cfce4eb0aa2a77af7fcb352bc9ea7b2fdb60e74a1b7e1f0ef70169dc6863e1536421606db3b0f197055263b4c3458158
|
7
|
+
data.tar.gz: e9a57e796da77a05151a8c14974aba9737f409761ba48562bd848ad26c1a1c30ae0016ed821e1630d85757583e8e17ffccaa820f9e3f06b9fafa62f939ec9c6c
|
data/lib/rubocop/ast.rb
CHANGED
@@ -6,7 +6,6 @@ require 'set'
|
|
6
6
|
|
7
7
|
require_relative 'ast/ext/range'
|
8
8
|
require_relative 'ast/ext/range_min_max'
|
9
|
-
require_relative 'ast/ext/set'
|
10
9
|
require_relative 'ast/node_pattern/method_definer'
|
11
10
|
require_relative 'ast/node_pattern'
|
12
11
|
require_relative 'ast/node/mixin/descendence'
|
data/lib/rubocop/ast/node.rb
CHANGED
@@ -272,10 +272,12 @@ module RuboCop
|
|
272
272
|
|
273
273
|
## Destructuring
|
274
274
|
|
275
|
+
# @!method receiver(node = self)
|
275
276
|
def_node_matcher :receiver, <<~PATTERN
|
276
277
|
{(send $_ ...) ({block numblock} (send $_ ...) ...)}
|
277
278
|
PATTERN
|
278
279
|
|
280
|
+
# @!method str_content(node = self)
|
279
281
|
def_node_matcher :str_content, '(str $_)'
|
280
282
|
|
281
283
|
def const_name
|
@@ -289,6 +291,7 @@ module RuboCop
|
|
289
291
|
end
|
290
292
|
end
|
291
293
|
|
294
|
+
# @!method defined_module0(node = self)
|
292
295
|
def_node_matcher :defined_module0, <<~PATTERN
|
293
296
|
{(class (const $_ $_) ...)
|
294
297
|
(module (const $_ $_) ...)
|
@@ -334,6 +337,7 @@ module RuboCop
|
|
334
337
|
end
|
335
338
|
|
336
339
|
# Some cops treat the shovel operator as a kind of assignment.
|
340
|
+
# @!method assignment_or_similar?(node = self)
|
337
341
|
def_node_matcher :assignment_or_similar?, <<~PATTERN
|
338
342
|
{assignment? (send _recv :<< ...)}
|
339
343
|
PATTERN
|
@@ -469,37 +473,47 @@ module RuboCop
|
|
469
473
|
node.match_guard_clause?
|
470
474
|
end
|
471
475
|
|
476
|
+
# @!method match_guard_clause?(node = self)
|
472
477
|
def_node_matcher :match_guard_clause?, <<~PATTERN
|
473
478
|
[${(send nil? {:raise :fail} ...) return break next} single_line?]
|
474
479
|
PATTERN
|
475
480
|
|
481
|
+
# @!method proc?(node = self)
|
476
482
|
def_node_matcher :proc?, <<~PATTERN
|
477
483
|
{(block (send nil? :proc) ...)
|
478
484
|
(block (send #global_const?(:Proc) :new) ...)
|
479
485
|
(send #global_const?(:Proc) :new)}
|
480
486
|
PATTERN
|
481
487
|
|
488
|
+
# @!method lambda?(node = self)
|
482
489
|
def_node_matcher :lambda?, '({block numblock} (send nil? :lambda) ...)'
|
490
|
+
|
491
|
+
# @!method lambda_or_proc?(node = self)
|
483
492
|
def_node_matcher :lambda_or_proc?, '{lambda? proc?}'
|
484
493
|
|
494
|
+
# @!method global_const?(node = self, name)
|
485
495
|
def_node_matcher :global_const?, '(const {nil? cbase} %1)'
|
486
496
|
|
497
|
+
# @!method class_constructor?(node = self)
|
487
498
|
def_node_matcher :class_constructor?, <<~PATTERN
|
488
499
|
{ (send #global_const?({:Class :Module :Struct}) :new ...)
|
489
500
|
(block (send #global_const?({:Class :Module :Struct}) :new ...) ...)}
|
490
501
|
PATTERN
|
491
502
|
|
492
503
|
# @deprecated Use `:class_constructor?`
|
504
|
+
# @!method struct_constructor?(node = self)
|
493
505
|
def_node_matcher :struct_constructor?, <<~PATTERN
|
494
506
|
(block (send #global_const?(:Struct) :new ...) _ $_)
|
495
507
|
PATTERN
|
496
508
|
|
509
|
+
# @!method class_definition?(node = self)
|
497
510
|
def_node_matcher :class_definition?, <<~PATTERN
|
498
511
|
{(class _ _ $_)
|
499
512
|
(sclass _ $_)
|
500
513
|
(block (send #global_const?({:Struct :Class}) :new ...) _ $_)}
|
501
514
|
PATTERN
|
502
515
|
|
516
|
+
# @!method module_definition?(node = self)
|
503
517
|
def_node_matcher :module_definition?, <<~PATTERN
|
504
518
|
{(module _ $_)
|
505
519
|
(block (send #global_const?(:Module) :new ...) _ $_)}
|
@@ -633,6 +647,7 @@ module RuboCop
|
|
633
647
|
end
|
634
648
|
end
|
635
649
|
|
650
|
+
# @!method new_class_or_module_block?(node = self)
|
636
651
|
def_node_matcher :new_class_or_module_block?, <<~PATTERN
|
637
652
|
^(casgn _ _ (block (send (const _ {:Class :Module}) :new) ...))
|
638
653
|
PATTERN
|
@@ -13,13 +13,9 @@ module RuboCop
|
|
13
13
|
#
|
14
14
|
# @overload each_child_node
|
15
15
|
# Yield all nodes.
|
16
|
-
# @overload each_child_node(type)
|
17
|
-
# Yield only nodes matching the type.
|
18
|
-
# @param [Symbol] type a node type
|
19
|
-
# @overload each_child_node(type_a, type_b, ...)
|
16
|
+
# @overload each_child_node(type, ...)
|
20
17
|
# Yield only nodes matching any of the types.
|
21
|
-
# @param [Symbol]
|
22
|
-
# @param [Symbol] type_b a node type
|
18
|
+
# @param [Symbol] type a node type
|
23
19
|
# @yieldparam [Node] node each child node
|
24
20
|
# @return [self] if a block is given
|
25
21
|
# @return [Enumerator] if no block is given
|
@@ -224,6 +224,7 @@ module RuboCop
|
|
224
224
|
|
225
225
|
private
|
226
226
|
|
227
|
+
# @!method in_macro_scope?(node = self)
|
227
228
|
def_node_matcher :in_macro_scope?, <<~PATTERN
|
228
229
|
{
|
229
230
|
root? # Either a root node,
|
@@ -239,14 +240,17 @@ module RuboCop
|
|
239
240
|
}
|
240
241
|
PATTERN
|
241
242
|
|
243
|
+
# @!method adjacent_def_modifier?(node = self)
|
242
244
|
def_node_matcher :adjacent_def_modifier?, <<~PATTERN
|
243
245
|
(send nil? _ ({def defs} ...))
|
244
246
|
PATTERN
|
245
247
|
|
248
|
+
# @!method bare_access_modifier_declaration?(node = self)
|
246
249
|
def_node_matcher :bare_access_modifier_declaration?, <<~PATTERN
|
247
250
|
(send nil? {:public :protected :private :module_function})
|
248
251
|
PATTERN
|
249
252
|
|
253
|
+
# @!method non_bare_access_modifier_declaration?(node = self)
|
250
254
|
def_node_matcher :non_bare_access_modifier_declaration?, <<~PATTERN
|
251
255
|
(send nil? {:public :protected :private :module_function} _)
|
252
256
|
PATTERN
|
@@ -9,6 +9,7 @@ module RuboCop
|
|
9
9
|
include ParameterizedNode::RestArguments
|
10
10
|
include MethodDispatchNode
|
11
11
|
|
12
|
+
# @!method attribute_accessor?(node = self)
|
12
13
|
def_node_matcher :attribute_accessor?, <<~PATTERN
|
13
14
|
[(send nil? ${:attr_reader :attr_writer :attr_accessor :attr} $...)
|
14
15
|
(_ _ _ _ ...)]
|
@@ -28,7 +28,7 @@ module RuboCop
|
|
28
28
|
module Macros
|
29
29
|
# Define a method which applies a pattern to an AST node
|
30
30
|
#
|
31
|
-
# The new method will return nil if the node does not match
|
31
|
+
# The new method will return nil if the node does not match.
|
32
32
|
# If the node matches, and a block is provided, the new method will
|
33
33
|
# yield to the block (passing any captures as block arguments).
|
34
34
|
# If the node matches, and no block is provided, the new method will
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
def ast_with_comments
|
42
42
|
return if !ast || !comments
|
43
43
|
|
44
|
-
@ast_with_comments ||= Parser::Source::Comment.
|
44
|
+
@ast_with_comments ||= Parser::Source::Comment.associate_by_identity(ast, comments)
|
45
45
|
end
|
46
46
|
|
47
47
|
# Returns the source lines, line break characters removed, excluding a
|
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.
|
4
|
+
version: 1.4.2
|
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: 2021-
|
13
|
+
date: 2021-05-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parser
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.0.1.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: 3.0.1.1
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: bundler
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,7 +61,6 @@ files:
|
|
61
61
|
- lib/rubocop/ast/builder.rb
|
62
62
|
- lib/rubocop/ast/ext/range.rb
|
63
63
|
- lib/rubocop/ast/ext/range_min_max.rb
|
64
|
-
- lib/rubocop/ast/ext/set.rb
|
65
64
|
- lib/rubocop/ast/node.rb
|
66
65
|
- lib/rubocop/ast/node/alias_node.rb
|
67
66
|
- lib/rubocop/ast/node/and_node.rb
|
@@ -162,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
161
|
requirements:
|
163
162
|
- - ">="
|
164
163
|
- !ruby/object:Gem::Version
|
165
|
-
version: 2.
|
164
|
+
version: 2.5.0
|
166
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
166
|
requirements:
|
168
167
|
- - ">="
|