Showing 16 of 16 total issues
Method serialize_queries
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def serialize_queries(resource)
resource.forms.each_with_object([]) do |form, result|
next unless form_is_query? form
result << {rel: form.name, href: form.action}
- 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 serialize_items
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def serialize_items(resource)
resource.seq.map do |item|
attrs = item.attributes.map do |name, value|
{
name: 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"
Further reading
Method def_set
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def def_set(*method_names)
method_names.each do |method_name|
define_singleton_method method_name do |arg = Undefined, &block|
if arg.equal?(Undefined)
unless block
- 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 render_resource
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def render_resource(resource, templ = section('resource'))
templ
.replace('.type') { |header| header.content(resource.type.to_s + (resource.collection? ? ' collection' : '')) }
.replace('.attribute', &render_attributes(resource.attributes))
.replace('.links') {|links| resource.links.empty? ? [] : links.replace('.link', &render_links(resource.links)) }
- 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 serialize_form_field
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def serialize_form_field(field)
if field.type == :fieldset
{
type: :fieldset,
fields: field.fields.map(&method(:serialize_form_field))
- 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 Resolve
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def Resolve(maybe_proc, context = nil) # rubocop:disable Style/MethodName
if maybe_proc.respond_to?(:to_proc) && !maybe_proc.instance_of?(Symbol)
if context
if maybe_proc.arity > 0
context.instance_eval(&maybe_proc)
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
def call(parsed_json, _env = {})
included = parsed_json['included'].nil? ? {} : parsed_json['included'].dup
if parsed_json['data'].is_a?(Array)
CollectionResource.new(
- 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 render_field
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def render_field(field)
attrs = field.to_h_compact
if attrs.key? :checked
if attrs[:checked]
- 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 render_field
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render_field(field)
attrs = field.to_h_compact
if attrs.key? :checked
if attrs[:checked]
Method convert_embedded
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def convert_embedded(relationships, included)
relationships.flat_map do |rel, relationship|
# A Link doesn't have to contain a `data` member.
# It can contain URLs instead, or as well, but we are only worried about *embedded* links here.
data = relationship['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 fields_flat
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def fields_flat(&block)
return to_enum(__method__) unless block_given?
fields.map do |field|
next field if field.type.equal? :legend
if field.respond_to?(:map_fields)
- 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 insert_hooks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def insert_hooks(hooks)
new_steps = hooks.inject(steps) do |steps, (type, target_step, name, hook)|
steps.flat_map do |step_name, callable|
if step_name.equal? target_step
case 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 convert_embedded
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def convert_embedded(embedded)
embedded.flat_map do |rel, resource|
case resource
when nil
NullResource.new
- 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 serialize_resource
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def serialize_resource(resource)
result = {}
result[:type] = pluralize(resource.type)
result[:id] = resource[:id].to_s if resource[:id]
- 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 map_to_resource_link
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def map_to_resource_link(mapper)
return unless mapper.expand_value(options.fetch(:if, true))
uri = mapper.expand_uri(template, options.fetch(:expand, true))
return if uri.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 call
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def call(resource, _env = nil)
output = {}
if resource.collection?
output[:data] = resource.map(&method(:serialize_resource))
output[:links] = serialize_links(resource.links) if resource.links.any?
- 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"