moneta-rb/moneta

View on GitHub

Showing 112 of 112 total issues

File sequel.rb has 599 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'sequel'

module Moneta
  module Adapters
    # Sequel backend
Severity: Major
Found in lib/moneta/adapters/sequel.rb - About 1 day to fix

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

          def run
            @thread = Thread.new do
              # Initialize the store
              @min.times { @available.push(add_store) }
    
    
    Severity: Minor
    Found in lib/moneta/pool.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

    Method new has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.new(name, options = {})
        expires = options[:expires]
        options.delete(:expires) unless Numeric === expires
        logger = options.delete(:logger)
        threadsafe = options.delete(:threadsafe)
    Severity: Minor
    Found in lib/moneta.rb - About 4 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 new has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.new(options = {})
            extensions = options.delete(:extensions)
            connection_validation_timeout = options.delete(:connection_validation_timeout)
            optimize = options.delete(:optimize)
            backend = options.delete(:backend) ||
    Severity: Minor
    Found in lib/moneta/adapters/sequel.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 Couch has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Couch
          include Defaults
    
          # @api private
          class HTTPError < StandardError
    Severity: Minor
    Found in lib/moneta/adapters/couch.rb - About 3 hrs to fix

      Class ActiveRecord has 29 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class ActiveRecord
            include Defaults
      
            supports :create, :increment, :each_key
      
      
      Severity: Minor
      Found in lib/moneta/adapters/activerecord.rb - About 3 hrs to fix

        Class Sequel has 29 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Sequel
              include Defaults
        
              supports :create, :increment, :each_key
              attr_reader :backend, :key_column, :value_column
        Severity: Minor
        Found in lib/moneta/adapters/sequel.rb - About 3 hrs to fix

          File couch.rb has 303 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'faraday'
          require 'multi_json'
          
          module Moneta
            module Adapters
          Severity: Minor
          Found in lib/moneta/adapters/couch.rb - About 3 hrs to fix

            Class PostgresHStore has 27 methods (exceeds 20 allowed). Consider refactoring.
            Open

                  class PostgresHStore < Sequel
                    def initialize(options)
                      @row = options.delete(:hstore).to_s
                      @backend.extension :pg_hstore
                      ::Sequel.extension :pg_hstore_ops
            Severity: Minor
            Found in lib/moneta/adapters/sequel.rb - About 3 hrs to fix

              Method call has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  def call(env)
                    key = env['PATH_INFO'][1..-1].to_s
                    case env['REQUEST_METHOD']
                    when 'HEAD'
                      if key.empty?
              Severity: Minor
              Found in lib/rack/moneta_rest.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 increment has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                    def increment(key, amount = 1, options = {})
                      with_connection do |conn|
                        begin
                          conn_ins(conn, key, amount.to_s)
                          amount
              Severity: Minor
              Found in lib/moneta/adapters/activerecord.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 mixins.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module Moneta
                # @api private
                module OptionSupport
                  # Return Moneta store with default options or additional proxies
                  #
              Severity: Minor
              Found in lib/moneta/mixins.rb - About 2 hrs to fix

                File transformer.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module Moneta
                  # Transforms keys and values (Marshal, YAML, JSON, Base64, MD5, ...).
                  # You can bypass the transformer (e.g. serialization) by using the `:raw` option.
                  #
                  # @example Add `Moneta::Transformer` to proxy stack
                Severity: Minor
                Found in lib/moneta/transformer.rb - About 2 hrs to fix

                  File cassandra.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'cassandra'
                  
                  module Moneta
                    module Adapters
                      # Cassandra backend
                  Severity: Minor
                  Found in lib/moneta/adapters/cassandra.rb - About 2 hrs to fix

                    Method mainloop has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def mainloop
                          if ios = IO.select(@ios, nil, @ios, TIMEOUT)
                            ios[2].each do |io|
                              io.close
                              delete_client(io)
                    Severity: Minor
                    Found in lib/moneta/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 start has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def start(options)
                          if @socket = options[:socket]
                            begin
                              UNIXServer.open(@socket)
                            rescue Errno::EADDRINUSE
                    Severity: Minor
                    Found in lib/moneta/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 initialize has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def initialize(options = {})
                            @key_column = options.delete(:key_column) || :k
                            @value_column = options.delete(:value_column) || :v
                    
                            if backend = options.delete(:backend)
                    Severity: Minor
                    Found in lib/moneta/adapters/activerecord.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 activerecord.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require 'active_record'
                    require 'uri'
                    
                    module Moneta
                      module Adapters
                    Severity: Minor
                    Found in lib/moneta/adapters/activerecord.rb - About 2 hrs to fix

                      Method store has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def store(key, value, options = {})
                              if @max_value && value.bytesize > @max_value
                                delete(key)
                              else
                                if entry = @entry[key]
                      Severity: Minor
                      Found in lib/moneta/adapters/lruhash.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 prepare_statements has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def prepare_statements
                              @key = @backend.prepare(<<-CQL)
                                SELECT #{@updated_column}, #{@expired_column}
                                FROM #{@table} WHERE #{@key_column} = ?
                                LIMIT 1
                      Severity: Minor
                      Found in lib/moneta/adapters/cassandra.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language