Class Request
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class Request
include Enumerable
include Scoping
include Scrolling
UNDEFINED = Class.new.freeze
File request.rb
has 273 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Chewy
module Search
# The main request DSL class. Supports multiple index requests.
# Supports ES5 search API and query DSL.
#
Method first
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def first(limit = UNDEFINED)
request_limit = limit == UNDEFINED ? 1 : limit
if performed? && (request_limit <= size || size == total)
limit == UNDEFINED ? wrappers.first : wrappers.first(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 find
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find(*ids)
return super if block_given?
ids = ids.flatten(1).map(&:to_s)
scope = except(EXTRA_STORAGES).filter(ids: {values: 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
Method pluck
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def pluck(*fields)
fields = fields.flatten(1).reject(&:blank?).map(&:to_s)
source_fields = fields - EVERFIELDS
scope = except(FIELD_STORAGES, EXTRA_STORAGES)
- 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"