mperham/sidekiq

View on GitHub

Showing 48 of 48 total issues

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

    def validate(item)
      raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: `#{item}`") unless item.is_a?(Hash) && item.key?("class") && item.key?("args")
      raise(ArgumentError, "Job args must be an Array: `#{item}`") unless item["args"].is_a?(Array)
      raise(ArgumentError, "Job class must be either a Class or String representation of the class name: `#{item}`") unless item["class"].is_a?(Class) || item["class"].is_a?(String)
      raise(ArgumentError, "Job 'at' must be a Numeric timestamp: `#{item}`") if item.key?("at") && !item["at"].is_a?(Numeric)
Severity: Minor
Found in lib/sidekiq/client.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 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 build_sessions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_sessions
          middlewares = self.middlewares
    
          s = sessions
    
    
    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 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 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(&block)
          results = []
          Sidekiq.redis do |conn|
            procs = conn.sscan_each("processes").to_a
            procs.sort.each do |key|
    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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def create(options = {})
            symbolized_options = options.transform_keys(&:to_sym)
    
            if !symbolized_options[:url] && (u = determine_redis_provider)
              symbolized_options[:url] = u
    Severity: Minor
    Found in lib/sidekiq/redis_connection.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 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 normalize_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def normalize_item(item)
          # 6.0.0 push_bulk bug, #4321
          # TODO Remove after a while...
          item.delete("at") if item.key?("at") && item["at"].nil?
    
    
    Severity: Minor
    Found in lib/sidekiq/client.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 log_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def log_info(options)
            redacted = "REDACTED"
    
            # deep clone so we can muck with these options all we want
            #
    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

    Severity
    Category
    Status
    Source
    Language