mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/collection.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Class Collection has 34 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

    Method create has 31 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.
          # TODO put the list of read options in a class-level constant when
          # we figure out what the full set of them is.
    Severity: Minor
    Found in lib/mongo/collection.rb - About 1 hr to fix

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

          def insert_one(document, opts = {})
            QueryCache.clear_namespace(namespace)
      
            client.send(: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.
              # TODO put the list of read options in a class-level constant when
              # we figure out what the full set of them is.
        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