Showing 12 of 12 total issues
Method validate_each
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
if value.is_a? Array
value.each_with_index do |element, index|
if element.is_a? Array
if element.length != 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 validate_each
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
if value.is_a? Array
value.each_with_index do |element, index|
if element.is_a? Array
if element.length != 2
Method visitor
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def visitor(klass)
visitor = visitor_by_module[klass]
unless visitor
klass.ancestors.each do |mod|
- 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 children
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def children(formatted_value)
if formatted_value.include? '-'
head, tail = formatted_value.split('-', 2)
if head.casecmp('URL') == 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 validate_each
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(object, attribute, value)
error_message_block = lambda{ object.errors.add attribute, "must be a valid (IP or hostname) address" }
begin
# Checks for valid IP addresses
if value.is_a? IPAddr
- 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 children
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def children(formatted_value)
if formatted_value.include? '-'
head, tail = formatted_value.split('-', 2)
if head.casecmp('URL') == 0
Method mutate_pass
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def mutate_pass(password)
mutations = {
'a' => '@',
'o' => '0',
'e' => '3',
- 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
Avoid deeply nested control flow statements. Open
unless parameter_name.present?
error = error_at(
:element => element,
:index => index,
:prefix => "has blank parameter name"
Method merge
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.merge(first_expanded, second_expanded)
if first_expanded.nil? && second_expanded.nil?
nil
elsif !first_expanded.nil? && second_expanded.nil?
first_expanded
- 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 validate_each
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(object, attribute, value)
error_message_block = lambda{ object.errors.add attribute, "must be a valid IPv4 or IPv6 address" }
begin
if value.is_a? IPAddr
potential_ip = value.dup
- 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 constant_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.constant_name(type)
case type
when Hash
if type.length < 1
raise ArgumentError, "Cannot destructure a Hash without entries"
- 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 validate_each
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
return if value.blank?
if is_simple?(value)
record.errors.add attribute, 'must contain letters, numbers, and at least one special character'
- 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"