mongodb/mongo-ruby-driver

View on GitHub

Showing 264 of 315 total issues

Method with_ssl_socket has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def with_ssl_socket(endpoint)
        host, port = endpoint.split(':')
        port ||= 443 # Default port for AWS KMS API

        # Create TCPSocket and set nodelay option
Severity: Minor
Found in lib/mongo/crypt/encryption_io.rb - About 1 hr to fix

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

          def initialize(server, options = {})
            unless server.is_a?(Server)
              raise ArgumentError, 'First argument must be a Server instance'
            end
            options = options.dup
    Severity: Minor
    Found in lib/mongo/server/connection_pool.rb - About 1 hr to fix

      Method validate_authentication_options! has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def validate_authentication_options!
            auth_mech = options[:auth_mech]
            user = options[:user]
            password = options[:password]
            auth_source = options[:auth_source]
      Severity: Minor
      Found in lib/mongo/client.rb - About 1 hr to fix

        Method add_txn_opts! has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def add_txn_opts!(command, read)
              command.tap do |c|
                # The read concern should be added to any command that starts a transaction.
                if starting_transaction?
                  # https://jira.mongodb.org/browse/SPEC-1161: transaction's
        Severity: Minor
        Found in lib/mongo/session.rb - About 1 hr to fix

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

                def initialize(server, options = {})
                  unless server.is_a?(Server)
                    raise ArgumentError, 'First argument must be a Server instance'
                  end
                  options = options.dup
          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 close_idle_sockets has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def close_idle_sockets
                  return if closed?
                  return unless max_idle_time
          
                  @lock.synchronize do
          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 legacy_read_with_retry has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def legacy_read_with_retry(session, server_selector)
                attempt = 0
                server = select_server(cluster, server_selector, session)
                begin
                  attempt += 1
          Severity: Minor
          Found in lib/mongo/retryable.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 run_state_machine has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def run_state_machine
                  while true
                    case state
                    when :error
                      Binding.check_ctx_status(self)
          Severity: Minor
          Found in lib/mongo/crypt/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 parse_code has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def parse_code
                  if document['ok'] == 1 || @options[:legacy]
                    @code = @code_name = nil
                  else
                    @code = document['code']
          Severity: Minor
          Found in lib/mongo/error/parser.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 13 (exceeds 5 allowed). Consider refactoring.
          Open

                  def initialize(replies, connection_description, ids)
                    @replies = [*replies] if replies
                    @connection_description = connection_description
                    if replies && replies.first && (doc = replies.first.documents.first)
                      if errors = doc['writeErrors']
          Severity: Minor
          Found in lib/mongo/operation/insert/bulk_result.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 parse! has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def parse!(remaining)
                hosts_and_db, options = remaining.split('?', 2)
                if options && options.index('?')
                  raise_invalid_error!("Options contain an unescaped question mark (?), or the database name contains a question mark and was not escaped")
                end
          Severity: Minor
          Found in lib/mongo/uri.rb - About 1 hr to fix

            Method set_aws_master_key has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def set_aws_master_key(master_key_opts)
                    unless master_key_opts
                      raise ArgumentError.new('The :master_key option cannot be nil')
                    end
            
            
            Severity: Minor
            Found in lib/mongo/crypt/data_key_context.rb - About 1 hr to fix

              Method run_state_machine has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def run_state_machine
                      while true
                        case state
                        when :error
                          Binding.check_ctx_status(self)
              Severity: Minor
              Found in lib/mongo/crypt/context.rb - About 1 hr to fix

                Method start_stop_srv_monitor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def start_stop_srv_monitor
                      # SRV URI is either always given or not for a given cluster, if one
                      # wasn't given we shouldn't ever have an SRV monitor to manage.
                      return unless options[:srv_uri]
                
                
                Severity: Minor
                Found in lib/mongo/cluster.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_many has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                      def create_many(*models)
                        client.send(:with_session, @options) do |session|
                          server = next_primary(nil, session)
                
                          models = models.flatten
                Severity: Minor
                Found in lib/mongo/index/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 initial has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                      def initial(cluster, monitoring, options)
                        cls = if options[:direct_connection]
                          if options[:connect] && options[:connect] && options[:connect].to_sym != :direct
                            raise ArgumentError, "Conflicting topology options: direct_connection=true and connect=#{options[:connect]}"
                          end
                Severity: Minor
                Found in lib/mongo/cluster/topology.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 disconnect! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def disconnect!
                      @state_change_lock.synchronize do
                        unless connecting? || connected?
                          return true
                        end
                Severity: Minor
                Found in lib/mongo/cluster.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 deliver has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                      def deliver(message, client, options = {})
                        if Lint.enabled? && !@socket
                          raise Error::LintError, "Trying to deliver a message over a disconnected connection (to #{address})"
                        end
                        buffer = serialize(message, client)
                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 kill_cursors has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                      def kill_cursors
                        to_kill_copy = {}
                        active_cursors_copy = []
                
                        @mutex.synchronize do
                Severity: Minor
                Found in lib/mongo/cluster/reapers/cursor_reaper.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 start has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                        def start(connection)
                          login = client_first_document
                          if connection && connection.features.op_msg_enabled?
                            selector = login
                            # The only valid database for X.509 authentication is $external.
                Severity: Minor
                Found in lib/mongo/auth/x509/conversation.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

                Severity
                Category
                Status
                Source
                Language