take-five/acts_as_ordered_tree

View on GitHub

Showing 7 of 7 total issues

Method each_without_cached_level has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def each_without_cached_level
        path = []

        @collection.each do |node|
          parent_id = node.ordered_tree_node.parent_id
Severity: Minor
Found in lib/acts_as_ordered_tree/iterators/level_calculator.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 start has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def start(&block)
      @attempts += 1

      with_transaction_state(&block)
    rescue ActiveRecord::StatementInvalid => error
Severity: Minor
Found in lib/acts_as_ordered_tree/persevering_transaction.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 traverse_up has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def traverse_up(node, including = [])
        return none unless node

        if can_traverse_up?(node)
          if node.ordered_tree_node.has_parent?
Severity: Minor
Found in lib/acts_as_ordered_tree/adapters/postgresql.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 feature has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def feature(name, options = {})
        @tree << if name.is_a?(Hash)
          version = name.delete(:versions) || @default_versions
          name, prereq = *name.first

Severity: Minor
Found in lib/acts_as_ordered_tree/compatibility/features.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 set has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def set(assignments)
        assignments.map do |attr, value|
          next unless attr.present?

          name = attr.is_a?(Arel::Attributes::Attribute) ? attr.name : attr.to_s
Severity: Minor
Found in lib/acts_as_ordered_tree/transaction/dsl.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 conditions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def conditions
        return nil unless tree.columns.scope?

        assoc_scope = method(:association_scope)
        join_scope = method(:join_association_scope)
Severity: Minor
Found in lib/acts_as_ordered_tree/tree/children_association.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 each has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def each
        return to_enum unless block_given?

        prepare if @cache.empty?

Severity: Minor
Found in lib/acts_as_ordered_tree/iterators/orphans_pruner.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