Showing 26 of 28 total issues
Method should_notify_on_exception?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def should_notify_on_exception?(exception, status_cd = nil, verbose = false)
# don't notify (email or web hooks) on exceptions raised locally
verbose && ExceptionNotification::Notifier.config[:skip_local_notification] && is_local? ?
puts("[NOTIFY LOCALLY] NO") :
nil
- 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 rescue_with_handler
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def rescue_with_handler(exception)
to_return = super
# Not sure how to do this. We aren't supposed to rely on the return value of the super handler.
#if to_return
verbose = self.class.exception_notifiable_verbose && respond_to?(:logger) && !logger.nil?
- 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 sections_for_email
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.sections_for_email(rejected_sections, request)
rejected_sections = rejected_sections.nil? ? request.nil? ? %w(request session) : [] : rejected_sections
rejected_sections.empty? ? config[:sections] : config[:sections].reject{|s| rejected_sections.include?(s) }
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 rescue_with_hooks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def rescue_with_hooks(exception)
verbose = self.class.notifiable_verbose && respond_to?(:logger) && !logger.nil?
logger.info("[RESCUE STYLE] rescue_with_hooks") if verbose
data = get_exception_data
# With ExceptionNotifiable you have an inherent request, and using a status code makes sense.
- 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 too many return
statements within this method. Open
return ExceptionNotification::Notifier.config[:notify_other_errors]
Method build_web_hook_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.build_web_hook_params(config, exception, controller, request, data={}, the_blamed = nil)
host = (request.env["HTTP_X_FORWARDED_HOST"] || request.env["HTTP_HOST"])
p = {
'environment' => (defined?(Rails) ? Rails.env : RAILS_ENV),
'exceptions' => [{
- 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"