mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/server.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Server has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Server
    extend Forwardable
    include Monitoring::Publishable
    include Event::Publisher

Severity: Minor
Found in lib/mongo/server.rb - About 3 hrs to fix

    File server.rb has 316 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Mongo
    
      # Represents a single server on the server side that can be standalone, part of
      # a replica set, or a mongos.
      #
    Severity: Minor
    Found in lib/mongo/server.rb - About 3 hrs to fix

      Method initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(address, cluster, monitoring, event_listeners, options = {})
            @address = address
            @cluster = cluster
            @monitoring = monitoring
            options = options.dup
      Severity: Minor
      Found in lib/mongo/server.rb - About 1 hr to fix

        Method unknown! has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def unknown!(options = {})
              pool = pool_internal
        
              if load_balancer?
                # When the client is in load-balanced topology, servers (the one and
        Severity: Minor
        Found in lib/mongo/server.rb - About 1 hr to fix

          Method unknown! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def unknown!(options = {})
                pool = pool_internal
          
                if load_balancer?
                  # When the client is in load-balanced topology, servers (the one and
          Severity: Minor
          Found in lib/mongo/server.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 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(address, cluster, monitoring, event_listeners, options = {})
          Severity: Minor
          Found in lib/mongo/server.rb - About 35 mins to fix

            Method summary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def summary
                  status = self.status || ''
                  if replica_set_name
                    status += " replica_set=#{replica_set_name}"
                  end
            Severity: Minor
            Found in lib/mongo/server.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