lib/taipo/utilities.rb
Method object_to_type_def
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.object_to_type_def(obj)
return obj.class.name unless obj.is_a? Enumerable
if obj.is_a? Array
element_types = Hash.new
- 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_to_type_def
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.object_to_type_def(obj)
return obj.class.name unless obj.is_a? Enumerable
if obj.is_a? Array
element_types = Hash.new
Method throw_error
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.throw_error(object:, name:, definition:, result: false)
subject = (result) ? "The return value of #{name}" : "Object '#{name}'"
if Taipo::Utilities.instance_method? definition
msg = "#{subject} does not respond to #{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"