lib/mongo/collection.rb
Class Collection
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Collection
extend Forwardable
include Retryable
include QueryableEncryption
include Helpers
Method create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
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.
Method insert_one
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def insert_one(document, opts = {})
QueryCache.clear_namespace(namespace)
client.send(:with_session, opts) do |session|
write_concern = if opts[:write_concern]
Method create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
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.
- Read upRead up
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
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
- Read upRead up
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"