rubocop-ast 1.9.1 → 1.13.0

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: c74f293f4bc64d882c585948fa1cadb54c207f6f21b1d46986751433c9e8f8e6
4
- data.tar.gz: c2d80c9d76eab9d8e9dfc1bb5d7ba3ea99ec55edda6c57e63acf894730f12e9d
3
+ metadata.gz: b3a3081c514303a8fb2f6ac3e4616da1d5f41ac4bd21d63407f9281534443385
4
+ data.tar.gz: dabd9d626ee4dd67946126b81f1a8852da16bb561caaabc91fa4b89648186fa6
5
5
  SHA512:
6
- metadata.gz: 48c641709f25b739e2fca2784601c50b0344c6ee5f23011b58795e118ebceb38488944fc3b7929b3ed62e0e79dff6cd279a5aac71e817a2c2c9624a9d15cc0d2
7
- data.tar.gz: ae3bdbcb7bc6664ecaf11ec72c98a598a88ea6d5b4b021607564fb361cf1663071bc9286a38af21b576c1f5cfc0d884895f845d825a331dff0cf7f106f9d6396
6
+ metadata.gz: f678e9d3b6da22c1be2861fd023121c50b161dfff5986ed14f49199c251bb041a2d2c3e93cacb86c9368dd71f8ed7575620984eeb54e65eaf183f062ffa11dee
7
+ data.tar.gz: 948888c0e83bca6acf73b06a0e5030bab2fde65cafa6366c6a3054cb07eca722d938f28a8b1e1bb226c8f48c9bb483b9d66704d432fdc87e23a4d2461809bb38
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # RuboCop AST
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/rubocop-ast.svg)](https://badge.fury.io/rb/rubocop-ast)
4
- [![CI](https://github.com/rubocop-hq/rubocop-ast/workflows/CI/badge.svg)](https://github.com/rubocop-hq/rubocop-ast/actions?query=workflow%3ACI)
5
- [![Test Coverage](https://api.codeclimate.com/v1/badges/a29666e6373bc41bc0a9/test_coverage)](https://codeclimate.com/github/rubocop-hq/rubocop-ast/test_coverage)
6
- [![Maintainability](https://api.codeclimate.com/v1/badges/a29666e6373bc41bc0a9/maintainability)](https://codeclimate.com/github/rubocop-hq/rubocop-ast/maintainability)
4
+ [![CI](https://github.com/rubocop/rubocop-ast/workflows/CI/badge.svg)](https://github.com/rubocop/rubocop-ast/actions?query=workflow%3ACI)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/a29666e6373bc41bc0a9/test_coverage)](https://codeclimate.com/github/rubocop/rubocop-ast/test_coverage)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/a29666e6373bc41bc0a9/maintainability)](https://codeclimate.com/github/rubocop/rubocop-ast/maintainability)
7
7
 
8
- Contains the classes needed by [RuboCop](https://github.com/rubocop-hq/rubocop) to deal with Ruby's AST, in particular:
8
+ Contains the classes needed by [RuboCop](https://github.com/rubocop/rubocop) to deal with Ruby's AST, in particular:
9
9
 
10
10
  * `RuboCop::AST::Node` ([doc](docs/modules/ROOT/pages/node_types.adoc))
11
11
  * `RuboCop::AST::NodePattern` ([doc](docs/modules/ROOT/pages/node_pattern.adoc))
@@ -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
@@ -28,9 +28,9 @@ module RuboCop
28
28
  node_parts[1]
29
29
  end
30
30
 
31
- # The `block` node associated with this method dispatch, if any.
31
+ # The `block` or `numblock` node associated with this method dispatch, if any.
32
32
  #
33
- # @return [BlockNode, nil] the `block` node associated with this method
33
+ # @return [BlockNode, nil] the `block` or `numblock` node associated with this method
34
34
  # call or `nil`
35
35
  def block_node
36
36
  parent if block_literal?
@@ -154,7 +154,7 @@ module RuboCop
154
154
  #
155
155
  # @return [Boolean] whether the dispatched method has a block
156
156
  def block_literal?
157
- parent&.block_type? && eql?(parent.send_node)
157
+ (parent&.block_type? || parent&.numblock_type?) && eql?(parent.send_node)
158
158
  end
159
159
 
160
160
  # Checks whether this node is an arithmetic operation
@@ -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
@@ -425,7 +425,7 @@ module RuboCop
425
425
  end
426
426
 
427
427
  def keyword?
428
- return true if special_keyword? || send_type? && prefix_not?
428
+ return true if special_keyword? || (send_type? && prefix_not?)
429
429
  return false unless KEYWORDS.include?(type)
430
430
 
431
431
  !OPERATOR_KEYWORDS.include?(type) || loc.operator.is?(type.to_s)
@@ -464,7 +464,7 @@ module RuboCop
464
464
  end
465
465
 
466
466
  def numeric_type?
467
- int_type? || float_type?
467
+ int_type? || float_type? || rational_type? || complex_type?
468
468
  end
469
469
 
470
470
  def range_type?
@@ -507,20 +507,20 @@ module RuboCop
507
507
  # @deprecated Use `:class_constructor?`
508
508
  # @!method struct_constructor?(node = self)
509
509
  def_node_matcher :struct_constructor?, <<~PATTERN
510
- (block (send #global_const?(:Struct) :new ...) _ $_)
510
+ ({block numblock} (send #global_const?(:Struct) :new ...) _ $_)
511
511
  PATTERN
512
512
 
513
513
  # @!method class_definition?(node = self)
514
514
  def_node_matcher :class_definition?, <<~PATTERN
515
515
  {(class _ _ $_)
516
516
  (sclass _ $_)
517
- (block (send #global_const?({:Struct :Class}) :new ...) _ $_)}
517
+ ({block numblock} (send #global_const?({:Struct :Class}) :new ...) _ $_)}
518
518
  PATTERN
519
519
 
520
520
  # @!method module_definition?(node = self)
521
521
  def_node_matcher :module_definition?, <<~PATTERN
522
522
  {(module _ $_)
523
- (block (send #global_const?(:Module) :new ...) _ $_)}
523
+ ({block numblock} (send #global_const?(:Module) :new ...) _ $_)}
524
524
  PATTERN
525
525
 
526
526
  # Some expressions are evaluated for their value, some for their side
@@ -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.5.2.
5
+ # Generated by: oedipus_lex version 2.6.0.
6
6
  # Source: lib/rubocop/ast/node_pattern/lexer.rex
7
7
  #++
8
8
 
@@ -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.13.0'
7
7
  end
8
8
  end
9
9
  end
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'
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.13.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-11-07 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
@@ -145,15 +150,15 @@ files:
145
150
  - lib/rubocop/ast/token.rb
146
151
  - lib/rubocop/ast/traversal.rb
147
152
  - lib/rubocop/ast/version.rb
148
- homepage: https://github.com/rubocop-hq/rubocop-ast
153
+ homepage: https://github.com/rubocop/rubocop-ast
149
154
  licenses:
150
155
  - MIT
151
156
  metadata:
152
157
  homepage_uri: https://www.rubocop.org/
153
- changelog_uri: https://github.com/rubocop-hq/rubocop-ast/blob/master/CHANGELOG.md
154
- source_code_uri: https://github.com/rubocop-hq/rubocop-ast/
158
+ changelog_uri: https://github.com/rubocop/rubocop-ast/blob/master/CHANGELOG.md
159
+ source_code_uri: https://github.com/rubocop/rubocop-ast/
155
160
  documentation_uri: https://docs.rubocop.org/rubocop-ast/
156
- bug_tracker_uri: https://github.com/rubocop-hq/rubocop-ast/issues
161
+ bug_tracker_uri: https://github.com/rubocop/rubocop-ast/issues
157
162
  post_install_message:
158
163
  rdoc_options: []
159
164
  require_paths: