Showing 644 of 684 total issues
Method on_send
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_send(node)
return unless if_node_child?(node)
return if explicit_not_force?(node)
return unless (exist_node = send_exist_node(node.parent).first)
return unless exist_node.first_argument == node.first_argument
- 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 check_case
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_case(node)
else_branch = node.else_branch
return false unless else_branch
return false unless break_statement?(else_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 populate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def populate(expr)
expressions = expr.expressions.to_a
until expressions.empty?
current = expressions.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 find_offense_node_by
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def find_offense_node_by(diagnostic)
ast = processed_source.ast
ast.each_node(:splat, :block_pass, :kwsplat) do |node|
next unless offense_position?(node, diagnostic)
- 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 allow_receiver?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def allow_receiver?(receiver)
if receiver.numeric_type? || (receiver.send_type? &&
(conversion_method?(receiver.method_name) ||
allowed_method_name?(receiver.method_name)))
true
- 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 check_send
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_send(node)
if node.arithmetic_operation?
lhs, _operation, rhs = *node
float?(lhs) || float?(rhs)
elsif FLOAT_RETURNING_METHODS.include?(node.method_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"
Further reading
Method on_block
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_block(node)
return unless node.lambda?
selector = node.send_node.source
- 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 check_case
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_case(node)
else_branch = node.else_branch
return false unless else_branch
return false unless flow_expression?(else_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 on_send
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_send(node)
return if node.parenthesized?
return unless (parent = node.parent)
return unless operator?(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 calls_on_multiple_lines?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def calls_on_multiple_lines?(node, _heredoc)
last_line = node.last_line
while send_node?(node)
return true unless last_line == node.last_line
return true unless all_on_same_line?(node.arguments)
- 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 mergeable?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def mergeable?(node)
return true unless node.call_type?
return false unless MERGE_METHODS.include?(node.method_name)
return true unless (parent = node.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 on_case_match
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_case_match(node)
node.in_pattern_branches.each do |branch|
next if branch.body
next if cop_config['AllowComments'] && contains_comments?(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 returned_accumulator_index
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def returned_accumulator_index(return_values, accumulator_name, element_name)
return_values.detect do |val|
next unless accumulator_index?(val, accumulator_name)
next true if val.method?(:[]=)
- 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_case
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_case(case_node)
if case_node.condition
check_case(case_node)
else
case_node.when_branches.each do |when_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 replacement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def replacement(regexp_node)
regexp_content = regexp_node.content
stack = []
chars = regexp_content.chars.each_with_object([]) do |char, strings|
if stack.empty? && char == '\\'
- 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 empty_if_branch?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def empty_if_branch?(node)
return false unless (parent = node.parent)
return true unless parent.if_type?
return true unless (if_branch = parent.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 on_str
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_str(node)
return if node.parent&.regexp_type?
return unless /(?<!\\)#\{.*\}/.match?(node.source)
return if heredoc?(node)
return unless node.loc.begin && node.loc.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 handle_as_symbol
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def handle_as_symbol(node)
to_method_symbol(node) do |receiver, sym_node, to_method|
next if receiver.nil? || !node.arguments.one?
message = format(
- 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 inside_class_with_stateful_parent?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def inside_class_with_stateful_parent?(node)
if (block_node = node.each_ancestor(:block, :numblock).first)
return false unless (super_class = class_new_block(block_node))
!allowed_class?(super_class)
- 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_branching_statement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_branching_statement(node)
branches(node).each_with_object(Set.new) do |branch, previous|
next unless consider_branch?(branch)
add_offense(offense_range(branch)) unless previous.add?(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"