Showing 89 of 95 total issues
Method initialize_schema
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize_schema(schema, default_validator)
if schema.is_a?(String)
begin
# Build a fake URI for this
schema_uri = JSON::Util::URI.parse(fake_uuid(schema))
Method initialize
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
super
@attributes = {
'type' => JSON::Schema::TypeAttribute,
'disallow' => JSON::Schema::DisallowAttribute,
Method validate
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.validate(current_schema, data, fragments, processor, validator, options = {})
errors = Hash.new { |hsh, k| hsh[k] = [] }
validation_error_count = 0
one_of = current_schema.schema['oneOf']
Method validate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.validate(current_schema, data, fragments, processor, validator, options = {})
return unless data.is_a?(Hash)
current_schema.schema['dependencies'].each do |property, dependency_value|
next unless data.has_key?(property.to_s)
- 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 get_extended_uri_and_schema
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.get_extended_uri_and_schema(s, current_schema, validator)
uri, schema = nil, nil
if s.is_a?(Hash)
uri = current_schema.uri
- 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
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.validate(current_schema, data, fragments, processor, validator, options = {})
if data.is_a?(String)
error_message = "The property '#{build_fragment(fragments)}' must be a date in the format of YYYY-MM-DD"
if REGEXP.match(data)
begin
- 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
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.validate(current_schema, data, fragments, processor, validator, options = {})
# Create a hash to hold errors that are generated during validation
errors = Hash.new { |hsh, k| hsh[k] = [] }
valid = false
- 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 initialize
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
super
@attributes = {
'type' => JSON::Schema::TypeAttribute,
'disallow' => JSON::Schema::DisallowAttribute,
Method validate
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.validate(current_schema, data, fragments, processor, validator, options = {})
return unless data.is_a?(Array)
schema = current_schema.schema
return unless schema['items'].is_a?(Array)
- 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 json_backend=
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def json_backend=(backend)
if defined?(MultiJson)
backend = backend == 'json' ? 'json_gem' : backend
MultiJson.respond_to?(:use) ? MultiJson.use(backend) : MultiJson.engine = backend
else
- 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
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.validate(current_schema, data, fragments, processor, validator, options = {})
return unless data.is_a?(String)
begin
ip = IPAddr.new(data)
- 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 initialize
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
super
@attributes = {
'type' => JSON::Schema::TypeAttribute,
'disallow' => JSON::Schema::DisallowAttribute,
Method normalize_ref
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def normalize_ref(base)
base_uri = self.class.parse(base)
defer_validation do
if relative?
# Check for absolute path
- 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 get_referenced_uri_and_schema
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_referenced_uri_and_schema(s, current_schema, validator)
uri, schema = nil, nil
temp_uri = JSON::Util::URI.normalize_ref(s['$ref'], current_schema.uri)
Method parse
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse(s)
if defined?(MultiJson)
begin
MultiJson.respond_to?(:adapter) ? MultiJson.load(s) : MultiJson.decode(s)
rescue MultiJson::ParseError => e
Method validate_dependency
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.validate_dependency(schema, data, property, value, fragments, processor, attribute, options)
Method remove_valid_properties
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.remove_valid_properties(extra_properties, current_schema, validator)
schema = current_schema.schema
if schema['properties']
extra_properties = extra_properties - schema['properties'].keys
- 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
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.validate(current_schema, data, fragments, processor, validator, options = {})
schema = current_schema.schema
return unless data.is_a?(Hash) && (schema['type'].nil? || schema['type'] == 'object')
extra_properties = remove_valid_properties(data.keys, current_schema, validator)
- 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
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.validate(current_schema, data, fragments, processor, validator, options = {})
Method validate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.validate(current_schema, data, fragments, processor, validator, options = {})