mongodb/mongo-ruby-driver

View on GitHub

Showing 190 of 244 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 parse_password! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_password!(string)
      if (string && pwd = string.partition(AUTH_USER_PWD_DELIM)[2])
        if pwd.length > 0
          raise_invalid_error!(UNESCAPED_USER_PWD) if pwd =~ UNSAFE
          pwd_decoded = decode(pwd)
Severity: Minor
Found in lib/mongo/uri.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 validate_authentication_options! has a Cognitive Complexity of 10 (exceeds 5 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

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 10 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(addresses_or_uri, options = nil)
      options = options ? options.dup : {}

      srv_uri = nil
      if addresses_or_uri.is_a?(::String)
Severity: Minor
Found in lib/mongo/client.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 validate_read_concern_option has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_read_concern_option(read_concern)
      return unless enabled?
      return if read_concern.nil?
      unless read_concern.is_a?(Hash)
        raise Error::LintError, "Read concern is not a hash: #{read_concern}"
Severity: Minor
Found in lib/mongo/lint.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 disconnect! has 27 lines of code (exceeds 25 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 1 hr to fix

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

        def initialize(string, options = {})
          @string = string
          @options = options
          parsed_scheme, _, remaining = string.partition(SCHEME_DELIM)
          unless parsed_scheme == scheme
    Severity: Minor
    Found in lib/mongo/uri.rb - About 1 hr to fix

      Method legacy_read_with_retry has 27 lines of code (exceeds 25 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

        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 distinct has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def distinct(field_name, opts = {})
                    if field_name.nil?
                      raise ArgumentError, 'Field name for distinct operation must be not nil'
                    end
                    cmd = { :distinct => collection.name,
          Severity: Minor
          Found in lib/mongo/collection/view/readable.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 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 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 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 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 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 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

                Severity
                Category
                Status
                Source
                Language