Showing 94 of 94 total issues
Method check_condition
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_condition(cond)
case cond.type
when :masgn
if @parser.version <= 23
diagnostic :error, :masgn_as_condition, nil, cond.loc.expression
Method append
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def append(action)
range = action.range
# Is this an insertion?
if range.empty?
Method analyse_hierarchy
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def analyse_hierarchy(action)
r = action.range
# left_index is the index of the first child that isn't completely to the left of action
left_index = bsearch_child_index { |child| child.range.end_pos > r.begin_pos }
# right_index is the index of the first child that is completely on the right of action
- 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 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process(initial_buffer)
buffer = initial_buffer
original_name = buffer.name
@rewriters.each do |rewriter_class|
Method begin_body
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def begin_body(compound_stmt, rescue_bodies=[],
else_t=nil, else_=nil,
ensure_t=nil, ensure_=nil)
if rescue_bodies.any?
if else_t
- 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 begin_body
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def begin_body(compound_stmt, rescue_bodies=[],
else_t=nil, else_=nil,
ensure_t=nil, ensure_=nil)
if rescue_bodies.any?
if else_t
Method dedent
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dedent(string)
original_encoding = string.encoding
# Prevent the following error when processing binary encoded source.
# "\xC0".split # => ArgumentError (invalid byte sequence in UTF-8)
lines = string.force_encoding(Encoding::BINARY).split("\\\n")
Method assignable
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def assignable(node)
case node.type
when :cvar
node.updated(:cvasgn)
Method recognize_encoding
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.recognize_encoding(string)
return if string.empty?
# extract the first two lines in an efficient way
string =~ /\A(.*)\n?(.*\n)?/
- 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_options
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def parse_options(options)
@option_parser.parse!(options)
# Slop has just removed recognized options from `options`.
@fragments << $stdin.read if options.delete('-')
- 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 eh_keyword_map
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def eh_keyword_map(compstmt_e, keyword_t, body_es,
else_t, else_e)
if compstmt_e.nil?
if keyword_t.nil?
begin_l = body_es.first.loc.expression
- 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
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def try(parser, ruby, file, show_ok: false)
try_ruby = lambda do |e|
Process.spawn(%{#{ruby} -c #{Shellwords.escape file}},
:err => '/dev/null', :out => '/dev/null')
_, status = Process.wait2
Method analyse_hierarchy
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def analyse_hierarchy(action)
r = action.range
# left_index is the index of the first child that isn't completely to the left of action
left_index = bsearch_child_index { |child| child.range.end_pos > r.begin_pos }
# right_index is the index of the first child that is completely on the right of action
Method process
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process(buffer)
ast = @parser.parse(buffer)
if @locate
LocationProcessor.new.process(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 initialize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(lexer, str_type, delimiter, str_s, heredoc_e = nil,
indent = false, dedent_body = false, label_allowed = false)
@lexer = lexer
@nesting = 1
Method initialize
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(lexer, str_type, delimiter, str_s, heredoc_e = nil,
indent = false, dedent_body = false, label_allowed = false)
Method def_singleton
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def def_singleton(def_t, definee, dot_t,
name_t, args,
body, end_t)
Method condition_map
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def condition_map(keyword_t, cond_e, begin_t, body_e, else_t, else_e, end_t)
Method condition
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def condition(cond_t, cond, then_t,
if_true, else_t, if_false, end_t)
Method for
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def for(for_t, iterator, in_t, iteratee,
do_t, body, end_t)