lib/onesignal/models/notification200_errors.rb
Method find_and_cast_into_type
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
Open
def find_and_cast_into_type(klass, data)
return if data.nil?
case klass.to_s
when 'Boolean'
- 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 find_and_cast_into_type
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def find_and_cast_into_type(klass, data)
return if data.nil?
case klass.to_s
when 'Boolean'
Method build
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def build(data)
# Go through the list of oneOf items and attempt to identify the appropriate one.
# Note:
# - We do not attempt to check whether exactly one item matches.
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
- 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
Open
return Date.parse(data)
Avoid too many return
statements within this method. Open
Open
return Time.parse(data)
Avoid too many return
statements within this method. Open
Open
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
Avoid too many return
statements within this method. Open
Open
return data.map { |item| find_and_cast_into_type(sub_type, item) }
Avoid too many return
statements within this method. Open
Open
return data if data.instance_of?(String)
Avoid too many return
statements within this method. Open
Open
return model if model && model.valid?
Avoid too many return
statements within this method. Open
Open
return data if data.instance_of?(Hash)
Avoid too many return
statements within this method. Open
Open
return model if model