rubocop-hq/rubocop-ast

View on GitHub

Showing 24 of 24 total issues

Class Node has 67 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Node < Parser::AST::Node # rubocop:disable Metrics/ClassLength
      include RuboCop::AST::Sexp
      extend NodePattern::Macros
      include RuboCop::AST::Descendence

Severity: Major
Found in lib/rubocop/ast/node.rb - About 1 day to fix

    File node.rb has 406 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module RuboCop
      module AST
        # `RuboCop::AST::Node` is a subclass of `Parser::AST::Node`. It provides
        # access to parent nodes and an object-oriented way to traverse an AST with
        # the power of `Enumerable`.
    Severity: Minor
    Found in lib/rubocop/ast/node.rb - About 5 hrs to fix

      Class ProcessedSource has 35 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class ProcessedSource
            # @api private
            STRING_SOURCE_NAME = '(string)'
      
            INVALID_LEVELS = %i[error fatal].freeze
      Severity: Minor
      Found in lib/rubocop/ast/processed_source.rb - About 4 hrs to fix

        Class SequenceSubcompiler has 32 methods (exceeds 20 allowed). Consider refactoring.
        Open

                class SequenceSubcompiler < Subcompiler
                  DELTA = 1
                  POSITIVE = :positive?.to_proc
                  private_constant :POSITIVE
        
        
        Severity: Minor
        Found in lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb - About 4 hrs to fix

          File sequence_subcompiler.rb has 303 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module RuboCop
            module AST
              class NodePattern
                class Compiler
                  # Compiles terms within a sequence to code that evalues to true or false.
          Severity: Minor
          Found in lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb - About 3 hrs to fix

            Class Token has 27 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class Token
                  LEFT_PAREN_TYPES = %i[tLPAREN tLPAREN2].freeze
            
                  attr_reader :pos, :type, :text
            
            
            Severity: Minor
            Found in lib/rubocop/ast/token.rb - About 3 hrs to fix

              Method parser_class has 67 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def parser_class(ruby_version, parser_engine)
                      case parser_engine
                      when :parser_whitequark
                        case ruby_version
                        when 1.9
              Severity: Major
              Found in lib/rubocop/ast/processed_source.rb - About 2 hrs to fix

                Class Changelog has 23 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Changelog # rubocop:disable Metrics/ClassLength
                  ENTRIES_PATH = 'changelog/'
                  FIRST_HEADER = /#{Regexp.escape("## master (unreleased)\n")}/m.freeze
                  ENTRIES_PATH_TEMPLATE = "#{ENTRIES_PATH}%<type>s_%<name>s.md"
                  TYPE_REGEXP = /#{Regexp.escape(ENTRIES_PATH)}([a-z]+)_/.freeze
                Severity: Minor
                Found in tasks/changelog.rb - About 2 hrs to fix

                  File processed_source.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'digest/sha1'
                  
                  # rubocop:disable Metrics/ClassLength
                  module RuboCop
                    module AST
                  Severity: Minor
                  Found in lib/rubocop/ast/processed_source.rb - About 2 hrs to fix

                    Method each_child_node has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def each_child_node(*types)
                            return to_enum(__method__, *types) unless block_given?
                    
                            children.each do |child|
                              next unless child.is_a?(::AST::Node)
                    Severity: Minor
                    Found in lib/rubocop/ast/node/mixin/descendence.rb - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method each_path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def each_path(&block)
                            return to_enum(__method__) unless block
                    
                            descendants = []
                            last = self
                    Severity: Minor
                    Found in lib/rubocop/ast/node/const_node.rb - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method in_sequence_head has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                              def in_sequence_head
                                return unless children.any?(&:in_sequence_head)
                    
                                new_children = children.map do |child|
                                  next child unless (replace = child.in_sequence_head)
                    Severity: Minor
                    Found in lib/rubocop/ast/node_pattern/node.rb - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method compile_min_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                              def compile_min_check
                                return 'false' unless node.variadic?
                    
                                unless @remaining_arity.end.infinite?
                                  not_too_much_remaining = "#{compile_remaining} <= #{@remaining_arity.max}"
                    Severity: Minor
                    Found in lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb - About 45 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method parent_module_name_for_block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def parent_module_name_for_block(ancestor)
                            if ancestor.method?(:class_eval)
                              # `class_eval` with no receiver applies to whatever module or class
                              # we are currently in
                              return unless (receiver = ancestor.receiver)
                    Severity: Minor
                    Found in lib/rubocop/ast/node.rb - About 45 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method visit_descendants has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def visit_descendants(types, &block)
                            children.each do |child|
                              next unless child.is_a?(::AST::Node)
                    
                              yield child if types.empty? || types.include?(child.type)
                    Severity: Minor
                    Found in lib/rubocop/ast/node/mixin/descendence.rb - About 35 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method parser_class has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def parser_class(ruby_version, parser_engine)
                            case parser_engine
                            when :parser_whitequark
                              case ruby_version
                              when 1.9
                    Severity: Minor
                    Found in lib/rubocop/ast/processed_source.rb - About 35 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method union_bind has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                              def union_bind(enum)
                                # We need to reset @bound before each branch is processed.
                                # Moreover we need to keep track of newly encountered wildcards.
                                # Var `newly_bound_intersection` will hold those that are encountered
                                # in all branches; these are not a problem.
                    Severity: Minor
                    Found in lib/rubocop/ast/node_pattern/compiler/binding.rb - About 35 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method delimiter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def delimiter(*deprecated, with_spacing: deprecated.first)
                            if with_spacing
                              hash_rocket? ? SPACED_HASH_ROCKET : SPACED_COLON
                            else
                              hash_rocket? ? HASH_ROCKET : COLON
                    Severity: Minor
                    Found in lib/rubocop/ast/node/pair_node.rb - About 25 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method branches has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def branches
                            if ternary?
                              [if_branch, else_branch]
                            elsif !else?
                              [if_branch]
                    Severity: Minor
                    Found in lib/rubocop/ast/node/if_node.rb - About 25 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method keyword? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def keyword?
                            return true if special_keyword? || (send_type? && prefix_not?)
                            return false unless KEYWORDS.include?(type)
                    
                            !OPERATOR_KEYWORDS.include?(type) || loc.operator.is?(type.to_s)
                    Severity: Minor
                    Found in lib/rubocop/ast/node.rb - About 25 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Severity
                    Category
                    Status
                    Source
                    Language