mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/cursor.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class Cursor has 26 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 10 (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 finalize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def self.finalize(cursor_id, cluster, op_spec, server, session)
    Severity: Minor
    Found in lib/mongo/cursor.rb - About 35 mins to fix

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

          def process(result)
            @remaining -= result.returned_count if limited?
            @coll_name ||= result.namespace.sub("#{database.name}.", '') if result.namespace
            unregister if result.cursor_id == 0
            @cursor_id = result.cursor_id
      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

      Method each has a Cognitive Complexity of 6 (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
            # returning initial result would miss documents in the second batch
      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