mongodb/mongo-ruby-driver

View on GitHub

Showing 312 of 370 total issues

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

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

      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

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

            def validate_session_support!
              @state_change_lock.synchronize do
                @sdam_flow_lock.synchronize do
                  if topology.data_bearing_servers?
                    unless topology.logical_session_timeout
        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

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

            Method validate_options! has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def validate_options!(addresses = nil)
                  if options[:write] && options[:write_concern] && options[:write] != options[:write_concern]
                    raise ArgumentError, "If :write and :write_concern are both given, they must be identical: #{options.inspect}"
                  end
            
            
            Severity: Major
            Found in lib/mongo/client.rb - About 2 hrs to fix

              Method read_from_socket has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def read_from_socket(length, timeout: nil)
                    # Just in case
                    if length == 0
                      return ''.force_encoding('BINARY')
                    end
              Severity: Major
              Found in lib/mongo/socket.rb - About 2 hrs to fix

                File uri.rb has 265 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 2 hrs to fix

                  Class Base has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                      class Base
                  
                        # Initialize the server selector.
                        #
                        # @example Initialize the selector.
                  Severity: Minor
                  Found in lib/mongo/server_selector/base.rb - About 2 hrs to fix

                    File server.rb has 263 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

                      File ocsp_verifier.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      module Net
                        autoload :HTTP, 'net/http'
                      end
                      
                      module Mongo
                      Severity: Minor
                      Found in lib/mongo/socket/ocsp_verifier.rb - About 2 hrs to fix

                        Method ruby_to_smc has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def ruby_to_smc(opts)
                                rv = {}
                                URI_OPTION_MAP.each do |uri_key, spec|
                                  if spec[:group]
                                    v = opts[spec[:group]]
                        Severity: Minor
                        Found in lib/mongo/uri/options_mapper.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 SdamFlow has 21 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                          class SdamFlow
                            extend Forwardable
                        
                            def initialize(cluster, previous_desc, updated_desc, awaited: false)
                              @cluster = cluster
                        Severity: Minor
                        Found in lib/mongo/cluster/sdam_flow.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

                            File retryable.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            module Mongo
                            
                              # Defines basic behavior around retrying operations.
                              #
                              # @since 2.1.0
                            Severity: Minor
                            Found in lib/mongo/retryable.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

                              Severity
                              Category
                              Status
                              Source
                              Language