talho/openphin

View on GitHub
lib/workers/query_swn_for_acknowledgments_worker.rb

Summary

Maintainability
D
1 day
Test Coverage

Method query has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
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
Severity: Minor
Found in lib/workers/query_swn_for_acknowledgments_worker.rb - About 6 hrs to fix

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

  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?
Severity: Minor
Found in lib/workers/query_swn_for_acknowledgments_worker.rb - About 4 hrs to fix

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

  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
Severity: Major
Found in lib/workers/query_swn_for_acknowledgments_worker.rb - About 2 hrs to fix

    Method processAcknowledgmentStatus has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    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?
    Severity: Minor
    Found in lib/workers/query_swn_for_acknowledgments_worker.rb - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

                  return false
      Severity: Major
      Found in lib/workers/query_swn_for_acknowledgments_worker.rb - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status