Method emit
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
def emit(obj, level)
case obj
when Array
if (obj.length == 0)
'[]'
- 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
File yaml.rb
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
module TwitterCldr
module Utils
class YAML
Method emit
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
def emit(obj, level)
case obj
when Array
if (obj.length == 0)
'[]'
Method emit_string
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def emit_string(str, level)
if @options[:quote_all_strings] && !str.is_a?(Symbol)
emit_quoted_string(str, level)
else
str = str.to_s
- 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 string_type
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def string_type(str)
if str.respond_to?(:encoding) && (!str.valid_encoding? || str.encoding == Encoding::ASCII_8BIT)
return false, false, false, false
end
(ucs_codes = str.unpack('U*')) rescue (
- 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 is_printable?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def is_printable?(ucs_code)
# YAML 1.1 / 4.1.1.
(
[0x09, 0x0a, 0x0d, 0x85].include?(ucs_code) ||
(ucs_code <= 0x7e && ucs_code >= 0x20) ||
- 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 yaml_escape
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def yaml_escape(str)
# YAML 1.1 / 4.1.6.
str.gsub(/[^a-zA-Z0-9]/u) do |c|
ucs_code, = (c.unpack('U') rescue [??])
case
- 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 dump
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def dump(obj, opts = {})
@options = opts.dup
@options[:indent_size] = 2 if @options[:indent_size].to_i <= 0
@options[:minimum_block_length] = 0 if @options[:minimum_block_length].to_i <= 0
@options.update(
- 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 true, true, is_one_line?(str), is_one_plain_line?(str)