# SciRuby/distribution

### Showing 74 of 98 total issues

#### Method `first_order` has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open

``````        def first_order(x, scale = 0, with_error = false)
xmaxt = -Math::LOG_FLOAT_MIN
xmax  = xmaxt - Math.log(xmaxt)
result = nil
error  = with_error ? nil : 0.0``````
Found in lib/distribution/math_extension/exponential_integral.rb - About 1 day 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"

#### File `chebyshev_series.rb` has 397 lines of code (exceeds 250 allowed). Consider refactoring. Open

``````module Distribution
module MathExtension
class ChebyshevSeries
DATA = { lopx: [2.16647910664395270521272590407,``````
Found in lib/distribution/math_extension/chebyshev_series.rb - About 5 hrs to fix

#### 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``````
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"

#### Method `cdf_genz` has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````        def cdf_genz(x, y, rho)
dh = -x
dk = -y
r = rho
twopi = 6.283185307179586``````
Found in lib/distribution/bivariatenormal/ruby.rb - About 4 hrs to fix

#### Method `q` has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open

``````        def q(a, x, with_error = false)
fail(ArgumentError, 'Range Error: a and x must be non-negative') if a < 0.0 || x < 0.0
if x == 0.0
return with_error ? [1.0, 0.0] : 1.0
elsif a == 0.0``````
Found in lib/distribution/math_extension/incomplete_gamma.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"

#### File `incomplete_gamma.rb` has 340 lines of code (exceeds 250 allowed). Consider refactoring. Open

``````module Distribution
module MathExtension
module IncompleteGamma
NMAX  = 5000
SMALL = Float::EPSILON**3``````
Found in lib/distribution/math_extension/incomplete_gamma.rb - About 4 hrs to fix

#### Method `cdf_genz` has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open

``````        def cdf_genz(x, y, rho)
dh = -x
dk = -y
r = rho
twopi = 6.283185307179586``````
Found in lib/distribution/bivariatenormal/ruby.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"

#### 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 }``````
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"

#### Method `q_series` has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````        def q_series(a, x, with_error = false)
term1 = nil
sum   = nil
term2 = nil
begin``````
Found in lib/distribution/math_extension/incomplete_gamma.rb - About 3 hrs to fix

#### Method `d` has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open

``````        def d(a, x, with_error = false)
error = nil
if a < 10.0
ln_a = Math.lgamma(a + 1.0).first
lnr  = a * Math.log(x) - x - ln_a``````
Found in lib/distribution/math_extension/incomplete_gamma.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"

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

``````        def evaluate(x, with_error = false)
ax = x.abs
e = nil

if ax <= 1.0``````
Found in lib/distribution/math_extension/erfc.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"

#### 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

``````
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"

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

``````        def evaluate(x, with_error = false)
fail(ArgumentError, 'x must be positive') if x <= 0
if x < 0.5
STDERR.puts("Warning: Don't know error on lg_x, error for this function will be incorrect") if with_error
lg = Math.lgamma(x).first``````
Found in lib/distribution/math_extension/gammastar.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"

#### Method `unnormalized` has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open

``````        def unnormalized(a, x, with_error = false)
fail(ArgumentError, 'x cannot be negative') if x < 0.0

if x == 0.0
result  = Math.gamma(a.to_f)``````
Found in lib/distribution/math_extension/incomplete_gamma.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"

#### Method `swing` has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open

``````      def swing(n)
return SmallOddSwing[n] if n < 33
sqrtN = Math.sqrt(n).floor
count = 0

``````
Found in lib/distribution/math_extension.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"

#### Method `cdf` has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open

``````      def cdf(aa, bb, sigma, epsilon = 0.0001, alpha = 2.5, max_iterations = 100) # :nodoc:
fail "Doesn't work yet"
a = [nil] + aa
b = [nil] + bb
m = aa.size``````
Found in lib/distribution/normalmultivariate.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"

#### Method `p` has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open

``````        def p(a, x, with_error = false)
fail(ArgumentError, 'Range Error: a must be positive, x must be non-negative') if a <= 0.0 || x < 0.0
if x == 0.0
return with_error ? [0.0, 0.0] : 0.0
elsif x < 20.0 || x < 0.5 * a``````
Found in lib/distribution/math_extension/incomplete_gamma.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"

#### Method `first_order` has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````        def first_order(x, scale = 0, with_error = false)
xmaxt = -Math::LOG_FLOAT_MIN
xmax  = xmaxt - Math.log(xmaxt)
result = nil
error  = with_error ? nil : 0.0``````
Found in lib/distribution/math_extension/exponential_integral.rb - About 2 hrs to fix

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

``````        def log_1plusx_minusx(x, with_error = false)
fail(ArgumentError, 'Range error: x must be > -1') if x <= -1

if x.abs < Math::ROOT5_FLOAT_EPSILON
result = x * x * (C1 + x * (C2 + x * (C3 + x * (C4 + x * begin``````
Found in lib/distribution/math_extension/log_utilities.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"

#### Method `quantile` has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open

``````        def quantile(p, a, b, rmin = 0, rmax = 1)
fail 'a <= 0' if a <= 0
fail 'b <= 0' if b <= 0
fail 'rmin == rmax' if rmin == rmax
fail 'p <= 0' if p <= 0``````
Found in lib/distribution/beta/ruby.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"