moneta-rb/moneta

View on GitHub

Showing 112 of 112 total issues

Method merge! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def merge!(pairs, options = {})
        keys = pairs.map { |key, _| key }

        if block_given?
          old_values = @backend.mget(*keys)
Severity: Minor
Found in lib/moneta/adapters/redis.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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(app, options = {}, &block)
        super
        if block
          raise ArgumentError, 'Use either block or option :store' if options[:store]
          @pool = ::Moneta.build(&block)
Severity: Minor
Found in lib/rack/session/moneta.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 request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def request(method, key, body = nil, returns: :nil, cache_rev: false, expect: nil, query: nil, headers: {})
        url = @backend.build_url(key, query)
        headers['Content-Type'] = 'application/json' if %i{put post}.include?(method)
        response = @backend.run_request(method, url, body || '', headers)

Severity: Minor
Found in lib/moneta/adapters/couch.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 wrap has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def wrap(name, *args)
      case name
      when :create, :store, :increment, :create
        each_key_save(args[0])
        yield
Severity: Minor
Found in lib/moneta/weak_each_key.rb - About 1 hr to fix

    Method initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def initialize(options = {})
            @table = options[:table] || 'moneta'
            @backend = options[:backend] ||
              begin
                raise ArgumentError, 'Option :file is required' unless options[:file]
    Severity: Minor
    Found in lib/moneta/adapters/sqlite.rb - About 1 hr to fix

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

          def initialize(store = nil, options = {}, &block)
            if block
              raise ArgumentError, 'Use either block or options' unless options.empty?
              @store = ::Moneta.build(&block)
            else
      Severity: Minor
      Found in lib/rack/moneta_rest.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 store has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def store(key, value, options = {})
              context do
                if record = Store.get(key)
                  record.update(k: key, v: value)
                else
      Severity: Minor
      Found in lib/moneta/adapters/datamapper.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 wrap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def wrap(*args)
            connect
            yield
          rescue Errno::ECONNRESET, Errno::EPIPE, IOError, SystemCallError
            @connect_lock.synchronize { close unless @server }
      Severity: Minor
      Found in lib/moneta/shared.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 increment has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def increment(key, amount = 1, options = {})
                @backend.transaction do
                  # this creates a row-level lock even if there is no existing row (a
                  # "gap lock").
                  if row = @load_for_update.call(key: key)
      Severity: Minor
      Found in lib/moneta/adapters/sequel.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(app, store = nil, options = {}, &block)
            @app = app
            @cache = options.delete(:cache)
            if block
              raise ArgumentError, 'Use either block or options' unless options.empty?
      Severity: Minor
      Found in lib/rack/moneta_store.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 initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def initialize(options = {})
              self.default_expires = options.delete(:expires)
              keyspace = options.delete(:keyspace) || 'moneta'
      
              @table = (options.delete(:column_family) || 'moneta').to_sym
      Severity: Minor
      Found in lib/moneta/adapters/cassandra.rb - About 1 hr to fix

        Method slice has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def slice(*keys, lock: false, **options)
                with_connection do |conn|
                  conn.create_table(:slice_keys, temporary: true) do |t|
                    t.string :key, null: false
                  end
        Severity: Minor
        Found in lib/moneta/adapters/activerecord.rb - About 1 hr to fix

          Method handle has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def handle(io, buffer)
                return if buffer.bytesize < 8 # At least 4 bytes for the marshalled array
                size = buffer[0, 4].unpack('N').first
                if size > MAXSIZE
                  delete_client(io)
          Severity: Minor
          Found in lib/moneta/server.rb - About 1 hr to fix

            Method fetch_values has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def fetch_values(*keys, **options)
                  return super if options.include?(:raw)
                  new_expires = expires_at(options, nil)
                  options = Utils.without(options, :expires)
                  substituted = {}
            Severity: Minor
            Found in lib/moneta/expires.rb - About 1 hr to fix

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

                    def remove_unneeded_stores
                      return unless @stopping || (@ttl && @last_checkout && Time.now - @last_checkout >= @ttl)
                      while (@stopping || @stores.length > @min) and store = @available.pop
                        store.close rescue nil
                        @stores.delete(store)
              Severity: Minor
              Found in lib/moneta/pool.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 compile_transformer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def compile_transformer(transformer, var, idx = 2)
                      value, options = var, []
                      transformer.each do |name|
                        raise ArgumentError, "Unknown transformer #{name}" unless t = TRANSFORMER[name]
                        require t[3] if t[3]
              Severity: Minor
              Found in lib/moneta/transformer.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 load has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def load(key, options = {})
                      value = @backend.get(key, false)
                      if value
                        expires = expires_value(options, nil)
                        unless expires == nil
              Severity: Minor
              Found in lib/moneta/adapters/memcached/native.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 handle_check_out has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def handle_check_out(reply)
                      @last_checkout = Time.now
                      if @stopping
                        reply.resolve(ShutdownError.new("Shutting down"))
                      elsif !@available.empty?
              Severity: Minor
              Found in lib/moneta/pool.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 store has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def store(key, value, options = {})
                      blob_value = blob(value)
                      unless @store_update.call(key: key, value: blob_value) == 1
                        @create.call(key: key, value: blob_value)
                      end
              Severity: Minor
              Found in lib/moneta/adapters/sequel.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 increment has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def increment(key, amount = 1, options = {})
                      expires = expires_value(options)
                      options.delete(:raw)
                      existing = Integer(@backend.fetch(key, options.merge(raw: true)) { 0 })
                      if amount > 0
              Severity: Minor
              Found in lib/moneta/adapters/activesupportcache.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

              Severity
              Category
              Status
              Source
              Language