rubinius/rubinius

View on GitHub
core/range.rb

Summary

Maintainability
D
2 days
Test Coverage

Method bsearch has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def bsearch
    return to_enum :bsearch unless block_given?

    unless @begin.kind_of? Numeric and @end.kind_of? Numeric
      raise TypeError, "bsearch is not available for #{@begin.class}"
Severity: Minor
Found in core/range.rb - About 4 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 each has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def each
    return to_enum { size } unless block_given?
    first, last = @begin, @end

    unless first.respond_to?(:succ) && !first.kind_of?(Time)
Severity: Minor
Found in core/range.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 size has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def size
    return nil unless @begin.kind_of?(Numeric)

    delta = @end - @begin
    return 0 if delta < 0
Severity: Minor
Found in core/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

Method bsearch has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def bsearch
    return to_enum :bsearch unless block_given?

    unless @begin.kind_of? Numeric and @end.kind_of? Numeric
      raise TypeError, "bsearch is not available for #{@begin.class}"
Severity: Major
Found in core/range.rb - About 2 hrs to fix

    Method step has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def step(step_size=1) # :yields: object
        return to_enum(:step, step_size) do
          m = Rubinius::Mirror::Range.reflect(self)
          m.step_iterations_size(*m.validate_step_size(@begin, @end, step_size))
        end unless block_given?
    Severity: Minor
    Found in core/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 each has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def each
        return to_enum { size } unless block_given?
        first, last = @begin, @end
    
        unless first.respond_to?(:succ) && !first.kind_of?(Time)
    Severity: Minor
    Found in core/range.rb - About 1 hr to fix

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

        def max
          return super if block_given? || (@excl && !@end.kind_of?(Numeric))
          return nil if @end < @begin || (@excl && @end == @begin)
          return @end unless @excl
      
      
      Severity: Minor
      Found in core/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 step has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def step(step_size=1) # :yields: object
          return to_enum(:step, step_size) do
            m = Rubinius::Mirror::Range.reflect(self)
            m.step_iterations_size(*m.validate_step_size(@begin, @end, step_size))
          end unless block_given?
      Severity: Minor
      Found in core/range.rb - About 1 hr to fix

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

          def initialize(first, last, exclude_end = false)
            raise NameError, "`initialize' called twice" if @begin
        
            unless first.kind_of?(Fixnum) && last.kind_of?(Fixnum)
              begin
        Severity: Minor
        Found in core/range.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 cover? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def cover?(value)
            # MRI uses <=> to compare, so must we.
        
            beg_compare = (@begin <=> value)
            return false unless beg_compare
        Severity: Minor
        Found in core/range.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 to_a has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def to_a
            return super unless @begin.kind_of? Fixnum and @end.kind_of? Fixnum
        
            fin = @end
            fin += 1 unless @excl
        Severity: Minor
        Found in core/range.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 @begin if last_true == start
        Severity: Major
        Found in core/range.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return @begin.kind_of?(Float) ? last_true.to_f : last_true
          Severity: Major
          Found in core/range.rb - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status