collectiveidea/delayed_job

View on GitHub

Showing 15 of 21 total issues

File shared_spec.rb has 604 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require File.expand_path('../../../../spec/sample_jobs', __FILE__)

require 'active_support/core_ext/numeric/time'

shared_examples_for 'a delayed_job backend' do
Severity: Major
Found in lib/delayed/backend/shared_spec.rb - About 1 day to fix

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

      class Worker # rubocop:disable ClassLength
        DEFAULT_LOG_LEVEL        = 'info'.freeze
        DEFAULT_SLEEP_DELAY      = 5
        DEFAULT_MAX_ATTEMPTS     = 25
        DEFAULT_MAX_RUN_TIME     = 4.hours
    Severity: Minor
    Found in lib/delayed/worker.rb - About 3 hrs to fix

      Method visit_Psych_Nodes_Mapping has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def visit_Psych_Nodes_Mapping(object) # rubocop:disable CyclomaticComplexity, MethodName, PerceivedComplexity
              klass = Psych.load_tags[object.tag]
              if klass
                # Implementation changed here https://github.com/ruby/psych/commit/2c644e184192975b261a81f486a04defa3172b3f
                # load_tags used to have class values, now the values are strings
      Severity: Minor
      Found in lib/delayed/psych_ext.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 start has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def start # rubocop:disable CyclomaticComplexity, PerceivedComplexity
            trap('TERM') do
              Thread.new { say 'Exiting...' }
              stop
              raise SignalException, 'TERM' if self.class.raise_signal_exceptions
      Severity: Minor
      Found in lib/delayed/worker.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 initialize has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(args) # rubocop:disable MethodLength
            @options = {
              :quiet => true,
              :pid_dir => "#{root}/tmp/pids",
              :log_dir => "#{root}/log"
      Severity: Major
      Found in lib/delayed/command.rb - About 2 hrs to fix

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

        require 'timeout'
        require 'active_support/dependencies'
        require 'active_support/core_ext/kernel/reporting'
        require 'active_support/core_ext/numeric/time'
        require 'active_support/core_ext/class/attribute_accessors'
        Severity: Minor
        Found in lib/delayed/worker.rb - About 2 hrs to fix

          Method visit_Psych_Nodes_Mapping has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def visit_Psych_Nodes_Mapping(object) # rubocop:disable CyclomaticComplexity, MethodName, PerceivedComplexity
                  klass = Psych.load_tags[object.tag]
                  if klass
                    # Implementation changed here https://github.com/ruby/psych/commit/2c644e184192975b261a81f486a04defa3172b3f
                    # load_tags used to have class values, now the values are strings
          Severity: Major
          Found in lib/delayed/psych_ext.rb - About 2 hrs to fix

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

                def handle_asynchronously(method, opts = {}) # rubocop:disable PerceivedComplexity
                  aliased_method = method.to_s.sub(/([?!=])$/, '')
                  punctuation = $1 # rubocop:disable PerlBackrefs
                  with_method = "#{aliased_method}_with_delay#{punctuation}"
                  without_method = "#{aliased_method}_without_delay#{punctuation}"
            Severity: Minor
            Found in lib/delayed/message_sending.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 daemonize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def daemonize # rubocop:disable PerceivedComplexity
                  dir = @options[:pid_dir]
                  FileUtils.mkdir_p(dir) unless File.exist?(dir)
            
                  if worker_pools
            Severity: Minor
            Found in lib/delayed/command.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 start has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def start # rubocop:disable CyclomaticComplexity, PerceivedComplexity
                  trap('TERM') do
                    Thread.new { say 'Exiting...' }
                    stop
                    raise SignalException, 'TERM' if self.class.raise_signal_exceptions
            Severity: Minor
            Found in lib/delayed/worker.rb - About 1 hr to fix

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

                    def hook(name, *args)
                      if payload_object.respond_to?(name)
                        method = payload_object.method(name)
                        method.arity.zero? ? method.call : method.call(self, *args)
                      end
              Severity: Minor
              Found in lib/delayed/backend/base.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 before_fork has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.before_fork
                    unless @files_to_reopen
                      @files_to_reopen = []
                      ObjectSpace.each_object(File) do |file|
                        @files_to_reopen << file unless file.closed?
              Severity: Minor
              Found in lib/delayed/worker.rb - About 25 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 max_run_time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def max_run_time
                      return unless payload_object.respond_to?(:max_run_time)
                      return unless (run_time = payload_object.max_run_time)
              
                      if run_time > Delayed::Worker.max_run_time
              Severity: Minor
              Found in lib/delayed/backend/base.rb - About 25 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 say has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def say(text, level = default_log_level)
                    text = "[Worker(#{name})] #{text}"
                    puts text unless @quiet
                    return unless logger
                    # TODO: Deprecate use of Fixnum log levels
              Severity: Minor
              Found in lib/delayed/worker.rb - About 25 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 work_off has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def work_off(num = 100)
                    success = 0
                    failure = 0
              
                    num.times do
              Severity: Minor
              Found in lib/delayed/worker.rb - About 25 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