mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/server/connection_common.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method add_server_diagnostics has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def add_server_diagnostics
        yield
      # Note that the exception should already have been mapped to a
      # Mongo::Error subclass when it gets to this method.
      rescue Error::SocketError, Error::SocketTimeoutError => e
Severity: Minor
Found in lib/mongo/server/connection_common.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 set_compressor! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def set_compressor!(reply)
        server_compressors = reply['compression']

        if options[:compressors]
          if intersection = (server_compressors & options[:compressors])
Severity: Minor
Found in lib/mongo/server/connection_common.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 handshake_document has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def handshake_document(app_metadata, speculative_auth_doc: nil, load_balancer: false, server_api: nil)
        serv_api = app_metadata.server_api || server_api
        document = if serv_api
                     HELLO_DOC.merge(Utils.transform_server_api(serv_api))
                   else
Severity: Minor
Found in lib/mongo/server/connection_common.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

There are no issues that match your filters.

Category
Status