Method trigger_index_notification
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def trigger_index_notification
return unless respond_to? :_index_root_notifiers
_index_root_notifiers.each do |index_name, block|
obj = instance_eval &block
obj = [obj] unless obj.respond_to? :each
- 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 schema
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def schema(for_index: nil, &block)
index_name = for_index.nil? ? self.index_name : for_index
manager = index_content_manager(index_name)
raise "Index #{index_name} has not been defined for #{name}" if manager.nil?
kv_pairs = manager.contents.map do |field_name, 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 generate_document
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_document(for_index: nil, observer: nil)
index_name = for_index.nil? ? self.index_name : for_index.to_s
return unless respond_to? :_index_content_managers
manager = _index_content_managers[index_name.to_s]
raise "Index #{index_name} does not exist" if manager.nil?
- 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"