khiav223577/multi_range

View on GitHub

Showing 12 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                    if query.begin and range.end
                      next false if query.begin > range.end
                      next false if query.begin == range.end and range.exclude_end?
                    end
          Severity: Minor
          Found in lib/patches/patch_interval_tree.rb and 1 other location - About 15 mins to fix
          lib/patches/patch_interval_tree.rb on lines 77..80

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 26.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                    if query.end and range.begin
                      next false if query.end < range.begin
                      next false if query.end == range.begin and query.exclude_end?
                    end
          Severity: Minor
          Found in lib/patches/patch_interval_tree.rb and 1 other location - About 15 mins to fix
          lib/patches/patch_interval_tree.rb on lines 69..72

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 26.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language