mongodb/mongo-ruby-driver

View on GitHub

Showing 447 of 447 total issues

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

      def validate_address_str!(address_str)
        case address_str
        when /\A\[[\d:]+\](?::(\d+))?\z/
          # ipv6 with optional port
          if port_str = $1
Severity: Minor
Found in lib/mongo/address/validator.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 insert_one has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def insert_one(documents, connection, context, operation_id, session, txn_num)
Severity: Minor
Found in lib/mongo/bulk_write.rb - About 45 mins to fix

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

            def initialize(kms_providers)
              if kms_providers.nil?
                raise ArgumentError.new("KMS providers options must not be nil")
              end
              if kms_providers.key?(:aws)
    Severity: Minor
    Found in lib/mongo/crypt/kms/credentials.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 transform_server_api has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        module_function def transform_server_api(server_api)
          {}.tap do |doc|
            if version = server_api[:version]
              doc['apiVersion'] = version
            end
    Severity: Minor
    Found in lib/mongo/utils.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_aes has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def do_aes(key_binary_p, iv_binary_p, input_binary_p, output_binary_p,
            response_length_p, status_p, decrypt: false, mode: :CBC)
    Severity: Minor
    Found in lib/mongo/crypt/handle.rb - About 45 mins to fix

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

          def socket(socket_timeout, opts = {})
            opts = {
              connect_timeout: Server::CONNECT_TIMEOUT,
            }.update(options).update(Hash[opts.map { |k, v| [k.to_sym, v] }])
      
      
      Severity: Minor
      Found in lib/mongo/address.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        class Error
      
          # Exception raised if the object is not a valid replacement document.
          class InvalidReplacementDocument < Error
      
      
      Severity: Minor
      Found in lib/mongo/error/invalid_replacement_document.rb and 1 other location - About 45 mins to fix
      lib/mongo/error/invalid_update_document.rb on lines 19..58

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 40.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            DELETE_ONE_TRANSFORM = ->(doc){
              {
                Operation::Q => doc[:filter],
                Operation::LIMIT => 1,
              }.tap do |d|
      Severity: Minor
      Found in lib/mongo/bulk_write/transformable.rb and 1 other location - About 40 mins to fix
      lib/mongo/bulk_write/transformable.rb on lines 61..69

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 38.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            DELETE_MANY_TRANSFORM = ->(doc){
              {
                Operation::Q => doc[:filter],
                Operation::LIMIT => 0,
              }.tap do |d|
      Severity: Minor
      Found in lib/mongo/bulk_write/transformable.rb and 1 other location - About 40 mins to fix
      lib/mongo/bulk_write/transformable.rb on lines 74..82

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 38.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              def validate_update_documents!(spec)
                if update = spec.is_a?(Array) ? spec&.first : spec
                  if key = update.keys&.first
                    unless key.to_s.start_with?("$")
                      if Mongo.validate_update_replace
      Severity: Minor
      Found in lib/mongo/collection/view/writable.rb and 1 other location - About 40 mins to fix
      lib/mongo/collection/view/writable.rb on lines 575..582

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 37.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              def validate_replacement_documents!(spec)
                if replace = spec.is_a?(Array) ? spec&.first : spec
                  if key = replace.keys&.first
                    if key.to_s.start_with?("$")
                      if Mongo.validate_update_replace
      Severity: Minor
      Found in lib/mongo/collection/view/writable.rb and 1 other location - About 40 mins to fix
      lib/mongo/collection/view/writable.rb on lines 553..560

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 37.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method generate has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def self.generate(address, operation_id, command_payload,
                reply_payload, duration, started_event:, server_connection_id: nil,
                service_id: nil
      Severity: Minor
      Found in lib/mongo/monitoring/event/command_succeeded.rb - About 35 mins to fix

        Method command_succeeded has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

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

              def initialize(address, cluster, monitoring, event_listeners, options = {})
          Severity: Minor
          Found in lib/mongo/server.rb - About 35 mins to fix

            Method command_completed has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

              Method create_encrypted_collection has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def create_encrypted_collection(database, coll_name, coll_opts, kms_provider, master_key)
              Severity: Minor
              Found in lib/mongo/client_encryption.rb - About 35 mins to fix

                Method select_server_impl has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      private def select_server_impl(cluster, ping, session, write_aggregation, deprioritized)
                Severity: Minor
                Found in lib/mongo/server_selector/base.rb - About 35 mins to fix

                  Method do_hmac_sha has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def do_hmac_sha(digest_name, key_binary_p, input_binary_p,
                          output_binary_p, status_p)
                  Severity: Minor
                  Found in lib/mongo/crypt/handle.rb - About 35 mins to fix

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

                          def initialize(host_name, cert, ca_cert, cert_store, **opts)
                    Severity: Minor
                    Found in lib/mongo/socket/ocsp_verifier.rb - About 35 mins to fix

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

                            def initialize(host, port, timeout, family, options = {})
                      Severity: Minor
                      Found in lib/mongo/socket/tcp.rb - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language