File search_index_backend.rb
has 755 lines of code (exceeds 250 allowed). Consider refactoring. Open
class SearchIndexBackend
SUPPORTED_ES_VERSION_MINIMUM = '7.8'.freeze
SUPPORTED_ES_VERSION_LESS_THAN = '9'.freeze
Class SearchIndexBackend
has 39 methods (exceeds 20 allowed). Consider refactoring. Open
class SearchIndexBackend
SUPPORTED_ES_VERSION_MINIMUM = '7.8'.freeze
SUPPORTED_ES_VERSION_LESS_THAN = '9'.freeze
Method get_mapping_properties_object
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_mapping_properties_object(object)
result = {
properties: {}
}
Method search_by_index
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.search_by_index(query, index, options = {})
return [] if query.blank?
url = build_url(type: index, action: '_search', with_pipeline: false, with_document_type: false)
return [] if url.blank?
Method create_pipeline
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_pipeline
SearchIndexBackend.processors(
"_ingest/pipeline/#{pipeline(create: true)}": [
{
action: 'delete',
Method processors
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.processors(data)
data.each do |key, items|
url = "#{Setting.get('es_url')}/#{key}"
items.each do |item|
- 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_by_query
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.update_by_query(type, data, where)
return if data.blank?
return if where.blank?
url_params = {
Method get_mapping_properties_object
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.get_mapping_properties_object(object)
result = {
properties: {}
}
- 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 search_by_index_sort
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.search_by_index_sort(index:, sort_by: nil, order_by: nil, fulltext: false)
result = (sort_by || [])
.map(&:to_s)
.each_with_object([])
.with_index do |(elem, memo), idx|
- 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 build_url
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.build_url(type: nil, action: nil, object_id: nil, with_pipeline: true, with_document_type: true, url_params: {})
return if !SearchIndexBackend.enabled?
# set index
index = build_index_name(type)
- 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 selectors
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.selectors(index, selectors = nil, options = {}, aggs_interval = nil)
raise 'no selectors given' if !selectors
url = build_url(type: index, action: '_search', with_pipeline: false, with_document_type: false)
return if url.blank?
Method search_by_index
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.search_by_index(query, index, options = {})
return [] if query.blank?
url = build_url(type: index, action: '_search', with_pipeline: false, with_document_type: false)
return [] if url.blank?
- 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 selectors
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.selectors(index, selectors = nil, options = {}, aggs_interval = nil)
raise 'no selectors given' if !selectors
url = build_url(type: index, action: '_search', with_pipeline: false, with_document_type: false)
return if url.blank?
- 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 info
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.info
url = Setting.get('es_url').to_s
return if url.blank?
response = make_request(url)
- 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 humanized_error
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.humanized_error(verb:, url:, response:, payload: nil)
prefix = "Unable to process #{verb} request to elasticsearch URL '#{url}'."
suffix = "\n\nResponse:\n#{response.inspect}\n\n"
if payload.respond_to?(:to_json)
- 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"