File request.rb
has 614 lines of code (exceeds 250 allowed). Consider refactoring. Open
module JSONAPI
class Request
attr_accessor :fields, :include, :filters, :sort_criteria, :errors, :controller_module_path,
:context, :paginator, :source_klass, :source_id,
:include_directives, :params, :warnings, :server_error_callbacks, :operations
Class Request
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class Request
attr_accessor :fields, :include, :filters, :sort_criteria, :errors, :controller_module_path,
:context, :paginator, :source_klass, :source_id,
:include_directives, :params, :warnings, :server_error_callbacks, :operations
Method verify_permitted_params
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def verify_permitted_params(params, allowed_fields)
formatted_allowed_fields = allowed_fields.collect { |field| format_key(field).to_sym }
params_not_allowed = []
params.each do |key, value|
- 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_fields
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def parse_fields(resource_klass, fields)
extracted_fields = {}
return extracted_fields if fields.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 verify_permitted_params
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def verify_permitted_params(params, allowed_fields)
formatted_allowed_fields = allowed_fields.collect { |field| format_key(field).to_sym }
params_not_allowed = []
params.each do |key, value|
Method parse_fields
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_fields(resource_klass, fields)
extracted_fields = {}
return extracted_fields if fields.nil?
Method parse_filters
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def parse_filters(resource_klass, filters)
parsed_filters = {}
# apply default filters
resource_klass._allowed_filters.each do |filter, opts|
- 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 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 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 setup_operations
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def setup_operations(params)
return if params.nil?
resource_klass = Resource.resource_klass_for(params[:controller]) if params[:controller]
- 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_update_relationship_operation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse_update_relationship_operation(resource_klass, verified_params, relationship, parent_key)
options = {
context: @context,
resource_id: parent_key,
relationship_type: relationship.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 parse_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse_params(resource_klass, params, allowed_fields)
verify_permitted_params(params, allowed_fields)
checked_attributes = {}
checked_to_one_relationships = {}
- 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_include_directives
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_include_directives(resource_klass, raw_include)
raw_include ||= ''
included_resources = []
begin
- 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 setup_update_action
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def setup_update_action(params, resource_klass)
resolve_singleton_id(params, resource_klass)
fields = parse_fields(resource_klass, params[:fields])
include_directives = parse_include_directives(resource_klass, params[:include])
- 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"