Method do_merge_schema
has a Cognitive Complexity of 139 (exceeds 5 allowed). Consider refactoring. Open
def do_merge_schema(schema, options = {})
if schema.is_a?(Array)
return schema.collect { |sch| do_merge_schema(sch, options) }
end
return schema unless schema.is_a?(Hash)
- 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 check_properties
has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring. Open
def check_properties(json_schema, options = {})
object_schema =
case json_schema['type']
when 'object'
json_schema
- 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 do_merge_schema
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_merge_schema(schema, options = {})
if schema.is_a?(Array)
return schema.collect { |sch| do_merge_schema(sch, options) }
end
return schema unless schema.is_a?(Hash)
Method check_properties
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_properties(json_schema, options = {})
object_schema =
case json_schema['type']
when 'object'
json_schema
Method get_embedded_schema
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def get_embedded_schema(ref, root_schema, root_name = '')
fail "invalid format for embedded reference #{ref}" unless ref =~ %r{\A#(\/[a-z]+(_|([0-9]|[a-z])+)*)*\Z}
fail "embedding itself (referencing '#')" if ref.eql?('#')
tokens = ref.split('/')
tokens.shift
- 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
fail "contains an unresolved reference #{ref}" unless options[:silent]
Avoid deeply nested control flow statements. Open
base_model = find_ref_schema(base_model) if base_model.is_a?(String)
Avoid deeply nested control flow statements. Open
value = existing_value.deep_merge(value) { |_, sch_value, ref_value| Cenit::Utility.array_hash_merge(sch_value, ref_value) } if value.is_a?(Hash)
Avoid deeply nested control flow statements. Open
if schema['type'] == 'object' && base_model['type'] != 'object'
schema['properties'] ||= {}
value_schema = schema['properties']['value'] || {}
value_schema = base_model.deep_merge(value_schema)
schema['properties']['value'] = value_schema.merge('title' => 'Value', 'xml' => { 'content' => true })
Avoid deeply nested control flow statements. Open
schema = { 'properties' => base_properties }.deep_merge(schema) do |_, ref_value, sch_value|
Cenit::Utility.array_hash_merge(ref_value, sch_value)
end unless base_properties.blank?
Avoid deeply nested control flow statements. Open
value += existing_value if value.is_a?(Array)
Avoid deeply nested control flow statements. Open
schema['extends'] = base_model['extends'] if base_model['extends']
Avoid deeply nested control flow statements. Open
next unless (base_properties = base_model['properties'])