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 79 (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
        deadline = Time.now + server_selection_timeout

        if session && session.pinned_server
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 85 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
        deadline = Time.now + server_selection_timeout

        if session && session.pinned_server
Severity: Major
Found in lib/mongo/server_selector/selectable.rb - About 3 hrs to fix

    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

    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

    There are no issues that match your filters.

    Category
    Status