InWork/queue_dispatcher

View on GitHub
lib/queue_dispatcher/acts_as_task_queue.rb

Summary

Maintainability
F
3 days
Test Coverage

Method run! has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
Open

      def run!(args = {})
        task          = nil
        @logger       = args[:logger] || Logger.new("#{File.expand_path(Rails.root)}/log/task_queue.log")
        finish_state  = 'aborted'
        task_queue    = self
Severity: Minor
Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 1 day 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

File acts_as_task_queue.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'sys/proctable'
require 'queue_dispatcher/rc_and_msg'

module QueueDispatcher
  module ActsAsTaskQueue
Severity: Minor
Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 3 hrs to fix

    Method run! has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def run!(args = {})
            task          = nil
            @logger       = args[:logger] || Logger.new("#{File.expand_path(Rails.root)}/log/task_queue.log")
            finish_state  = 'aborted'
            task_queue    = self
    Severity: Major
    Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 3 hrs to fix

      Method determine_state_of_task_array has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

            def determine_state_of_task_array(task_array)
              successful = true
              new = true
              pending = false
              error = false
      Severity: Minor
      Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 2 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 pop has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def pop(args = {})
              task      = nil
              log_debug = acts_as_task_queue_config.debug
      
              transaction do
      Severity: Minor
      Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 2 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 task_states has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def task_states
              states = determine_state_of_task_array acts_as_task_queue_tasks
      
              if states[:empty]
                nil
      Severity: Minor
      Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 1 hr 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 determine_state_of_task_array has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def determine_state_of_task_array(task_array)
              successful = true
              new = true
              pending = false
              error = false
      Severity: Minor
      Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                        if task.dependent_tasks_had_errors
                          error_msg = 'Dependent tasks had errors!'
                          log :msg => error_msg,
                              :sev => :warn, 
                              :print_log => print_log
        Severity: Major
        Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 45 mins to fix

          Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(args)
                  @task_class_name               = (args[:task_model] || :task).to_s.underscore
                  @leave_finished_tasks_in_queue = args[:leave_finished_tasks_in_queue].nil? ? false : args[:leave_finished_tasks_in_queue]
                  @leave_running_tasks_in_queue  = args[:leave_running_tasks_in_queue].nil? ? false : args[:leave_running_tasks_in_queue]
                  @leave_running_tasks_in_queue  = true if @leave_finished_tasks_in_queue
          Severity: Minor
          Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 35 mins 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 get_next_pending has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def get_next_pending
                  task_queue = nil
          
                  transaction do
                    # Find next task_queue which is not running and not in state error
          Severity: Minor
          Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 35 mins 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 reset_immediately! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def reset_immediately!
                  self.where('state != ?', 'heartbeat').each do |tq|
                    tq.update_attributes state: 'aborted'
          
                    # Kill the TaskQueue with SIGKILL
          Severity: Minor
          Found in lib/queue_dispatcher/acts_as_task_queue.rb - About 35 mins 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

          There are no issues that match your filters.

          Category
          Status