Showing 20 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Faml
module FilterCompilers
class Scss < TiltBase
def compile(ast)
temple = [:multi, [:static, "\n"], [:newline]]
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 38.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Faml
module FilterCompilers
class Sass < TiltBase
def compile(ast)
temple = [:multi, [:static, "\n"], [:newline]]
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 38.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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"