mongodb/mongo-ruby-driver

View on GitHub

Showing 423 of 480 total issues

Method select_server_for_retry has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def select_server_for_retry(original_error, session, server_selector, context, failed_server)
Severity: Minor
Found in lib/mongo/retryable/read_worker.rb - About 35 mins to fix

    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def initialize(host, port, timeout, family, options = {})
    Severity: Minor
    Found in lib/mongo/socket/tcp.rb - About 35 mins to fix

      Method do_hmac_sha has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def do_hmac_sha(digest_name, key_binary_p, input_binary_p,
              output_binary_p, status_p)
      Severity: Minor
      Found in lib/mongo/crypt/handle.rb - About 35 mins to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def initialize(mongocrypt, io, master_key_document, key_alt_names, key_material)
        Severity: Minor
        Found in lib/mongo/crypt/data_key_context.rb - About 35 mins to fix

          Method handshake_document has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def handshake_document(app_metadata, speculative_auth_doc: nil, load_balancer: false, server_api: nil)
                  serv_api = app_metadata.server_api || server_api
                  document = if serv_api
                               HELLO_DOC.merge(Utils.transform_server_api(serv_api))
                             else
          Severity: Minor
          Found in lib/mongo/server/connection_common.rb - About 35 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 generate_reply has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def self.generate_reply(command_payload, reply_payload)
                    if reply_payload
                      reply = reply_payload[:reply]
                      if cursor = reply[:cursor]
                        if !cursor.key?(Collection::NS)
          Severity: Minor
          Found in lib/mongo/monitoring/event/command_succeeded.rb - About 35 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 disconnect! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def disconnect!(options = nil)
                  # Note: @closed may be true here but we also may have a socket.
                  # Check the socket and not @closed flag.
                  @auth_mechanism = nil
                  @last_checkin = nil
          Severity: Minor
          Found in lib/mongo/server/connection.rb - About 35 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 standard_dependencies has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def standard_dependencies
            gem 'yard', '>= 0.9.35'
            gem 'ffi'
          
            group :development, :testing do
          Severity: Minor
          Found in gemfiles/standard.rb - About 35 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 command_completed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def command_completed(result, address, operation_id, payload, duration,
                  started_event:, server_connection_id: nil, service_id: nil
                )
                  document = result ? (result.documents || []).first : nil
                  if document && (document['ok'] && document['ok'] != 1 || document.key?('$err'))
          Severity: Minor
          Found in lib/mongo/monitoring/publishable.rb - About 35 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 serialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def serialize(message, context, buffer = BSON::ByteBuffer.new)
                  # Driver specifications only mandate the fixed 16MiB limit for
                  # serialized BSON documents. However, the server returns its
                  # active serialized BSON document size limit in the hello response,
                  # which is +max_bson_object_size+ below. The +DEFAULT_MAX_BSON_OBJECT_SIZE+
          Severity: Minor
          Found in lib/mongo/server/connection_base.rb - About 35 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 valid_available_connection? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def valid_available_connection?(connection, pid, connection_global_id)
                  if connection.pid != pid
                    log_warn("Detected PID change - Mongo client should have been reconnected (old pid #{connection.pid}, new pid #{pid}")
                    connection.disconnect!(reason: :stale)
                    @populate_semaphore.signal
          Severity: Minor
          Found in lib/mongo/server/connection_pool.rb - About 35 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 summary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def summary
                fileno = @socket&.fileno rescue '<no socket>' || '<no socket>'
                if monitor?
                  indicator = if options[:push]
                    'pm'
          Severity: Minor
          Found in lib/mongo/socket.rb - About 35 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 converse_multi_step has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def converse_multi_step(connection, conversation,
                  speculative_auth_result: nil
                )
                  # Although the SASL conversation in theory can have any number of
                  # steps, all defined authentication methods have a predefined number
          Severity: Minor
          Found in lib/mongo/auth/base.rb - About 35 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 summary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def summary
                status = self.status || ''
                if replica_set_name
                  status += " replica_set=#{replica_set_name}"
                end
          Severity: Minor
          Found in lib/mongo/server.rb - About 35 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 remove has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def remove(host, disconnect: true)
                address = Address.new(host)
                removed_servers = []
                @update_lock.synchronize do
                  @servers.delete_if do |server|
          Severity: Minor
          Found in lib/mongo/cluster.rb - About 35 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 convert_ms has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def convert_ms(name, value)
                  case value
                  when String
                    if /\A-?\d+(\.\d+)?\z/ !~ value
                      log_warn("Invalid ms value for #{name}: #{value}")
          Severity: Minor
          Found in lib/mongo/uri/options_mapper.rb - About 35 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 convert_max_staleness has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def convert_max_staleness(name, value)
                  int = if value.is_a?(String) && /\A-?\d+\z/ =~ value
                    value.to_i
                  elsif value.is_a?(Integer)
                    value
          Severity: Minor
          Found in lib/mongo/uri/options_mapper.rb - About 35 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 create_cursor! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def create_cursor!(timeout_ms = nil)
                    # clear the cache because we may get a newer or an older server
                    # (rolling upgrades)
                    @start_at_operation_time_supported = nil
          
          
          Severity: Minor
          Found in lib/mongo/collection/view/change_stream.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(server_session, client, options = {})
                if options[:causal_consistency] && options[:snapshot]
                  raise ArgumentError, ':causal_consistency and :snapshot options cannot be both set on a session'
                end
          
          
          Severity: Minor
          Found in lib/mongo/session.rb - About 35 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 validate_read_preference! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_read_preference!(command)
                return unless in_transaction?
                return unless command['$readPreference']
          
                mode = command['$readPreference']['mode'] || command['$readPreference'][:mode]
          Severity: Minor
          Found in lib/mongo/session.rb - About 35 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