Showing 32 of 34 total issues
Method initialize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(opts = {})
super
@format = options[:format]
unless [:xhtml, :html, :xml].include?(@format)
if @format == :html4 || @format == :html5
Method on_dynamic
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def on_dynamic(code)
return [:dynamic, code] unless string_literal?(code)
return [:dynamic, code] if code.include?("\n")
temple = [:multi]
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def on_multi(*exps)
exps = exps.each_with_index.map do |e,i|
if e.first == :static && i > 0 && exps[i-1].first == :code
[:static, e.last.lstrip]
elsif e.first == :static && i < exps.size-1 && exps[i+1].first == :code
- 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_html_tag
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def on_html_tag(name, attrs, content = nil)
name = name.to_s
closed = !content || (empty_exp?(content) && (@format == :xml || options[:autoclose].include?(name)))
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
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 on_static
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_static(content)
return [:static, content] unless @pretty
unless @pre_tags && @pre_tags =~ content
content = content.sub(/\A\s*\n?/, "\n".freeze) if @indent_next
content = content.gsub("\n".freeze, indent)
- 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 false
Avoid too many return
statements within this method. Open
return false
Method indent_dynamic
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def indent_dynamic(text, indent_next, indent, pre_tags = nil)
text = text.to_s
safe = text.respond_to?(:html_safe?) && text.html_safe?
return text if pre_tags && text =~ pre_tags
- 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_literal?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def string_literal?(code)
return false if SyntaxChecker.syntax_error?(code)
type, instructions = Ripper.sexp(code)
return false if type != :program
- 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 chain_class_constructor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def chain_class_constructor(filter, local_options)
define_options(filter.options.valid_keys) if respond_to?(:define_options) && filter.respond_to?(:options)
proc do |engine|
opts = {}.update(engine.options)
opts.delete_if {|k,v| !filter.options.valid_key?(k) } if filter.respond_to?(:options)
- 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 tag_indent
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def tag_indent(name)
if @format == :xml
flag = @indent_next != nil
@indent_next = true
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"