Showing 270 of 302 total issues
Class RedundantParentheses
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class RedundantParentheses < Cop
include Parentheses
ALLOWED_LITERALS = %i[irange erange].freeze
File variable_force.rb
has 264 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RubbyCop
module Cop
# This force provides a way to track local variables and scopes of Ruby.
# Cops interact with this force need to override some of the hook methods.
#
Class LineLength
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class LineLength < Cop
include ConfigurableMax
include IgnoredPattern
MSG = 'Line is too long. [%d/%d]'.freeze
Class VariableForce
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class VariableForce
# Namespace for branch classes for each control structure.
module Branch
def self.of(target_node, scope: nil)
([target_node] + target_node.ancestors).each do |node|
Method base_configs
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def base_configs(path, inherit_from)
configs = Array(inherit_from).compact.map do |f|
if f =~ /\A#{URI::Parser.new.make_regexp(%w[http https])}\z/
f = RemoteConfig.new(f, File.dirname(path)).file
else
- 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_redundant_merge
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def each_redundant_merge(node)
redundant_merge(node) do |receiver, pairs|
next unless receiver
next if node.value_used? &&
!EachWithObjectInspector.new(node, receiver).value_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 each_bad_cons
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def each_bad_cons(node)
node.children.each_cons(2) do |child1, child2|
# `'abc' 'def'` -> (dstr (str "abc") (str "def"))
next unless string_literal?(child1) && string_literal?(child2)
next unless child1.loc.last_line == child2.loc.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 on_return
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def on_return(return_node)
return if return_value?(return_node)
return_node.each_ancestor(:block, :def, :defs) do |node|
break if scoped_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 block_end_align_target
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def block_end_align_target(node)
while (parent = node.parent)
break if !parent || !parent.loc
break if parent.loc.line != node.loc.line && !parent.masgn_type?
break unless block_end_align_target?(parent, 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 find_class_or_module
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def find_class_or_module(node, namespace)
return nil if node.nil?
name = namespace.pop
on_node(%i[class module casgn], node) do |child|
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
def on_send(node)
TARGET_METHODS.each do |target_class, target_method|
target_receiver = s(:const, nil, target_class)
next if node.receiver != target_receiver
- 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 investigate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def investigate(processed_source)
last_token = processed_source.tokens.last
last_line =
last_token ? last_token.pos.line : processed_source.lines.length
- 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 reference!
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def reference!(node)
reference = Reference.new(node, @scope)
@references << reference
consumed_branches = Set.new
- 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 offense?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def offense?(node)
condition = node.condition
if safe_assignment?(condition)
!safe_assignment_allowed?
- 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_extraneous_space
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def each_extraneous_space(tokens)
brackets = Brackets.new(*specifics)
tokens.each_cons(2) do |t1, t2|
next unless matching_brackets?(brackets, t1, t2)
- 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_missing_space
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def each_missing_space(tokens)
tokens.each_cons(2) do |t1, t2|
next unless kind(t1)
next unless space_missing?(t1, t2)
next unless space_required_before?(t2)
- 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 investigate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def investigate(processed_source)
processed_source.comments.each_with_index do |comment, ix|
next unless first_comment_line?(processed_source.comments, ix)
margin, first_word, colon, space, note = split_comment(comment)
- 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_nesting_level
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def check_nesting_level(node, max, current_level)
if consider_node?(node)
current_level += 1 unless node.if_type? && node.elsif?
if current_level > max
self.max = current_level
- 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 investigate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def investigate(processed_source)
processed_source.comments.each do |comment|
next unless comment.text =~ /\A#+[^#\s=:+-]/
next if comment.text.start_with?('#!') && comment.loc.line == 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 of
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.of(target_node, scope: nil)
([target_node] + target_node.ancestors).each do |node|
return nil unless node.parent
return nil unless scope.include?(node)
klass = CLASSES_BY_TYPE[node.parent.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"