rubocop-hq/rubocop-ast

View on GitHub
lib/rubocop/ast/node.rb

Summary

Maintainability
D
2 days
Test Coverage
B
83%

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

      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 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

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

            def parent_module_name
              # what class or module is this method/constant/etc definition in?
              # returns nil if answer cannot be determined
              ancestors = each_ancestor(:class, :module, :sclass, :casgn, :block)
              result    = ancestors.filter_map do |ancestor|
      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

      There are no issues that match your filters.

      Category
      Status