rubocop-ast 1.9.1 → 1.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c74f293f4bc64d882c585948fa1cadb54c207f6f21b1d46986751433c9e8f8e6
4
- data.tar.gz: c2d80c9d76eab9d8e9dfc1bb5d7ba3ea99ec55edda6c57e63acf894730f12e9d
3
+ metadata.gz: 49a89bf3c08f4088e33d9e9c32916642a43c688f9f2895d0674499b56040d303
4
+ data.tar.gz: f2acb484f169f463660e2460de5d6239e2e70c61a0752506e20cf0c8fa3b800b
5
5
  SHA512:
6
- metadata.gz: 48c641709f25b739e2fca2784601c50b0344c6ee5f23011b58795e118ebceb38488944fc3b7929b3ed62e0e79dff6cd279a5aac71e817a2c2c9624a9d15cc0d2
7
- data.tar.gz: ae3bdbcb7bc6664ecaf11ec72c98a598a88ea6d5b4b021607564fb361cf1663071bc9286a38af21b576c1f5cfc0d884895f845d825a331dff0cf7f106f9d6396
6
+ metadata.gz: bc01b203ca7d2c7ca5a5b3080b9cb59e29f806402b88ea7499484b5e45e9efdad5ed166ea8511417454a3931ebabf2a888bf74a6acf0e903847f5a671519d2a8
7
+ data.tar.gz: a6684ef1b97ea7e58726d314af92b07dd941d630ce6c60da34f8ce8cbb4e4b54ccf5397e7582abe43edb81f31869abb6e99f208ec79090856edf130a1fb53e92
data/lib/rubocop/ast.rb CHANGED
@@ -39,10 +39,12 @@ require_relative 'ast/node/and_node'
39
39
  require_relative 'ast/node/arg_node'
40
40
  require_relative 'ast/node/args_node'
41
41
  require_relative 'ast/node/array_node'
42
+ require_relative 'ast/node/asgn_node'
42
43
  require_relative 'ast/node/block_node'
43
44
  require_relative 'ast/node/break_node'
44
45
  require_relative 'ast/node/case_match_node'
45
46
  require_relative 'ast/node/case_node'
47
+ require_relative 'ast/node/casgn_node'
46
48
  require_relative 'ast/node/class_node'
47
49
  require_relative 'ast/node/const_node'
48
50
  require_relative 'ast/node/def_node'
@@ -61,6 +63,9 @@ require_relative 'ast/node/keyword_splat_node'
61
63
  require_relative 'ast/node/lambda_node'
62
64
  require_relative 'ast/node/module_node'
63
65
  require_relative 'ast/node/next_node'
66
+ require_relative 'ast/node/op_asgn_node'
67
+ require_relative 'ast/node/and_asgn_node'
68
+ require_relative 'ast/node/or_asgn_node'
64
69
  require_relative 'ast/node/or_node'
65
70
  require_relative 'ast/node/pair_node'
66
71
  require_relative 'ast/node/procarg0_node'
@@ -20,6 +20,7 @@ module RuboCop
20
20
  # @api private
