Showing 15 of 15 total issues
Class Resource
has 72 methods (exceeds 20 allowed). Consider refactoring. Open
class Resource
extend ActiveModel::Naming
extend ActiveModel::Translation
include ActiveModel::Validations
include ActiveModel::Conversion
File resource.rb
has 454 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'forwardable'
require 'active_support/all'
require 'active_model'
module JsonApiClient
Class Builder
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Builder
attr_reader :klass
delegate :key_formatter, to: :klass
Class NestedParamPaginator
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class NestedParamPaginator
DEFAULT_WRAPPER_NAME = "page".freeze
DEFAULT_PAGE_PARAM = "page".freeze
DEFAULT_PER_PAGE_PARAM = "per_page".freeze
Method save
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def save
return false unless valid?
raise JsonApiClient::Errors::ResourceImmutableError if _immutable
self.last_result_set = if persisted?
- 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 compute_type
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.compute_type(klass, type_name)
return klass.custom_type_to_class.fetch(type_name).constantize if klass.custom_type_to_class.key?(type_name)
# If the type is prefixed with a scope operator then we assume that
# the type_name is an absolute reference.
return type_name.constantize if type_name.match(/^::/)
- 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 handle_status
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_status(code, env)
custom_handler = custom_handler_for(code)
return custom_handler.call(env) if custom_handler.present?
case code
Method track_json_api_errors
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def track_json_api_errors(msg)
return msg unless env.try(:body).kind_of?(Hash) || env.body.key?('errors')
errors_msg = env.body['errors'].map { |e| e['title'] }.compact.join('; ').presence
return msg unless errors_msg
- 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 method_missing
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(method, *args, &block)
if method.to_s =~ /^(.*)_changed\?$/
has_attribute?($1) ? attribute_changed?($1) : nil
elsif method.to_s =~ /^(.*)_was$/
has_attribute?($1) ? attribute_was($1) : 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 relationship_data_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def relationship_data_for(name, relationship_definition)
# look in included data
if relationship_definition.key?("data")
if relationships.attribute_changed?(name)
return relation_objects_for(name, relationship_definition)
- 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_orders
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse_orders(*args)
args.map do |arg|
case arg
when Hash
arg.map do |k, v|
- 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_default_properties
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def setup_default_properties
self.class.schema.each_property do |property|
unless attributes.has_key?(property.name) || property.default.nil?
attribute_will_change!(property.name) if add_defaults_to_changes
attributes[property.name] = property.default
- 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 path
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def path(params = nil)
parts = [resource_path]
if params && _prefix_path.present?
path_params = params.delete(:path) || params
parts.unshift(_set_prefix_path(path_params.symbolize_keys))
- 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 cast
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cast(value)
return nil if value.nil?
return value if type.nil?
type_caster = TypeFactory.type_for(type)
return value if type_caster.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 select_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def select_params
if @fields.empty?
{}
else
field_result = Hash.new { |h,k| h[k] = [] }
- 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"