Showing 18 of 20 total issues
Method collect_attribute_info
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def collect_attribute_info(info, ast)
if ast.object_ref
info.object_reference_count += 1
return
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 compile
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def compile(ast)
if !ast.object_ref && !ast.old_attributes && !ast.new_attributes
return compile_static_id_and_class(ast.static_id, ast.static_class)
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 collect_attribute_info
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def collect_attribute_info(info, ast)
if ast.object_ref
info.object_reference_count += 1
return
end
Method compile_html_comment
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def compile_html_comment(ast)
if ast.children.empty?
if ast.conditional.empty?
[:html, :comment, [:static, " #{ast.comment} "]]
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 walk_ast
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def walk_ast(info, ast)
info.ast_types[ast.class.to_s.sub(/\A.*::(.+)\z/, '\1')] += 1
case ast
when HamlParser::Ast::Root
ast.children.each { |c| walk_ast(info, c) }
Method compile_slow_attributes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def compile_slow_attributes(old_attributes, new_attributes, static_id, static_class, object_ref)
h = {}
unless static_class.empty?
h[:class] = static_class
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 walk_ast
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def walk_ast(info, ast)
info.ast_types[ast.class.to_s.sub(/\A.*::(.+)\z/, '\1')] += 1
case ast
when HamlParser::Ast::Root
ast.children.each { |c| walk_ast(info, c) }
- 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_element
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def compile_element(ast)
temple = [
:haml, :tag,
ast.tag_name,
self_closing?(ast),
- 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 try_static_value
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def try_static_value(key_static, node, force_static: false)
case node.type
when :sym, :int, :float, :str, :rational, :complex
set_static_attribute(key_static, node.children[0])
when :true
Method compile_interpolation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def compile_interpolation(text, lineno, escape_html: @escape_html)
s = StringScanner.new(text)
temple = [:multi]
pos = s.pos
while s.scan_until(INTERPOLATION_BEGIN)
- 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 on_haml_tag
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def on_haml_tag(name, self_closing, attrs, content = nil)
name = name.to_s
closed = self_closing && (!content || empty_exp?(content))
result = [:multi, [:static, "<#{name}"], compile(attrs)]
result << [:static, (closed && @format != :html ? ' /' : '') + '>']
- 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_slow_attributes
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def compile_slow_attributes(old_attributes, new_attributes, static_id, static_class, object_ref)
Method suppress_code_newline?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def suppress_code_newline?(ast)
ast.is_a?(HamlParser::Ast::Script) ||
ast.is_a?(HamlParser::Ast::SilentScript) ||
(ast.is_a?(HamlParser::Ast::Element) && suppress_code_newline?(ast.oneline_child)) ||
(ast.is_a?(HamlParser::Ast::Element) && !ast.children.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 on_multi
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_multi(*exprs)
i = exprs.size - 1
marker = false
while i >= 0
case exprs[i]
- 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 on_multi
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_multi(*exprs)
i = exprs.size - 1
depth = 0
while i >= 0
case exprs[i]
- 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_static_id_and_class
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def compile_static_id_and_class(static_id, static_class)
[:html, :attrs].tap do |html_attrs|
unless static_class.empty?
html_attrs << [:haml, :attr, 'class', [:static, static_class]]
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 optimizable?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def optimizable?(old_attributes, new_attributes, static_attributes, dynamic_attributes)
if static_attributes.nil?
return false
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 try_optimize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def try_optimize(old_attributes, new_attributes, static_id, static_class)
parser = StaticHashParser.new
unless parser.parse("{#{new_attributes}#{old_attributes}}")
assert_valid_ruby_code!(old_attributes)
return [nil, 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"