mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/cursor.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Class Cursor has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Cursor
    extend Forwardable
    include Enumerable
    include Retryable

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

    Method try_next has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def try_next
          if @documents.nil?
            # Since published versions of Mongoid have a copy of old driver cursor
            # code, our dup call in #process isn't invoked when Mongoid query
            # cache is active. Work around that by also calling dup here on
    Severity: Minor
    Found in lib/mongo/cursor.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 try_next has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def try_next
          if @documents.nil?
            # Since published versions of Mongoid have a copy of old driver cursor
            # code, our dup call in #process isn't invoked when Mongoid query
            # cache is active. Work around that by also calling dup here on
    Severity: Minor
    Found in lib/mongo/cursor.rb - About 1 hr to fix

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

          def each
      
            # If we already iterated past the first batch (i.e., called get_more
            # at least once), the cursor on the server side has advanced past
            # the first batch and restarting iteration from the beginning by
      Severity: Minor
      Found in lib/mongo/cursor.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 get_more_operation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_more_operation
            spec = {
              session: @session,
              db_name: database.name,
              coll_name: collection_name,
      Severity: Minor
      Found in lib/mongo/cursor.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(view, result, server, options = {})
            unless result.is_a?(Operation::Result)
              raise ArgumentError, "Second argument must be a Mongo::Operation::Result: #{result.inspect}"
            end
      
      
      Severity: Minor
      Found in lib/mongo/cursor.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