mperham/dalli

View on GitHub

Showing 34 of 40 total issues

File server.rb has 600 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'socket'
require 'timeout'

module Dalli
  class Server
Severity: Major
Found in lib/dalli/server.rb - About 1 day to fix

    Class Server has 59 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Server
        attr_accessor :hostname
        attr_accessor :port
        attr_accessor :weight
        attr_accessor :options
    Severity: Major
    Found in lib/dalli/server.rb - About 1 day to fix

      Method get_multi_yielder has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_multi_yielder(keys)
            perform do
              return {} if keys.empty?
              ring.lock do
                begin
      Severity: Minor
      Found in lib/dalli/client.rb - About 5 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 Client has 38 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Client
      
          ##
          # Dalli::Client is the main class which developers will use to interact with
          # the memcached server.  Usage:
      Severity: Minor
      Found in lib/dalli/client.rb - About 5 hrs to fix

        File client.rb has 292 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'digest/md5'
        require 'set'
        
        # encoding: ascii
        module Dalli
        Severity: Minor
        Found in lib/dalli/client.rb - About 3 hrs to fix

          Method multi_response_nonblock has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def multi_response_nonblock
                raise 'multi_response has completed' if @multi_buffer.nil?
          
                @multi_buffer << @sock.read_available
                buf = @multi_buffer
          Severity: Minor
          Found in lib/dalli/server.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 get_multi_yielder has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def get_multi_yielder(keys)
                perform do
                  return {} if keys.empty?
                  ring.lock do
                    begin
          Severity: Minor
          Found in lib/dalli/client.rb - About 1 hr to fix

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

                def server_for_key(key)
                  if @continuum
                    hkey = hash_for(key)
                    20.times do |try|
                      entryidx = binary_search(@continuum, hkey)
            Severity: Minor
            Found in lib/dalli/ring.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 readfull has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                  def readfull(count)
                    value = String.new('')
                    begin
                      while true
                        value << read_nonblock(count - value.bytesize)
            Severity: Minor
            Found in lib/dalli/socket.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 generic_response has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def generic_response(unpack=false, cache_nils=false)
                  (extras, _, status, count) = read_header.unpack(NORMAL_HEADER)
                  data = read(count) if count > 0
                  if status == 1
                    cache_nils ? NOT_FOUND : nil
            Severity: Minor
            Found in lib/dalli/server.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 serialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def serialize(key, value, options=nil)
                  marshalled = false
                  value = unless options && options[:raw]
                    marshalled = true
                    begin
            Severity: Minor
            Found in lib/dalli/server.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 deserialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def deserialize(value, flags)
                  value = self.compressor.decompress(value) if (flags & FLAG_COMPRESSED) != 0
                  value = self.serializer.load(value) if (flags & FLAG_SERIALIZED) != 0
                  value
                rescue TypeError
            Severity: Minor
            Found in lib/dalli/server.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 multi_response_nonblock has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def multi_response_nonblock
                  raise 'multi_response has completed' if @multi_buffer.nil?
            
                  @multi_buffer << @sock.read_available
                  buf = @multi_buffer
            Severity: Minor
            Found in lib/dalli/server.rb - About 1 hr to fix

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

                  def sasl_authentication
                    Dalli.logger.info { "Dalli/SASL authenticating as #{username}" }
              
                    # negotiate
                    req = [REQUEST, OPCODES[:auth_negotiation], 0, 0, 0, 0, 0, 0, 0].pack(FORMAT[:noop])
              Severity: Minor
              Found in lib/dalli/server.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 extract_dalli_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def extract_dalli_options(options)
                      return [options[:cache]] if options[:cache]
              
                      # Filter out Rack::Session-specific options and apply our defaults
                      mopts = DEFAULT_DALLI_OPTIONS.merge \
              Severity: Minor
              Found in lib/rack/session/dalli.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 serialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def serialize(key, value, options=nil)
                    marshalled = false
                    value = unless options && options[:raw]
                      marshalled = true
                      begin
              Severity: Minor
              Found in lib/dalli/server.rb - About 1 hr to fix

                Method with_block has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def with_block(env, default=nil, &block)
                        @mutex.lock if @mutex and env['rack.multithread']
                        @pool.with(&block)
                      rescue ::Dalli::DalliError, Errno::ECONNREFUSED
                        raise if $!.message =~ /undefined class/
                Severity: Minor
                Found in lib/rack/session/dalli.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 fetch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def fetch(key, ttl=nil, options=nil)
                      options = options.nil? ? CACHE_NILS : options.merge(CACHE_NILS) if @options[:cache_nils]
                      val = get(key, options)
                      not_found = @options[:cache_nils] ?
                        val == Dalli::Server::NOT_FOUND :
                Severity: Minor
                Found in lib/dalli/client.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 get_session has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def get_session(env, sid)
                        with_block(env, [nil, {}]) do |dc|
                          unless sid and !sid.empty? and session = dc.get(sid)
                            old_sid, sid, session = sid, generate_sid_with(dc), {}
                            unless dc.add(sid, session, @default_ttl)
                Severity: Minor
                Found in lib/rack/session/dalli.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 set_cas has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def set_cas(key, value, cas, ttl=nil, options=nil)
                Severity: Minor
                Found in lib/dalli/cas/client.rb - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language