khiav223577/multi_range

View on GitHub

Showing 10 of 13 total issues

Method search_s_center has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

      def search_s_center(query)
        s_center.select do |range|
          # when this range is smaller than and not overlaps with `query`
          #      range          query
          #   |---------|    |---------|
Severity: Minor
Found in lib/patches/patch_interval_tree.rb - About 3 hrs 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 merge_overlaps has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def merge_overlaps(merge_same_value = true)
    return MultiRange.new([]) if @ranges.size == 0

    new_ranges = []
    current_range = nil
Severity: Minor
Found in lib/multi_range.rb - About 2 hrs 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

Class MultiRange has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

class MultiRange
  INDEX_WITH_DEFAULT = Object.new

  attr_reader :ranges

Severity: Minor
Found in lib/multi_range.rb - About 2 hrs to fix

    Method possible_sub_ranges_of has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def possible_sub_ranges_of(range, other)
        sub_range1 = range.begin...other.begin if other.begin
    
        if other.end
          sub_range2_begin = if other.exclude_end?
    Severity: Minor
    Found in lib/multi_range.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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def initialize(ranges)
        if ranges.is_a? MultiRange
          @ranges = ranges.ranges
          @is_float = ranges.is_float?
        else
    Severity: Minor
    Found in lib/multi_range.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 search has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def search(query, options = {})
            options = IntervalTree::Tree::DEFAULT_OPTIONS.merge(options)
    
            return nil unless @top_node
    
    
    Severity: Minor
    Found in lib/patches/patch_interval_tree.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 divide_intervals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def divide_intervals(intervals)
            return nil if intervals.empty?
            x_center = center(intervals)
            s_center = []
            s_left = []
    Severity: Minor
    Found in lib/patches/patch_interval_tree.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

    Avoid too many return statements within this method.
    Open

        return range1.end + 1 >= range2.begin
    Severity: Major
    Found in lib/multi_range.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return range2
      Severity: Major
      Found in lib/multi_range.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return range1 if range1.exclude_end?
        Severity: Major
        Found in lib/multi_range.rb - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language