mongodb/mongo-ruby-driver

View on GitHub

Showing 196 of 247 total issues

Method legacy_read_with_retry has 29 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 normalized? has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.normalized?(string, form = :nfc)
        encoding = string.encoding
        case encoding
        when Encoding::UTF_8
          case form
    Severity: Minor
    Found in lib/mongo/auth/stringprep/unicode_normalize/normalize.rb - About 1 hr to fix

      Method update_rs_without_primary has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def update_rs_without_primary
            if topology.replica_set_name.nil?
              @topology = Topology::ReplicaSetNoPrimary.new(
                topology.options.merge(replica_set_name: updated_desc.replica_set_name),
                topology.monitoring, self)
      Severity: Minor
      Found in lib/mongo/cluster/sdam_flow.rb - About 1 hr to fix

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

            def update_rs_from_primary
              if topology.replica_set_name.nil?
                @topology = Topology::ReplicaSetWithPrimary.new(
                  topology.options.merge(replica_set_name: updated_desc.replica_set_name),
                  topology.monitoring, self)
        Severity: Minor
        Found in lib/mongo/cluster/sdam_flow.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 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 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 retry_read has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def retry_read(original_error, server_selector, session, &block)
                        begin
                          server = select_server(cluster, server_selector, session)
                        rescue => e
                          original_error.add_note("later retry failed: #{e.class}: #{e}")
                  Severity: Minor
                  Found in lib/mongo/retryable.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] || 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 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 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 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

                      Severity
                      Category
                      Status
                      Source
                      Language