Showing 16 of 16 total issues
Class Money
has 45 methods (exceeds 20 allowed). Consider refactoring. Open
class Money
include Comparable
include Money::Arithmetic
extend Constructors
Class Currency
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Currency
include Comparable
extend Enumerable
extend Money::Currency::Heuristics
Method symbol_value_from
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def symbol_value_from(rules)
if rules.has_key?(:symbol)
if rules[:symbol] === true
if rules[:disambiguate] && currency.disambiguate_symbol
currency.disambiguate_symbol
- 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
File money.rb
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "money/bank/variable_exchange"
require "money/bank/single_currency"
require "money/money/arithmetic"
require "money/money/constructors"
require "money/money/formatter"
Method <=>
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def <=>(other)
unless other.is_a?(Money)
return unless other.respond_to?(:zero?) && other.zero?
return other.is_a?(CoercedNumeric) ? 0 <=> fractional : fractional <=> 0
end
- 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 generate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.generate(amount, parts, whole_amounts = true)
parts = if parts.is_a?(Numeric)
Array.new(parts, 1)
elsif parts.all?(&:zero?)
Array.new(parts.count, 1)
- 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 initialize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def initialize( obj, currency = Money.default_currency, options = {})
# For backwards compatability, if options is not a Hash, treat it as a bank parameter
unless options.is_a?(Hash)
options = { bank: options }
end
- 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 append_sign
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def append_sign(formatted_number)
sign = money.negative? ? '-' : ''
if rules[:sign_positive] == true && money.positive?
sign = '+'
- 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 normalize_formatting_rules
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def normalize_formatting_rules(rules)
if rules.size == 0
rules = {}
elsif rules.size == 1
rules = rules.pop
- 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 generate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.generate(amount, parts, whole_amounts = true)
parts = if parts.is_a?(Numeric)
Array.new(parts, 1)
elsif parts.all?(&:zero?)
Array.new(parts.count, 1)
Method remainder
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def remainder(val)
if val.is_a?(Money) && currency != val.currency
val = val.exchange_to(currency)
end
- 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 determine_format_from_formatting_rules
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def determine_format_from_formatting_rules(rules)
return currency.format if currency.format && !rules.has_key?(:symbol_position)
symbol_position = symbol_position_from(rules)
- 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 warn_about_deprecated_rules
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def warn_about_deprecated_rules(rules)
if rules.has_key?(:symbol_position)
position = rules[:symbol_position]
template = position == :before ? '%u%n' : '%n%u'
- 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 as_d
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def as_d(num)
if num.respond_to?(:to_d)
num.is_a?(Rational) ? num.to_d(self.class.conversion_precision) : num.to_d
else
BigDecimal(num.to_s.empty? ? 0 : num.to_s)
- 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 format_decimal_part
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def format_decimal_part(value)
return nil if currency.decimal_places == 0 && !Money.default_infinite_precision
return nil if rules[:no_cents]
return nil if rules[:no_cents_if_whole] && value.to_i == 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 symbol_position_from
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def symbol_position_from(rules)
if rules.has_key?(:symbol_position)
if [:before, :after].include?(rules[:symbol_position])
return rules[:symbol_position]
else
- 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"