mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/socket/ssl.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method create_context has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def create_context(options)
        OpenSSL::SSL::SSLContext.new.tap do |context|
          if OpenSSL::SSL.const_defined?(:OP_NO_RENEGOTIATION)
            context.options = context.options | OpenSSL::SSL::OP_NO_RENEGOTIATION
          end
Severity: Minor
Found in lib/mongo/socket/ssl.rb - About 2 hrs 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 create_context has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def create_context(options)
        OpenSSL::SSL::SSLContext.new.tap do |context|
          if OpenSSL::SSL.const_defined?(:OP_NO_RENEGOTIATION)
            context.options = context.options | OpenSSL::SSL::OP_NO_RENEGOTIATION
          end
Severity: Minor
Found in lib/mongo/socket/ssl.rb - About 1 hr to fix

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

          def initialize(host, port, host_name, timeout, family, options = {})
    Severity: Minor
    Found in lib/mongo/socket/ssl.rb - About 45 mins to fix

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

            def set_cert(context, options)
              # Since we clear cert_text during processing, we need to examine
              # ssl_cert_object here to avoid considering it if we have also
              # processed the text.
              if options[:ssl_cert]
      Severity: Minor
      Found in lib/mongo/socket/ssl.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_cert_verification has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_cert_verification(context, options)
              context.verify_mode = OpenSSL::SSL::VERIFY_PEER
              cert_store = OpenSSL::X509::Store.new
              if options[:ssl_ca_cert]
                cert_store.add_file(options[:ssl_ca_cert])
      Severity: Minor
      Found in lib/mongo/socket/ssl.rb - About 35 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 load_private_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def load_private_key(text, passphrase)
              args = if passphrase
                [text, passphrase]
              else
                [text]
      Severity: Minor
      Found in lib/mongo/socket/ssl.rb - About 25 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

      There are no issues that match your filters.

      Category
      Status