mperham/sidekiq

View on GitHub

Showing 45 of 45 total issues

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

require "sidekiq"

require "zlib"
require "base64"

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

    File cli.rb has 296 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 3 hrs to fix

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

          def run(boot_app: true)
            boot_application if boot_app
      
            if environment == "development" && $stdout.tty? && Sidekiq.log_formatter.is_a?(Sidekiq::Logger::Formatters::Pretty)
              print_banner
      Severity: Minor
      Found in lib/sidekiq/cli.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

      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

        Class CLI has 25 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

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

          module Sidekiq
            class WebApplication
              extend WebRouter
          
              REDIS_KEYS = %w[redis_version uptime_in_days connected_clients used_memory_human used_memory_peak_human]
          Severity: Minor
          Found in lib/sidekiq/web/application.rb - About 2 hrs to fix

            Method page has a Cognitive Complexity of 18 (exceeds 5 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 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 push_bulk has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def push_bulk(items)
                  args = items["args"]
                  raise ArgumentError, "Bulk arguments must be an Array of Arrays: [[1], [2]]" unless args.is_a?(Array) && args.all?(Array)
                  return [] if args.empty? # no jobs to push
            
            
            Severity: Minor
            Found in lib/sidekiq/client.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

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

            require "uri"
            require "set"
            require "yaml"
            require "cgi"
            
            
            Severity: Minor
            Found in lib/sidekiq/web/helpers.rb - About 2 hrs to fix

              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 setup_options has a Cognitive Complexity of 16 (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 has 48 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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  module Sidekiq
                    module Extensions
                      ##
                      # Adds `delay`, `delay_for` and `delay_until` methods to all Classes to offload class method
                      # execution to Sidekiq.
                  Severity: Major
                  Found in lib/sidekiq/extensions/class_methods.rb and 1 other location - About 1 hr to fix
                  lib/sidekiq/extensions/active_record.rb on lines 5..41

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 73.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  module Sidekiq
                    module Extensions
                      ##
                      # Adds +delay+, +delay_for+ and +delay_until+ methods to ActiveRecord to offload instance method
                      # execution to Sidekiq.
                  Severity: Major
                  Found in lib/sidekiq/extensions/active_record.rb and 1 other location - About 1 hr to fix
                  lib/sidekiq/extensions/class_methods.rb on lines 5..39

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 73.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Method option_parser has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Method run has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

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

                          def delete_by_jid(score, jid)
                            Sidekiq.redis do |conn|
                              elements = conn.zrangebyscore(name, score, score)
                              elements.each do |element|
                                if element.index(jid)
                      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 page has 37 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 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
                          Severity
                          Category
                          Status
                          Source
                          Language