app/presenters/v2/relations_presenter.rb
Method serialize_relationships
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Open
def serialize_relationships(relationships, controller, depth, obj, opts, parents, orphans)
response = {}
(relationships || {}).each do |relationship_name, association|
associated_model = get_associated_model_class_for(obj, association.association_name)
next unless associated_model
- 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_to_one_relationship
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def serialize_to_one_relationship(response, associated_model_instance, associated_controller, relationship_name, depth, opts, parents, orphans)
Method serialize_to_many_relationship
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def serialize_to_many_relationship(response, associated_model_instances, associated_controller, relationship_name, depth, opts, parents, orphans)
Method serialize_relationships
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def serialize_relationships(relationships, controller, depth, obj, opts, parents, orphans)
Method add_relationship_url_to_response
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def add_relationship_url_to_response(response, controller, associated_controller, relationship_name, association, obj)
Method to_hash
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def to_hash(controller, obj, opts, depth, parents, orphans=nil)
Method relationship_link_only?
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def relationship_link_only?(association, associated_controller, relationship_name, opts, depth, parents)