Method check_schema
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def check_schema(json, name, defined_types, embedded_refs, root_schema)
if (refs = json['$ref'])
refs = [refs] unless refs.is_a?(Array)
refs.each { |ref| embedded_refs[ref] = check_embedded_ref(ref, root_schema) if ref.is_a?(String) && ref.start_with?('#') }
elsif json['type'].nil? || json['type'].eql?('object')
- 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
Class JsonDataType
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class JsonDataType < DataType
include Setup::SnippetCode
origins Setup::CrossOriginShared::DEFAULT_ORIGINS
Method for_each_ref
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def for_each_ref(visited = Set.new, params = {}, &block)
schema = params[:schema] || self.schema
not_found = params[:not_found]
refs = []
if (ref = schema['$ref'])
- 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 json_data_type.rb
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Setup
class JsonDataType < DataType
include Setup::SnippetCode
origins Setup::CrossOriginShared::DEFAULT_ORIGINS
Method check_requires
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def check_requires(json)
properties = json['properties']
if (required = json['required'])
if required.is_a?(Array)
required.each do |property|
- 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_definitions
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def check_definitions(json, parent, defined_types, embedded_refs, root_schema)
if (defs = json['definitions'])
raise Exception.new('definitions format is invalid') unless defs.is_a?(Hash)
defs.each do |def_name, def_spec|
raise Exception.new("type definition '#{def_name}' is not an object type") unless def_spec.is_a?(Hash) && (def_spec['type'].nil? || def_spec['type'].eql?('object'))
- 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 validate_model
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def validate_model
if schema_code.is_a?(Hash)
if schema_changed?
begin
json_schema, _ = validate_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 build_indices
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def build_indices
unique_properties = self.unique_properties
indexed_properties = []
begin
records_model.collection.indexes.each do |index|
- 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_indices
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_indices
unique_properties = self.unique_properties
indexed_properties = []
begin
records_model.collection.indexes.each do |index|
Avoid deeply nested control flow statements. Open
raise Exception.new("specification of property '#{property_name}' is not valid") unless property_spec.is_a?(Hash)
Avoid deeply nested control flow statements. Open
if defined_types.include?(camelized_property_name) && !(property_spec['$ref'] || 'object'.eql?(property_spec['type']))
raise Exception.new("'#{name.underscore}' already defines #{property_name} (use #/[definitions|properties]/#{property_name} instead)")
end
Method check_schema
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_schema(json, name, defined_types, embedded_refs, root_schema)
Method check_definitions
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_definitions(json, parent, defined_types, embedded_refs, root_schema)
Method schema=
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def schema=(sch)
old_schema = schema
sch = JSON.parse(sch.to_s) unless sch.is_a?(Hash)
sch = sch.deep_stringify_keys
self.code = JSON.pretty_generate(sch)
- 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"