Showing 4 of 4 total issues
Method validate_smtp
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_smtp(hash)
raise ValidationError, "smtp::host missing or invalid" unless hash.has_key?('host') && ValidationUtils.valid_hostname?(hash['host'])
raise ValidationError, "smtp::port missing or invalid" unless hash.has_key?('port') && (hash['port'].to_i != 0)
raise ValidationError, "smtp::username missing" unless hash.has_key? 'username'
raise ValidationError, "smtp::password missing" unless hash.has_key? 'password'
- 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_templates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_templates(hash)
raise ValidationError, "templates::html not specified" unless hash.has_key? 'html'
raise ValidationError, "templates::plain not specified" unless hash.has_key? 'plain'
raise ValidationError, "templates::html not found" unless File.exist?(File.expand_path(hash['html']))
raise ValidationError, "templates::plain not found" unless File.exist?(File.expand_path(hash['plain']))
- 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_recipients
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_recipients(hash)
raise ValidationError, "recipients::csv missing" unless hash.has_key? 'csv'
raise ValidationError, "recipients::csv invalid file path" unless File.exist?(File.expand_path(hash['csv']))
raise ValidationError, "recipients::csv empty" if RecipientParser.empty_csv? hash['csv']
raise ValidationError, "recipients::csv invalid column headers" unless RecipientParser.valid_csv? hash['csv']
- 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 valid_hostname?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def valid_hostname?(hostname)
if !hostname || hostname.length > 255 || hostname.scan('..').any?
return false
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"