mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/server_selector/selectable.rb

Summary

Maintainability
D
2 days
Test Coverage

Method select_server has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
Open

      def select_server(cluster, ping = nil, session = nil)
        server_selection_timeout = cluster.options[:server_selection_timeout] || SERVER_SELECTION_TIMEOUT

        # Special handling for zero timeout: if we have to select a server,
        # and the timeout is zero, fail immediately (since server selection
Severity: Minor
Found in lib/mongo/server_selector/selectable.rb - About 1 day 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 select_server has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def select_server(cluster, ping = nil, session = nil)
        server_selection_timeout = cluster.options[:server_selection_timeout] || SERVER_SELECTION_TIMEOUT

        # Special handling for zero timeout: if we have to select a server,
        # and the timeout is zero, fail immediately (since server selection
Severity: Major
Found in lib/mongo/server_selector/selectable.rb - About 3 hrs to fix

    File selectable.rb has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Mongo
      module ServerSelector
    
        # Provides common behavior for filtering a list of servers by server mode or tag set.
        #
    Severity: Minor
    Found in lib/mongo/server_selector/selectable.rb - About 2 hrs to fix

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

            def server_selection_diagnostic_message(cluster)
              msg = ''
              dead_monitors = []
              cluster.servers_list.each do |server|
                thread = server.monitor.instance_variable_get('@thread')
      Severity: Minor
      Found in lib/mongo/server_selector/selectable.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 candidates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def candidates(cluster)
              if cluster.single?
                cluster.servers.each { |server| validate_max_staleness_support!(server) }
              elsif cluster.sharded?
                local_threshold = local_threshold_with_cluster(cluster)
      Severity: Minor
      Found in lib/mongo/server_selector/selectable.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