rubinius/rubinius

View on GitHub
core/numeric.rb

Summary

Maintainability
D
2 days
Test Coverage

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

  def step(limit=nil, step=nil, to: nil, by: nil)
    unless block_given?
      return to_enum(:step, limit, step, to: to, by: by) do
        Rubinius::Mirror::Numeric.reflect(self).step_size(limit, step, to, by)
      end
Severity: Minor
Found in core/numeric.rb - About 6 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 Numeric has 39 methods (exceeds 20 allowed). Consider refactoring.
Open

class Numeric
  include Comparable

  # Always raises TypeError, as dup'ing Numerics is not allowed.
  def initialize_copy(other)
Severity: Minor
Found in core/numeric.rb - About 5 hrs to fix

    Method step has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def step(limit=nil, step=nil, to: nil, by: nil)
        unless block_given?
          return to_enum(:step, limit, step, to: to, by: by) do
            Rubinius::Mirror::Numeric.reflect(self).step_size(limit, step, to, by)
          end
    Severity: Major
    Found in core/numeric.rb - About 2 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                  while i < n
                    d = i * step + value
                    d = limit if limit < d
                    yield d
                    i += 1
      Severity: Major
      Found in core/numeric.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    while i < n
                      d = i * step + value
                      d = limit if limit > d
                      yield d
                      i += 1
        Severity: Major
        Found in core/numeric.rb - About 45 mins to fix

          Method math_coerce has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def math_coerce(other, error=:coerce_error)
              begin
                values = other.coerce(self)
              rescue
                if error == :coerce_error
          Severity: Minor
          Found in core/numeric.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

          There are no issues that match your filters.

          Category
          Status