mongodb/mongo-ruby-driver

View on GitHub

Showing 393 of 447 total issues

Method run_sdam_flow has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run_sdam_flow(previous_desc, updated_desc, options = {})
      if load_balanced?
        if updated_desc.config.empty?
          unless options[:keep_connection_pool]
            servers_list.each do |server|
Severity: Minor
Found in lib/mongo/cluster.rb - About 1 hr to fix

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

              def initialize(opts)
                @opts = opts
                return if empty?
    
                if opts[:access_token]
    Severity: Minor
    Found in lib/mongo/crypt/kms/gcp/credentials.rb - About 1 hr to fix

      Method delete_one has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def delete_one(opts = {})
                with_session(opts) do |session|
                  write_concern = if opts[:write_concern]
                    WriteConcern.get(opts[:write_concern])
                  else
      Severity: Minor
      Found in lib/mongo/collection/view/writable.rb - About 1 hr to fix

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

              def initialize(kms_providers, kms_tls_options, options={})
                # FFI::AutoPointer uses a custom release strategy to automatically free
                # the pointer once this object goes out of scope
                @mongocrypt = FFI::AutoPointer.new(
                  Binding.mongocrypt_new,
        Severity: Minor
        Found in lib/mongo/crypt/handle.rb - About 1 hr to fix

          Method publish_heartbeat has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def publish_heartbeat(server, awaited: false)
                if monitoring?
                  started_event = Event::ServerHeartbeatStarted.new(
                    server.address, awaited: awaited)
                  started(SERVER_HEARTBEAT, started_event)
          Severity: Minor
          Found in lib/mongo/monitoring.rb - About 1 hr to fix

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

                  def deliver(message, context, options = {})
                    if Lint.enabled? && !@socket
                      raise Error::LintError, "Trying to deliver a message over a disconnected connection (to #{address})"
                    end
                    buffer = serialize(message, context)
            Severity: Minor
            Found in lib/mongo/server/connection_base.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 close_available_connections has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def close_available_connections(service_id)
                    if @server.load_balancer? && service_id
                      loop do
                        conn = @available_connections.detect do |conn|
                          conn.service_id == service_id &&
            Severity: Minor
            Found in lib/mongo/server/connection_pool.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 do_clear has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def do_clear(options = nil)
                    check_invariants
            
                    service_id = options && options[:service_id]
            
            
            Severity: Minor
            Found in lib/mongo/server/connection_pool.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 create_and_add_connection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def create_and_add_connection
                    connection = nil
            
                    @lock.synchronize do
                      if !closed? && @ready &&
            Severity: Minor
            Found in lib/mongo/server/connection_pool.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 validate_read! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def validate_read!(option, opts)
                  if option == :read && opts.has_key?(:read)
                    read = opts[:read]
                    # We could check if read is a Hash, but this would fail
                    # for custom classes implementing key access ([]).
            Severity: Minor
            Found in lib/mongo/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

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

                      module_function def convert_limit_and_batch_size!(command)
                        if command[:limit] && command[:limit] < 0 &&
                          command[:batchSize] && command[:batchSize] < 0
                        then
                          command[:limit] = command[:limit].abs
            Severity: Minor
            Found in lib/mongo/operation/find/builder/command.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 collections_info_spec has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def collections_info_spec(session, options = {})
                    { selector: {
                        listCollections: 1,
                        cursor: batch_size ? { batchSize: batch_size } : {} },
                      db_name: @database.name,
            Severity: Minor
            Found in lib/mongo/database/view.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 validate_update_documents! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                    def validate_update_documents!(spec)
                      if update = spec.is_a?(Array) ? spec&.first : spec
                        if key = update.keys&.first
                          unless key.to_s.start_with?("$")
                            if Mongo.validate_update_replace
            Severity: Minor
            Found in lib/mongo/collection/view/writable.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 suppress_read_write_concern! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def suppress_read_write_concern!(command)
                  command.tap do |c|
                    next unless in_transaction?
            
                    c.delete(:readConcern) unless starting_transaction?
            Severity: Minor
            Found in lib/mongo/session.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 maybe_set_schema_map has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def maybe_set_schema_map(options)
                    if !options[:schema_map] && !options[:schema_map_path]
                      @schema_map = nil
                    elsif options[:schema_map] && options[:schema_map_path]
                      raise ArgumentError.new(
            Severity: Minor
            Found in lib/mongo/crypt/handle.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(flags, options, main_document, *sequences)
                    if flags
                      flags.each do |flag|
                        unless KNOWN_FLAGS.key?(flag)
                          raise ArgumentError, "Unknown flag: #{flag.inspect}"
            Severity: Minor
            Found in lib/mongo/protocol/msg.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 set_algorithm_opts has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def set_algorithm_opts(options)
                    Binding.ctx_setopt_algorithm(self, options[:algorithm])
                    if %w(Indexed RangePreview).include?(options[:algorithm])
                      if options[:contention_factor]
                        Binding.ctx_setopt_contention_factor(self, options[:contention_factor])
            Severity: Minor
            Found in lib/mongo/crypt/explicit_encryption_context.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 get_records has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def get_records(hostname, srv_service_name=nil, srv_max_hosts=nil)
                    query_name = record_prefix(srv_service_name) + hostname
                    resources = @resolver.getresources(query_name, Resolv::DNS::Resource::IN::SRV)
            
                    # Collect all of the records into a Result object, raising an error
            Severity: Minor
            Found in lib/mongo/srv/resolver.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 get_connection has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def get_connection(pid, connection_global_id)
                    if connection = next_available_connection(connection_global_id)
                      unless valid_available_connection?(connection, pid, connection_global_id)
                        return nil
                      end
            Severity: Minor
            Found in lib/mongo/server/connection_pool.rb - About 1 hr to fix

              Method close has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def close
                    @state_change_lock.synchronize do
                      unless connecting? || connected?
                        return nil
                      end
              Severity: Minor
              Found in lib/mongo/cluster.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language