mperham/sidekiq

View on GitHub

Showing 42 of 53 total issues

File api.rb has 644 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "sidekiq"

module Sidekiq
  module RedisScanner
    def sscan(conn, key)
Severity: Major
Found in lib/sidekiq/api.rb - About 1 day to fix

    Method sidekiq_class_attribute has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

            def sidekiq_class_attribute(*attrs)
              instance_reader = true
              instance_writer = true
    
              attrs.each do |name|
    Severity: Minor
    Found in lib/sidekiq/worker.rb - About 6 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 Web has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Web
        ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../web")
        VIEWS = "#{ROOT}/views"
        LOCALES = ["#{ROOT}/locales"]
        LAYOUT = "#{VIEWS}/layout.erb"
    Severity: Minor
    Found in lib/sidekiq/web.rb - About 2 hrs to fix

      File cli.rb has 278 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      $stdout.sync = true
      
      require "yaml"
      require "singleton"
      require "optparse"
      Severity: Minor
      Found in lib/sidekiq/cli.rb - About 2 hrs to fix

        File application.rb has 272 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Sidekiq
          class WebApplication
            extend WebRouter
        
            CONTENT_LENGTH = "Content-Length"
        Severity: Minor
        Found in lib/sidekiq/web/application.rb - About 2 hrs to fix

          Class CLI has 23 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class CLI
              include Util
              include Singleton unless $TESTING
          
              attr_accessor :launcher
          Severity: Minor
          Found in lib/sidekiq/cli.rb - About 2 hrs to fix

            Method setup_options has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                def setup_options(args)
                  # parse CLI options
                  opts = parse_options(args)
            
                  set_environment opts[:environment]
            Severity: Minor
            Found in lib/sidekiq/cli.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 sidekiq_class_attribute has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def sidekiq_class_attribute(*attrs)
                      instance_reader = true
                      instance_writer = true
            
                      attrs.each do |name|
            Severity: Major
            Found in lib/sidekiq/worker.rb - About 2 hrs to fix

              Method fetch_stats! has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def fetch_stats!
                    pipe1_res = Sidekiq.redis { |conn|
                      conn.pipelined do
                        conn.get("stat:processed")
                        conn.get("stat:failed")
              Severity: Minor
              Found in lib/sidekiq/api.rb - About 1 hr to fix

                Method parse_options has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def parse_options(argv)
                      opts = {}
                
                      @parser = OptionParser.new { |o|
                        o.on "-c", "--concurrency INT", "processor threads to use" do |arg|
                Severity: Minor
                Found in lib/sidekiq/cli.rb - About 1 hr to fix

                  Method normalize_item has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def normalize_item(item)
                        raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: { 'class' => SomeWorker, 'args' => ['bob', 1, :foo => 'bar'] }") unless item.is_a?(Hash) && item.key?("class") && item.key?("args")
                        raise(ArgumentError, "Job args must be an Array") unless item["args"].is_a?(Array)
                        raise(ArgumentError, "Job class must be either a Class or String representation of the class name") unless item["class"].is_a?(Class) || item["class"].is_a?(String)
                        raise(ArgumentError, "Job 'at' must be a Numeric timestamp") 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 has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def ❤
                        key = identity
                        fails = procd = 0
                  
                        begin
                  Severity: Minor
                  Found in lib/sidekiq/launcher.rb - About 1 hr to fix

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

                          def create(options = {})
                            options.keys.each do |key|
                              options[key.to_sym] = options.delete(key)
                            end
                    
                    
                    Severity: Minor
                    Found in lib/sidekiq/redis_connection.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 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 attempt_retry has 32 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 page has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def page(key, pageidx = 1, page_size = 25, opts = nil)
                              current_page = pageidx.to_i < 1 ? 1 : pageidx.to_i
                              pageidx = current_page - 1
                              total_size = 0
                              items = []
                        Severity: Minor
                        Found in lib/sidekiq/paginator.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 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 28 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
                            Severity
                            Category
                            Status
                            Source
                            Language