mongodb/mongo-ruby-driver

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

Summary

Maintainability
C
1 day
Test Coverage

File binding.rb has 415 lines of code (exceeds 250 allowed). Consider refactoring.
Open

unless ENV['LIBMONGOCRYPT_PATH']
  # It seems that MRI maintains autoload configuration for a module until
  # that module is defined, but JRuby removes autoload configuration as soon
  # as the referenced file is attempted to be loaded, even if the module
  # never ends up being defined.
Severity: Minor
Found in lib/mongo/crypt/binding.rb - About 5 hrs to fix

    Class Binding has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Binding
          extend FFI::Library
    
          begin
            ffi_lib ENV['LIBMONGOCRYPT_PATH']
    Severity: Minor
    Found in lib/mongo/crypt/binding.rb - About 3 hrs 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

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

              def self.ctx_mongo_op(context)
                binary = Binary.new
        
                check_ctx_status(context) do
                  mongocrypt_ctx_mongo_op(context.ctx_p, binary.ref)
        Severity: Minor
        Found in lib/mongo/crypt/binding.rb and 1 other location - About 15 mins to fix
        lib/mongo/crypt/binding.rb on lines 1012..1022

        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 25.

        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 self.ctx_finalize(context)
                binary = Binary.new
        
                check_ctx_status(context) do
                  mongocrypt_ctx_finalize(context.ctx_p, binary.ref)
        Severity: Minor
        Found in lib/mongo/crypt/binding.rb and 1 other location - About 15 mins to fix
        lib/mongo/crypt/binding.rb on lines 779..789

        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 25.

        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

        There are no issues that match your filters.

        Category
        Status