SciRuby/distribution

View on GitHub
lib/distribution/math_extension/incomplete_beta.rb

Summary

Maintainability
D
2 days
Test Coverage

Method evaluate has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

        def evaluate(a, b, x, with_error = false)
          fail(ArgumentError, "Domain error: a(#{a}), b(#{b}) must be positive; x(#{x}) must be between 0 and 1, inclusive") if a <= 0 || b <= 0 || x < 0 || x > 1
          if x == 0
            return with_error ? [0.0, 0.0] : 0.0
          elsif x == 1
Severity: Minor
Found in lib/distribution/math_extension/incomplete_beta.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 log_beta has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

        def log_beta(x, y, with_error = false)
          sign = nil

          fail(ArgumentError, 'x and y must be nonzero') if x == 0.0 || y == 0.0
          fail(ArgumentError, 'not defined for negative integers') if [x, y].any? { |v| v < 0 }
Severity: Minor
Found in lib/distribution/math_extension/incomplete_beta.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 continued_fraction has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

        def continued_fraction(a, b, x, epsabs = nil, with_error = false)
          num_term = 1
          den_term = 1 - (a + b) * x.quo(a + 1)
          k        = 0

Severity: Minor
Found in lib/distribution/math_extension/incomplete_beta.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 log_beta has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def log_beta(x, y, with_error = false)
          sign = nil

          fail(ArgumentError, 'x and y must be nonzero') if x == 0.0 || y == 0.0
          fail(ArgumentError, 'not defined for negative integers') if [x, y].any? { |v| v < 0 }
Severity: Minor
Found in lib/distribution/math_extension/incomplete_beta.rb - About 1 hr to fix

    Method evaluate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def evaluate(a, b, x, with_error = false)
              fail(ArgumentError, "Domain error: a(#{a}), b(#{b}) must be positive; x(#{x}) must be between 0 and 1, inclusive") if a <= 0 || b <= 0 || x < 0 || x > 1
              if x == 0
                return with_error ? [0.0, 0.0] : 0.0
              elsif x == 1
    Severity: Minor
    Found in lib/distribution/math_extension/incomplete_beta.rb - About 1 hr to fix

      Method continued_fraction has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def continued_fraction(a, b, x, epsabs = nil, with_error = false)
                num_term = 1
                den_term = 1 - (a + b) * x.quo(a + 1)
                k        = 0
      
      
      Severity: Minor
      Found in lib/distribution/math_extension/incomplete_beta.rb - About 1 hr to fix

        Method continued_fraction has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def continued_fraction(a, b, x, epsabs = nil, with_error = false)
        Severity: Minor
        Found in lib/distribution/math_extension/incomplete_beta.rb - About 35 mins to fix

          Method axpy has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def axpy(aa, yy, a, b, x)
          Severity: Minor
          Found in lib/distribution/math_extension/incomplete_beta.rb - About 35 mins to fix

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

                    def axpy(aa, yy, a, b, x)
                      return aa * 0 + yy if x == 0.0
                      return aa * 1 + yy if x == 1.0
            
                      ln_beta   = Math.logbeta(a, b)
            Severity: Minor
            Found in lib/distribution/math_extension/incomplete_beta.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