Method to_hash
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
def to_hash(flatten: false, history: {}, include_meta: true, placeholders: false)
history[object_id] = true
hash = self.class.fields.values.reduce(HashWithIndifferentAccess.new) do |memo, field|
name = field.name
value = instance_variable_get("@#{attr_name(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
Class Plat
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Plat
include FieldMapper::NameHelper
include FieldMapper::Marshaller
class << self
File plat.rb
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "digest/md5"
require_relative "../errors"
require_relative "../name_helper"
require_relative "../marshaller"
require_relative "field"
Method to_hash
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_hash(flatten: false, history: {}, include_meta: true, placeholders: false)
history[object_id] = true
hash = self.class.fields.values.reduce(HashWithIndifferentAccess.new) do |memo, field|
name = field.name
value = instance_variable_get("@#{attr_name(name)}")
Method symbolize_hash
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def symbolize_hash(hash)
hash.reduce({}) do |memo, pair|
key = pair.first.intern
value = pair.last
value = symbolize_hash(value) if value.is_a?(Hash)
- 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 assign_params
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def assign_params(params)
pending_assignments.clear
params.each do |name, value|
field = self.class.fields[name]
next if field.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 add_pending_assignment_for_plat_list
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def add_pending_assignment_for_plat_list(field, value)
pending_assignments << lambda do |descendant_plats|
list = value.reduce([]) do |memo, val|
if val.is_a?(Numeric)
plat = descendant_plats[val]
- 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
Avoid deeply nested control flow statements. Open
if history[oid].nil?
history[oid] = true
val.to_hash(
flatten: flatten,
history: history,
Avoid deeply nested control flow statements. Open
value = marshal(value) if flatten
Method add_pending_assignment_for_plat
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_pending_assignment_for_plat(field, value)
pending_assignments << lambda do |descendant_plats|
if value.is_a?(Numeric)
plat = descendant_plats[value]
assign_param field.name, plat unless plat.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"