lib/cc/config/validation/hash_validations.rb
Method validate_key_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def validate_key_type(key, types)
if types.is_a?(Class)
return validate_key_type(key, [types])
elsif data.key?(key)
unless types.include?(data[key].class)
- 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 key_type_error_message
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def key_type_error_message(key, types)
if types.one?
klass_name = types[0].to_s.downcase
article =
if klass_name[0] == "a"
- 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
Add empty line after guard clause. Open
Open
end
- Read upRead up
- Exclude checks
Enforces empty line after guard clause
Example:
# bad
def foo
return if need_return?
bar
end
# good
def foo
return if need_return?
bar
end
# good
def foo
return if something?
return if something_different?
bar
end
# also good
def foo
if something?
do_something
return if need_return?
end
end