Showing 105 of 156 total issues
Method initialize
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
#:underscored_key, :camelized_key, :dasherized_key, or custom
self.json_key_format = :dasherized_key
#:underscored_route, :camelized_route, :dasherized_route, or custom
Method cached_relationships_hash
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def cached_relationships_hash(source, fetchable_fields, relationship_data)
relationships = {}
source.relationships.try(:each_pair) do |k,v|
if fetchable_fields.include?(unformat_key(k).to_sym)
- 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_to_many_relationship
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def parse_to_many_relationship(resource_klass, link_value, relationship, &add_result)
if (link_value.is_a?(Hash) || link_value.is_a?(ActionController::Parameters))
linkage = link_value[:data]
else
fail JSONAPI::Exceptions::InvalidLinksObject.new(error_object_overrides)
- 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 change
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def change(callback)
completed = false
if @changing
run_callbacks callback 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 _replace_fields
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _replace_fields(field_data)
field_data[:attributes].each do |attribute, value|
begin
send "#{attribute}=", value
@save_needed = true
- 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 perform_joins
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform_joins(records, options)
join_array = flatten_join_tree_by_depth
join_array.each do |level_joins|
level_joins.each do |join_details|
Method parse_to_many_relationship
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_to_many_relationship(resource_klass, link_value, relationship, &add_result)
if (link_value.is_a?(Hash) || link_value.is_a?(ActionController::Parameters))
linkage = link_value[:data]
else
fail JSONAPI::Exceptions::InvalidLinksObject.new(error_object_overrides)
Method parse_params
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_params(resource_klass, params, allowed_fields)
verify_permitted_params(params, allowed_fields)
checked_attributes = {}
checked_to_one_relationships = {}
Method parse_sort_criteria
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def parse_sort_criteria(resource_klass, sort_criteria)
return unless sort_criteria.present?
unless JSONAPI.configuration.allow_sort
fail JSONAPI::Exceptions::ParameterNotAllowed.new(:sort)
- 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_join
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_join(path, default_type = :inner, default_polymorphic_join_type = :left)
if source_relationship
if source_relationship.polymorphic?
# Polymorphic paths will come it with the resource_type as the first segment (for example `#documents.comments`)
# We just need to prepend the relationship portion the
- 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 jsonapi_link
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def jsonapi_link(*links)
link_type = links.first
formatted_relationship_name = format_route(link_type)
options = links.extract_options!.dup
- 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 _replace_to_many_links
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _replace_to_many_links(relationship_type, relationship_key_values, options)
relationship = self.class._relationship(relationship_type)
reflect = reflect_relationship?(relationship, options)
Method find
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find
filters = params[:filters]
include_directives = params[:include_directives]
sort_criteria = params[:sort_criteria]
paginator = params[:paginator]
Method links_page_params
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def links_page_params(options = {})
record_count = options[:record_count]
links_page_params = {}
links_page_params['first'] = {
Method initialize
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(resource_klass, id, type, context, fetchable_fields, relationships,
links_json, attributes_json, meta_json)
Method inherited
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def inherited(subclass)
super
subclass.abstract(false)
subclass.immutable(false)
subclass.caching(_caching)
Method object_hash
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def object_hash(source, relationship_data)
obj_hash = {}
return obj_hash if source.nil?
Method check_include
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def check_include(resource_klass, include_parts)
relationship_name = unformat_key(include_parts.first)
relationship = resource_klass._relationship(relationship_name)
if relationship && format_key(relationship_name) == include_parts.first
- 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_to_one_relationship
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_to_one_relationship(resource_klass, link_value, relationship)
if link_value.nil?
linkage = nil
else
linkage = link_value[: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 parse
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.parse(source_resource_klass:, segment_string:, parse_fields: true)
first_part, last_part = segment_string.split('#', 2)
relationship = source_resource_klass._relationship(first_part)
if relationship
- 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"