mongodb/mongo-ruby-driver

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

Summary

Maintainability
D
1 day
Test Coverage

File ssl.rb has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Mongo
  class Socket

    # Wrapper for TLS sockets.
    #
Severity: Minor
Found in lib/mongo/socket/ssl.rb - About 2 hrs to fix

    Class SSL has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class SSL < Socket
          include OpenSSL
    
          # Initializes a new TLS socket.
          #
    Severity: Minor
    Found in lib/mongo/socket/ssl.rb - About 2 hrs to fix

      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 connect! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def connect!
              sockaddr = ::Socket.pack_sockaddr_in(port, host)
              connect_timeout = options[:connect_timeout]
              map_exceptions do
                if connect_timeout && connect_timeout != 0
      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 connect! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def connect!
                sockaddr = ::Socket.pack_sockaddr_in(port, host)
                connect_timeout = options[:connect_timeout]
                map_exceptions do
                  if connect_timeout && connect_timeout != 0
        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 extract_certs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def extract_certs(text)
                    [].tap do |list|
                      pos = 0
            
                      while (begin_idx = text.index(BEGIN_CERT, pos))
            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