Showing 16 of 16 total issues
Method to_haml
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
def to_haml(tabs, options)
return "" if converted_to_haml
if name == "script" &&
(attr_hash['type'].nil? || attr_hash['type'].to_s == "text/javascript") &&
- 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
File html.rb
has 377 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cgi'
require 'nokogiri'
require 'html2haml/html/erb'
# Haml monkeypatches various Nokogiri classes
Method to_haml
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_haml(tabs, options)
return "" if converted_to_haml
if name == "script" &&
(attr_hash['type'].nil? || attr_hash['type'].to_s == "text/javascript") &&
Method dynamic_attributes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def dynamic_attributes
#reject any attrs without <haml>
@dynamic_attributes = attr_hash.select {|name, value| value =~ %r{<haml.*</haml} }
@dynamic_attributes.each do |name, value|
fragment = Nokogiri::XML.fragment(CGI.unescapeHTML(value))
- 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 to_haml
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def to_haml(tabs, options)
attrs = external_id.nil? ? ["", "", ""] :
external_id.scan(/DTD\s+([^\s]+)\s*([^\s]*)\s*([^\s]*)\s*\/\//)[0]
raise Haml::SyntaxError.new("Invalid doctype") if attrs == 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!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse!
begin
parse
rescue Exception => e
raise e if @options[:trace] || e.is_a?(SystemExit)
- 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 CGI.unescapeHTML(inner_text).split("\n").map do |line|
next "" if line.strip.empty?
"#{output}- #{line.strip}\n"
end.join
Avoid too many return
statements within this method. Open
return render_children("", tabs, options)
Avoid too many return
statements within this method. Open
return output + "\n#{tabulate(tabs + 1)}:preserve\n" +
inner_text.gsub(/^/, tabulate(tabs + 2))
Avoid too many return
statements within this method. Open
return output + child.to_haml(tabs + 1, options).lstrip
Avoid too many return
statements within this method. Open
return output + "\n" + text
Avoid too many return
statements within this method. Open
return output + " " + text.lstrip.gsub(/^\\/, '') unless text.chomp.include?("\n") || text.empty?
Method process_result
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def process_result
super
require 'html2haml/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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(template, options = {})
@options = options
if template.is_a? Nokogiri::XML::Node
@template = template
- 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 add_stmt
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_stmt(src, code)
src << '</haml_block>' if block_closer?(code) || mid_block?(code)
src << '<haml_silent>' << h(code) << '</haml_silent>' unless code.strip == "end"
src << '<haml_block>' if block_opener?(code) || mid_block?(code)
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 to_haml_filter
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_haml_filter(filter, tabs, options)
content =
if children.first && children.first.cdata?
decode_entities(children.first.content_without_cdata_tokens)
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"