mongodb/mongo-ruby-driver

View on GitHub

Showing 423 of 480 total issues

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

Avoid too many return statements within this method.
Open

        return :primary if primary?
Severity: Major
Found in lib/mongo/server/description.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return nil
    Severity: Major
    Found in lib/mongo/auth/aws/credentials_retriever.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return :other if other?
      Severity: Major
      Found in lib/mongo/server/description.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return :secondary if secondary?
        Severity: Major
        Found in lib/mongo/server/description.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return :standalone if standalone?
          Severity: Major
          Found in lib/mongo/server/description.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return true
            Severity: Major
            Found in lib/mongo/cluster/sdam_flow.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return false
              Severity: Major
              Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                          return false
                Severity: Major
                Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                            return false
                  Severity: Major
                  Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                              return false
                    Severity: Major
                    Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                return false
                      Severity: Major
                      Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                  return false
                        Severity: Major
                        Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

                          Method prepare_web_identity_inputs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def prepare_web_identity_inputs
                                    token_file = ENV['AWS_WEB_IDENTITY_TOKEN_FILE']
                                    role_arn = ENV['AWS_ROLE_ARN']
                                    if token_file.nil? || role_arn.nil?
                                      return nil
                          Severity: Minor
                          Found in lib/mongo/auth/aws/credentials_retriever.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

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

                                def prune!
                                  # Load balancers spec explicitly requires not to prune sessions.
                                  # No rationale is provided as of the time of this writing.
                                  return if @cluster.load_balanced?
                          
                          
                          Severity: Minor
                          Found in lib/mongo/session/session_pool.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

                          Method detect_container has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def detect_container
                                    runtime = docker_present? && 'docker'
                                    orchestrator = kubernetes_present? && 'kubernetes'
                          
                                    return unless runtime || orchestrator
                          Severity: Minor
                          Found in lib/mongo/server/app_metadata/environment.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

                          Method region has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def region
                                    # Common case
                                    if host == 'sts.amazonaws.com'
                                      return 'us-east-1'
                                    end
                          Severity: Minor
                          Found in lib/mongo/auth/aws/request.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

                          Method build_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def build_message(connection, auth_source, selector)
                                  if connection && connection.features.op_msg_enabled?
                                    selector = selector.dup
                                    selector[Protocol::Msg::DATABASE_IDENTIFIER] = auth_source
                                    cluster_time = connection.mongos? && connection.cluster_time
                          Severity: Minor
                          Found in lib/mongo/auth/conversation_base.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

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

                                def handshake!(speculative_auth_doc: nil)
                                  unless socket
                                    raise Error::InternalDriverError, "Cannot handshake because there is no usable socket (for #{address})"
                                  end
                          
                          
                          Severity: Minor
                          Found in lib/mongo/server/pending_connection.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

                          Method validate_camel_case_read_preference_mode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def validate_camel_case_read_preference_mode(mode)
                                return unless enabled?
                                if mode
                                  unless %w(primary primaryPreferred secondary secondaryPreferred nearest).include?(mode.to_s)
                                    raise Error::LintError, "Invalid read preference mode: #{mode}"
                          Severity: Minor
                          Found in lib/mongo/lint.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

                          Severity
                          Category
                          Status
                          Source
                          Language