mongodb/mongo-ruby-driver

View on GitHub

Showing 260 of 313 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 initialize has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(addresses_or_uri, options = nil)
      options = options ? options.dup : {}

      srv_uri = nil
      if addresses_or_uri.is_a?(::String)
Severity: Major
Found in lib/mongo/client.rb - About 2 hrs to fix

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

          class MapReduce
            extend Forwardable
            include Enumerable
            include Immutable
            include Loggable
    Severity: Minor
    Found in lib/mongo/collection/view/map_reduce.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

      File server.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Mongo
      
        # Represents a single server on the server side that can be standalone, part of
        # a replica set, or a mongos.
        #
      Severity: Minor
      Found in lib/mongo/server.rb - About 2 hrs to fix

        Method set_crypto_hooks has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def set_crypto_hooks
                @aes_encrypt = Proc.new do |_, key_binary_p, iv_binary_p, input_binary_p,
                  output_binary_p, response_length_p, status_p|
                  do_aes(
                    key_binary_p,
        Severity: Major
        Found in lib/mongo/crypt/handle.rb - About 2 hrs to fix

          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 update_rs_from_primary has 48 lines of code (exceeds 25 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

              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 initialize has a Cognitive Complexity of 15 (exceeds 5 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

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

                    def add_error_labels(client, connection, session)
                      begin
                        yield
                      rescue Mongo::Error::SocketError => e
                        if session && session.in_transaction? && !session.committing_transaction?
              Severity: Minor
              Found in lib/mongo/operation/shared/response_handling.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 write_with_retry has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def write_with_retry(session, write_concern, ending_transaction = false, &block)
                    if ending_transaction && !session
                      raise ArgumentError, 'Cannot end a transaction without a session'
                    end
              
              
              Severity: Minor
              Found in lib/mongo/retryable.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 read_from_socket has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def read_from_socket(length)
                    # Just in case
                    if length == 0
                      return ''.force_encoding('BINARY')
                    end
              Severity: Minor
              Found in lib/mongo/socket.rb - About 1 hr to fix

                Method commit_transaction has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def commit_transaction(options=nil)
                      check_if_ended!
                      check_if_no_transaction!
                
                      if within_states?(TRANSACTION_ABORTED_STATE)
                Severity: Minor
                Found in lib/mongo/session.rb - About 1 hr to fix

                  Method initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def initialize(addresses_or_uri, options = nil)
                        options = options ? options.dup : {}
                  
                        srv_uri = nil
                        if addresses_or_uri.is_a?(::String)
                  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 check_in has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def check_in(connection)
                          check_invariants
                  
                          @lock.synchronize do
                            unless connection.connection_pool == self
                  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 validate_new_options! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def validate_new_options!(opts = Options::Redacted.new)
                        return Options::Redacted.new unless opts
                        Lint.validate_underscore_read_preference(opts[:read])
                        Lint.validate_read_concern_option(opts[:read_concern])
                        opts.each.inject(Options::Redacted.new) do |_options, (k, v)|
                  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 add_read_preference has a Cognitive Complexity of 14 (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
                          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 initialize has 42 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 validate_authentication_options! has 41 lines of code (exceeds 25 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
                      Severity
                      Category
                      Status
                      Source
                      Language