Showing 74 of 98 total issues
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
- Read upRead up
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 cdf
has 43 lines of code (exceeds 25 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
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 }
Method cdf
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def cdf(z)
return 0.0 if z < -12
return 1.0 if z > 12
return 0.5 if z == 0.0
- Read upRead up
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_1plusx
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def log_1plusx(x, with_error = false)
fail(ArgumentError, 'Range error: x must be > -1') if x <= -1
if x.abs < Math::ROOT6_FLOAT_EPSILON
result = x * (1.0 + x * (C1 + x * (C2 + x * (C3 + x * (C4 + x * begin
- Read upRead up
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 f_continued_fraction
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def f_continued_fraction(a, x, with_error = false)
hn = 1.0 # convergent
cn = 1.0 / SMALL
dn = 1.0
n = 2
- Read upRead up
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 q_large_x
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def q_large_x(a, x, with_error = false)
d = d(a, x, with_error)
d, d_err = d if with_error
sum = 1.0
term = 1.0
- Read upRead up
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 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
Method quantile
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def quantile(probability, n, m)
return Float::NAN if n <= 0.0 || m <= 0.0
if n == Float::INFINITY || n == -Float::INFINITY || m == Float::INFINITY || m == -Float::INFINITY
return 1.0
- Read upRead up
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 ptsub
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def ptsub(q, n)
q = q.to_f
if n == 1 && 0.001 < q && q < 0.01
eps = 1.0e-4
elsif n == 2 && q < 0.0001
- Read upRead up
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 evaluate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def evaluate(x, with_error = false)
ax = x.abs
e = nil
if ax <= 1.0
Method evaluate
has 29 lines of code (exceeds 25 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
Method cdf_hull
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cdf_hull(a, b, rho)
# puts "a:#{a} - b:#{b} - rho:#{rho}"
if a <= 0 && b <= 0 && rho <= 0
# puts "ruta 1"
aprime = a.quo(Math.sqrt(2.0 * (1.0 - rho**2)))
Method unnormalized
has 28 lines of code (exceeds 25 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)
Method cdf_jantaravareerat
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def cdf_jantaravareerat(x, y, rho, s1 = 1, s2 = 1)
# Special cases
return 1 if x > LIMIT && y > LIMIT
return 0 if x < -LIMIT || y < -LIMIT
return Distribution::Normal.cdf(y) if x > LIMIT
- Read upRead up
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 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
Method d
has 26 lines of code (exceeds 25 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
Method q
has 26 lines of code (exceeds 25 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
Method cdf_hull
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def cdf_hull(a, b, rho)
# puts "a:#{a} - b:#{b} - rho:#{rho}"
if a <= 0 && b <= 0 && rho <= 0
# puts "ruta 1"
aprime = a.quo(Math.sqrt(2.0 * (1.0 - rho**2)))
- Read upRead up
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 p_series
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def p_series(a, x, with_error = false)
d = d(a, x, with_error)
d, d_err = d if with_error
sum = 1.0
term = 1.0
- Read upRead up
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"