mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/collection/view/iterable.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

        def each
          # If the caching cursor is closed and was not fully iterated,
          # the documents we have in it are not the complete result set and
          # we have no way of completing that iteration.
          # Therefore, discard that cursor and start iteration again.
Severity: Minor
Found in lib/mongo/collection/view/iterable.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 initial_query_op has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def initial_query_op(session)
          spec = {
            coll_name: collection.name,
            filter: filter,
            projection: projection,
Severity: Minor
Found in lib/mongo/collection/view/iterable.rb - About 1 hr to fix

    Method each has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def each
              # If the caching cursor is closed and was not fully iterated,
              # the documents we have in it are not the complete result set and
              # we have no way of completing that iteration.
              # Therefore, discard that cursor and start iteration again.
    Severity: Minor
    Found in lib/mongo/collection/view/iterable.rb - About 1 hr to fix

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

              def select_cursor(session)
                if respond_to?(:write?, true) && write?
                  server = server_selector.select_server(cluster, nil, session, write_aggregation: true)
                  result = send_initial_query(server, session)
      
      
      Severity: Minor
      Found in lib/mongo/collection/view/iterable.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 initial_query_op has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def initial_query_op(session)
                spec = {
                  coll_name: collection.name,
                  filter: filter,
                  projection: projection,
      Severity: Minor
      Found in lib/mongo/collection/view/iterable.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