mongodb/mongo-ruby-driver

View on GitHub

Showing 264 of 315 total issues

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

      def initialize(mongocrypt, io, doc, options={})
        super(mongocrypt, io)

        if options[:key_id].nil? && options[:key_alt_name].nil?
          raise ArgumentError.new(
Severity: Minor
Found in lib/mongo/crypt/explicit_encryption_context.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 set_aws_master_key has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def set_aws_master_key(master_key_opts)
        unless master_key_opts
          raise ArgumentError.new('The :master_key option cannot be nil')
        end

Severity: Minor
Found in lib/mongo/crypt/data_key_context.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 set_kms_providers_aws has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def set_kms_providers_aws(kms_providers)
        unless kms_providers[:aws]
          raise ArgumentError.new('The :aws KMS provider must not be nil')
        end

Severity: Minor
Found in lib/mongo/crypt/handle.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 validate_length! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

          def validate_length!(index, num_chunks, chunk, length_read)
            if num_chunks > 0 && chunk.data.data.size > 0
              raise Error::ExtraFileChunk.new unless index < num_chunks
              if index == num_chunks - 1
                unless chunk.data.data.size + length_read == file_info.length
Severity: Minor
Found in lib/mongo/grid/stream/read.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 standard_dependencies has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def standard_dependencies
  gem 'yard'
  gem 'ffi'

  group :development, :testing do
Severity: Minor
Found in gemfiles/standard.rb - About 1 hr to fix

    Method ec2_metadata_credentials has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def ec2_metadata_credentials
              http = Net::HTTP.new('169.254.169.254')
              req = Net::HTTP::Put.new('/latest/api/token',
                # The TTL is required in order to obtain the metadata token.
                {'x-aws-ec2-metadata-token-ttl-seconds' => '30'})
    Severity: Minor
    Found in lib/mongo/auth/aws/credentials_retriever.rb - About 1 hr to fix

      Method abort_transaction has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def abort_transaction
            check_if_ended!
            check_if_no_transaction!
      
            if within_states?(TRANSACTION_COMMITTED_STATE)
      Severity: Minor
      Found in lib/mongo/session.rb - About 1 hr to fix

        Method execute has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def execute
              operation_id = Monitoring.next_operation_id
              result_combiner = ResultCombiner.new
              operations = op_combiner.combine
        
        
        Severity: Minor
        Found in lib/mongo/bulk_write.rb - About 1 hr to fix

          Method set_kms_providers_aws has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def set_kms_providers_aws(kms_providers)
                  unless kms_providers[:aws]
                    raise ArgumentError.new('The :aws KMS provider must not be nil')
                  end
          
          
          Severity: Minor
          Found in lib/mongo/crypt/handle.rb - About 1 hr to fix

            Method validate_uri_options! has 34 lines of code (exceeds 25 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 1 hr to fix

              Method write_with_retry has 34 lines of code (exceeds 25 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 1 hr to fix

                Method deliver has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def deliver(message, client, options = {})
                        if Lint.enabled? && !@socket
                          raise Error::LintError, "Trying to deliver a message over a disconnected connection (to #{address})"
                        end
                        buffer = serialize(message, client)
                Severity: Minor
                Found in lib/mongo/server/connection_base.rb - About 1 hr to fix

                  Method initialize has 33 lines of code (exceeds 25 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

                    Method check_in has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def check_in(connection)
                            check_invariants
                    
                            @lock.synchronize do
                              unless connection.connection_pool == self
                    Severity: Minor
                    Found in lib/mongo/server/connection_pool.rb - About 1 hr to fix

                      Method download_url has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def download_url
                          @download_url ||= begin
                            info = JSON.load(uri_open('http://downloads.mongodb.org/current.json').read)
                            version = info['versions'].detect do |version|
                              version['version'].start_with?(desired_version) &&
                      Severity: Minor
                      Found in .evergreen/tools.rb - About 1 hr to fix

                        Method convert_limit_and_batch_size has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                                  def convert_limit_and_batch_size(command)
                                    if command[:limit] && command[:limit] < 0 &&
                                        command[:batchSize] && command[:batchSize] < 0
                        
                                      command[:limit] = command[:limit].abs
                        Severity: Minor
                        Found in lib/mongo/collection/view/builder/find_command.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 validate_read! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def validate_read!(option, opts)
                              if option == :read && opts.has_key?(:read)
                                read = opts[:read]
                                # We could check if read is a Hash, but this would fail
                                # for custom classes implementing key access ([]).
                        Severity: Minor
                        Found in lib/mongo/client.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 find_one_and_update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                                def find_one_and_update(document, opts = {})
                                  cmd = { :findAndModify => collection.name, :query => filter }
                                  cmd[:update] = document
                                  cmd[:fields] = projection if projection
                                  cmd[:sort] = sort if sort
                        Severity: Minor
                        Found in lib/mongo/collection/view/writable.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 read_with_retry has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def read_with_retry(session = nil, server_selector = nil, &block)
                              if session.nil? && server_selector.nil?
                                # Older versions of Mongoid call read_with_retry without arguments.
                                # This is already not correct in a MongoDB 3.6+ environment with
                                # sessions. For compatibility we emulate the legacy driver behavior
                        Severity: Minor
                        Found in lib/mongo/retryable.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 suppress_read_write_concern! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def suppress_read_write_concern!(command)
                              command.tap do |c|
                                next unless in_transaction?
                        
                                c.delete(:readConcern) unless starting_transaction?
                        Severity: Minor
                        Found in lib/mongo/session.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

                        Severity
                        Category
                        Status
                        Source
                        Language