rubocop-ast 1.34.1 → 1.35.0
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/builder.rb +1 -0
- data/lib/rubocop/ast/node/ensure_node.rb +7 -0
- data/lib/rubocop/ast/node/keyword_begin_node.rb +44 -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: 561b04e1f93f2547b0aacb052524a3a3ef33374393da44b52c5252e9188a8617
|
4
|
+
data.tar.gz: 82061fc362d4ab8f9f8342ab5732cc6e435504467ed8f27f5b8b22a6443e23b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 131019a04a091fc37a343a0c5f2481cba184b54883366e3362f98323dd7d2fe2f640ae7ee0bcad5c204fe17932d6116714df5e2a3123f8f1ee3f9b9890f866ba
|
7
|
+
data.tar.gz: c4c17c1178ee04b0e9ca05b442eadf121a2a1755be779e9ad508762ce7878c47249dca964028aebae71feda02e0fb8dd471e1fb3299b2f858506220ab14c418e
|
data/lib/rubocop/ast/builder.rb
CHANGED
@@ -13,6 +13,13 @@ module RuboCop
|
|
13
13
|
node_parts[1]
|
14
14
|
end
|
15
15
|
|
16
|
+
# Returns the `rescue` node of the `ensure`, if present.
|
17
|
+
#
|
18
|
+
# @return [Node, nil] The `rescue` node.
|
19
|
+
def rescue_node
|
20
|
+
node_parts[0] if node_parts[0].rescue_type?
|
21
|
+
end
|
22
|
+
|
16
23
|
# Checks whether this node body is a void context.
|
17
24
|
# Always `true` for `ensure`.
|
18
25
|
#
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module AST
|
5
|
+
# A node extension for `kwbegin` nodes. This will be used in place of a plain
|
6
|
+
# node when the builder constructs the AST, making its methods available
|
7
|
+
# to all `kwbegin` nodes within RuboCop.
|
8
|
+
class KeywordBeginNode < Node
|
9
|
+
# Returns the body of the `kwbegin` block. Returns `self` if the `kwbegin` contains
|
10
|
+
# multiple nodes.
|
11
|
+
#
|
12
|
+
# @return [Node, nil] The body of the `kwbegin`.
|
13
|
+
def body
|
14
|
+
return unless node_parts.any?
|
15
|
+
|
16
|
+
if rescue_node
|
17
|
+
rescue_node.body
|
18
|
+
elsif ensure_node
|
19
|
+
ensure_node.node_parts[0]
|
20
|
+
elsif node_parts.one?
|
21
|
+
node_parts[0]
|
22
|
+
else
|
23
|
+
self
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns the `rescue` node of the `kwbegin` block, if one is present.
|
28
|
+
#
|
29
|
+
# @return [Node, nil] The `rescue` node within `kwbegin`.
|
30
|
+
def ensure_node
|
31
|
+
node_parts[0] if node_parts[0]&.ensure_type?
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the `rescue` node of the `kwbegin` block, if one is present.
|
35
|
+
#
|
36
|
+
# @return [Node, nil] The `rescue` node within `kwbegin`.
|
37
|
+
def rescue_node
|
38
|
+
return ensure_node&.rescue_node if ensure_node&.rescue_node
|
39
|
+
|
40
|
+
node_parts[0] if node_parts[0]&.rescue_type?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/rubocop/ast/version.rb
CHANGED
data/lib/rubocop/ast.rb
CHANGED
@@ -60,6 +60,7 @@ require_relative 'ast/node/in_pattern_node'
|
|
60
60
|
require_relative 'ast/node/index_node'
|
61
61
|
require_relative 'ast/node/indexasgn_node'
|
62
62
|
require_relative 'ast/node/int_node'
|
63
|
+
require_relative 'ast/node/keyword_begin_node'
|
63
64
|
require_relative 'ast/node/keyword_splat_node'
|
64
65
|
require_relative 'ast/node/lambda_node'
|
65
66
|
require_relative 'ast/node/masgn_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.35.0
|
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-11 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/index_node.rb
|
70
70
|
- lib/rubocop/ast/node/indexasgn_node.rb
|
71
71
|
- lib/rubocop/ast/node/int_node.rb
|
72
|
+
- lib/rubocop/ast/node/keyword_begin_node.rb
|
72
73
|
- lib/rubocop/ast/node/keyword_splat_node.rb
|
73
74
|
- lib/rubocop/ast/node/lambda_node.rb
|
74
75
|
- lib/rubocop/ast/node/masgn_node.rb
|