Showing 3 of 3 total issues
Method extract_major_minor_with_single_delimiter
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def extract_major_minor_with_single_delimiter(num, currency, delimiter)
if expect_whole_subunits?
possible_major, possible_minor = split_major_minor(num, delimiter)
if minor_has_correct_dp_for_currency_subunit?(possible_minor, currency)
split_major_minor(num, delimiter)
- 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 extract_major_minor_with_tentative_delimiter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def extract_major_minor_with_tentative_delimiter(num, delimiter)
if num.scan(delimiter).length > 1
# Multiple matches; treat as thousands separator
[num.gsub(delimiter, ''), '00']
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"
Further reading
Method to_money
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_money(currency = nil)
money_hash = self.respond_to?(:with_indifferent_access) ? self.with_indifferent_access : self
hash_currency = if money_hash[:currency].is_a?(Hash)
money_hash[:currency][:iso_code]
- 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"