mongodb/mongo-ruby-driver

View on GitHub

Showing 195 of 247 total issues

File sdam_flow.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Mongo::Cluster
  # Handles SDAM flow for a server description changed event.
  #
  # Updates server descriptions, topology descriptions and publishes
  # SDAM events.
Severity: Minor
Found in lib/mongo/cluster/sdam_flow.rb - About 3 hrs to fix

    Method parse! has a Cognitive Complexity of 24 (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 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

    Method check_out has 83 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

      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 initialize has 77 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 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

            Class Server has 26 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 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 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

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

                  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)
                        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

                  File selectable.rb has 267 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 17 (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 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

                      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
                        Severity
                        Category
                        Status
                        Source
                        Language