Showing 19 of 39 total issues
Class SeregaAttributeNormalizer
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class SeregaAttributeNormalizer
#
# AttributeNormalizer instance methods
#
module AttributeNormalizerInstanceMethods
Method call
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def call(object, max_count:)
# Procs (but not lambdas) can accept all provided parameters
parameters = object.is_a?(Proc) ? object.parameters : object.method(:call).parameters
return 1 if parameters[0] == NO_NAMED_REST_PARAM
return max_count if object.is_a?(Proc) && !object.lambda?
- 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 inherited
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def inherited(subclass)
config_class = Class.new(self::SeregaConfig)
config_class.serializer_class = subclass
subclass.const_set(:SeregaConfig, config_class)
subclass.instance_variable_set(:@config, subclass::SeregaConfig.new(config.opts))
Method append_many
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def append_many(preloads, plan)
plan.points.each do |point|
current_preloads = point.attribute.preloads
next unless current_preloads
- 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 after_load_plugin
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.after_load_plugin(serializer_class, **opts)
serializer_class::SeregaConfig.include(ConfigInstanceMethods)
batch_loaders_class = Class.new(SeregaBatchLoaders)
batch_loaders_class.serializer_class = serializer_class
Method validate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate(serializer_class, fields)
fields.each do |name, nested_fields|
attribute = serializer_class && serializer_class.attributes[name]
# Save error when no attribute with checked name exists
- 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 attributes_points
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def attributes_points(modifiers)
only = modifiers[:only] || FROZEN_EMPTY_HASH
except = modifiers[:except] || FROZEN_EMPTY_HASH
with = modifiers[:with] || FROZEN_EMPTY_HASH
points = []
- 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 add_metadata
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_metadata(object, context, hash)
self.class.meta_attributes.each_value do |meta_attribute|
metadata = meta_attribute_value(object, context, meta_attribute)
next unless metadata
- 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_if_unless
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_if_unless(obj, ctx, opt_if_name, opt_unless_name)
opt_if = attribute.opt_if[opt_if_name]
opt_unless = attribute.opt_if[opt_unless_name]
return true if opt_if.nil? && opt_unless.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 parse
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse(fields)
res = {}
attribute = +""
char = +""
path_stack = 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 visible?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def visible?(modifiers)
except = modifiers[:except] || FROZEN_EMPTY_HASH
only = modifiers[:only] || FROZEN_EMPTY_HASH
with = modifiers[:with] || FROZEN_EMPTY_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 define
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def define(loader_name, callable = nil, &block)
if (!callable && !block) || (callable && block)
raise SeregaError, "Batch loader can be specified with one of arguments - callable value or &block"
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 call
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.call(callable, callable_description)
parameters = callable.is_a?(Proc) ? callable.parameters : callable.method(:call).parameters
parameters.each do |parameter|
next unless parameter[0] == :keyreq
- 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_preloads
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def prepare_preloads
opts = init_opts
preloads_provided = opts.key?(:preload)
preloads =
if preloads_provided
- 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 after_load_plugin
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.after_load_plugin(serializer_class, **opts)
serializer_class::SeregaConfig.include(ConfigInstanceMethods)
batch_loaders_class = Class.new(SeregaBatchLoaders)
batch_loaders_class.serializer_class = serializer_class
- 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 preload
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def preload(object, preloads)
return object if object.nil? || (object.is_a?(Array) && object.empty?) || preloads.empty?
preload_handler = handlers.find { |handler| handler.fit?(object) }
raise SeregaError, "Can't preload #{preloads.inspect} to #{object.inspect}" unless preload_handler
- 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 transform=
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def transform=(value)
raise SeregaError, "Transform value must respond to #call" unless value.respond_to?(:call)
params = value.is_a?(Proc) ? value.parameters : value.method(:call).parameters
if params.count != 1 || !params.all? { |param| (param[0] == :req) || (param[0] == :opt) }
- 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_usage_with_other_options
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_usage_with_other_options(path, opts)
return unless path
preload = opts[:preload]
raise SeregaError, "Invalid option preload_path: #{path.inspect}. Can be provided only when :preload option provided" unless preload
- 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 plugin
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def plugin(name, **opts)
raise SeregaError, "This plugin is already loaded" if plugin_used?(name)
plugin = SeregaPlugins.find_plugin(name)
- 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"