rubocop-ast 1.16.0 → 1.19.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/node/mixin/parameterized_node.rb +1 -1
- data/lib/rubocop/ast/node.rb +2 -2
- data/lib/rubocop/ast/node_pattern/compiler/binding.rb +2 -2
- data/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb +2 -2
- data/lib/rubocop/ast/node_pattern/node.rb +3 -3
- data/lib/rubocop/ast/processed_source.rb +17 -2
- data/lib/rubocop/ast/token.rb +4 -0
- data/lib/rubocop/ast/traversal.rb +2 -2
- data/lib/rubocop/ast/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e2940fc0009d2a8c22394b0dfdff3d48e28dcb9b696b5eaabcac8efefcc4e479
         | 
| 4 | 
            +
              data.tar.gz: 3a42602c36dfffbe35474ab9431dbf2437e22d5b4c3b485fce79c1e12868ff2c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 19d3856b627d85f6636619c7517220f3882e3aecd5f7daaefd9c7ef98d773dd535e86b3754f29d33364926c2d8ce4daf6ad936542c0a185a30a7996aea18de07
         | 
| 7 | 
            +
              data.tar.gz: 2aab89172bbca7244c06ca1950dc5c2cb5868e3454d507c6ae1c2ecf545d3a0ce77b0bedaaa69f39823a1fc066914d4fb731f4e911aa706eeff0f8aa1d790ec1
         | 
| @@ -84,7 +84,7 @@ module RuboCop | |
| 84 84 | 
             
                    include ParameterizedNode
         | 
| 85 85 | 
             
                    # @return [Array<Node>] arguments, if any
         | 
| 86 86 | 
             
                    def arguments
         | 
