Showing 10 of 235 total issues
Class Base
has 39 methods (exceeds 20 allowed). Consider refactoring. Open
class Base
include DoNothingActiveRecordMethods
include TemplateMethods
extend Queries
extend AliasAttribute
Method build_from
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.build_from(object: nil, exception: nil, class_name: nil, type: nil)
if object
args = [:message, :original_error, :level, :type, :class_name].each_with_object({}) do |meth, hash|
hash[meth] = object.public_send(meth) if object.respond_to? meth
end
- 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 create_method
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_method(m, type)
plural_type = (type.to_s + "s").to_sym
if safe_method?(type, m)
def_type = type == :method ? :class_defs : :defs
def_method = class_introspector.parsed_source.public_send(def_type).detect { |meth| meth.name == m }
- 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 process_attr
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def process_attr(attr)
enums = enums(attr.name)
attr.default = Virtus::Attribute.build(attr.type).coerce(attr.default)
attr.attribute_writer = "write_attribute(:#{attr.name}, val)"
attr.attribute_reader = "read_attribute(:#{attr.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 process_attr
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_attr(attr)
enums = enums(attr.name)
attr.default = Virtus::Attribute.build(attr.type).coerce(attr.default)
attr.attribute_writer = "write_attribute(:#{attr.name}, val)"
attr.attribute_reader = "read_attribute(:#{attr.name})"
Method coerce
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def coerce(key)
return if key.nil?
coerced_key = key_type.coerce(key)
if key && self.class.enums.key?(coerced_key)
if self.class.ignore_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 object_for_inspect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def object_for_inspect(value)
if value.is_a?(String) && value.length > 50
"#{value[0, 50]}...".inspect
elsif value.is_a?(Date) || value.is_a?(Time)
%("#{value.to_s(:db)}")
- 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 constants
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def constants
class_introspector.get_class.constants.map do |v|
c = class_introspector.get_class.const_get(v)
next if [Module, Class].include?(c.class)
const = if /\A#</ =~ c.inspect
- 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 display_errors
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def display_errors
uniq_errors.each do |e|
next unless ENV["DEBUG"] || !(e.level == :debug)
display_verbosity_three(e) || display_verbosity_two(e)
- 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 create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create(attributes = {}, &block)
if attributes.is_a?(Array)
attributes.collect { |attr| create(attr, &block) }
else
record = new(id: attributes.delete(:id) || attributes.delete("id"))
- 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"