Showing 672 of 672 total issues
Method correction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def correction(node)
if offense_array_node?(node)
'[]'
elsif str_node(node)
preferred_string_literal
- 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_block
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
return unless node.lambda_or_proc?
return unless nil_return?(node.body)
message = format(MSG, type: node.lambda? ? 'lambda' : 'proc')
- 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 return_value_used?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def return_value_used?(node)
return false unless node.parent
# If there are parentheses around the block, check if that
# is being used.
- 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 token_after_last_string
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def token_after_last_string(successor, base_index)
index = base_index + 3
if successor.type == COMPLEX_STRING_BEGIN_TOKEN
ends_to_find = 1
while ends_to_find.positive?
- 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_or
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def on_or(node)
root_of_or_node = root_of_or_node(node)
return unless node == root_of_or_node
return unless nested_variable_comparison?(root_of_or_node)
- 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 used_in_condition?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def used_in_condition?(node, condition)
if condition.send_type?
return true if condition.assignment_method? && partial_matched?(node, condition)
return false if !condition.comparison_method? && !condition.predicate_method?
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_hash
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def on_hash(node)
pairs = node.pairs
return if pairs.empty?
- 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_send
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def on_send(node)
return unless (receiver = node.receiver)
return unless (regexp = exact_regexp_match(node))
parsed_regexp = Regexp::Parser.parse(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 find_macros
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_macros(class_def)
# Find all the macros (`attr_reader`, `attr_writer`, etc.) in the class body
# and turn them into `Macro` objects so that they can be processed.
return {} if !class_def || class_def.def_type?
- 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 expand_elsif
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def expand_elsif(node, elsif_branches = [])
return [] if node.nil? || !node.if_type? || !node.elsif?
elsif_branches << node.if_branch
- 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 find_def_node_from_ascendant
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_def_node_from_ascendant(node)
return unless (parent = node.parent)
return parent if parent.def_type? || parent.defs_type?
return node.parent.child_nodes.first if define_method?(parent)
- 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 collect_parts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def collect_parts(node, parts = [])
return unless node
if plus_node?(node)
collect_parts(node.receiver, parts)
- 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 acceptable_19_syntax_symbol?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def acceptable_19_syntax_symbol?(sym_name)
sym_name.delete_prefix!(':')
if cop_config['PreferHashRocketsForNonAlnumEndingSymbols'] &&
# Prefer { :production? => false } over { production?: false } and
- 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 find_parent_not_enumerable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_parent_not_enumerable(node)
return unless (parent = node.parent)
if parent.pair_type? || parent.hash_type? || parent.array_type?
find_parent_not_enumerable(parent)
- 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 scope_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def scope_type(node)
while (parent = node.parent)
case parent.type
when :class, :module
return :lexical
- 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_array
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def on_array(node)
if bracketed_array_of?(:str, node)
return if complex_content?(node.values)
return if within_matrix_of_complex_content?(node)
- 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_dstr
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def on_dstr(node)
return unless single_interpolation?(node)
add_offense(node) do |corrector|
embedded_node = node.children.first
- 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 argument_with_operator?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def argument_with_operator?(argument)
return true if ARGUMENT_WITH_OPERATOR_TYPES.include?(argument.type)
return false unless argument.hash_type?
return false unless (node = argument.children.first)
- 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_if
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def on_if(node)
return unless node.modifier_form? && node.body.if_type?
add_offense(node.loc.keyword, message: format(MSG, keyword: node.keyword)) do |corrector|
keyword = node.if? ? 'if' : 'unless'
- 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 comments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def comments
processed_source.lines.each.with_index.with_object({}) do |(line, line_number), comments|
next if line.start_with?(SHEBANG)
comment = MagicComment.parse(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"