Showing 644 of 684 total issues
Method on_sym
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_sym(node)
return unless quoted?(node)
message = style == :single_quotes ? MSG_SINGLE : MSG_DOUBLE
- 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 preferred_send_condition
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def preferred_send_condition(node) # rubocop:disable Metrics/CyclomaticComplexity
receiver_source = node.receiver&.source
return receiver_source if node.method?(:!)
# receiver may be implicit (self)
- 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_heredoc
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_heredoc(node)
body = heredoc_body(node)
return if body.strip.empty?
body_indent_level = indent_level(body)
- 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)
node.send_node.each_node(:send, :csend) do |send_node|
receiver = send_node.receiver
next unless (receiver&.block_type? || receiver&.numblock_type?) && receiver&.multiline?
- 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 duplicated_expressions?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def duplicated_expressions?(node, expressions)
unique_expressions = expressions.uniq
return false unless expressions.size >= 1 && unique_expressions.one?
unique_expression = unique_expressions.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 private_constant?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def private_constant?(node)
return false unless node.casgn_type? && node.namespace.nil?
return false unless (parent = node.parent)
parent.each_child_node(:send) do |child_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 alignment_node
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def alignment_node(node)
ancestor_node = ancestor_node(node)
return ancestor_node if ancestor_node.nil? || ancestor_node.kwbegin_type?
return if ancestor_node.respond_to?(:send_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 check_assignment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_assignment(node, rhs)
return if node.send_type? && node.loc.operator&.source != '='
return unless rhs
return unless supported_types.include?(rhs.type)
return if rhs.single_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 each_top_level_descendant
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def each_top_level_descendant(node, types, &block)
node.each_child_node do |child|
next if classlike_node?(child)
if types.include?(child.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 source_from_node_with_heredoc
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def source_from_node_with_heredoc(node)
last_line = -1
node.each_descendant do |descendant|
next unless descendant.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 belong_to_outer_scope?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def belong_to_outer_scope?(target_node)
return true if !naked_top_level? && target_node.equal?(node)
return true if ancestor_node?(target_node)
return false unless target_node.parent.equal?(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 wanted_dir_patterns
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def wanted_dir_patterns(base_dir, exclude_pattern, flags)
# Escape glob characters in base_dir to avoid unwanted behavior.
base_dir = base_dir.gsub(/[\\\{\}\[\]\*\?]/) do |reserved_glob_character|
"\\#{reserved_glob_character}"
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 ruby_executable?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def ruby_executable?(file)
return false unless File.extname(file).empty? && File.exist?(file)
first_line = File.open(file, &:readline)
/#!.*(#{ruby_interpreters(file).join('|')})/.match?(first_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 run_hook
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def run_hook(method_name, *args)
cops.each do |cop|
next unless cop.respond_to?(method_name)
cop.public_send(method_name, *args)
- 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
Avoid too many return
statements within this method. Open
return if last_expression?(dispatch_node) && !method_dispatch_as_argument?(dispatch_node)
Avoid too many return
statements within this method. Open
return if dispatch_node.parent && parentheses?(dispatch_node.parent)
Avoid too many return
statements within this method. Open
return true if should_merge?(base_mode, key)
Avoid too many return
statements within this method. Open
return if !node.braces? || allowed_double_splat_receiver?(kwsplat)
Avoid too many return
statements within this method. Open
return false if /^-?0.0/.match?(mantissa)
Avoid too many return
statements within this method. Open
return unless (kwsplat = node.each_ancestor(:kwsplat).first)