mongodb/mongo-ruby-driver

View on GitHub

Showing 163 of 216 total issues

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

      def stop!(wait=false)
        # Although disconnect! documentation implies a possibility of
        # failure, all of our disconnects always return true
        if connection.disconnect!
          if @thread
Severity: Minor
Found in lib/mongo/server/monitor.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 read_with_retry has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def read_with_retry(session = nil, server_selector = nil, &block)
      if session.nil? && server_selector.nil?
        # Older versions of Mongoid call read_with_retry without arguments.
        # This is already not correct in a MongoDB 3.6+ environment with
        # sessions. For compatibility we emulate the legacy driver behavior
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 close has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def close(options = nil)
        return if closed?

        @lock.synchronize do
          until @available_connections.empty?
Severity: Minor
Found in lib/mongo/server/connection_pool.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 find_one_and_update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def find_one_and_update(document, opts = {})
          cmd = { :findAndModify => collection.name, :query => filter }
          cmd[:update] = document
          cmd[:fields] = projection if projection
          cmd[:sort] = sort if sort
Severity: Minor
Found in lib/mongo/collection/view/writable.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 parse_uri_options! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_uri_options!(string)
      return {} unless string
      string.split(INDIV_URI_OPTS_DELIM).reduce({}) do |uri_options, opt|
        key, value = opt.split('=', 2)
        if value.nil?
Severity: Minor
Found in lib/mongo/uri.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 check_in has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def check_in(connection)
        @lock.synchronize do
          unless @checked_out_connections.include?(connection)
            raise ArgumentError, "Trying to check in a connection which is not currently checked out by this pool: #{connection}"
          end
Severity: Minor
Found in lib/mongo/server/connection_pool.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 set_key has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def set_key(context, options)
        passphrase = options[:ssl_key_pass_phrase]
        if options[:ssl_key]
          context.key = passphrase ? OpenSSL::PKey.read(File.read(options[:ssl_key]), passphrase) :
            OpenSSL::PKey.read(File.open(options[:ssl_key]))
Severity: Minor
Found in lib/mongo/socket/ssl.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 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 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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def initialize(command_name, database_name, address, request_id,
                operation_id, command, socket_object_id = nil
      Severity: Major
      Found in lib/mongo/monitoring/event/command_started.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 try_next has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def try_next
                if @documents.nil?
                  @documents = process(@initial_result)
                  # the documents here can be an empty array, hence
                  # we may end up issuing a getMore in the first try_next call
          Severity: Minor
          Found in lib/mongo/cursor.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 execute_operation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def execute_operation(name, values, server, operation_id, result_combiner, session, txn_num = nil)
                raise Error::UnsupportedCollation.new if op_combiner.has_collation && !server.features.collation_enabled?
                raise Error::UnsupportedArrayFilters.new if op_combiner.has_array_filters && !server.features.array_filters_enabled?
                begin
                  if values.size > server.max_write_batch_size
          Severity: Minor
          Found in lib/mongo/bulk_write.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 retry_write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def retry_write(original_error, txn_num, &block)
                # We do not request a scan of the cluster here, because error handling
                # for the error which triggered the retry should have updated the
                # server description and/or topology as necessary (specifically,
                # a socket error or a not master error should have marked the respective
          Severity: Minor
          Found in lib/mongo/retryable.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 generate has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def self.generate(address, operation_id, payload, message, failure, duration)
          Severity: Minor
          Found in lib/mongo/monitoring/event/command_failed.rb - About 45 mins to fix

            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 parse_txt_options! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse_txt_options!(string)
                    return {} unless string
                    string.split(INDIV_URI_OPTS_DELIM).reduce({}) do |txt_options, opt|
                      raise Error::InvalidTXTRecord.new(INVALID_OPTS_VALUE_DELIM) unless opt.index(URI_OPTS_VALUE_DELIM)
                      key, value = opt.split(URI_OPTS_VALUE_DELIM)
            Severity: Minor
            Found in lib/mongo/uri/srv_protocol.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