mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/crypt/handle.rb

Summary

Maintainability
C
1 day
Test Coverage

Method set_crypto_hooks has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def set_crypto_hooks
        @aes_encrypt = Proc.new do |_, key_binary_p, iv_binary_p, input_binary_p,
          output_binary_p, response_length_p, status_p|
          do_aes(
            key_binary_p,
Severity: Major
Found in lib/mongo/crypt/handle.rb - About 3 hrs to fix

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

          def maybe_set_schema_map(options)
            if !options[:schema_map] && !options[:schema_map_path]
              @schema_map = nil
            elsif options[:schema_map] && options[:schema_map_path]
              raise ArgumentError.new(
    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 initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def initialize(kms_providers, kms_tls_options, options={})
            # FFI::AutoPointer uses a custom release strategy to automatically free
            # the pointer once this object goes out of scope
            @mongocrypt = FFI::AutoPointer.new(
              Binding.mongocrypt_new,
    Severity: Minor
    Found in lib/mongo/crypt/handle.rb - About 1 hr to fix

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

            def initialize(kms_providers, kms_tls_options, options={})
              # FFI::AutoPointer uses a custom release strategy to automatically free
              # the pointer once this object goes out of scope
              @mongocrypt = FFI::AutoPointer.new(
                Binding.mongocrypt_new,
      Severity: Minor
      Found in lib/mongo/crypt/handle.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 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

          There are no issues that match your filters.

          Category
          Status