Class View
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class View
# Defines read related behavior for collection view.
#
# @since 2.0.0
Method estimated_document_count
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def estimated_document_count(opts = {})
unless view.filter.empty?
raise ArgumentError, "Cannot call estimated_document_count when querying with a filter"
end
- 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
File readable.rb
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Mongo
class Collection
class View
# Defines read related behavior for collection view.
Method estimated_document_count
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def estimated_document_count(opts = {})
unless view.filter.empty?
raise ArgumentError, "Cannot call estimated_document_count when querying with a filter"
end
Method parallel_scan
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parallel_scan(cursor_count, options = {})
if options[:session]
# The session would be overwritten by the one in +options+ later.
session = client.send(:get_session, @options)
else
Method distinct
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def distinct(field_name, opts = {})
if field_name.nil?
raise ArgumentError, 'Field name for distinct operation must be not nil'
end
opts = @options.merge(opts) unless Mongo.broken_view_options
Method count
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def count(opts = {})
opts = @options.merge(opts) unless Mongo.broken_view_options
cmd = { :count => collection.name, :query => filter }
cmd[:skip] = opts[:skip] if opts[:skip]
cmd[:hint] = opts[:hint] if opts[:hint]
Method count
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def count(opts = {})
opts = @options.merge(opts) unless Mongo.broken_view_options
cmd = { :count => collection.name, :query => filter }
cmd[:skip] = opts[:skip] if opts[:skip]
cmd[:hint] = opts[:hint] if opts[:hint]
- 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 count_documents
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def count_documents(opts = {})
opts = @options.merge(opts) unless Mongo.broken_view_options
pipeline = [:'$match' => filter]
pipeline << { :'$skip' => opts[:skip] } if opts[:skip]
pipeline << { :'$limit' => opts[:limit] } if opts[:limit]
- 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 distinct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def distinct(field_name, opts = {})
if field_name.nil?
raise ArgumentError, 'Field name for distinct operation must be not nil'
end
opts = @options.merge(opts) unless Mongo.broken_view_options
- 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"