mongodb/mongo-ruby-driver

View on GitHub

Showing 423 of 480 total issues

File sdam_flow.rb has 437 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 6 hrs to fix

    Method verify_one_responder has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

          def verify_one_responder(uri)
            original_uri = uri
            redirect_count = 0
            http_response = nil
            loop do
    Severity: Minor
    Found in lib/mongo/socket/ocsp_verifier.rb - About 6 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 options_mapper.rb has 430 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Mongo
      class URI
    
        # Performs mapping between URI options and Ruby options.
        #
    Severity: Minor
    Found in lib/mongo/uri/options_mapper.rb - About 6 hrs to fix

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

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

        Method add_txn_opts! has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
        Open

            def add_txn_opts!(command, read, context)
              command.tap do |c|
                # The read concern should be added to any command that starts a transaction.
                if starting_transaction?
                  # https://jira.mongodb.org/browse/SPEC-1161: transaction's
        Severity: Minor
        Found in lib/mongo/session.rb - About 6 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 Collection has 37 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Collection
            extend Forwardable
            include Retryable
            include QueryableEncryption
            include Helpers
        Severity: Minor
        Found in lib/mongo/collection.rb - About 4 hrs to fix

          Method initialize has a Cognitive Complexity of 32 (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 4 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 View has 35 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class View
          
                # Defines read related behavior for collection view.
                #
                # @since 2.0.0
          Severity: Minor
          Found in lib/mongo/collection/view/readable.rb - About 4 hrs to fix

            File base.rb has 354 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Mongo
            
              module ServerSelector
            
                class Base
            Severity: Minor
            Found in lib/mongo/server_selector/base.rb - About 4 hrs to fix

              Class Cluster has 34 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 4 hrs to fix

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

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

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

                      def validate_options!(addresses = nil, is_srv: 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 4 hrs to fix

                    Method select_server_impl has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          private def select_server_impl(cluster, ping, session, write_aggregation, deprioritized, csot_timeout)
                            if cluster.topology.is_a?(Cluster::Topology::LoadBalanced)
                              return cluster.servers.first
                            end
                    
                    
                    Severity: Major
                    Found in lib/mongo/server_selector/base.rb - About 3 hrs to fix

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

                          def initialize(addresses_or_uri, options = nil)
                            options = options ? options.dup : {}
                      
                            srv_uri = nil
                            if addresses_or_uri.is_a?(::String)
                      Severity: Minor
                      Found in lib/mongo/client.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 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

                      File writable.rb has 329 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

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

                        Class Server has 31 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 with_transaction has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def with_transaction(options = nil)
                                if timeout_ms = (options || {})[:timeout_ms]
                                  timeout_sec = timeout_ms / 1_000.0
                                  deadline = Utils.monotonic_time + timeout_sec
                                  @with_transaction_deadline = deadline
                          Severity: Major
                          Found in lib/mongo/session.rb - About 3 hrs to fix

                            File server.rb has 321 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 3 hrs to fix

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

                                  def initialize(addresses_or_uri, options = nil)
                                    options = options ? options.dup : {}
                              
                                    srv_uri = nil
                                    if addresses_or_uri.is_a?(::String)
                              Severity: Major
                              Found in lib/mongo/client.rb - About 3 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language