owahab/active_sorting

View on GitHub

Showing 4 of 4 total issues

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

      def active_sorting_make_changes(old_list, new_list, changes, id_column)
        new_list.each_with_index do |id, index|
          next unless changes.include?(id)
          if index == new_list.count.pred
            # We're moving an item to last position,
Severity: Minor
Found in lib/active_sorting/model.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 active_sorting_changes_required has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def active_sorting_changes_required(old_list, new_list)
        raise Exceptions::InvalidListSize, "Sortable new and old lists should be of the same length" if old_list.count != new_list.count
        changes = []
        proposal1 = active_sorting_calculate_changes(old_list.dup, new_list.dup)
        if proposal1.count >= (new_list.count / 4)
Severity: Minor
Found in lib/active_sorting/model.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 active_sorting_calculate_changes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def active_sorting_calculate_changes(old_list, new_list, changes = [])
        new_list.each_with_index do |id, index|
          next unless old_list[index] != id
          # This item has changed
          changes << id
Severity: Minor
Found in lib/active_sorting/model.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

TODO found
Open

        # TODO: columns_hash breaks when database has no tables
Severity: Minor
Found in lib/active_sorting/model.rb by fixme
Severity
Category
Status
Source
Language