mongoid/moped

View on GitHub
lib/moped/node.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Node has 39 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Node
    include Executable
    include Instrumentable

    # @!attribute address
Severity: Minor
Found in lib/moped/node.rb - About 5 hrs to fix

    Method update has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def update(database, collection, selector, change, concern, options = {})
    Severity: Minor
    Found in lib/moped/node.rb - About 45 mins to fix

      Method ensure_connected has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def ensure_connected(&block)
            unless (conn = stack(:connection)).empty?
              return yield(conn.first)
            end
      
      
      Severity: Minor
      Found in lib/moped/node.rb - About 45 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 insert has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def insert(database, collection, documents, concern, options = {})
      Severity: Minor
      Found in lib/moped/node.rb - About 35 mins to fix

        Method remove has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def remove(database, collection, selector, concern, options = {})
        Severity: Minor
        Found in lib/moped/node.rb - About 35 mins to fix

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

              def refresh
                if address.resolve(self)
                  begin
                    @refreshed_at = Time.now
                    configure(command("admin", ismaster: 1))
          Severity: Minor
          Found in lib/moped/node.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

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

              def connection
                connection_acquired = false
                begin
                  pool.with do |conn|
                    connection_acquired = true
          Severity: Minor
          Found in lib/moped/node.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