Showing 60 of 60 total issues
Class Request
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class Request
include Enumerable
include Scoping
include Scrolling
UNDEFINED = Class.new.freeze
Class BulkBuilder
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class BulkBuilder
# @param index [Chewy::Index] desired index
# @param to_index [Array<Object>] objects to index
# @param delete [Array<Object>] objects or ids to delete
# @param fields [Array<Symbol, String>] and array of fields for documents update
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 sync
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def sync(only: nil, except: nil, parallel: nil, output: $stdout)
subscribed_task_stats(output) do
indexes_from(only: only, except: except).each_with_object([]) do |index, synced_indexes|
output.puts "Synchronizing #{index}"
output.puts " #{index} doesn't support outdated synchronization" unless index.supports_outdated_sync?
- 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 dynamic_template
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
ruby2_keywords def dynamic_template(*args)
options = args.extract_options!.deep_symbolize_keys
if args.first
template_name = :"template_#{dynamic_templates.count.next}"
template = {template_name => {mapping: 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"
Further reading
Method update_proc
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def update_proc(index_name, *args, &block)
options = args.extract_options!
method = args.first
proc do
- 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 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 resolve
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def resolve(params, repository)
if params.is_a?(Array)
params.flatten.reject(&:blank?).each.with_object({}) do |name_or_hash, result|
options = if name_or_hash.is_a?(Hash)
name_or_hash
- 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 scroll_batches
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def scroll_batches(batch_size: Request::DEFAULT_BATCH_SIZE, scroll: Request::DEFAULT_SCROLL)
return enum_for(:scroll_batches, batch_size: batch_size, scroll: scroll) unless block_given?
result = perform(size: batch_size, scroll: scroll)
total = [raw_limit_value, result.fetch('hits', {}).fetch('total', {}).fetch('value', 0)].compact.min
- 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 index_entry
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def index_entry(object)
entry = {}
entry[:_id] = index_object_ids[object] if index_object_ids[object]
entry[:routing] = routing(object) if join_field?
- 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 non_proc_values
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def non_proc_values(field, nesting)
non_proc_fields = non_proc_fields_for(field, nesting)
object = "object#{nesting}"
if non_proc_fields.present?
- 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 reset!
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reset!(suffix = nil, apply_journal: true, journal: false, **import_options)
result = if suffix.present?
start_time = Time.now
indexes = self.indexes - [index_name]
create! suffix, alias: false
Method parent_changed?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parent_changed?(data, old_parent)
return false unless old_parent
return false unless join_field?
return false unless @fields.include?(join_field.to_sym)
return false unless data.key?(join_field)
- 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 source_for
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def source_for(proc, nesting)
ast = Parser::CurrentRuby.parse(proc.source)
lambdas = exctract_lambdas(ast)
raise "No lambdas found, try to reformat your code:\n`#{proc.source}`" unless lambdas
- 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 request_bodies
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def request_bodies(body)
if @bulk_size
serializer = ::Elasticsearch::API.serializer
pieces = body.each_with_object(['']) do |piece, result|
operation, meta = piece.to_a.first
- 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 entry_id
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def entry_id(object)
if type_root.id
type_root.compose_id(object)
else
id = object.id if object.respond_to?(:id)
- 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 import_parallel
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def import_parallel(objects, routine)
raise "The `parallel` gem is required for parallel import, please add `gem 'parallel'` to your Gemfile" unless '::Parallel'.safe_constantize
ActiveSupport::Notifications.instrument 'import_objects.chewy', index: self do |payload|
batches = adapter.import_references(*objects, routine.options.slice(:batch_size)).to_a
- 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 mock_elasticsearch_response_sources
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mock_elasticsearch_response_sources(index, hits, &block)
raw_response = {
'took' => 4,
'timed_out' => false,
'_shards' => {
Method mock_elasticsearch_response_sources
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mock_elasticsearch_response_sources(index, hits)
raw_response = {
'took' => 4,
'timed_out' => false,
'_shards' => {
Method pluck_in_batches
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def pluck_in_batches(scope, fields: [], batch_size: nil, typecast: true)
unless block_given?
return enum_for(
:pluck_in_batches,
scope,
- 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"