mongodb/mongo-ruby-driver

View on GitHub

Showing 158 of 211 total issues

Method select_server has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def select_server(cluster, ping = nil)
        if cluster.replica_set?
          validate_max_staleness_value_early!
        end
        if cluster.addresses.empty?
Severity: Major
Found in lib/mongo/server_selector/selectable.rb - About 2 hrs to fix

    Class Cursor has 24 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 Result has 23 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 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize(seeds, monitoring, options = Options::Redacted.new)
              if options[:monitoring_io] != false && !options[:server_selection_semaphore]
                raise ArgumentError, 'Need server selection semaphore'
              end
        
        
        Severity: Major
        Found in lib/mongo/cluster.rb - About 2 hrs to fix

          File cluster.rb has 269 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 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

            File client.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Mongo
            
              # The client is the entry point to the driver and is the main object that
              # will be interacted with.
              #
            Severity: Minor
            Found in lib/mongo/client.rb - About 2 hrs to fix

              Method initialize has a Cognitive Complexity of 17 (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

              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 commit_transaction has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def commit_transaction(options=nil)
                      check_if_ended!
                      check_if_no_transaction!
                
                      if within_states?(TRANSACTION_ABORTED_STATE)
                Severity: Major
                Found in lib/mongo/session.rb - About 2 hrs to fix

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

                      def parse_servers!(string)
                        raise_invalid_error!(INVALID_HOST) unless string.size > 0
                        string.split(HOST_DELIM).reduce([]) do |servers, host|
                          if host[0] == '['
                            if host.index(']:')
                  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 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def initialize(seeds, monitoring, options = Options::Redacted.new)
                        if options[:monitoring_io] != false && !options[:server_selection_semaphore]
                          raise ArgumentError, 'Need server selection semaphore'
                        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 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

                  File connection_pool.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module Mongo
                    class Server
                  
                      # Represents a connection pool for server connections.
                      #
                  Severity: Minor
                  Found in lib/mongo/server/connection_pool.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

                      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

                        Method normalized? has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def self.normalized?(string, form = :nfc)
                            encoding = string.encoding
                            case encoding
                            when Encoding::UTF_8
                              case form
                        Severity: Minor
                        Found in lib/mongo/auth/stringprep/unicode_normalize/normalize.rb - About 1 hr 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 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                                def initialize(options, monitoring, cluster)
                                  options = validate_options(options, cluster)
                        
                                  @options = options
                                  @monitoring = monitoring
                        Severity: Minor
                        Found in lib/mongo/cluster/topology/base.rb - About 1 hr 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 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def check_out
                                raise_if_closed!
                        
                                publish_cmap_event(
                                  Monitoring::Event::Cmap::ConnectionCheckOutStarted.new(@server.address)
                        Severity: Minor
                        Found in lib/mongo/server/connection_pool.rb - About 1 hr to fix

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

                                def initialize(server, options = {})
                                  unless server.is_a?(Server)
                                    raise ArgumentError, 'First argument must be a Server instance'
                                  end
                                  options = options.dup
                          Severity: Minor
                          Found in lib/mongo/server/connection_pool.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language