InWork/queue_dispatcher

View on GitHub

Showing 23 of 23 total issues

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 my_events has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

          def my_events
            # Remember the selected page, if the AJAX-Request wants to update the current page
            page = session[:my_events_page] = params[:page] if params[:page] || ! request.xhr?
            page = session[:my_events_page] if page.nil? && request.xhr?
            @tasks = current_user.send(self.class.acts_as_task_controller_config.task_class_name.pluralize).order('id DESC').page(page)
    Severity: Minor
    Found in lib/queue_dispatcher/acts_as_task_controller.rb - About 3 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 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 visit_Psych_Nodes_Scalar has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def visit_Psych_Nodes_Scalar(o)
              @st[o.anchor] = o.value if o.anchor
      
              if klass = Psych.load_tags[o.tag]
                instance = klass.allocate
      Severity: Major
      Found in lib/queue_dispatcher/psych_ext.rb - About 2 hrs to fix

        Method visit_Psych_Nodes_Scalar has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def visit_Psych_Nodes_Scalar(o)
                @st[o.anchor] = o.value if o.anchor
        
                if klass = Psych.load_tags[o.tag]
                  instance = klass.allocate
        Severity: Minor
        Found in lib/queue_dispatcher/psych_ext.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 my_events has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def my_events
                # Remember the selected page, if the AJAX-Request wants to update the current page
                page = session[:my_events_page] = params[:page] if params[:page] || ! request.xhr?
                page = session[:my_events_page] if page.nil? && request.xhr?
                @tasks = current_user.send(self.class.acts_as_task_controller_config.task_class_name.pluralize).order('id DESC').page(page)
        Severity: Minor
        Found in lib/queue_dispatcher/acts_as_task_controller.rb - About 1 hr to fix

          Method icon_for_task has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def icon_for_task task
              icon = 'icon_warning.gif'
              alt  = 'Unknwon'
          
              if task.pending?
          Severity: Minor
          Found in app/helpers/tasks_helper.rb - About 1 hr to fix

            Method update_state_and_exec_callbacks has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def update_state_and_exec_callbacks(result, remove_from_queue = false, logger = nil)
                    rc = output = error_msg = nil
            
                    if result.methods.map(&:to_sym).include?(:rc) && result.methods.map(&:to_sym).include?(:output) && result.methods.map(&:to_sym).include?(:error_msg)
                      rc        = result.rc
            Severity: Minor
            Found in lib/queue_dispatcher/acts_as_task.rb - About 1 hr to fix

              Method icon_for_task has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def icon_for_task task
                  icon = 'icon_warning.gif'
                  alt  = 'Unknwon'
              
                  if task.pending?
              Severity: Minor
              Found in app/helpers/tasks_helper.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 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 update_state_and_exec_callbacks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def update_state_and_exec_callbacks(result, remove_from_queue = false, logger = nil)
                      rc = output = error_msg = nil
              
                      if result.methods.map(&:to_sym).include?(:rc) && result.methods.map(&:to_sym).include?(:output) && result.methods.map(&:to_sym).include?(:error_msg)
                        rc        = result.rc
              Severity: Minor
              Found in lib/queue_dispatcher/acts_as_task.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

                Method visit_Psych_Nodes_Mapping_with_class has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def visit_Psych_Nodes_Mapping_with_class(object)
                        return revive(Psych.load_tags[object.tag], object) if Psych.load_tags[object.tag]
                
                        case object.tag
                        when /^!ruby\/ActiveRecord:(.+)$/
                Severity: Minor
                Found in lib/queue_dispatcher/psych_ext.rb - About 1 hr to fix

                  Method visit_Psych_Nodes_Mapping_with_class has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def visit_Psych_Nodes_Mapping_with_class(object)
                          return revive(Psych.load_tags[object.tag], object) if Psych.load_tags[object.tag]
                  
                          case object.tag
                          when /^!ruby\/ActiveRecord:(.+)$/
                  Severity: Minor
                  Found in lib/queue_dispatcher/psych_ext.rb - About 55 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 + has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def +(other)
                        rc_and_msg = self.clone
                        rc_and_msg.rc += other.rc
                        rc_and_msg.output = rc_and_msg.output ? "#{output}\n#{other.output}" : other.output if other.output.present?
                        rc_and_msg.error_msg = rc_and_msg.error_msg ? "#{error_msg}\n#{other.error_msg}" : other.error_msg if other.error_msg.present?
                  Severity: Minor
                  Found in lib/queue_dispatcher/rc_and_msg.rb - About 45 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

                  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

                    Severity
                    Category
                    Status
                    Source
                    Language