mongodb/mongo-ruby-driver

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

Summary

Maintainability
B
4 hrs
Test Coverage

Method check has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def check
        if @connection && @connection.pid != Process.pid
          log_warn("Detected PID change - Mongo client should have been reconnected (old pid #{@connection.pid}, new pid #{Process.pid}")
          @connection.disconnect!
          @connection = nil
Severity: Minor
Found in lib/mongo/server/monitor.rb - About 1 hr to fix

    Method check has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def check
            if @connection && @connection.pid != Process.pid
              log_warn("Detected PID change - Mongo client should have been reconnected (old pid #{@connection.pid}, new pid #{Process.pid}")
              @connection.disconnect!
              @connection = nil
    Severity: Minor
    Found in lib/mongo/server/monitor.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 do_work has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def do_work
            scan!
            # @next_wanted_scan may be updated by the push monitor.
            # However we need to check for termination flag so that the monitor
            # thread exits when requested.
    Severity: Minor
    Found in lib/mongo/server/monitor.rb - About 55 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(server, event_listeners, monitoring, options = {})
            unless monitoring.is_a?(Monitoring)
              raise ArgumentError, "Wrong monitoring type: #{monitoring.inspect}"
            end
            unless options[:app_metadata]
    Severity: Minor
    Found in lib/mongo/server/monitor.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 run_sdam_flow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def run_sdam_flow(result, awaited: false)
            @sdam_mutex.synchronize do
              old_description = server.description
    
              new_description = Description.new(server.address, result,
    Severity: Minor
    Found in lib/mongo/server/monitor.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