Showing 10 of 10 total issues
Class Entity
has 42 methods (exceeds 20 allowed). Consider refactoring. Open
class Entity
attr_reader :object, :delegator, :options
# The Entity DSL allows you to mix entity functionality into
# your existing classes.
File entity.rb
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'grape_entity/json'
module Grape
# An Entity is a lightweight structure that allows you to easily
# represent data from your application in a consistent and abstracted
Method normalized_exposures
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def normalized_exposures(entity, options)
return easy_normalized_exposures(entity, options) unless deep_complex_nesting?(entity) # optimization
table = nested_exposures.each_with_object({}) do |exposure, output|
should_expose = exposure.with_attr_path(entity, options) do
- 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 expose
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.expose(*args, &block)
options = merge_options(args.last.is_a?(Hash) ? args.pop : {})
if args.size > 1
- 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 merge_options
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.merge_options(options)
opts = {}
merge_logic = proc do |key, existing_val, new_val|
if %i[if unless].include?(key)
- 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 normalized_exposures
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def normalized_exposures(entity, options)
return easy_normalized_exposures(entity, options) unless deep_complex_nesting?(entity) # optimization
table = nested_exposures.each_with_object({}) do |exposure, output|
should_expose = exposure.with_attr_path(entity, options) do
Method represent
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.represent(objects, options = {})
@present_collection ||= nil
if objects.respond_to?(:to_ary) && !@present_collection
root_element = root_element(:collection_root)
inner = objects.to_ary.map { |object| new(object, options.reverse_merge(collection: true)).presented }
- 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 expose_nil_condition
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def expose_nil_condition(attribute, options)
Condition.new_unless(
proc do |object, entity_options|
if options[:proc].nil?
delegator = Delegator.new(object)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method exec_with_object
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def exec_with_object(options, &block)
if block.parameters.count == 1
instance_exec(object, &block)
else
instance_exec(object, options, &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 add
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add(exposure, result)
# Save a result array in collections' array if it should be merged
if result.is_a?(Array) && exposure.for_merge
@output_collection << result
elsif exposure.for_merge
- 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"