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 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 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 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"