File validator.rb
has 1158 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'resolv'
module Mongoff
module Validator
extend self
Method validate_instance
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
def validate_instance(instance, options = {})
unless (visited = options[:visited])
visited = options[:visited] = Set.new
end
unless (soft_checked = visited.include?(instance))
- 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_patternProperties
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
def check_patternProperties(patterns, instance, state, data_type, options)
path = options[:path] || '#'
unless (checked_properties = state[:checked_properties])
checked_properties = state[:checked_properties] = Set.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 check_type
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def check_type(types, instance, _, _, options, schema)
return if instance.nil? && options[:skip_nulls]
if types
types = [types] unless types.is_a?(Array)
types = types.map(&:to_s).map(&:to_sym)
- 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_additionalProperties
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def check_additionalProperties(schema, instance, state, data_type, options)
path = options[:path] || '#'
unless (checked_properties = state[:checked_properties])
checked_properties = state[:checked_properties] = Set.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 check_properties
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def check_properties(properties, instance, state, data_type, options)
path = options[:path] || '#'
unless (checked_properties = state[:checked_properties])
checked_properties = state[:checked_properties] = Set.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 check_dependentRequired
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def check_dependentRequired(properties, instance)
return unless instance
if instance.is_a?(Mongoff::Record)
has_errors = false
stored_properties = instance.orm_model.stored_properties_on(instance).map(&: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 check_string_format
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def check_string_format(format, instance)
case format
when 'date', 'date-time', 'time'
unless DATE_TIME_TYPES.any? { |type| instance.is_a?(type) }
- 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_items
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def check_items(items_schema, items, state, data_type, options)
path = options[:path] || '#'
if items.is_a?(Mongoff::RecordArray)
items_schema = items.orm_model.schema
data_type = items.orm_model.data_type
- 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_dependentSchemas
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def check_dependentSchemas(properties, instance, _, data_type)
return unless instance
if instance.is_a?(Mongoff::Record)
has_errors = false
stored_properties = instance.orm_model.stored_properties_on(instance).map(&: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 validate_instance
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_instance(instance, options = {})
unless (visited = options[:visited])
visited = options[:visited] = Set.new
end
unless (soft_checked = visited.include?(instance))
Method check_required
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def check_required(properties, instance)
return unless instance && properties.is_a?(Array)
if instance.is_a?(Mongoff::Record)
has_errors = false
stored_properties = instance.orm_model.stored_properties_on(instance)
- 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_patternProperties
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_patternProperties(patterns, instance, state, data_type, options)
path = options[:path] || '#'
unless (checked_properties = state[:checked_properties])
checked_properties = state[:checked_properties] = Set.new
end
Method check_propertyNames
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def check_propertyNames(schema, instance, state, data_type, options)
path = options[:path] || '#'
schema = data_type.merge_schema(schema)
if instance.is_a?(Mongoff::Record)
unless state[:instance_clear]
- 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_additionalProperties
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_additionalProperties(schema, instance, state, data_type, options)
path = options[:path] || '#'
unless (checked_properties = state[:checked_properties])
checked_properties = state[:checked_properties] = Set.new
end
Method check_properties
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_properties(properties, instance, state, data_type, options)
path = options[:path] || '#'
unless (checked_properties = state[:checked_properties])
checked_properties = state[:checked_properties] = Set.new
end
Method check_items
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_items(items_schema, items, state, data_type, options)
path = options[:path] || '#'
if items.is_a?(Mongoff::RecordArray)
items_schema = items.orm_model.schema
data_type = items.orm_model.data_type
Method check_string_format
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_string_format(format, instance)
case format
when 'date', 'date-time', 'time'
unless DATE_TIME_TYPES.any? { |type| instance.is_a?(type) }
Method check_type
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_type(types, instance, _, _, options, schema)
return if instance.nil? && options[:skip_nulls]
if types
types = [types] unless types.is_a?(Array)
types = types.map(&:to_s).map(&:to_sym)
Method _handle_error
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _handle_error(instance, err, property = :base)
return unless instance
msg = err.is_a?(String) ? err : err.message
if block_given?
msg = yield msg
- 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_propertyNames
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_propertyNames(schema, instance, state, data_type, options)
path = options[:path] || '#'
schema = data_type.merge_schema(schema)
if instance.is_a?(Mongoff::Record)
unless state[:instance_clear]
Method check_dependentRequired
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_dependentRequired(properties, instance)
return unless instance
if instance.is_a?(Mongoff::Record)
has_errors = false
stored_properties = instance.orm_model.stored_properties_on(instance).map(&:to_s)
Method check_contains
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def check_contains(contains_schema, items, state, data_type, options, schema)
return unless items.is_a?(Mongoff::RecordArray) || items.is_a?(Array)
contains_schema = data_type.merge_schema(contains_schema)
data_type = items.orm_model.data_type if items.is_a?(Mongoff::RecordArray)
max_min = schema['maxContains'] || schema['minContains']
- 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_dependentSchemas
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_dependentSchemas(properties, instance, _, data_type)
return unless instance
if instance.is_a?(Mongoff::Record)
has_errors = false
stored_properties = instance.orm_model.stored_properties_on(instance).map(&:to_s)
Method check_oneOf
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def check_oneOf(schemas, instance, _, data_type)
one_index = nil
schemas.each_with_index do |schema, index|
valid =
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 check_schema_items
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def check_schema_items(items_schema)
_check_type(:items, items_schema, Hash, Array)
if items_schema.is_a?(Hash)
begin
validate(items_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 check_additionalItems
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check_additionalItems(items_schema, items, state, data_type, options)
if (start_index = state[:additional_items_index]) && start_index < items.length
path = options[:path] || '#'
items_schema = items_schema.is_a?(FalseClass) ? false : (items_schema || true)
items_schema = data_type.merge_schema(items_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 check_contains
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_contains(contains_schema, items, state, data_type, options, schema)
Method check_maximum
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_maximum(maximum, instance, _state, _data_type, _options, schema)
Method check_type
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_type(types, instance, _, _, options, schema)
Method check_format
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_format(format, instance, _state, _data_type, _options, schema)
Method check_schema_type
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_schema_type(types)
return if types.nil?
types = [types] unless types.is_a?(Array)
types = types.map(&:to_s).map(&:to_sym)
raise_path_less_error "types are not unique" unless types.uniq.length === types.length
- 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_minimum
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_minimum(minimum, instance, _state, _data_type, _options, schema)
Method check_patternProperties
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_patternProperties(patterns, instance, state, data_type, options)
Method check_additionalProperties
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_additionalProperties(schema, instance, state, data_type, options)
Method check_properties
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_properties(properties, instance, state, data_type, options)
Method check_items
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_items(items_schema, items, state, data_type, options)
Method check_propertyNames
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_propertyNames(schema, instance, state, data_type, options)
Method check_additionalItems
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_additionalItems(items_schema, items, state, data_type, options)
Method check_maximum
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_maximum(maximum, instance, _state, _data_type, _options, schema)
if instance.is_a?(Numeric)
if schema['exclusiveMaximum'].is_a?(TrueClass)
raise_path_less_error "must be strictly less than #{maximum}" if instance >= maximum
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 check_minimum
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_minimum(minimum, instance, _state, _data_type, _options, schema)
if instance.is_a?(Numeric)
if schema['exclusiveMinimum'].is_a?(TrueClass)
raise_path_less_error "must be strictly greater than #{minimum}" if instance <= minimum
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 check_maxProperties
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_maxProperties(max, instance)
if instance.is_a?(Mongoff::Record) || instance.is_a?(Hash)
instance = instance.orm_model.stored_properties_on(instance) if instance.is_a?(Mongoff::Record)
raise_path_less_error "has too many properties (#{instance.size} of #{max} max)" if instance.size > max
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 check_minProperties
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_minProperties(min, instance)
if instance.is_a?(Mongoff::Record) || instance.is_a?(Hash)
instance = instance.orm_model.stored_properties_on(instance) if instance.is_a?(Mongoff::Record)
raise_path_less_error "has too few properties (#{instance.size} for #{min} min)" if instance.size < min
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 check_format
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_format(format, instance, _state, _data_type, _options, schema)
if instance
if schema['type'] == 'string'
check_string_format(format, instance)
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def check_minProperties(min, instance)
if instance.is_a?(Mongoff::Record) || instance.is_a?(Hash)
instance = instance.orm_model.stored_properties_on(instance) if instance.is_a?(Mongoff::Record)
raise_path_less_error "has too few properties (#{instance.size} for #{min} min)" if instance.size < min
end
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 36.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def check_maxProperties(max, instance)
if instance.is_a?(Mongoff::Record) || instance.is_a?(Hash)
instance = instance.orm_model.stored_properties_on(instance) if instance.is_a?(Mongoff::Record)
raise_path_less_error "has too many properties (#{instance.size} of #{max} max)" if instance.size > max
end
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 36.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def check_schema_oneOf(schemas)
_check_type(:oneOf, schemas, Array)
raise_path_less_error 'oneOf schemas should not be empty' if schemas.length == 0
schemas.each_with_index do |schema, index|
begin
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
begin
validate_instance(value, options.merge(
path: "#{path}/#{property}",
schema: schema,
data_type: data_type
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
begin
validate_instance(property, options.merge(
path: "#{path}/#{property}",
schema: schema,
data_type: data_type
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def check_schema_allOf(schemas)
_check_type(:allOf, schemas, Array)
raise_path_less_error 'allOf schemas should not be empty' if schemas.length == 0
schemas.each_with_index do |schema, index|
begin
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def check_schema_anyOf(schemas)
_check_type(:anyOf, schemas, Array)
raise_path_less_error 'anyOf schemas should not be empty' if schemas.length == 0
schemas.each_with_index do |schema, index|
begin
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def check_minimum(minimum, instance, _state, _data_type, _options, schema)
if instance.is_a?(Numeric)
if schema['exclusiveMinimum'].is_a?(TrueClass)
raise_path_less_error "must be strictly greater than #{minimum}" if instance <= minimum
else
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 28.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def check_maximum(maximum, instance, _state, _data_type, _options, schema)
if instance.is_a?(Numeric)
if schema['exclusiveMaximum'].is_a?(TrueClass)
raise_path_less_error "must be strictly less than #{maximum}" if instance >= maximum
else
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 28.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def check_schema_properties(value)
_check_type(:properties, value, Hash)
value.each do |property, schema|
begin
validate(schema)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 26.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def check_schema_dependentSchemas(properties)
_check_type(:dependentSchemas, properties, Hash)
properties.each do |property_name, dependent_schema|
begin
validate(dependent_schema)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 26.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def check_maxItems(max, items)
if items.is_a?(Mongoff::RecordArray) || items.is_a?(Array)
raise_path_less_error "has too many items (#{items.count} of #{max} max)" if items.count > max
end
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 25.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def check_minItems(min, items)
if items.is_a?(Mongoff::RecordArray) || items.is_a?(Array)
raise_path_less_error "has too few items (#{items.count} for #{min} min)" if items.count < min
end
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 25.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76