21
21
  NODE_MAP = {
22
22
  and: AndNode,
23
+ and_asgn: AndAsgnNode,
23
24
  alias: AliasNode,
24
25
  arg: ArgNode,
25
26
  blockarg: ArgNode,
@@ -32,10 +33,15 @@ module RuboCop
32
33
  shadowarg: ArgNode,
33
34
  args: ArgsNode,
34
35
  array: ArrayNode,
36
+ lvasgn: AsgnNode,
37
+ ivasgn: AsgnNode,
38
+ cvasgn: AsgnNode,
39
+ gvasgn: AsgnNode,
35
40
  block: BlockNode,
36
41
  numblock: BlockNode,
37
42
  break: BreakNode,
38
43
  case_match: CaseMatchNode,
44
+ casgn: CasgnNode,
39
45
  case: CaseNode,
40
46
  class: ClassNode,
41
47
  const: ConstNode,
@@ -60,6 +66,8 @@ module RuboCop
60
66
  lambda: LambdaNode,
61
67
  module: ModuleNode,
62
68
  next: NextNode,
69
+ op_asgn: OpAsgnNode,
70
+ or_asgn: OrAsgnNode,
63
71
  or: OrNode,
64
72
  pair: PairNode,
65
73
  procarg0: Procarg0Node,
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `op_asgn` nodes.
6
+ # This will be used in place of a plain node when the builder constructs
7
+ # the AST, making its methods available to all assignment nodes within RuboCop.
8
+ class AndAsgnNode < OpAsgnNode
9
+ # The operator being used for assignment as a symbol.
10
+ #
11
+ # @return [Symbol] the assignment operator
12
+ def operator
13
+ :'&&'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `lvasgn`, `ivasgn`, `cvasgn`, and `gvasgn` nodes.
6
+ # This will be used in place of a plain node when the builder constructs
7
+ # the AST, making its methods available to all assignment nodes within RuboCop.
8
+ class AsgnNode < Node
9
+ # The name of the variable being assigned as a symbol.
10
+ #
11
+ # @return [Symbol] the name of the variable being assigned
12
+ def name
13
+ node_parts[0]
14
+ end
15
+
16
+ # The expression being assigned to the variable.
17
+ #
18
+ # @return [Node] the expression being assigned.
19
+ def expression
20
+ node_parts[1]
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `casgn` nodes.
6
+ # This will be used in place of a plain node when the builder constructs
7
+ # the AST, making its methods available to all assignment nodes within RuboCop.
8
+ class CasgnNode < Node
9
+ # The namespace of the constant being assigned.
10
+ #
11
+ # @return [Node, nil] the node associated with the scope (e.g. cbase, const, ...)
12
+ def namespace
13
+ node_parts[0]
14
+ end
15
+
16
+ # The name of the variable being assigned as a symbol.
17
+ #
18
+ # @return [Symbol] the name of the variable being assigned
19
+ def name
20
+ node_parts[1]
21
+ end
22
+
23
+ # The expression being assigned to the variable.
24
+ #
25
+ # @return [Node] the expression being assigned.
26
+ def expression
27
+ node_parts[2]
28
+ end
29
+ end
30
+ end
31
+ end
@@ -4,8 +4,6 @@ module RuboCop
4
4
  module AST
5
5
  # A node extension for `const` nodes.
6
6
  class ConstNode < Node
7
- # The `send` node associated with this block.
8
- #
9
7
  # @return [Node, nil] the node associated with the scope (e.g. cbase, const, ...)
10
8
  def namespace
11
9
  children[0]
@@ -16,8 +14,6 @@ module RuboCop
16
14
  children[1]
17
15
  end
18
16
 
19
- # The body of this block.
20
- #
21
17
  # @return [Boolean] if the constant is a Module / Class, according to the standard convention.
22
18
  # Note: some classes might have uppercase in which case this method
23
19
  # returns false
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `op_asgn` nodes.
6
+ # This will be used in place of a plain node when the builder constructs
7
+ # the AST, making its methods available to all assignment nodes within RuboCop.
8
+ class OpAsgnNode < Node
9
+ # @return [AsgnNode] the assignment node
10
+ def assignment_node
11
+ node_parts[0]
12
+ end
13
+
14
+ # The name of the variable being assigned as a symbol.
15
+ #
16
+ # @return [Symbol] the name of the variable being assigned
17
+ def name
18
+ assignment_node.name
19
+ end
20
+
21
+ # The operator being used for assignment as a symbol.
22
+ #
23
+ # @return [Symbol] the assignment operator
24
+ def operator
25
+ node_parts[1]
26
+ end
27
+
28
+ # The expression being assigned to the variable.
29
+ #
30
+ # @return [Node] the expression being assigned.
31
+ def expression
32
+ node_parts.last
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `op_asgn` nodes.
6
+ # This will be used in place of a plain node when the builder constructs
7
+ # the AST, making its methods available to all assignment nodes within RuboCop.
8
+ class OrAsgnNode < OpAsgnNode
9
+ # The operator being used for assignment as a symbol.
10
+ #
11
+ # @return [Symbol] the assignment operator
12
+ def operator
13
+ :'||'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -54,7 +54,7 @@ module RuboCop
54
54
  children_nodes.sum(&:nb_captures)
55
55
  end
56
56
 
57
- # @return [Boolean] returns wether it matches a variable number of elements
57
+ # @return [Boolean] returns whether it matches a variable number of elements
58
58
  def variadic?
59
59
  arity.is_a?(Range)
60
60
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module AST
5
5
  module Version
6
- STRING = '1.9.1'
6
+ STRING = '1.10.0'
7
7
  end
8
8
  end
9
9
  end
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.9.1
4
+ version: 1.10.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: 2021-08-10 00:00:00.000000000 Z
13
+ date: 2021-08-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser
@@ -63,14 +63,17 @@ files:
63
63
  - lib/rubocop/ast/ext/range_min_max.rb
64
64
  - lib/rubocop/ast/node.rb
65
65
  - lib/rubocop/ast/node/alias_node.rb
66
+ - lib/rubocop/ast/node/and_asgn_node.rb
66
67
  - lib/rubocop/ast/node/and_node.rb
67
68
  - lib/rubocop/ast/node/arg_node.rb
68
69
  - lib/rubocop/ast/node/args_node.rb
69
70
  - lib/rubocop/ast/node/array_node.rb
71
+ - lib/rubocop/ast/node/asgn_node.rb
70
72
  - lib/rubocop/ast/node/block_node.rb
71
73
  - lib/rubocop/ast/node/break_node.rb
72
74
  - lib/rubocop/ast/node/case_match_node.rb
73
75
  - lib/rubocop/ast/node/case_node.rb
76
+ - lib/rubocop/ast/node/casgn_node.rb
74
77
  - lib/rubocop/ast/node/class_node.rb
75
78
  - lib/rubocop/ast/node/const_node.rb
76
79
  - lib/rubocop/ast/node/def_node.rb
@@ -102,6 +105,8 @@ files:
102
105
  - lib/rubocop/ast/node/mixin/predicate_operator_node.rb
103
106
  - lib/rubocop/ast/node/module_node.rb
104
107
  - lib/rubocop/ast/node/next_node.rb
108
+ - lib/rubocop/ast/node/op_asgn_node.rb
109
+ - lib/rubocop/ast/node/or_asgn_node.rb
105
110
  - lib/rubocop/ast/node/or_node.rb
106
111
  - lib/rubocop/ast/node/pair_node.rb
107
112
  - lib/rubocop/ast/node/procarg0_node.rb