mongodb/mongo-ruby-driver

View on GitHub

Showing 423 of 480 total issues

Method set_crypto_hooks has 89 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 3 hrs to fix

    Method verify_one_responder has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def verify_one_responder(uri)
            original_uri = uri
            redirect_count = 0
            http_response = nil
            loop do
    Severity: Major
    Found in lib/mongo/socket/ocsp_verifier.rb - About 3 hrs to fix

      File socket.rb has 313 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'mongo/socket/ssl'
      require 'mongo/socket/tcp'
      require 'mongo/socket/unix'
      require 'mongo/socket/ocsp_verifier'
      require 'mongo/socket/ocsp_cache'
      Severity: Minor
      Found in lib/mongo/socket.rb - About 3 hrs to fix

        Class Socket has 29 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Socket
            include ::Socket::Constants
        
            # Error message for TLS related exceptions.
            #
        Severity: Minor
        Found in lib/mongo/socket.rb - About 3 hrs to fix

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

              def initialize(seeds, monitoring, options = Options::Redacted.new)
                if seeds.nil?
                  raise ArgumentError, 'Seeds cannot be nil'
                end
          
          
          Severity: Major
          Found in lib/mongo/cluster.rb - About 3 hrs to fix

            Method change_doc has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                    def change_doc
                      {}.tap do |doc|
                        if @options[:full_document]
                          doc[:fullDocument] = @options[:full_document]
                        end
            Severity: Minor
            Found in lib/mongo/collection/view/change_stream.rb - About 3 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 uri.rb has 308 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Mongo
            
              # The URI class provides a way for users to parse the MongoDB uri as
              # defined in the connection string format spec.
              #
            Severity: Minor
            Found in lib/mongo/uri.rb - About 3 hrs to fix

              Method server_description_changed has 84 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def server_description_changed
                    @previous_server_descriptions = servers_list.map do |server|
                      [server.address.to_s, server.description]
                    end
              
              
              Severity: Major
              Found in lib/mongo/cluster/sdam_flow.rb - About 3 hrs to fix

                Class Result has 28 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class Result
                      extend Forwardable
                      include Enumerable
                
                      # The field name for the cursor document in an aggregation.
                Severity: Minor
                Found in lib/mongo/operation/result.rb - About 3 hrs to fix

                  Method kill_cursors has a Cognitive Complexity of 23 (exceeds 5 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 3 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 description.rb has 300 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module Mongo
                    class Server
                  
                      # Represents a description of the server, populated by the result of the
                      # hello command.
                  Severity: Minor
                  Found in lib/mongo/server/description.rb - About 3 hrs to fix

                    File readable.rb has 297 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    module Mongo
                      class Collection
                        class View
                    
                          # Defines read related behavior for collection view.
                    Severity: Minor
                    Found in lib/mongo/collection/view/readable.rb - About 3 hrs to fix

                      Method estimated_document_count has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def estimated_document_count(opts = {})
                                unless view.filter.empty?
                                  raise ArgumentError, "Cannot call estimated_document_count when querying with a filter"
                                end
                      
                      
                      Severity: Minor
                      Found in lib/mongo/collection/view/readable.rb - About 3 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 parse! has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def parse!(remaining)
                            hosts_and_db, options = remaining.split('?', 2)
                            if options && options.index('?')
                              raise_invalid_error!("Options contain an unescaped question mark (?), or the database name contains a question mark and was not escaped")
                            end
                      Severity: Minor
                      Found in lib/mongo/uri.rb - About 3 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 a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def initialize(options)
                              Crypt.validate_ffi!
                              # Note that this call may eventually, via other method invocations,
                              # create additional clients which have to be cleaned up.
                              @options = set_default_options(options).freeze
                      Severity: Minor
                      Found in lib/mongo/crypt/auto_encrypter.rb - About 3 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

                      Class ScramConversationBase has 26 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                          class ScramConversationBase < SaslConversationBase
                      
                            # The minimum iteration count for SCRAM-SHA-1 and SCRAM-SHA-256.
                            MIN_ITER_COUNT = 4096
                      
                      
                      Severity: Minor
                      Found in lib/mongo/auth/scram_conversation_base.rb - About 3 hrs to fix

                        File cursor.rb has 290 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module Mongo
                        
                          # Client-side representation of an iterator over a query result set on
                          # the server.
                          #
                        Severity: Minor
                        Found in lib/mongo/cursor.rb - About 2 hrs to fix

                          Method commit_transaction has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def commit_transaction(options=nil)
                                QueryCache.clear
                                check_if_ended!
                                check_if_no_transaction!
                          
                          
                          Severity: Minor
                          Found in lib/mongo/session.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 ssl.rb has 287 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          module Mongo
                            class Socket
                          
                              # Wrapper for TLS sockets.
                              #
                          Severity: Minor
                          Found in lib/mongo/socket/ssl.rb - About 2 hrs to fix

                            Method validate_uri_options! has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def validate_uri_options!
                                  # The URI options spec requires that we raise an error if there are conflicting values of
                                  # 'tls' and 'ssl'. In order to fulfill this, we parse the values of each instance into an
                                  # array; assuming all values in the array are the same, we replace the array with that value.
                                  unless uri_options[:ssl].nil? || uri_options[:ssl].empty?
                            Severity: Major
                            Found in lib/mongo/uri.rb - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language