mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/collection.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Collection has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Collection
    extend Forwardable
    include Retryable
    include QueryableEncryption
    include Helpers
Severity: Minor
Found in lib/mongo/collection.rb - About 4 hrs to fix

    File collection.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'mongo/bulk_write'
    require 'mongo/collection/view'
    require 'mongo/collection/helpers'
    require 'mongo/collection/queryable_encryption'
    
    
    Severity: Minor
    Found in lib/mongo/collection.rb - About 2 hrs to fix

      Method create has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def create(opts = {})
            # Passing read options to create command causes it to break.
            # Filter the read options out. Session is also excluded here as it gets
            # used by the call to with_session and should not be part of the
            # operation. If it gets passed to the operation it would fail BSON
      Severity: Minor
      Found in lib/mongo/collection.rb - About 1 hr to fix

        Method insert_one has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def insert_one(document, opts = {})
              QueryCache.clear_namespace(namespace)
        
              client.with_session(opts) do |session|
                write_concern = if opts[:write_concern]
        Severity: Minor
        Found in lib/mongo/collection.rb - About 1 hr to fix

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

              def create(opts = {})
                # Passing read options to create command causes it to break.
                # Filter the read options out. Session is also excluded here as it gets
                # used by the call to with_session and should not be part of the
                # operation. If it gets passed to the operation it would fail BSON
          Severity: Minor
          Found in lib/mongo/collection.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 with has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def with(new_options)
                new_options.keys.each do |k|
                  raise Error::UnchangeableCollectionOption.new(k) unless CHANGEABLE_OPTIONS.include?(k)
                end
                options = @options.dup
          Severity: Minor
          Found in lib/mongo/collection.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