moneta-rb/moneta

View on GitHub

Showing 106 of 106 total issues

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

      def read(len)
        buffer = ''
        loop do
          begin
            case received = @io.recv_nonblock(len)
Severity: Minor
Found in lib/moneta/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 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 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 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 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/mysql.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 compile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def compile(keys, values)
                @key_validator ||= compile_validator(KEY_TRANSFORMER)
                @load_key_validator ||= compile_validator(LOAD_KEY_TRANSFORMER)
                @test_key_validator ||= compile_validator(TEST_KEY_TRANSFORMER)
                @value_validator ||= compile_validator(VALUE_TRANSFORMER)
        Severity: Minor
        Found in lib/moneta/transformer.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 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 slice has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def slice(*keys, **options)
                      @backend.get_multi(keys).tap do |pairs|
                        next if pairs.empty?
                        expires = expires_value(options, nil)
                        next if expires == nil
              Severity: Minor
              Found in lib/moneta/adapters/memcached/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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def initialize(options = {})
                      if options[:backend]
                        @backend = options[:backend]
                      else
                        raise ArgumentError, 'Option :file is required' unless options[:file]
              Severity: Minor
              Found in lib/moneta/adapters/tokyocabinet.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

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

                    def read_multi_entries(names, options)
                      keys = names.map { |name| normalize_key(name, options) }
                      entries = @store
                        .values_at(*keys, **moneta_options(options, false))
                        .map(&method(:make_entry))
              Severity: Minor
              Found in lib/active_support/cache/moneta_store.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 each_key has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def each_key
                      rc, = consistency
                      return enum_for(:each_key) unless block_given?
                      result = @backend.execute(@each_key, consistency: rc, page_size: 100)
                      loop do
              Severity: Minor
              Found in lib/moneta/adapters/cassandra.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 slice has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def slice(*keys, **options)
                      rc, wc = consistency(options)
                      result = @backend.execute(@slice, options.merge(consistency: rc, arguments: [keys]))
                      expires = expires_value(options, nil)
                      updated = [] if expires != nil
              Severity: Minor
              Found in lib/moneta/adapters/cassandra.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 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

              Severity
              Category
              Status
              Source
              Language