mongodb/mongo-ruby-driver

View on GitHub

Showing 393 of 447 total issues

Method handshake_and_authenticate! has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def handshake_and_authenticate!
        speculative_auth_doc = nil
        if options[:user] || options[:auth_mech]
          # To create an Auth instance, we need to specify the mechanism,
          # but at this point we don't know the mechanism that ultimately
Severity: Minor
Found in lib/mongo/server/pending_connection.rb - About 1 hr to fix

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

        def validate_session_support!
          if topology.is_a?(Topology::LoadBalanced)
            return
          end
    
    
    Severity: Minor
    Found in lib/mongo/cluster.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 close has a Cognitive Complexity of 13 (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 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 close_idle_sockets has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def close_idle_sockets
            return if closed?
            return unless max_idle_time
    
            @lock.synchronize do
    Severity: Minor
    Found in lib/mongo/server/connection_pool.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_connection has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def get_connection(pid, connection_global_id)
            if connection = next_available_connection(connection_global_id)
              unless valid_available_connection?(connection, pid, connection_global_id)
                return nil
              end
    Severity: Minor
    Found in lib/mongo/server/connection_pool.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 13 (exceeds 5 allowed). Consider refactoring.
    Open

            def find_one_and_update(document, opts = {})
              value = with_session(opts) do |session|
                write_concern = if opts[:write_concern]
                  WriteConcern.get(opts[:write_concern])
                else
    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 reconstruct_uri has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def reconstruct_uri
          servers = @servers.join(',')
          options = options_mapper.ruby_to_string(@uri_options).map do |k, vs|
            unless vs.nil?
              if vs.is_a?(Array)
    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 initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

            def initialize(replies, connection_description, connection_global_id, ids)
              @replies = [*replies] if replies
              @connection_description = connection_description
              @connection_global_id = connection_global_id
              if replies && replies.first && (doc = replies.first.documents.first)
    Severity: Minor
    Found in lib/mongo/operation/insert/bulk_result.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 13 (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 parse_code has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_code
            if document['ok'] == 1 || @options[:legacy]
              @code = @code_name = nil
            else
              @code = document['code']
    Severity: Minor
    Found in lib/mongo/error/parser.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_command has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

            def find_command
              document = BSON::Document.new(
                find: collection,
                filter: query_filter,
              )
    Severity: Minor
    Found in lib/mongo/protocol/query.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 deserialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.deserialize(io,
            max_message_size = MAX_MESSAGE_SIZE,
            expected_response_to = nil,
            options = {}
          )
    Severity: Minor
    Found in lib/mongo/protocol/message.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 run_state_machine has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def run_state_machine
            while true
              case state
              when :error
                Binding.check_ctx_status(self)
    Severity: Minor
    Found in lib/mongo/crypt/context.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 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def find_one_and_update(document, opts = {})
              value = with_session(opts) do |session|
                write_concern = if opts[:write_concern]
                  WriteConcern.get(opts[:write_concern])
                else
    Severity: Minor
    Found in lib/mongo/collection/view/writable.rb - About 1 hr to fix

      Method download_url has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def download_url
          @download_url ||= begin
            info = JSON.load(uri_open('http://downloads.mongodb.org/current.json').read)
            version = info['versions'].detect do |version|
              version['version'].start_with?(desired_version) &&
      Severity: Minor
      Found in .evergreen/tools.rb - About 1 hr to fix

        Method handshake! has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def handshake!(speculative_auth_doc: nil)
                unless socket
                  raise Error::InternalDriverError, "Cannot handshake because there is no usable socket (for #{address})"
                end
        
        
        Severity: Minor
        Found in lib/mongo/server/pending_connection.rb - About 1 hr to fix

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

                  def initialize(options, monitoring, cluster)
                    options = validate_options(options, cluster)
          
                    @options = options
                    @monitoring = monitoring
          Severity: Minor
          Found in lib/mongo/cluster/topology/base.rb - About 1 hr to fix

            Method update_one has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def update_one(spec, opts = {})
                      with_session(opts) do |session|
                        write_concern = if opts[:write_concern]
                          WriteConcern.get(opts[:write_concern])
                        else
            Severity: Minor
            Found in lib/mongo/collection/view/writable.rb - About 1 hr to fix

              Method replace_one has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def replace_one(replacement, opts = {})
                        with_session(opts) do |session|
                          write_concern = if opts[:write_concern]
                            WriteConcern.get(opts[:write_concern])
                          else
              Severity: Minor
              Found in lib/mongo/collection/view/writable.rb - About 1 hr to fix

                Method update_many has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def update_many(spec, opts = {})
                          with_session(opts) do |session|
                            write_concern = if opts[:write_concern]
                              WriteConcern.get(opts[:write_concern])
                            else
                Severity: Minor
                Found in lib/mongo/collection/view/writable.rb - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language