mongodb/mongo-ruby-driver

View on GitHub

Showing 423 of 480 total issues

Method create_context has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def create_context(options)
        OpenSSL::SSL::SSLContext.new.tap do |context|
          if OpenSSL::SSL.const_defined?(:OP_NO_RENEGOTIATION)
            context.options = context.options | OpenSSL::SSL::OP_NO_RENEGOTIATION
          end
Severity: Minor
Found in lib/mongo/socket/ssl.rb - About 2 hrs 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 commit_transaction has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def commit_transaction(options=nil)
      QueryCache.clear
      check_if_ended!
      check_if_no_transaction!

Severity: Major
Found in lib/mongo/session.rb - About 2 hrs to fix

    Class SdamFlow has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class SdamFlow
        extend Forwardable
    
        def initialize(cluster, previous_desc, updated_desc, awaited: false)
          @cluster = cluster
    Severity: Minor
    Found in lib/mongo/cluster/sdam_flow.rb - About 2 hrs to fix

      Method standard_dependencies has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def standard_dependencies
        gem 'yard', '>= 0.9.35'
        gem 'ffi'
      
        group :development, :testing do
      Severity: Major
      Found in gemfiles/standard.rb - About 2 hrs to fix

        Method validate_authentication_options! has a Cognitive Complexity of 16 (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 2 hrs 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 apply_find_timeouts_to has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

                def apply_find_timeouts_to(spec, timeout_ms)
                  view = context&.view
                  return spec unless view
        
                  case view.cursor_type
        Severity: Minor
        Found in lib/mongo/operation/find/op_msg.rb - About 2 hrs 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 connect! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def connect!
                sockaddr = ::Socket.pack_sockaddr_in(port, host)
                connect_timeout = options[:connect_timeout]
                map_exceptions do
                  if connect_timeout && connect_timeout != 0
        Severity: Minor
        Found in lib/mongo/socket/ssl.rb - About 2 hrs 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 has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run
            opts = {
              region: ENV.fetch('MONGO_RUBY_DRIVER_AWS_AUTH_REGION'),
              access_key_id: ENV.fetch('MONGO_RUBY_DRIVER_AWS_AUTH_ACCESS_KEY_ID'),
              secret_access_key: ENV.fetch('MONGO_RUBY_DRIVER_AWS_AUTH_SECRET_ACCESS_KEY'),
        Severity: Minor
        Found in .evergreen/lib/ecs_setup.rb - About 1 hr to fix

          Method deliver has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def deliver(message, context, options = {})
                  if Lint.enabled? && !@socket
                    raise Error::LintError, "Trying to deliver a message over a disconnected connection (to #{address})"
                  end
                  buffer = serialize(message, context)
          Severity: Minor
          Found in lib/mongo/server/connection_base.rb - About 1 hr to fix

            Method abort_transaction has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def abort_transaction(options = nil)
                  QueryCache.clear
            
                  check_if_ended!
                  check_if_no_transaction!
            Severity: Minor
            Found in lib/mongo/session.rb - About 1 hr to fix

              Method run_benchmark has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                    def run_benchmark
                      [].tap do |timings|
                        iteration_count = 0
                        cumulative_time = 0
              
              
              Severity: Minor
              Found in profile/driver_bench/base.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 normalized? has a Cognitive Complexity of 15 (exceeds 5 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

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

                    def add_read_preference(sel, connection)
                      Lint.assert_type(connection, Server::Connection)
              
                      # https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#topology-type-single
                      read_doc = if connection.description.standalone?
              Severity: Minor
              Found in lib/mongo/operation/shared/sessions_supported.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 each has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def each
              
                    # If we already iterated past the first batch (i.e., called get_more
                    # at least once), the cursor on the server side has advanced past
                    # the first batch and restarting iteration from the beginning by
              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 initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                        def initialize(opts)
                          @opts = opts
                          return if empty?
              
                          if opts[:access_token]
              Severity: Minor
              Found in lib/mongo/crypt/kms/gcp/credentials.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 retry_read has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                    def retry_read(original_error, session, server_selector, context: nil, failed_server: nil, &block)
                      server = select_server_for_retry(
                        original_error, session, server_selector, context, failed_server
                      )
              
              
              Severity: Minor
              Found in lib/mongo/retryable/read_worker.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 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def initialize(server, options = {})
                      unless server.is_a?(Server)
                        raise ArgumentError, 'First argument must be a Server instance'
                      end
                      options = options.dup
              Severity: Minor
              Found in lib/mongo/server/connection_pool.rb - About 1 hr to fix

                Method kill_cursors has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def kill_cursors
                        # TODO optimize this to batch kill cursor operations for the same
                        # server/database/collection instead of killing each cursor
                        # individually.
                        loop do
                Severity: Minor
                Found in lib/mongo/cluster/reapers/cursor_reaper.rb - About 1 hr to fix

                  Method add_txn_opts! has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def add_txn_opts!(command, read, context)
                        command.tap do |c|
                          # The read concern should be added to any command that starts a transaction.
                          if starting_transaction?
                            # https://jira.mongodb.org/browse/SPEC-1161: transaction's
                  Severity: Minor
                  Found in lib/mongo/session.rb - About 1 hr to fix

                    Method handshake_and_authenticate! has a Cognitive Complexity of 14 (exceeds 5 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

                    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