rubocop-hq/rubocop-ast

View on GitHub

Showing 24 of 24 total issues

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

      def inverse_delimiter(*deprecated, with_spacing: deprecated.first)
        if with_spacing
          hash_rocket? ? SPACED_COLON : SPACED_HASH_ROCKET
        else
          hash_rocket? ? COLON : HASH_ROCKET
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 def_modifier has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def def_modifier(node = self)
        arg = node.children[2]

        return unless node.send_type? && node.receiver.nil? && arg.is_a?(::AST::Node)

Severity: Minor
Found in lib/rubocop/ast/node/mixin/method_dispatch_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

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

        def enforce_same_captures(enum)
          return to_enum __method__, enum unless block_given?

          captures_before = captures_after = nil
          enum.each do |node|
Severity: Minor
Found in lib/rubocop/ast/node_pattern/compiler.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