rubocop-hq/rubocop

View on GitHub
lib/rubocop/cop/mixin/check_line_breakable.rb

Summary

Maintainability
A
3 hrs
Test Coverage
A
100%

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

      def contained_by_breakable_collection_on_same_line?(node)
        node.each_ancestor.find do |ancestor|
          # Ignore ancestors on different lines.
          break if ancestor.first_line != node.first_line

Severity: Minor
Found in lib/rubocop/cop/mixin/check_line_breakable.rb - About 1 hr 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 contained_by_multiline_collection_that_could_be_broken_up? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def contained_by_multiline_collection_that_could_be_broken_up?(node)
        node.each_ancestor.find do |ancestor|
          if (ancestor.hash_type? || ancestor.array_type?) &&
             breakable_collection?(ancestor, ancestor.children)
            return children_could_be_broken_up?(ancestor.children)
Severity: Minor
Found in lib/rubocop/cop/mixin/check_line_breakable.rb - About 1 hr 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 shift_elements_for_heredoc_arg has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def shift_elements_for_heredoc_arg(node, elements, index)
        return index unless node.send_type? || node.array_type?

        heredoc_index = elements.index { |arg| arg.respond_to?(:heredoc?) && arg.heredoc? }
        return index unless heredoc_index
Severity: Minor
Found in lib/rubocop/cop/mixin/check_line_breakable.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

There are no issues that match your filters.

Category
Status