Showing 68 of 77 total issues
Method try_parse_haml_emacs_magic_comment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def try_parse_haml_emacs_magic_comment(scanner)
pos = scanner.pos
return unless scanner.scan(/.*?-\*-\s*/n)
# From Ruby's parse.y
return unless scanner.scan(/([^\s'":;]+)\s*:\s*("(?:\\.|[^"])*"|[^"\s;]+?)[\s;]*-\*-/n)
- 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 parse_key!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse_key!(tokens)
_, type, str = tokens.shift
case type
when :on_sp
parse_key!(tokens)
- 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 merge_all_attrs
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def merge_all_attrs(hashes)
merged = {}
hashes.each do |hash|
unless hash.is_a?(Hash)
raise ArgumentError, "Non-hash object is given to attributes!"
- 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 plain
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def plain(line, escape_html = nil)
if block_opened?
raise SyntaxError.new(Error.message(:illegal_nesting_plain), @next_line.index)
end
- 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 comment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def comment(text)
if text[0..1] == '!['
revealed = true
text = text[1..-1]
else
- 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 compile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def compile(code)
[].tap do |exps|
tokens = Ripper.lex(code.strip)
tokens.pop while tokens.last && [:on_comment, :on_sp].include?(tokens.last[1])
- 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 compile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def compile(node, &block)
temple = [:multi]
return temple if node.children.empty?
temple << [:whitespace] if prepend_whitespace?(node)
- 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 check_encoding
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_encoding(str)
if str.valid_encoding?
# Get rid of the Unicode BOM if possible
# Shortcut for UTF-8 which might be the majority case
if str.encoding == Encoding::UTF_8
- 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 unless scanner.scan(/\s*(?:,|$)\s*/)
Avoid too many return
statements within this method. Open
return name, [:dynamic, var]
Avoid too many return
statements within this method. Open
return name, [:static, content.first[1]] if content.size == 1
Avoid too many return
statements within this method. Open
return name, [:dynamic,
%!"#{content.each_with_object(''.dup) {|(t, v), s| s << (t == :str ? Util.inspect_obj(v)[1...-1] : "\#{#{v}}")}}"!]
Avoid too many return
statements within this method. Open
return push plain(line.strip!(1), false) if line.text[1] == ?\s || line.text[1..2] == '#{'
Avoid too many return
statements within this method. Open
return push plain(line.strip!(2)) if line.text[1] == SCRIPT
Avoid too many return
statements within this method. Open
return push doctype(line.text) if line.text[0, 3] == '!!!'
Avoid too many return
statements within this method. Open
return push plain(line.strip!(3), false) if line.text[1, 2] == '=='
Avoid too many return
statements within this method. Open
return push script(line.strip!(2), false) if line.text[1] == SCRIPT
Avoid too many return
statements within this method. Open
return push plain(line.strip!(1), :escape_html) if line.text[1] == ?\s || line.text[1..2] == '#{'
Avoid too many return
statements within this method. Open
return push haml_comment(line.text[2..-1]) if line.text[1] == SILENT_COMMENT
Avoid too many return
statements within this method. Open
return false unless scanner.scan(re)