mperham/sidekiq

View on GitHub

Showing 44 of 44 total issues

File api.rb has 665 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

    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 24 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 cli.rb has 274 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 268 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

            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 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

              File helpers.rb has 256 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 normalize_item has a Cognitive Complexity of 16 (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 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 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 push_bulk has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def push_bulk(items)
                        arg = items["args"].first
                        return [] unless arg # no jobs to push
                        raise ArgumentError, "Bulk arguments must be an Array of Arrays: [[1], [2]]" unless arg.is_a?(Array)
                  
                  
                  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

                  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.  Examples:
                  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..38

                  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 all Classes to offload class method
                      # execution to Sidekiq.  Examples:
                  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..40

                  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 has 41 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 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 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

                        Severity
                        Category
                        Status
                        Source
                        Language