mongodb/mongo-ruby-driver

View on GitHub

Showing 178 of 233 total issues

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

    def server_description_changed
      unless update_server_descriptions
        # All of the transitions require that server whose updated_desc we are
        # processing is still in the cluster (i.e., was not removed as a result
        # of processing another response, potentially concurrently).
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

Method check_out has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def check_out
        publish_cmap_event(
          Monitoring::Event::Cmap::ConnectionCheckOutStarted.new(@server.address)
        )

Severity: Major
Found in lib/mongo/server/connection_pool.rb - About 3 hrs to fix

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

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

      File cluster.rb has 291 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'mongo/cluster/topology'
      require 'mongo/cluster/reapers/socket_reaper'
      require 'mongo/cluster/reapers/cursor_reaper'
      require 'mongo/cluster/periodic_executor'
      
      
      Severity: Minor
      Found in lib/mongo/cluster.rb - About 3 hrs to fix

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

                def initialize(seeds, monitoring, options = Options::Redacted.new)
                  if options[:monitoring_io] == false && !options.key?(:cleanup)
                    options = options.dup
                    options[:cleanup] = false
                  end
            Severity: Major
            Found in lib/mongo/cluster.rb - About 2 hrs to fix

              Class Server has 24 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 2 hrs to fix

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

                        def change_doc
                          { fullDocument: ( @options[:full_document] || FULL_DOCUMENT_DEFAULT ) }.tap do |doc|
                            if resuming?
                              # We have a resume token once we retrieved any documents.
                              # However, if the first getMore fails and the user didn't pass
                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

                Class ConnectionPool has 23 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

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

                      def initialize(string, options = {})
                        @string = string
                        @options = options
                        parsed_scheme, _, remaining = string.partition(SCHEME_DELIM)
                        raise_invalid_error!(INVALID_SCHEME) unless parsed_scheme == scheme
                  Severity: Minor
                  Found in lib/mongo/uri.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 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def initialize(seeds, monitoring, options = Options::Redacted.new)
                        if options[:monitoring_io] == false && !options.key?(:cleanup)
                          options = options.dup
                          options[:cleanup] = false
                        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

                  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

                  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

                    File selectable.rb has 255 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

                      Method write_with_retry has a Cognitive Complexity of 16 (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 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 server_description_changed has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def server_description_changed
                            unless update_server_descriptions
                              # All of the transitions require that server whose updated_desc we are
                              # processing is still in the cluster (i.e., was not removed as a result
                              # of processing another response, potentially concurrently).
                      Severity: Major
                      Found in lib/mongo/cluster/sdam_flow.rb - About 2 hrs 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
                          Severity
                          Category
                          Status
                          Source
                          Language