mongodb/mongo-ruby-driver

View on GitHub

Showing 195 of 247 total issues

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

              def ismaster
                @mutex.synchronize do
                  if monitoring.monitoring?
                    monitoring.started(
                      Monitoring::SERVER_HEARTBEAT,
        Severity: Minor
        Found in lib/mongo/server/monitor.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 check_bidi! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def check_bidi!(out)
                if out.each_char.any? { |c| table_contains?(Tables::C8, c) }
                  raise Mongo::Error::FailedStringPrepValidation.new(Error::FailedStringPrepValidation::INVALID_BIDIRECTIONAL)
                end
        
        
        Severity: Minor
        Found in lib/mongo/auth/stringprep.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 command_failed has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def command_failed(failure, address, operation_id, payload, message, duration)
        Severity: Minor
        Found in lib/mongo/monitoring/publishable.rb - About 45 mins to fix

          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

          Method disconnect! has a Cognitive Complexity of 8 (exceeds 5 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 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 aggregate_write_errors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def aggregate_write_errors(count)
                    return unless @replies
                    @replies.reduce(nil) do |errors, reply|
                      if write_errors = reply.documents.first['writeErrors']
                        wes = write_errors.collect do |we|
          Severity: Minor
          Found in lib/mongo/operation/shared/result/aggregatable.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def initialize(command_name, database_name, address, request_id,
                    operation_id, command, socket_object_id: nil, connection_id: nil
          Severity: Minor
          Found in lib/mongo/monitoring/event/command_started.rb - About 45 mins to fix

            Method command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def command(server)
                    sel = selector(server).dup
                    add_write_concern!(sel)
                    sel[Protocol::Msg::DATABASE_IDENTIFIER] = db_name
                    unless server.standalone?
            Severity: Minor
            Found in lib/mongo/operation/shared/sessions_supported.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 reject! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def reject!
                    if block_given?
                      n_keys = keys.size
                      keys.each do |key|
                        delete(key) if yield(key, self[key])
            Severity: Minor
            Found in lib/mongo/options/redacted.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 set_server_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def set_server_list(server_address_strs)
                  @sdam_flow_lock.synchronize do
                    server_address_strs.each do |address_str|
                      unless servers_list.any? { |server| server.address.seed == address_str }
                        add(address_str)
            Severity: Minor
            Found in lib/mongo/cluster.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 try_next has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def try_next
                      raise StopIteration.new if closed?
                      retried = false
            
                      begin
            Severity: Minor
            Found in lib/mongo/collection/view/change_stream.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 clear has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def clear(options = nil)
                    raise_if_closed!
            
                    if options && options[:stop_populator]
                      stop_populator
            Severity: Minor
            Found in lib/mongo/server/connection_pool.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 generate has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def self.generate(address, operation_id, payload, message, failure, duration)
            Severity: Minor
            Found in lib/mongo/monitoring/event/command_failed.rb - About 45 mins to fix
              Severity
              Category
              Status
              Source
              Language