Method query
has a Cognitive Complexity of 194 (exceeds 5 allowed). Consider refactoring. Open
def query(query, options = {})
# support scroll api
# map function is small performance hit
if options[:scroll_id].present? && options.dig(:page, :scroll)
begin
- 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 query
has 548 lines of code (exceeds 25 allowed). Consider refactoring. Open
def query(query, options = {})
# support scroll api
# map function is small performance hit
if options[:scroll_id].present? && options.dig(:page, :scroll)
begin
File indexable.rb
has 966 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Indexable
extend ActiveSupport::Concern
require "aws-sdk-sqs"
Method switch_index
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def switch_index(options = {})
alias_name = options[:alias] || index_name
index_name = (options[:index] || self.index_name) + "_v1"
alternate_index_name = (options[:index] || self.index_name) + "_v2"
is_write_index = options[:is_write_index] || name != "OtherDoi"
Method create_template
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_template
alias_name = index_name
body =
if name == "Doi" || name == "DataciteDoi" || name == "OtherDoi"
Method active_index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def active_index
ret = nil
alias_name = index_name
client = Elasticsearch::Model.client
- 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 create_index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_index(options = {})
alias_name = options[:alias] || index_name
index_name = (options[:index] || self.index_name) + "_v1"
alternate_index_name = (options[:index] || self.index_name) + "_v2"
client = Elasticsearch::Model.client
- 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 create_template
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_template
alias_name = index_name
body =
if name == "Doi" || name == "DataciteDoi" || name == "OtherDoi"
- 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
Avoid deeply nested control flow statements. Open
if options[:client_id].present?
options[:client_id].split(",").each { |id|
should << { term: { "client_ids": { value: id, case_insensitive: true } } }
}
minimum_should_match = 1
Avoid deeply nested control flow statements. Open
elsif name == "ProviderPrefix"
must =
if query.present?
[{ prefix: { prefix_id: query } }]
else
Avoid deeply nested control flow statements. Open
if options[:year].present?
filter <<
{
range: {
created_at: {
Method send_message
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def send_message(body, options = {})
sqs = Aws::SQS::Client.new
queue_name_prefix =
if Rails.env.stage?
ENV["ES_PREFIX"].present? ? "stage" : "test"
- 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
Avoid deeply nested control flow statements. Open
query.present? ? [{ prefix: { prefix: query } }] : [{ match_all: {} }]
Avoid deeply nested control flow statements. Open
if options[:state].present?
filter << { terms: { state: options[:state].to_s.split(",") } }
end
Avoid deeply nested control flow statements. Open
if options[:provider_id].present?
options[:provider_id].split(",").each { |id|
should << { term: { "provider_ids": { value: id, case_insensitive: true } } }
}
minimum_should_match = 1