| 87 | 
            -
                      children[first_argument_index | 
| 87 | 
            +
                      children[first_argument_index..].freeze
         | 
| 88 88 | 
             
                    end
         | 
| 89 89 |  | 
| 90 90 | 
             
                    # A shorthand for getting the first argument of the node.
         | 
    
        data/lib/rubocop/ast/node.rb
    CHANGED
    
    | @@ -57,7 +57,7 @@ module RuboCop | |
| 57 57 | 
             
                  # @api private
         | 
| 58 58 | 
             
                  BASIC_CONDITIONALS = %i[if while until].to_set.freeze
         | 
| 59 59 | 
             
                  # @api private
         | 
| 60 | 
            -
                  CONDITIONALS = (BASIC_CONDITIONALS + [ | 
| 60 | 
            +
                  CONDITIONALS = (BASIC_CONDITIONALS + %i[case case_match]).freeze
         | 
| 61 61 | 
             
                  # @api private
         | 
| 62 62 | 
             
                  POST_CONDITION_LOOP_TYPES = %i[while_post until_post].to_set.freeze
         | 
| 63 63 | 
             
                  # @api private
         | 
| @@ -194,7 +194,7 @@ module RuboCop | |
| 194 194 | 
             
                  def right_siblings
         | 
| 195 195 | 
             
                    return [].freeze unless parent
         | 
| 196 196 |  | 
| 197 | 
            -
                    parent.children[sibling_index + 1 | 
| 197 | 
            +
                    parent.children[sibling_index + 1..].freeze
         | 
| 198 198 | 
             
                  end
         | 
| 199 199 |  | 
| 200 200 | 
             
                  # Common destructuring method. This can be used to normalize
         | 
| @@ -20,8 +20,8 @@ module RuboCop | |
| 20 20 | 
             
                        end
         | 
| 21 21 |  | 
| 22 22 | 
             
                        if var == :forbidden_unification
         | 
| 23 | 
            -
                          raise Invalid, "Wildcard #{name} was first seen in a subset of a" \
         | 
| 24 | 
            -
                                         " | 
| 23 | 
            +
                          raise Invalid, "Wildcard #{name} was first seen in a subset of a " \
         | 
| 24 | 
            +
                                         "union and can't be used outside that union"
         | 
| 25 25 | 
             
                        end
         | 
| 26 26 | 
             
                        var
         | 
| 27 27 | 
             
                      end
         | 
| @@ -371,13 +371,13 @@ module RuboCop | |
| 371 371 |  | 
| 372 372 | 
             
                      # @return [Hash] of {subcompiler => code}
         | 
| 373 373 | 
             
                      def compile_union_forks
         | 
| 374 | 
            -
                        compiler.each_union(node.children). | 
| 374 | 
            +
                        compiler.each_union(node.children).to_h do |child|
         | 
| 375 375 | 
             
                          subsequence_terms = child.is_a?(Node::Subsequence) ? child.children : [child]
         | 
| 376 376 | 
             
                          fork = dup
         | 
| 377 377 | 
             
                          code = fork.compile_terms(subsequence_terms, @remaining_arity)
         | 
| 378 378 | 
             
                          @in_sync = false if @cur_index != :variadic_mode
         | 
| 379 379 | 
             
                          [fork, code]
         | 
| 380 | 
            -
                        end | 
| 380 | 
            +
                        end
         | 
| 381 381 | 
             
                      end
         | 
| 382 382 |  | 
| 383 383 | 
             
                      # Modifies in place `forks` to insure that `cur_{child|index}_var` are ok
         | 
| @@ -116,7 +116,7 @@ module RuboCop | |
| 116 116 |  | 
| 117 117 | 
             
                      def initialize(type, children = [], properties = {})
         | 
| 118 118 | 
             
                        if (replace = children.first.in_sequence_head)
         | 
| 119 | 
            -
                          children = [*replace, *children[1 | 
| 119 | 
            +
                          children = [*replace, *children[1..]]
         | 
| 120 120 | 
             
                        end
         | 
| 121 121 |  | 
| 122 122 | 
             
                        super
         | 
| @@ -130,7 +130,7 @@ module RuboCop | |
| 130 130 | 
             
                      end
         | 
| 131 131 |  | 
| 132 132 | 
             
                      def arg_list
         | 
| 133 | 
            -
                        children[1 | 
| 133 | 
            +
                        children[1..]
         | 
| 134 134 | 
             
                      end
         | 
| 135 135 | 
             
                    end
         | 
| 136 136 | 
             
                    FunctionCall = Predicate
         | 
| @@ -212,7 +212,7 @@ module RuboCop | |
| 212 212 |  | 
| 213 213 | 
             
                        return unless (replace = children.first.in_sequence_head)
         | 
| 214 214 |  | 
| 215 | 
            -
                        [with(children: [*replace, *children[1 | 
| 215 | 
            +
                        [with(children: [*replace, *children[1..]])]
         | 
| 216 216 | 
             
                      end
         | 
| 217 217 | 
             
                    end
         | 
| 218 218 |  | 
| @@ -226,9 +226,24 @@ module RuboCop | |
| 226 226 | 
             
                    [ast, comments, tokens]
         | 
| 227 227 | 
             
                  end
         | 
| 228 228 |  | 
| 229 | 
            -
                  # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
         | 
| 229 | 
            +
                  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
         | 
| 230 230 | 
             
                  def parser_class(ruby_version)
         | 
| 231 231 | 
             
                    case ruby_version
         | 
| 232 | 
            +
                    when 1.9
         | 
| 233 | 
            +
                      require 'parser/ruby19'
         | 
| 234 | 
            +
                      Parser::Ruby19
         | 
| 235 | 
            +
                    when 2.0
         | 
| 236 | 
            +
                      require 'parser/ruby20'
         | 
| 237 | 
            +
                      Parser::Ruby20
         | 
| 238 | 
            +
                    when 2.1
         | 
| 239 | 
            +
                      require 'parser/ruby21'
         | 
| 240 | 
            +
                      Parser::Ruby21
         | 
| 241 | 
            +
                    when 2.2
         | 
| 242 | 
            +
                      require 'parser/ruby22'
         | 
| 243 | 
            +
                      Parser::Ruby22
         | 
| 244 | 
            +
                    when 2.3
         | 
| 245 | 
            +
                      require 'parser/ruby23'
         | 
| 246 | 
            +
                      Parser::Ruby23
         | 
| 232 247 | 
             
                    when 2.4
         | 
| 233 248 | 
             
                      require 'parser/ruby24'
         | 
| 234 249 | 
             
                      Parser::Ruby24
         | 
| @@ -255,7 +270,7 @@ module RuboCop | |
| 255 270 | 
             
                            "RuboCop found unknown Ruby version: #{ruby_version.inspect}"
         | 
| 256 271 | 
             
                    end
         | 
| 257 272 | 
             
                  end
         | 
| 258 | 
            -
                  # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
         | 
| 273 | 
            +
                  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
         | 
| 259 274 |  | 
| 260 275 | 
             
                  def create_parser(ruby_version)
         | 
| 261 276 | 
             
                    builder = RuboCop::AST::Builder.new
         | 
    
        data/lib/rubocop/ast/token.rb
    CHANGED
    
    
| @@ -34,7 +34,7 @@ module RuboCop | |
| 34 34 |  | 
| 35 35 | 
             
                    def def_callback(type, *signature,
         | 
| 36 36 | 
             
                                     arity: signature.size..signature.size,
         | 
| 37 | 
            -
                                     arity_check: ENV | 
| 37 | 
            +
                                     arity_check: ENV.fetch('RUBOCOP_DEBUG', nil) && self.arity_check(arity),
         | 
| 38 38 | 
             
                                     body: self.body(signature, arity_check))
         | 
| 39 39 | 
             
                      type, *aliases = type
         | 
| 40 40 | 
             
                      lineno = caller_locations(1, 1).first.lineno
         | 
| @@ -162,7 +162,7 @@ module RuboCop | |
| 162 162 | 
             
                  ### generic processing of any other node (forward compatibility)
         | 
| 163 163 | 
             
                  defined = instance_methods(false)
         | 
| 164 164 | 
             
                            .grep(/^on_/)
         | 
| 165 | 
            -
                            .map { |s| s.to_s[3 | 
| 165 | 
            +
                            .map { |s| s.to_s[3..].to_sym } # :on_foo => :foo
         | 
| 166 166 |  | 
| 167 167 | 
             
                  to_define = ::Parser::Meta::NODE_TYPES.to_a
         | 
| 168 168 | 
             
                  to_define -= defined
         | 
    
        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.19.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: 2022- | 
| 13 | 
            +
            date: 2022-07-09 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: parser
         | 
| @@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 168 168 | 
             
              requirements:
         | 
| 169 169 | 
             
              - - ">="
         | 
| 170 170 | 
             
                - !ruby/object:Gem::Version
         | 
| 171 | 
            -
                  version: 2. | 
| 171 | 
            +
                  version: 2.6.0
         | 
| 172 172 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 173 173 | 
             
              requirements:
         | 
| 174 174 | 
             
              - - ">="
         |