injixo/time_frame

View on GitHub

Showing 4 of 4 total issues

Class TimeFrame has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class TimeFrame
  attr_reader :min, :max

  EMPTY = Empty.instance

Severity: Minor
Found in lib/time_frame/time_frame.rb - About 3 hrs to fix

    Method build_sub_tree has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_sub_tree(lower, upper, ancestor = nil, side = nil)
          mid = (lower + upper) / 2
          node = @tree_nodes[mid]
    
          node.update_ancestor_relation(ancestor, side) if ancestor && side
    Severity: Minor
    Found in lib/time_frame/collection.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

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

        def each(&block)
          return [] if @array1.empty? || @array2.empty?
          yield_current_pair(&block) if current_pair_overlaps?
          while each_array_has_many_items?
            shift
    Severity: Minor
    Found in lib/time_frame/time_frame_overlaps.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 add_matching has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_matching(node, result, &matcher)
          return unless node && yield(node.child_time_frame)
    
          add_matching(node.left_child, result, &matcher)
          result << node.item if yield(node.time_frame)
    Severity: Minor
    Found in lib/time_frame/collection.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