mperham/sidekiq

View on GitHub

Showing 45 of 45 total issues

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

    def build_sessions
      middlewares = self.middlewares

      unless using?(::Rack::Protection) || ENV["RACK_ENV"] == "test"
        middlewares.unshift [[::Rack::Protection, {use: :authenticity_token}], nil]
Severity: Minor
Found in lib/sidekiq/web.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 attempt_retry has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def attempt_retry(worker, msg, queue, exception)
      max_retry_attempts = retry_attempts_from(msg["retry"], @max_retries)

      msg["queue"] = (msg["retry_queue"] || queue)

Severity: Minor
Found in lib/sidekiq/job_retry.rb - About 1 hr to fix

    Method process has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def process(work)
          jobstr = work.job
          queue = work.queue_name
    
          # Treat malformed JSON as a special case: job goes straight to the morgue.
    Severity: Minor
    Found in lib/sidekiq/processor.rb - About 1 hr to fix

      Method resolve_class has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def resolve_class(klass_name)
              return nil if !klass_name || klass_name.empty?
              # constantize
              names = klass_name.split("::")
              names.shift if names.empty? || names.first.empty?
      Severity: Minor
      Found in lib/sidekiq/delay.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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def run
            boot_system
            if environment == "development" && $stdout.tty? && Sidekiq.log_formatter.is_a?(Sidekiq::Logger::Formatters::Pretty)
              print_banner
            end
      Severity: Minor
      Found in lib/sidekiq/cli.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 remove_job has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove_job
            Sidekiq.redis do |conn|
              results = conn.multi {
                conn.zrangebyscore(parent.name, score, score)
                conn.zremrangebyscore(parent.name, score, score)
      Severity: Minor
      Found in lib/sidekiq/api.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 run has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def run
            boot_system
            if environment == "development" && $stdout.tty? && Sidekiq.log_formatter.is_a?(Sidekiq::Logger::Formatters::Pretty)
              print_banner
            end
      Severity: Minor
      Found in lib/sidekiq/cli.rb - About 1 hr to fix

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

          def self.redis_info
            redis do |conn|
              # admin commands can't go through redis-namespace starting
              # in redis-namespace 2.0
              if conn.respond_to?(:namespace)
        Severity: Minor
        Found in lib/sidekiq.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 attempt_retry has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def attempt_retry(worker, msg, queue, exception)
              max_retry_attempts = retry_attempts_from(msg["retry"], @max_retries)
        
              msg["queue"] = (msg["retry_queue"] || queue)
        
        
        Severity: Minor
        Found in lib/sidekiq/job_retry.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 global has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def global(jobstr, queue)
              yield
            rescue Handled => ex
              raise ex
            rescue Sidekiq::Shutdown => ey
        Severity: Minor
        Found in lib/sidekiq/job_retry.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 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def each
              Sidekiq.redis do |conn|
                procs = conn.sscan_each("processes").to_a
                procs.sort.each do |key|
                  valid, workers = conn.pipelined {
        Severity: Minor
        Found in lib/sidekiq/api.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 redis has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.redis
            raise ArgumentError, "requires a block" unless block_given?
            redis_pool.with do |conn|
              retryable = true
              begin
        Severity: Minor
        Found in lib/sidekiq.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 raw_push has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def raw_push(payloads)
              if Sidekiq::Testing.fake?
                payloads.each do |job|
                  job = Sidekiq.load_json(Sidekiq.dump_json(job))
                  job["enqueued_at"] = Time.now.to_f unless job["at"]
        Severity: Minor
        Found in lib/sidekiq/testing.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 local has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def local(worker, jobstr, queue)
              yield
            rescue Handled => ex
              raise ex
            rescue Sidekiq::Shutdown => ey
        Severity: Minor
        Found in lib/sidekiq/job_retry.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 add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def add(severity, message = nil, progname = nil, &block)
              severity ||= ::Logger::UNKNOWN
              progname ||= @progname
        
              return true if @logdev.nil? || severity < level
        Severity: Minor
        Found in lib/sidekiq/logger.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 enqueue_jobs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def enqueue_jobs(now = Time.now.to_f.to_s, sorted_sets = SETS)
                # A job's "score" in Redis is the time at which it should be processed.
                # Just check Redis for the set of jobs with a timestamp before now.
                Sidekiq.redis do |conn|
                  sorted_sets.each do |sorted_set|
        Severity: Minor
        Found in lib/sidekiq/scheduled.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 log_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def log_info(options)
                # Don't log Redis AUTH password
                redacted = "REDACTED"
                scrubbed_options = options.dup
                if scrubbed_options[:url] && (uri = URI.parse(scrubbed_options[:url])) && uri.password
        Severity: Minor
        Found in lib/sidekiq/redis_connection.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 user_preferred_languages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def user_preferred_languages
              languages = env["HTTP_ACCEPT_LANGUAGE"]
              languages.to_s.downcase.gsub(/\s+/, "").split(",").map { |language|
                locale, quality = language.split(";q=", 2)
                locale = nil if locale == "*" # Ignore wildcards
        Severity: Minor
        Found in lib/sidekiq/web/helpers.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 handle_exception has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_exception(ex, ctx = {})
              Sidekiq.error_handlers.each do |handler|
                handler.call(ex, ctx)
              rescue => ex
                Sidekiq.logger.error "!!! ERROR HANDLER THREW AN ERROR !!!"
        Severity: Minor
        Found in lib/sidekiq/exception_handler.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 boot_system has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def boot_system
              ENV["RACK_ENV"] = ENV["RAILS_ENV"] = environment
        
              if File.directory?(options[:require])
                require "rails"
        Severity: Minor
        Found in lib/sidekiq/cli.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