Showing 6 of 11 total issues
Method typecast
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.typecast(value, options = {})
begin
array = (!value.is_a?(::Array) && value.respond_to?(:split)) ? value.split(options[:split]): Attrio::Helpers.to_a(value).flatten
if options[:element].present?
- 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 typecast
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.typecast(value, options = {})
begin
set = value.respond_to?(:split) ? value.split(options[:split]).to_set : Attrio::Helpers.to_a(value).to_set
if options[:element].present?
- 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 define_typecasting_method
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self.define_typecasting_method(klass, type, options)
klass.send :define_method, options[:method_name] do |value|
if !value.nil?
value = if type.respond_to?(:typecast) && type.respond_to?(:typecasted?)
type.typecasted?(value, options) ? value : type.typecast(*[value, options])
- 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 typecast
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.typecast(value, options = {})
true_values = options[:true] || options[:true_values] || ['yes', '1', 1, 'true']
false_values = options[:false] || options[:false_values]
if false_values.present?
- 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_type
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.cast_type(constant)
return constant if constant.is_a?(Class) && !!(constant < Attrio::Types::Base)
string = constant.to_s
string = string.camelize if (string =~ /\w_\w/ || string.chars.first.downcase == string.chars.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
Avoid too many return
statements within this method. Open
return constant