Showing 3 of 3 total issues
Method valid?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def valid?(ean)
return false if ean.blank?
return false unless ean =~ /^\d+$/
return false unless (8..13).include?(ean.length)
return false unless calc_check_digit(ean)
- 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 email_format_valid?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def email_format_valid?(email)
domain, local = email.reverse.split('@', 2)
return false if domain.blank? || local.blank?
return false if email.length > MAX_EMAIL_LENGTH
- 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 email_domain_syntax_valid?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def email_domain_syntax_valid?(domain)
parts = domain.reverse.downcase.gsub(/(?:^\[(.+)\]$)/,'\1').split('.', -1)
return false if parts.size == 1 && options[:reject_one_level_domain]
return false unless parts.all? { |part| part =~ /^(?!\-)[[:alnum:]\-]+(?<!\-)$/ && part.length < MAX_DOMAIN_PART_LENGTH }
- 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"