mongodb/mongo-ruby-driver

View on GitHub

Showing 393 of 447 total issues

Method checkout has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def checkout
        @mutex.synchronize do
          loop do
            if @queue.empty?
              return ServerSession.new
Severity: Minor
Found in lib/mongo/session/session_pool.rb - About 55 mins 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_work has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def do_work
        scan!
        # @next_wanted_scan may be updated by the push monitor.
        # However we need to check for termination flag so that the monitor
        # thread exits when requested.
Severity: Minor
Found in lib/mongo/server/monitor.rb - About 55 mins 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 count has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def count(opts = {})
          opts = @options.merge(opts) unless Mongo.broken_view_options
          cmd = { :count => collection.name, :query => filter }
          cmd[:skip] = opts[:skip] if opts[:skip]
          cmd[:hint] = opts[:hint] if opts[:hint]
Severity: Minor
Found in lib/mongo/collection/view/readable.rb - About 55 mins 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 end_session has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def end_session
      if !ended? && @client
        if within_states?(TRANSACTION_IN_PROGRESS_STATE)
          begin
            abort_transaction
Severity: Minor
Found in lib/mongo/session.rb - About 55 mins 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 select! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def select!
        if block_given?
          n_keys = keys.size
          keys.each do |key|
            delete(key) unless yield(key, self[key])
Severity: Minor
Found in lib/mongo/options/redacted.rb - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
Open

    def each
      if @cached_docs
        @cached_docs.each do |doc|
          yield doc
        end
Severity: Minor
Found in lib/mongo/caching_cursor.rb - About 55 mins 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 serialize_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def serialize_fields(buffer, max_bson_size = nil)
        fields.each do |field|
          value = instance_variable_get(field[:name])
          if field[:multi]
            value.each do |item|
Severity: Minor
Found in lib/mongo/protocol/message.rb - About 55 mins 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 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def initialize(command_name, database_name, address, request_id,
          operation_id, reply, duration, started_event:,
          server_connection_id: nil, service_id: nil
Severity: Major
Found in lib/mongo/monitoring/event/command_succeeded.rb - About 50 mins to fix

    Method setopt_crypto_hooks has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def self.setopt_crypto_hooks(handle,
            aes_encrypt_cb, aes_decrypt_cb, random_cb,
            hmac_sha_512_cb, hmac_sha_256_cb, hmac_hash_cb
    Severity: Major
    Found in lib/mongo/crypt/binding.rb - About 50 mins to fix

      Method server_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def server_type
              return :load_balancer if load_balancer?
              return :arbiter if arbiter?
              return :ghost if ghost?
              return :sharded if mongos?
      Severity: Minor
      Found in lib/mongo/server/description.rb - About 45 mins 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 summarize_perf_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def summarize_perf_data(data)
              puts '===== Performance Results ====='
              data.each do |item|
                puts format('%s : %4.4g', item['info']['test_name'], item['metrics'][0]['value'])
                next unless item['metrics'].length > 1
      Severity: Minor
      Found in profile/driver_bench/suite.rb - About 45 mins 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_bidi! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def check_bidi!(out)
              if out.each_char.any? { |c| table_contains?(Tables::C8, c) }
                raise Mongo::Error::FailedStringPrepValidation.new(Error::FailedStringPrepValidation::INVALID_BIDIRECTIONAL)
              end
      
      
      Severity: Minor
      Found in lib/mongo/auth/stringprep.rb - About 45 mins 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_delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def find_one_and_delete(opts = {})
                with_session(opts) do |session|
                  write_concern = if opts[:write_concern]
                    WriteConcern.get(opts[:write_concern])
                  else
      Severity: Minor
      Found in lib/mongo/collection/view/writable.rb - About 45 mins 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_invariants has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def check_invariants
              return unless Lint.enabled?
      
              # Server summary calls pool summary which requires pool lock -> deadlock.
              # Obtain the server summary ahead of time.
      Severity: Minor
      Found in lib/mongo/server/connection_pool.rb - About 45 mins 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_work has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def do_work
              @lock.synchronize do
                return if @stop_requested
              end
      
      
      Severity: Minor
      Found in lib/mongo/server/push_monitor.rb - About 45 mins 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_compressor! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_compressor!(reply)
              server_compressors = reply['compression']
      
              if options[:compressors]
                if intersection = (server_compressors & options[:compressors])
      Severity: Minor
      Found in lib/mongo/server/connection_common.rb - About 45 mins 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_server_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_server_list(server_address_strs)
            @sdam_flow_lock.synchronize do
              # If one of the new addresses is not in the current servers list,
              # add it to the servers list.
              server_address_strs.each do |address_str|
      Severity: Minor
      Found in lib/mongo/cluster.rb - About 45 mins 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 stop! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def stop!
              @lock.synchronize do
                @stop_requested = true
                if @connection
                  # Interrupt any in-progress exhausted hello reads by
      Severity: Minor
      Found in lib/mongo/server/push_monitor.rb - About 45 mins 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 command_failed has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def command_failed(failure, address, operation_id, payload, message, duration,
              started_event:, server_connection_id: nil, service_id: nil
      Severity: Minor
      Found in lib/mongo/monitoring/publishable.rb - About 45 mins to fix

        Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def initialize(command_name, database_name, address, request_id,
                  operation_id, command, socket_object_id: nil, connection_id: nil,
                  connection_generation: nil, server_connection_id: nil,
                  service_id: nil
        Severity: Minor
        Found in lib/mongo/monitoring/event/command_started.rb - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language