Method record_to_hash
has a Cognitive Complexity of 144 (exceeds 5 allowed). Consider refactoring. Open
def record_to_hash(record, options, referenced, enclosed_model, max_entries, viewport)
return record if Cenit::Utility.json_object?(record)
model =
begin
record.orm_model
- 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 record_to_xml_element
has a Cognitive Complexity of 104 (exceeds 5 allowed). Consider refactoring. Open
def record_to_xml_element(data_type, schema, record, xml_doc, enclosed_property_name, options, namespaces)
return unless record
if Cenit::Utility.json_object?(record)
return Nokogiri::XML({ enclosed_property_name => record }.to_xml(dasherize: false)).root.first_element_child
end
- 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 formater.rb
has 623 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Edi
module Formatter
def self_record
self
end
Method record_to_edi
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def record_to_edi(data_type, options, schema, record, enclosed_property_name = nil)
output = []
return output unless record
field_sep = options[:field_separator]
segment =
- 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 record_to_hash
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
def record_to_hash(record, options, referenced, enclosed_model, max_entries, viewport)
return record if Cenit::Utility.json_object?(record)
model =
begin
record.orm_model
Method record_to_xml_element
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
def record_to_xml_element(data_type, schema, record, xml_doc, enclosed_property_name, options, namespaces)
return unless record
if Cenit::Utility.json_object?(record)
return Nokogiri::XML({ enclosed_property_name => record }.to_xml(dasherize: false)).root.first_element_child
end
Method do_store
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def do_store(json, key, value, options, schema = {}, store_anyway = false)
if options[:nqnames]
key = key.to_s.split(':').last
end
if value.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"
Further reading
Method prepare_options
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def prepare_options(options)
include_id = options[:include_id]
[:ignore, :only, :embedding, :inspecting, :including].each do |option|
value = (options[option] || [])
value = [value] unless value.is_a?(Enumerable)
- 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 edi_value
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def edi_value(record, property_name, property_schema, property_model, options)
if (value = record[property_name]).nil?
value = property_schema['default'] || ''
end
value = property_model.to_string(value) if property_model
- 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
Consider simplifying this complex logical expression. Open
if property_schema['virtual'] ||
((property_schema['edi'] || {})['discard'] && !(included_anyway = options[:including_discards] || options[:including].include?(property_name.to_sym))) ||
(can_be_referenced && referenced && !key_properties.include?(property_name)) ||
options[:ignore].include?(name.to_sym) ||
(options[:only].present? && options[:only].exclude?(name.to_sym) && !included_anyway)
Method record_to_edi
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def record_to_edi(data_type, options, schema, record, enclosed_property_name = nil)
output = []
return output unless record
field_sep = options[:field_separator]
segment =
Method json_value
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def json_value(value, options, schema)
case value
when Time, Date, DateTime
value = value.to_time
if schema && schema['format'] == 'time'
- 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
Consider simplifying this complex logical expression. Open
if (options[:inspecting].include?(:_type) ||
options[:including].include?(:_type) ||
(enclosed_model && !record.orm_model.eql?(enclosed_model)) ||
(options[:polymorphic] && record.orm_model.hereditary?)) && !json['_reference'] && !options[:ignore].include?(:_type) && (!options[:only] || options[:only].include?(:_type))
json['_type'] = model.to_s
Method parse_viewport
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def parse_viewport(value)
value = value.to_s.split(' ').map do |seq|
seq.chars.inject([]) do |a, char|
case char
when '{', '}'
- 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
Consider simplifying this complex logical expression. Open
next if property_schema['virtual'] ||
((property_schema['edi'] || {})['discard'] && !(included_anyway = options[:including_discards])) ||
options[:ignore].include?(name.to_sym) ||
(options[:only] && !options[:only].include?(name.to_sym) && !included_anyway)
Method do_store
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_store(json, key, value, options, schema = {}, store_anyway = false)
if options[:nqnames]
key = key.to_s.split(':').last
end
if value.nil?
Method prepare_options
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepare_options(options)
include_id = options[:include_id]
[:ignore, :only, :embedding, :inspecting, :including].each do |option|
value = (options[option] || [])
value = [value] unless value.is_a?(Enumerable)
Method parse_viewport
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_viewport(value)
value = value.to_s.split(' ').map do |seq|
seq.chars.inject([]) do |a, char|
case char
when '{', '}'
Method ns_prefix_for
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def ns_prefix_for(ns, namespaces, preferred = nil)
letters = true
ns = preferred || ns.split(':').last.split('/').last.underscore.split('_').collect { |token| (letters &&= token[0] =~ /[[:alpha:]]/) ? token[0] : '' }.join
ns = 'ns' if ns.blank?
if namespaces.values.include?(ns)
- 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 to_xml_element
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def to_xml_element(options = {})
prepare_options(options)
unless (xml_doc = options[:xml_doc])
options[:xml_doc] = xml_doc = Nokogiri::XML::Document.new
end
- 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 parse_viewport_seq
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def parse_viewport_seq(seq, hash)
previous_token = nil
until seq.empty?
case (token = seq.shift)
when '{'
- 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 record_to_xml_element
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def record_to_xml_element(data_type, schema, record, xml_doc, enclosed_property_name, options, namespaces)
Method record_to_hash
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def record_to_hash(record, options, referenced, enclosed_model, max_entries, viewport)
Avoid deeply nested control flow statements. Open
if Cenit::Utility.json_object?(sub_record)
json_objects << sub_record
else
elements << record_to_xml_element(data_type, property_schema, sub_record, xml_doc, nil, options, namespaces)
end
Method do_store
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def do_store(json, key, value, options, schema = {}, store_anyway = false)
Avoid deeply nested control flow statements. Open
if content.nil?
content = value
content_property = property_name
else
raise Exception.new("More than one content property found: '#{content_property}' and '#{property_name}'")
Avoid deeply nested control flow statements. Open
if field_sep == :by_fixed_length
value.join
else
while value.last.blank?
value.pop
Method record_to_edi
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def record_to_edi(data_type, options, schema, record, enclosed_property_name = nil)
Method edi_value
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def edi_value(record, property_name, property_schema, property_model, options)
Method normalize_nested_query
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def normalize_nested_query(value, prefix, unsafe)
case value
when Array
value.map do |v|
normalize_nested_query(v, "#{prefix}[]", unsafe)
- 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 to_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_params(options = {})
unsafe = options[:unsafe]
sort.map do |k, values|
if values.is_a?(Array)
values << nil if values.empty?
- 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"