lib/money/money.rb
Class Money
has 45 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Money
include Comparable
include Money::Arithmetic
extend Constructors
File money.rb
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require "money/bank/variable_exchange"
require "money/bank/single_currency"
require "money/money/arithmetic"
require "money/money/constructors"
require "money/money/formatter"
Method initialize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
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 as_d
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
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"