mongodb/mongo-ruby-driver

View on GitHub

Showing 178 of 233 total issues

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

    def try_next
      if @documents.nil?
        # Since published versions of Mongoid have a copy of old driver cursor
        # code, our dup call in #process isn't invoked when Mongoid query
        # cache is active. Work around that by also calling dup here on
Severity: Minor
Found in lib/mongo/cursor.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 find_one_and_update has a Cognitive Complexity of 10 (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 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 10 (exceeds 5 allowed). Consider refactoring.
Open

      def get_records(hostname)
        query_name = RECORD_PREFIX + 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 start_transaction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def start_transaction(options = nil)
      if options
        Lint.validate_read_concern_option(options[:read_concern])

=begin
Severity: Minor
Found in lib/mongo/session.rb - About 1 hr to fix

    Method check_in has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def check_in(connection)
            @lock.synchronize do
              unless connection.connection_pool == self
                raise ArgumentError, "Trying to check in a connection which was not checked out by this pool: #{connection} checked out from pool #{connection.connection_pool} (for #{self})"
              end
    Severity: Minor
    Found in lib/mongo/server/connection_pool.rb - About 1 hr to fix

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

              def initialize(command_name, database_name, address, request_id, operation_id, message, failure, duration)
      Severity: Major
      Found in lib/mongo/monitoring/event/command_failed.rb - About 1 hr to fix

        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] || @database
                @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 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 select! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def select!
                if block_given?
                  n_keys = keys.size
                  keys.each do |key|
                    delete(key) unless yield(key, self[key])
        Severity: Minor
        Found in lib/mongo/options/redacted.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)
              uri_options = {}
              unless string
                return uri_options
              end
        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 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 checkout has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def checkout
                @mutex.synchronize do
                  loop do
                    if @queue.empty?
                      return ServerSession.new
        Severity: Minor
        Found in lib/mongo/session/session_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 close has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def close(options = nil)
                return if closed?
        
                options ||= {}
        
        
        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 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 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 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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def initialize(options)
                        options = Options::Mapper.transform_keys_to_symbols(options)
                        options = Options::Mapper.transform_values_to_strings(options).freeze
                
                        if options[:w]
                Severity: Minor
                Found in lib/mongo/write_concern/base.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 process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def process(result)
                      unless implicit?
                        set_operation_time(result)
                        if cluster_time_doc = result.cluster_time
                          advance_cluster_time(cluster_time_doc)
                Severity: Minor
                Found in lib/mongo/session.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