app/models/concerns/indexable.rb
Method query
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
Open
def query(query, options = {})
aggregations = options[:totals_agg] == true ? totals_aggregations : get_aggregations_hash(options[:aggregations])
options[:page] ||= {}
options[:page][:number] ||= 1
options[:page][:size] ||= 25
- 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 indexable.rb
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
module Indexable
extend ActiveSupport::Concern
require "aws-sdk-sqs"
Method query
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def query(query, options = {})
aggregations = options[:totals_agg] == true ? totals_aggregations : get_aggregations_hash(options[:aggregations])
options[:page] ||= {}
options[:page][:number] ||= 1
options[:page][:size] ||= 25
Method create_index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
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"