Method all
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def all(options = {}, scope = nil)
scope ||= scoped
scope = scope.includes(*options[:include]) if options[:include]
scope = scope.limit(options[:limit]) if options[:limit]
scope = scope.any_in(_id: options[:bulk_ids]) if options[:bulk_ids]
- 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 mongoid.rb
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'mongoid'
require 'rails_admin/config/sections/list'
require 'rails_admin/adapters/mongoid/association'
require 'rails_admin/adapters/mongoid/object_extension'
require 'rails_admin/adapters/mongoid/property'
Method filter_scope
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def filter_scope(scope, filters, fields = config.list.fields.select(&:filterable?))
statements = []
filters.each_pair do |field_name, filters_dump|
filters_dump.each_value do |filter_dump|
- 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 sort_by
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def sort_by(options, scope)
return scope unless options[:sort]
case options[:sort]
when String
- 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 get
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get(id, scope = scoped)
object = scope.find(id)
return nil unless object
object.extend(ObjectExtension)
- 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"