mongodb/mongo-ruby-driver

View on GitHub

Showing 169 of 222 total issues

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

      def initialize(host, port, timeout, family, options = {})
Severity: Minor
Found in lib/mongo/socket/tcp.rb - About 35 mins to fix

    Method update_one has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def update_one(documents, server, operation_id, session, txn_num)
    Severity: Minor
    Found in lib/mongo/bulk_write.rb - About 35 mins to fix

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

            def initialize(database, collection, selector, update, options = {})
      Severity: Minor
      Found in lib/mongo/protocol/update.rb - About 35 mins to fix

        Method start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def start(connection = nil)
                  login = LOGIN.merge(mechanism: X509::MECHANISM)
                  login[:user] = user.name if user.name
                  if connection && connection.features.op_msg_enabled?
                    selector = login
        Severity: Minor
        Found in lib/mongo/auth/x509/conversation.rb - About 35 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 clear has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def clear(options = nil)
                raise_if_closed!
        
                @lock.synchronize do
                  @generation += 1
        Severity: Minor
        Found in lib/mongo/server/connection_pool.rb - About 35 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 update_rs_with_primary_from_member has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_rs_with_primary_from_member
              if topology.replica_set_name != updated_desc.replica_set_name
                log_warn(
                  "Removing server #{updated_desc.address.to_s} because it has an " +
                  "incorrect replica set name (#{updated_desc.replica_set_name}); " +
        Severity: Minor
        Found in lib/mongo/cluster/sdam_flow.rb - About 35 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 command has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def command(server)
                sel = selector(server).dup
                add_write_concern!(sel)
                sel[Protocol::Msg::DATABASE_IDENTIFIER] = db_name
                sel['$readPreference'] = read.to_doc if read
        Severity: Minor
        Found in lib/mongo/operation/shared/sessions_supported.rb - About 35 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 end_session has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def end_session
              if !ended? && @client
                if within_states?(TRANSACTION_IN_PROGRESS_STATE)
                  begin
                    abort_transaction
        Severity: Minor
        Found in lib/mongo/session.rb - About 35 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 populate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def populate
                return if closed?
        
                catch(:done) do
                  loop do
        Severity: Minor
        Found in lib/mongo/server/connection_pool.rb - About 35 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 document has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def document
                client_document = full_client_document
                while client_document.to_bson.to_s.size > MAX_DOCUMENT_SIZE do
                  if client_document[:os][:name] || client_document[:os][:architecture]
                    client_document[:os].delete(:name)
        Severity: Minor
        Found in lib/mongo/server/app_metadata.rb - About 35 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_reply has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def self.generate_reply(command_payload, reply_payload)
                  if reply_payload
                    reply = reply_payload[:reply]
                    if cursor = reply[:cursor]
                      if !cursor.key?(Collection::NS)
        Severity: Minor
        Found in lib/mongo/monitoring/event/command_succeeded.rb - About 35 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 server_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def server_type
                return :arbiter if arbiter?
                return :ghost if ghost?
                return :sharded if mongos?
                return :primary if primary?
        Severity: Minor
        Found in lib/mongo/server/description.rb - About 35 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 count has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def count(opts = {})
                  cmd = { :count => collection.name, :query => filter }
                  cmd[:skip] = opts[:skip] if opts[:skip]
                  cmd[:hint] = opts[:hint] if opts[:hint]
                  cmd[:limit] = opts[:limit] if opts[:limit]
        Severity: Minor
        Found in lib/mongo/collection/view/readable.rb - About 35 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 open_download_stream_by_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def open_download_stream_by_name(filename, opts = {}, &block)
                revision = opts.fetch(:revision, -1)
                if revision < 0
                  skip = revision.abs - 1
                  sort = { 'uploadDate' => Mongo::Index::DESCENDING }
        Severity: Minor
        Found in lib/mongo/grid/fs_bucket.rb - About 35 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 initial has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def initial(cluster, monitoring, options)
                cls = if options.key?(:connect)
                  OPTIONS.fetch(options[:connect].to_sym)
                elsif options.key?(:replica_set) || options.key?(:replica_set_name)
                  ReplicaSetNoPrimary
        Severity: Minor
        Found in lib/mongo/cluster/topology.rb - About 35 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_cert_verification has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def set_cert_verification(context, options)
                context.verify_mode = OpenSSL::SSL::VERIFY_PEER
                cert_store = OpenSSL::X509::Store.new
                if options[:ssl_ca_cert]
                  cert_store.add_file(options[:ssl_ca_cert])
        Severity: Minor
        Found in lib/mongo/socket/ssl.rb - About 35 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 deserialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.deserialize(io, max_message_size = MAX_MESSAGE_SIZE, expected_response_to = nil)
                length, _request_id, response_to, _op_code = deserialize_header(BSON::ByteBuffer.new(io.read(16)))
        
                # Protection from potential DOS man-in-the-middle attacks. See
                # DRIVERS-276.
        Severity: Minor
        Found in lib/mongo/protocol/message.rb - About 35 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

        Avoid too many return statements within this method.
        Open

                return :secondary if secondary?
        Severity: Major
        Found in lib/mongo/server/description.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return :standalone if standalone?
          Severity: Major
          Found in lib/mongo/server/description.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return :other if other?
            Severity: Major
            Found in lib/mongo/server/description.rb - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language