mongodb/mongo-ruby-driver

View on GitHub

Showing 447 of 447 total issues

File tables.rb has 3148 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Mongo
  module Auth
    module StringPrep
      # Contains character tables defined by RFC 3454 (string preparation).
      #
Severity: Major
Found in lib/mongo/auth/stringprep/tables.rb - About 1 wk to fix

    File tables.rb has 1161 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module UnicodeNormalize  # :nodoc:
      accents = "" \
        "[\u0300-\u034E\u0350-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7" \
        "\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711" \
        "\u0730-\u074A\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1" \
    Severity: Major
    Found in lib/mongo/auth/stringprep/unicode_normalize/tables.rb - About 2 days to fix

      Method select_server_impl has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
      Open

            private def select_server_impl(cluster, ping, session, write_aggregation)
              if cluster.topology.is_a?(Cluster::Topology::LoadBalanced)
                return cluster.servers.first
              end
      
      
      Severity: Minor
      Found in lib/mongo/server_selector/base.rb - About 1 day 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 a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring.
      Open

            def check_out(connection_global_id: nil)
              check_invariants
      
              publish_cmap_event(
                Monitoring::Event::Cmap::ConnectionCheckOutStarted.new(@server.address)
      Severity: Minor
      Found in lib/mongo/server/connection_pool.rb - About 1 day 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 697 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: Major
      Found in lib/mongo/client.rb - About 1 day to fix

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

        module Mongo
          class Server
        
            # Represents a connection pool for server connections.
            #
        Severity: Major
        Found in lib/mongo/server/connection_pool.rb - About 1 day to fix

          Method validate_options! has a Cognitive Complexity of 71 (exceeds 5 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: Minor
          Found in lib/mongo/client.rb - About 1 day 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 binding.rb has 607 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          unless ENV['LIBMONGOCRYPT_PATH']
            begin
              require 'libmongocrypt_helper'
            rescue LoadError => e
              # It seems that MRI maintains autoload configuration for a module until
          Severity: Major
          Found in lib/mongo/crypt/binding.rb - About 1 day to fix

            File session.rb has 545 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'mongo/session/session_pool'
            require 'mongo/session/server_session'
            
            module Mongo
            
            
            Severity: Major
            Found in lib/mongo/session.rb - About 1 day to fix

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

                  def validate_uri_options!
                    # The URI options spec requires that we raise an error if there are conflicting values of
                    # 'tls' and 'ssl'. In order to fulfill this, we parse the values of each instance into an
                    # array; assuming all values in the array are the same, we replace the array with that value.
                    unless uri_options[:ssl].nil? || uri_options[:ssl].empty?
              Severity: Minor
              Found in lib/mongo/uri.rb - About 7 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_new_options! has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_new_options!(opts)
                    return Options::Redacted.new unless opts
                    if opts[:read_concern]
                      # Raise an error for non user-settable options
                      if opts[:read_concern][:after_cluster_time]
              Severity: Minor
              Found in lib/mongo/client.rb - About 7 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_requests! has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_requests!
                    requests_empty = true
                    @requests.each do |req|
                      requests_empty = false
                      if op = req.keys.first
              Severity: Minor
              Found in lib/mongo/bulk_write.rb - About 7 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 do_execute has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
              Open

                    def do_execute(connection, context, options = {})
                      session&.materialize_if_needed
                      unpin_maybe(session, connection) do
                        add_error_labels(connection, context) do
                          add_server_diagnostics(connection) do
              Severity: Minor
              Found in lib/mongo/operation/shared/executable.rb - About 7 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 cluster.rb has 466 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 7 hrs to fix

                Class OptionsMapper has 50 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class OptionsMapper
                
                      include Loggable
                
                      # Instantates the options mapper.
                Severity: Minor
                Found in lib/mongo/uri/options_mapper.rb - About 7 hrs to fix

                  Method read_from_socket has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def read_from_socket(length, timeout: nil)
                        # Just in case
                        if length == 0
                          return ''.force_encoding('BINARY')
                        end
                  Severity: Minor
                  Found in lib/mongo/socket.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

                  Method with_transaction has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def with_transaction(options=nil)
                        # Non-configurable 120 second timeout for the entire operation
                        deadline = Utils.monotonic_time + 120
                        transaction_in_progress = false
                        loop do
                  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 Session has 48 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class Session
                      extend Forwardable
                      include Retryable
                      include Loggable
                      include ClusterTime::Consumer
                  Severity: Minor
                  Found in lib/mongo/session.rb - About 6 hrs to fix

                    Class Description has 47 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                        class Description
                    
                          # Constant for reading arbiter info from config.
                          #
                          # @since 2.0.0
                    Severity: Minor
                    Found in lib/mongo/server/description.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

                      Severity
                      Category
                      Status
                      Source
                      Language