resque/resque

View on GitHub

Showing 32 of 32 total issues

Class Worker has 78 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Worker
    include Resque::Helpers
    extend Resque::Helpers
    include Resque::Logging

Severity: Major
Found in lib/resque/worker.rb - About 1 day to fix

    File worker.rb has 618 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'time'
    require 'set'
    require 'redis/distributed'
    
    module Resque
    Severity: Major
    Found in lib/resque/worker.rb - About 1 day to fix

      File resque.rb has 309 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'mono_logger'
      require 'redis/namespace'
      require 'forwardable'
      
      require 'resque/version'
      Severity: Minor
      Found in lib/resque.rb - About 3 hrs to fix

        Class Job has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Job
            include Helpers
            extend Helpers
            def redis
              Resque.redis
        Severity: Minor
        Found in lib/resque/job.rb - About 3 hrs to fix

          Method prune_dead_workers has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def prune_dead_workers
                return unless data_store.acquire_pruning_dead_worker_lock(self, Resque.heartbeat_interval)
          
                all_workers = Worker.all
          
          
          Severity: Minor
          Found in lib/resque/worker.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 new_kill_child has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def new_kill_child
                if @child
                  unless child_already_exited?
                    if pre_shutdown_timeout && pre_shutdown_timeout > 0.0
                      log_with_severity :debug, "Waiting #{pre_shutdown_timeout.to_f}s for child process to exit"
          Severity: Minor
          Found in lib/resque/worker.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 work has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def work(interval = 5.0, &block)
                interval = Float(interval)
                startup
          
                loop do
          Severity: Minor
          Found in lib/resque/worker.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 page_entries_info has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

            def page_entries_info(start, stop, size, name = nil)
              if size == 0
                name ? "No #{name}s" : '<b>0</b>'
              elsif size == 1
                'Showing <b>1</b>' + (name ? " #{name}" : '')
          Severity: Minor
          Found in lib/resque/server/helpers.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

          Class Server has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Server < Sinatra::Base
              require 'resque/server/helpers'
          
              dir = File.dirname(File.expand_path(__FILE__))
          
          
          Severity: Minor
          Found in lib/resque/server.rb - About 2 hrs to fix

            File data_store.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Resque
              # An interface between Resque's persistence and the actual
              # implementation.
              class DataStore
                extend Forwardable
            Severity: Minor
            Found in lib/resque/data_store.rb - About 2 hrs to fix

              Method perform has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def perform
                    job = payload_class
                    job_args = args || []
                    job_was_performed = false
              
              
              Severity: Minor
              Found in lib/resque/job.rb - About 1 hr to fix

                Method unregister_worker has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def unregister_worker(exception = nil)
                      # If we're still processing a job, make sure it gets logged as a
                      # failure.
                      if (hash = processing) && !hash.empty?
                        job = Job.new(hash['queue'], hash['payload'])
                Severity: Minor
                Found in lib/resque/worker.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 each has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                      def self.each(offset = 0, limit = self.count, queue = :failed, class_name = nil, order = 'desc')
                        if class_name
                          original_limit = limit
                          limit = count
                        end
                Severity: Minor
                Found in lib/resque/failure/redis.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 each has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                      def self.each(offset = 0, limit = self.count, queue = :failed, class_name = nil, order = 'desc')
                        items = all(offset, limit, queue)
                        items = [items] unless items.is_a? Array
                        reversed = false
                        if order.eql? 'desc'
                Severity: Minor
                Found in lib/resque/failure/redis_multi_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 working has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.working
                      names = all
                      return [] unless names.any?
                
                      reportedly_working = {}
                Severity: Minor
                Found in lib/resque/worker.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 perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def perform
                      job = payload_class
                      job_args = args || []
                      job_was_performed = false
                
                
                Severity: Minor
                Found in lib/resque/job.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 constantize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def constantize(camel_cased_word)
                    camel_cased_word = camel_cased_word.to_s
                
                    if camel_cased_word.include?('-')
                      camel_cased_word = classify(camel_cased_word)
                Severity: Minor
                Found in lib/resque.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 run_hook has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def run_hook(name, *args)
                      hooks = Resque.send(name)
                      return if hooks.empty?
                      return if name == :before_first_fork && @before_first_fork_hook_ran
                      msg = "Running #{name} hooks"
                Severity: Minor
                Found in lib/resque/worker.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 perform_with_fork has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def perform_with_fork(job, &block)
                      run_hook :before_fork, job
                
                      begin
                        @child = fork do
                Severity: Minor
                Found in lib/resque/worker.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

                Method each has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def self.each(offset = 0, limit = self.count, queue = nil, class_name = nil, order = 'desc', &block)
                Severity: Minor
                Found in lib/resque/failure.rb - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language