Showing 68 of 77 total issues
Method process_line
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_line(line)
case line.text[0]
when DIV_CLASS; push div(line)
when DIV_ID
return push plain(line) if %w[{ @ $].include?(line.text[1])
Method parse_new_attributes
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_new_attributes(text)
scanner = StringScanner.new(text)
last_line = @line.index + 1
attributes = {}
Method each_attr
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def each_attr(tokens)
attr_tokens = []
open_tokens = Hash.new { |h, k| h[k] = 0 }
tokens.each do |token|
Method filter_and_join
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def filter_and_join(value, separator)
return '' if (value.respond_to?(:empty?) && value.empty?)
if value.is_a?(Array)
value = value.flatten
- 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 flatten_attributes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def flatten_attributes(attributes)
flattened = {}
attributes.each do |key, value|
case 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 compile_boolean!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def compile_boolean!(temple, key, values)
exp = literal_for(values.last)
if Temple::StaticAnalyzer.static?(exp)
value = eval(exp)
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
def on_multi(*exps)
exps = exps.dup
result = [:multi]
buffer = []
- 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 next_line
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def next_line
line = @template.shift || raise(StopIteration)
# `flat?' here is a little outdated,
# so we have to manually check if either the previous or current line
- 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_tokens!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def compile_tokens!(exps, tokens)
beg_str, end_str = strip_quotes!(tokens)
until tokens.empty?
_, type, str = tokens.shift
- 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 compute_tabs
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def compute_tabs(line)
return 0 if line.text.empty? || !line.whitespace
if @indentation.nil?
@indentation = line.whitespace
- 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 rstrip_whitespace!
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def rstrip_whitespace!(temple)
return if temple.size == 1
case temple[0]
when :multi
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 close_silent_script
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def close_silent_script(node)
@script_level_stack.pop if ["if", "case", "unless"].include? node.value[:keyword]
# Post-process case statements to normalize the nesting of "when" clauses
return unless node.value[:keyword] == "case"
- 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 balance
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def balance(scanner, start, finish, count = 0)
str = ''.dup
scanner = StringScanner.new(scanner) unless scanner.is_a? StringScanner
regexp = Regexp.new("(.*?)[\\#{start.chr}\\#{finish.chr}]", Regexp::MULTILINE)
while scanner.scan(regexp)
- 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 count_lines
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.count_lines(exp)
type, *args = exp
case type
when :multi
args.map { |a| count_lines(a) }.reduce(:+) || 0
- 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 build_boolean!
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_boolean!(escape_attrs, quote, format, buf, key, value)
Method handle_ruby_multiline
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def handle_ruby_multiline(line)
line.text.rstrip!
return line unless is_ruby_multiline?(line.text)
begin
# Use already fetched @next_line in the first loop. Otherwise, fetch next
- 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
Consider simplifying this complex logical expression. Open
unless (flat? && !closes_flat?(line) && !closes_flat?(@line)) ||
(line_defined && @line.text[0] == ?: && line.full =~ %r[^#{@line.full[/^\s+/]}\s])
return next_line if line.text.empty?
handle_multiline(line)
Method build
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build(escape_attrs, quote, format, object_ref, *hashes)
Method parse_class_and_id
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_class_and_id(list)
attributes = {}
return attributes if list.empty?
list.scan(/([#.])([-:_a-zA-Z0-9\@]+)/) do |type, property|
- 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"