Showing 14 of 16 total issues
Method call
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def call(template_str)
@ast = Ast::Root.new
@stack = []
@line_parser = LineParser.new(@filename, template_str)
@indent_tracker = IndentTracker.new(on_enter: method(:indent_enter), on_leave: method(:indent_leave))
- 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_attributes
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def parse_attributes(rest)
old_attributes = nil
new_attributes = nil
object_ref = nil
- 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_line
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_line(line)
text, indent = @indent_tracker.process(line, @line_parser.lineno)
if text.empty?
@ast << create_node(Ast::Empty)
Method call
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(template_str)
@ast = Ast::Root.new
@stack = []
@line_parser = LineParser.new(@filename, template_str)
@indent_tracker = IndentTracker.new(on_enter: method(:indent_enter), on_leave: method(:indent_leave))
Method parse_line
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_line(line)
text, indent = @indent_tracker.process(line, @line_parser.lineno)
if text.empty?
@ast << create_node(Ast::Empty)
- 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 indent_enter
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def indent_enter(_, _text)
empty_lines = []
while @ast.children.last.is_a?(Ast::Empty)
empty_lines << @ast.children.pop
end
Method scan_quoted_value
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def scan_quoted_value(scanner, quote)
re = /((?:\\.|\#(?!\{)|[^#{quote}\\#])*)(#{quote}|#\{)/
pos = scanner.pos
loop do
unless scanner.scan(re)
- 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 indent_enter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def indent_enter(_, _text)
empty_lines = []
while @ast.children.last.is_a?(Ast::Empty)
empty_lines << @ast.children.pop
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 attributes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def attributes
attrs = old_attributes || ''
if new_attributes
if attrs.empty?
attrs = new_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 append
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def append(line)
indent, text = @indent_tracker.split(line)
if text.empty?
@ast.texts << ''
return
- 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_class_and_id
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_class_and_id(class_and_id)
classes = []
id = ''
scanner = StringScanner.new(class_and_id)
until scanner.eos?
- 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 indent_leave
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def indent_leave(indent_level, text, lineno)
if @comment_level
if indent_level <= @comment_level
# finish comment mode
@comment_level = nil
- 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_sanitized
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_sanitized(text)
if text.start_with?('&==')
create_node(Ast::Text) { |t| t.text = text[3..-1].lstrip }
elsif text[1] == '=' || text[1] == '~'
node = create_node(Ast::Script)
- 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_unescape
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_unescape(text)
if text.start_with?('!==')
create_node(Ast::Text) do |t|
t.text = text[3..-1].lstrip
t.escape_html = false
- 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"