mongodb/mongo-ruby-driver

View on GitHub

Showing 227 of 284 total issues

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

      def initialize(options)
        @database = options[:database] || Database::ADMIN
        @auth_source = options[:auth_source] || self.class.default_auth_source(options)
        @name = options[:user]
        @password = options[:password] || options[:pwd]
Severity: Minor
Found in lib/mongo/auth/user.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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def each
      # If we already iterated past the first batch (i.e., called get_more
      # at least once), the cursor on the server side has advanced past
      # the first batch and restarting iteration from the beginning by
      # returning initial result would miss documents in the second batch
Severity: Minor
Found in lib/mongo/cursor.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 run_sdam_flow has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def run_sdam_flow(previous_desc, updated_desc, options = {})
      @sdam_flow_lock.synchronize do
        flow = SdamFlow.new(self, previous_desc, updated_desc)
        flow.server_description_changed

Severity: Minor
Found in lib/mongo/cluster.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 legacy_write_with_retry has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def legacy_write_with_retry(server = nil, session = nil)
      # This is the pre-session retry logic, and is not subject to
      # current retryable write specifications.
      # In particular it does not retry on SocketError and SocketTimeoutError.
      attempt = 0
Severity: Minor
Found in lib/mongo/retryable.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 maybe_encrypt has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def maybe_encrypt(server, client)
        # TODO verify compression happens later, i.e. when this method runs
        # the message is not compressed.
        if client && client.encrypter && client.encrypter.encrypt?
          if server.max_wire_version < 8
Severity: Minor
Found in lib/mongo/protocol/msg.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 serialize_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def serialize_fields(buffer, max_bson_size = nil)
        fields.each do |field|
          value = instance_variable_get(field[:name])
          if field[:multi]
            value.each do |item|
Severity: Minor
Found in lib/mongo/protocol/message.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 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def initialize(command_name, database_name, address, request_id, operation_id, reply, duration)
Severity: Major
Found in lib/mongo/monitoring/event/command_succeeded.rb - About 50 mins to fix

    Method execute_operation has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def execute_operation(name, values, server, operation_id, result_combiner, session, txn_num = nil)
    Severity: Major
    Found in lib/mongo/bulk_write.rb - About 50 mins to fix

      Method split_execute has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def split_execute(name, values, server, operation_id, result_combiner, session, txn_num)
      Severity: Major
      Found in lib/mongo/bulk_write.rb - About 50 mins to fix

        Method setopt_crypto_hooks has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def self.setopt_crypto_hooks(handle,
                aes_encrypt_cb, aes_decrypt_cb, random_cb,
                hmac_sha_512_cb, hmac_sha_256_cb, hmac_hash_cb
        Severity: Major
        Found in lib/mongo/crypt/binding.rb - About 50 mins to fix

          Method ismaster has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def ismaster
                  @mutex.synchronize do
                    if monitoring.monitoring?
                      monitoring.started(
                        Monitoring::SERVER_HEARTBEAT,
          Severity: Minor
          Found in lib/mongo/server/monitor.rb - About 45 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 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def initialize(command_name, database_name, address, request_id,
                    operation_id, command, socket_object_id: nil, connection_id: nil
          Severity: Minor
          Found in lib/mongo/monitoring/event/command_started.rb - About 45 mins to fix

            Method try_next has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def try_next
                      raise StopIteration.new if closed?
                      retried = false
            
                      begin
            Severity: Minor
            Found in lib/mongo/collection/view/change_stream.rb - About 45 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 reject! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def reject!
                    if block_given?
                      n_keys = keys.size
                      keys.each do |key|
                        delete(key) if yield(key, self[key])
            Severity: Minor
            Found in lib/mongo/options/redacted.rb - About 45 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 set_server_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def set_server_list(server_address_strs)
                  @sdam_flow_lock.synchronize do
                    server_address_strs.each do |address_str|
                      unless servers_list.any? { |server| server.address.seed == address_str }
                        add(address_str)
            Severity: Minor
            Found in lib/mongo/cluster.rb - About 45 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 aggregate_write_errors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def aggregate_write_errors(count)
                      return unless @replies
                      @replies.reduce(nil) do |errors, reply|
                        if write_errors = reply.documents.first['writeErrors']
                          wes = write_errors.collect do |we|
            Severity: Minor
            Found in lib/mongo/operation/shared/result/aggregatable.rb - About 45 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 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def command(server)
                    sel = selector(server).dup
                    add_write_concern!(sel)
                    sel[Protocol::Msg::DATABASE_IDENTIFIER] = db_name
                    unless server.standalone?
            Severity: Minor
            Found in lib/mongo/operation/shared/sessions_supported.rb - About 45 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 set_compressor! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def set_compressor!(reply)
                    server_compressors = reply['compression']
            
                    if options[:compressors]
                      if intersection = (server_compressors & options[:compressors])
            Severity: Minor
            Found in lib/mongo/server/connection_common.rb - About 45 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 check_bidi! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def check_bidi!(out)
                    if out.each_char.any? { |c| table_contains?(Tables::C8, c) }
                      raise Mongo::Error::FailedStringPrepValidation.new(Error::FailedStringPrepValidation::INVALID_BIDIRECTIONAL)
                    end
            
            
            Severity: Minor
            Found in lib/mongo/auth/stringprep.rb - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def disconnect!
                  unless @connecting || @connected
                    return true
                  end
                  if options[:cleanup] != false
            Severity: Minor
            Found in lib/mongo/cluster.rb - About 45 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