Showing 687 of 687 total issues
Method on_if
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_if(node)
return if node.body || same_line?(node.loc.begin, node.loc.end)
return if cop_config['AllowComments'] && contains_comments?(node)
range = offense_range(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_if
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_if(node)
return unless offense?(node)
message = enforce_single_line_ternary_operator?(node) ? MSG_SINGLE_LINE : MSG_IF
- 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 complex_content?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def complex_content?(strings, complex_regex: word_regex)
strings.any? do |s|
next unless s.str_content
string = s.str_content.dup.force_encoding(::Encoding::UTF_8)
- 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 implements_respond_to_missing?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def implements_respond_to_missing?(node)
return false unless (grand_parent = node.parent.parent)
grand_parent.each_descendant(node.type) do |descendant|
return true if descendant.method?(:respond_to_missing?)
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def on_if(node)
condition = node.condition
return if defined_nodes(condition).any? { |n| defined_argument_is_undefined?(node, n) } ||
pattern_matching_nodes(condition).any?
return unless (msg = message(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 same_line?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def same_line?(node, line)
return false unless (source_range = node.source_range)
if node.is_a?(AST::StrNode)
if node.heredoc?
- 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 replace_braces_with_do_end
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def replace_braces_with_do_end(corrector, loc)
b = loc.begin
e = loc.end
corrector.insert_before(b, ' ') unless whitespace_before?(b)
- 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 unless node.command?(:alias_method)
return unless style == :prefer_alias && alias_keyword_possible?(node)
return unless node.arguments.count == 2
- 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 too_long_single_line?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def too_long_single_line?(node)
return false unless max_line_length
range = node.source_range
return false unless range.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 check
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check(node)
return if node.heredoc?
return unless node.loc.respond_to?(:begin)
return unless node.loc.begin
- 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) # rubocop:disable InternalAffairs/NumblockHandler
return unless node.single_line?
return unless eligible_method?(node)
return unless eligible_arguments?(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 semicolon_position
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def semicolon_position(tokens)
if tokens.last.semicolon?
-1
elsif tokens.first.semicolon?
0
- 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
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check(send_node)
return if previous_line_comment?(send_node) || !groupable_accessor?(send_node)
return unless (grouped_style? && groupable_sibling_accessors(send_node).size > 1) ||
(separated_style? && send_node.arguments.size > 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 check_assignment_to_condition
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_assignment_to_condition(node)
return unless candidate_node?(node)
ignore_node(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 parenthesized_it_method_in_block?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parenthesized_it_method_in_block?(node)
return false unless node.method?(:it)
return false unless (block_node = node.each_ancestor(:block).first)
return false unless block_node.arguments.empty_and_without_delimiters?
- 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 it_method_in_block?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def it_method_in_block?(node)
return false unless node.method?(:it)
return false unless (block_node = node.each_ancestor(:block).first)
return false unless block_node.arguments.empty_and_without_delimiters?
- 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
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check(node)
return unless start_with_percent_q_variant?(node)
return if interpolated_quotes?(node) || allowed_percent_q?(node)
add_offense(node) do |corrector|
- 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 offending_node?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def offending_node?(node, lhs_receiver, rhs, rhs_receiver) # rubocop:disable Metrics/CyclomaticComplexity
return false if lhs_receiver != rhs_receiver || rhs_receiver.nil?
return false if use_var_only_in_unless_modifier?(node, lhs_receiver)
return false if chain_length(rhs, rhs_receiver) > max_chain_length
return false if unsafe_method_used?(rhs, rhs_receiver.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_send
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_send(node)
return unless stabby_lambda_with_args?(node)
return unless redundant_parentheses?(node) || missing_parentheses?(node)
arguments = node.block_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 on_def
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_def(node)
return if forced_parentheses?(node)
args = 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"