mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/operation/shared/executable.rb

Summary

Maintainability
C
1 day
Test Coverage

Method do_execute has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

      def do_execute(connection, context, options = {})
        session&.materialize_if_needed
        unpin_maybe(session, connection) do
          add_error_labels(connection, context) do
            add_server_diagnostics(connection) do
Severity: Minor
Found in lib/mongo/operation/shared/executable.rb - About 7 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 do_execute has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def do_execute(connection, context, options = {})
        session&.materialize_if_needed
        unpin_maybe(session, connection) do
          add_error_labels(connection, context) do
            add_server_diagnostics(connection) do
Severity: Minor
Found in lib/mongo/operation/shared/executable.rb - About 1 hr to fix

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

          def process_result_for_sdam(result, connection)
            if (result.not_master? || result.node_recovering?) &&
              connection.generation >= connection.server.pool.generation(service_id: connection.service_id)
            then
              if result.node_shutting_down?
    Severity: Minor
    Found in lib/mongo/operation/shared/executable.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