mongoid/moped

View on GitHub

Showing 28 of 28 total issues

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

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

      class Query
        include Enumerable
        include Retryable
    
        # @attribute [r] collection The collection to execute the query on.
    Severity: Minor
    Found in lib/moped/query.rb - About 3 hrs to fix

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

          def refresh(nodes_to_refresh = seeds)
            refreshed_nodes = []
            seen = {}
            # Set up a recursive lambda function for refreshing a node and it's peers.
            refresh_node = ->(node) do
      Severity: Minor
      Found in lib/moped/cluster.rb - About 2 hrs 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 resolve has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def resolve(node)
            return @resolved if @resolved
            start = Time.now
            retries = 0
            begin
      Severity: Minor
      Found in lib/moped/address.rb - About 2 hrs 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

      Class Session has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Session
          include Optionable
      
          # @!attribute cluster
          #   @return [ Cluster ] The cluster of nodes.
      Severity: Minor
      Found in lib/moped/session.rb - About 2 hrs to fix

        Method execute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def execute(node)
                node.process(operation) do |reply|
                  # Avoid LocalJumpError
                  ret = nil
                  if reply.unauthorized? && node.credentials.key?(@database)
        Severity: Minor
        Found in lib/moped/operation/read.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 flags has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def flags(name, flag_map = {})
                  class_eval <<-RUBY, __FILE__, __LINE__ + 1
                    def #{name}
                      @#{name} ||= []
                    end
        Severity: Minor
        Found in lib/moped/protocol/message.rb - About 1 hr to fix

          Method resolve has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def resolve(node)
                return @resolved if @resolved
                start = Time.now
                retries = 0
                begin
          Severity: Minor
          Found in lib/moped/address.rb - About 1 hr to fix

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

                def refresh_peers(node, &block)
                  node.peers.each do |node|
                    if node.address.resolved
                      block.call(node) unless seeds.include?(node)
                      peers.push(node) unless peers.include?(node)
            Severity: Minor
            Found in lib/moped/cluster.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 int64 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def int64(name, options = {})
                      attr_writer name
            
                      if options[:type] == :array
                        class_eval <<-RUBY, __FILE__, __LINE__ + 1
            Severity: Minor
            Found in lib/moped/protocol/message.rb - About 1 hr to fix

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

                  def with_retry(cluster, retries = cluster.max_retries, &block)
                    begin
                      block.call
                    rescue Errors::ConnectionFailure, Errors::PotentialReconfiguration => e
                      raise e if e.is_a?(Errors::PotentialReconfiguration) &&
              Severity: Minor
              Found in lib/moped/retryable.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 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def initialize(database, collection, cursor_id, limit, options = {})
                Severity: Minor
                Found in lib/moped/protocol/get_more.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 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

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

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

                            def modify(change, options = {})
                              command = {
                                findAndModify: collection.name,
                                query: selector
                              }.merge(options)
                        Severity: Minor
                        Found in lib/moped/query.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 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 options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def options
                              options_string, options = match[10], { database: database }
                              unless options_string.nil?
                                options_string.split(/\&/).each do |option_string|
                                  key, value = option_string.split(/=/)
                        Severity: Minor
                        Found in lib/moped/uri.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

                        Severity
                        Category
                        Status
                        Source
                        Language