Showing 33 of 33 total issues
File parser.rb
has 403 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Slim
# Parses Slim code and transforms it to a Temple expression
# @api private
class Parser < Temple::Parser
define_options :file,
Method parse_tag
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def parse_tag(tag)
if @tag_shortcut[tag]
@line.slice!(0, tag.size) unless @attr_shortcut[tag]
tag = @tag_shortcut[tag]
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 parse_text_block
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def parse_text_block(first_line = nil, text_indent = nil)
result = [:multi]
if !first_line || first_line.empty?
text_indent = nil
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 parse_attributes
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def parse_attributes(attributes = [:html, :attrs])
# Check to see if there is a delimiter right after the tag name
delimiter = nil
if @line =~ @attr_list_delims_re
delimiter = @attr_list_delims[$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 process
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def process
args = @args.dup
unless @options[:input]
file = args.shift
if file
- 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_tag
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_tag(tag)
if @tag_shortcut[tag]
@line.slice!(0, tag.size) unless @attr_shortcut[tag]
tag = @tag_shortcut[tag]
end
Method initialize
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def initialize(opts = {})
super
@attr_list_delims = options[:attr_list_delims]
@code_attr_delims = options[:code_attr_delims]
tabsize = options[:tabsize]
- 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_ruby_code
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def parse_ruby_code(outer_delimiter)
code, count, delimiter, close_delimiter = '', 0, nil, nil
# Attribute ends with space or attribute delimiter
end_re = /\A[\s#{Regexp.escape outer_delimiter.to_s}]/
- 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 set_opts
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_opts(opts)
opts.on('-s', '--stdin', 'Read input from standard input instead of an input file') do
@options[:input] = $stdin
end
Method lambda
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def lambda(name, &block)
@lookup.each do |lookup|
case lookup
when :method
return @dict.public_send(name, &block) if @dict.respond_to?(name, false)
- 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 []
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def [](name)
@lookup.each do |lookup|
case lookup
when :method
return @dict.public_send(name) if @dict.respond_to?(name, false)
- 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_line_indicators
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_line_indicators
case @line
when /\A\/!( ?)/
# HTML comment
@stacks.last << [:html, :comment, [:slim, :text, :verbatim, parse_text_block($', @indents.last + $1.size + 2)]]
Method parse_attributes
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_attributes(attributes = [:html, :attrs])
# Check to see if there is a delimiter right after the tag name
delimiter = nil
if @line =~ @attr_list_delims_re
delimiter = @attr_list_delims[$1]
Method parse_line
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def parse_line
if @line =~ /\A\s*\Z/
@stacks.last << [:newline]
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 on_multi
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def on_multi(*exps)
# The [:multi] blocks serve two purposes.
# On outer level, they collect the building blocks like
# tags, verbatim text, and implicit/explicit text.
# Within a text block, they collect the individual
- 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 unknown_line_indicator
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def unknown_line_indicator
if @line =~ /\A>( ?)/
# Found explicit text block.
@stacks.last << [:slim, :text, :explicit, parse_text_block($', @indents.last + $1.size + 1)]
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 initialize
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(opts = {})
super
@attr_list_delims = options[:attr_list_delims]
@code_attr_delims = options[:code_attr_delims]
tabsize = options[:tabsize]
Method parse_quoted_attribute
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def parse_quoted_attribute(quote)
value, count = '', 0
until count == 0 && @line[0] == quote[0]
if @line =~ /\A(\\)?\Z/
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
def on_multi(*exps)
result = [:multi]
# This variable is true if the previous line was
# (1) a control code and (2) contained indented content.
prev_indent = false
- 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 12 (exceeds 5 allowed). Consider refactoring. Open
def on_html_tag(tag, attributes, content = nil)
return super if tag != 'include'
name = content.to_a.flatten.select {|s| String === s }.join
raise ArgumentError, 'Invalid include statement' unless attributes == [:html, :attrs] && !name.empty?
unless file = find_file(name)
- 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"