mongodb/mongo-ruby-driver

View on GitHub

Showing 260 of 313 total issues

Method server_description_changed has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def server_description_changed
      @previous_server_descriptions = servers_list.map do |server|
        [server.address.to_s, server.description]
      end

Severity: Minor
Found in lib/mongo/cluster/sdam_flow.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 Cluster has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Cluster
    extend Forwardable
    include Monitoring::Publishable
    include Event::Subscriber
    include Loggable
Severity: Minor
Found in lib/mongo/cluster.rb - About 3 hrs to fix

    Class Binding has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Binding
          extend FFI::Library
    
          begin
            ffi_lib ENV['LIBMONGOCRYPT_PATH']
    Severity: Minor
    Found in lib/mongo/crypt/binding.rb - About 3 hrs to fix

      Method validate_uri_options! has a Cognitive Complexity of 25 (exceeds 5 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: 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 parse! has a Cognitive Complexity of 25 (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 select_server has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def select_server(cluster, ping = nil, session = nil)
              server_selection_timeout = cluster.options[:server_selection_timeout] || SERVER_SELECTION_TIMEOUT
      
              # Special handling for zero timeout: if we have to select a server,
              # and the timeout is zero, fail immediately (since server selection
      Severity: Major
      Found in lib/mongo/server_selector/selectable.rb - About 3 hrs to fix

        Method read_from_socket has a Cognitive Complexity of 24 (exceeds 5 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 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 Server has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Server
            extend Forwardable
            include Monitoring::Publishable
            include Event::Publisher
        
        
        Severity: Minor
        Found in lib/mongo/server.rb - About 3 hrs to fix

          Method initialize has 79 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 with_transaction has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def with_transaction(options=nil)
                  # Non-configurable 120 second timeout for the entire operation
                  deadline = Time.now + 120
                  transaction_in_progress = false
                  loop do
            Severity: Major
            Found in lib/mongo/session.rb - About 3 hrs to fix

              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

                Method server_description_changed has 74 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 2 hrs to fix

                  Method commit_transaction has a Cognitive Complexity of 21 (exceeds 5 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 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

                  Class Cursor has 25 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class Cursor
                      extend Forwardable
                      include Enumerable
                      include Retryable
                  
                  
                  Severity: Minor
                  Found in lib/mongo/cursor.rb - About 2 hrs to fix

                    Class ConnectionPool has 25 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                        class ConnectionPool
                          include Loggable
                          include Monitoring::Publishable
                          extend Forwardable
                    
                    
                    Severity: Minor
                    Found in lib/mongo/server/connection_pool.rb - About 2 hrs to fix

                      Class Result has 25 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 2 hrs to fix

                        Method change_doc has a Cognitive Complexity of 20 (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 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 a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def initialize(seeds, monitoring, options = Options::Redacted.new)
                              if seeds.nil?
                                raise ArgumentError, 'Seeds cannot be nil'
                              end
                        
                        
                        Severity: Minor
                        Found in lib/mongo/cluster.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 selectable.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module Mongo
                          module ServerSelector
                        
                            # Provides common behavior for filtering a list of servers by server mode or tag set.
                            #
                        Severity: Minor
                        Found in lib/mongo/server_selector/selectable.rb - About 2 hrs to fix

                          Class Message has 23 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                              class Message
                                include Id
                                include Serializers
                          
                                # The batch size constant.
                          Severity: Minor
                          Found in lib/mongo/protocol/message.rb - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language