lib/workers/query_swn_for_acknowledgments_worker.rb
Method query
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
Open
def query(args = nil)
alert_classes = Alert.child_classes
alert_classes.each do |alert_class|
alert_class.active.has_acknowledge.find_each do |alert|
next if alert.alert_attempts.with_device('Device::PhoneDevice').not_acknowledged.size == 0 && alert.alert_attempts.with_device('Device::EmailDevice').not_acknowledged.size == 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 processAcknowledgmentStatus
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
Open
def processAcknowledgmentStatus alert, rcptStatus = nil, time_offset = 0
return false if rcptStatus.nil? || rcptStatus['id'].blank?
user = User.find_by_id(rcptStatus['id'])
if user.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 query
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def query(args = nil)
alert_classes = Alert.child_classes
alert_classes.each do |alert_class|
alert_class.active.has_acknowledge.find_each do |alert|
next if alert.alert_attempts.with_device('Device::PhoneDevice').not_acknowledged.size == 0 && alert.alert_attempts.with_device('Device::EmailDevice').not_acknowledged.size == 0
Method processAcknowledgmentStatus
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def processAcknowledgmentStatus alert, rcptStatus = nil, time_offset = 0
return false if rcptStatus.nil? || rcptStatus['id'].blank?
user = User.find_by_id(rcptStatus['id'])
if user.nil?
Avoid too many return
statements within this method. Open
Open
return false