mongodb/mongo-ruby-driver

View on GitHub

Showing 393 of 447 total issues

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

    Method initialize has a Cognitive Complexity of 19 (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 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 stale_primary? has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def stale_primary?
          if updated_desc.max_wire_version >= 17
            if updated_desc.election_id.nil? && !topology.max_election_id.nil?
              return true
            end
    Severity: Minor
    Found in lib/mongo/cluster/sdam_flow.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 MapReduce has 23 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

        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

          File readable.rb has 269 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            Method validate_new_options! has 59 lines of code (exceeds 25 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: Major
            Found in lib/mongo/client.rb - About 2 hrs to fix

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

                  class FSBucket
                    extend Forwardable
              
                    # The default root prefix.
                    #
              Severity: Minor
              Found in lib/mongo/grid/fs_bucket.rb - About 2 hrs to fix

                Method update_rs_from_primary has 57 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: Major
                Found in lib/mongo/cluster/sdam_flow.rb - About 2 hrs to fix

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

                        def ruby_to_string(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 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

                  File cursor.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module Mongo
                  
                    # Client-side representation of an iterator over a query result set on
                    # the server.
                    #
                  Severity: Minor
                  Found in lib/mongo/cursor.rb - About 2 hrs to fix

                    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

                      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

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

                              def each
                                # If the caching cursor is closed and was not fully iterated,
                                # the documents we have in it are not the complete result set and
                                # we have no way of completing that iteration.
                                # Therefore, discard that cursor and start iteration again.
                      Severity: Minor
                      Found in lib/mongo/collection/view/iterable.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 standard_dependencies has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      def standard_dependencies
                        gem 'yard', '>= 0.9.35'
                        gem 'ffi'
                      
                        group :development, :testing do
                      Severity: Major
                      Found in gemfiles/standard.rb - About 2 hrs to fix

                        Method commit_transaction has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Method run has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def run
                              opts = {
                                region: ENV.fetch('MONGO_RUBY_DRIVER_AWS_AUTH_REGION'),
                                access_key_id: ENV.fetch('MONGO_RUBY_DRIVER_AWS_AUTH_ACCESS_KEY_ID'),
                                secret_access_key: ENV.fetch('MONGO_RUBY_DRIVER_AWS_AUTH_SECRET_ACCESS_KEY'),
                          Severity: Minor
                          Found in .evergreen/lib/ecs_setup.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language