lib/rubocop/cop/variable_force.rb
Class VariableForce
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class VariableForce < Force # rubocop:disable Metrics/ClassLength
VARIABLE_ASSIGNMENT_TYPE = :lvasgn
REGEXP_NAMED_CAPTURE_TYPE = :match_with_lvasgn
VARIABLE_ASSIGNMENT_TYPES = [VARIABLE_ASSIGNMENT_TYPE, REGEXP_NAMED_CAPTURE_TYPE].freeze
Method mark_assignments_as_referenced_in_loop
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def mark_assignments_as_referenced_in_loop(node)
referenced_variable_names_in_loop, assignment_nodes_in_loop = find_variables_in_loop(node)
referenced_variable_names_in_loop.each do |name|
variable = variable_table.find_variable(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 process_variable_operator_assignment
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def process_variable_operator_assignment(node)
if LOGICAL_OPERATOR_ASSIGNMENT_TYPES.include?(node.type)
asgn_node, rhs_node = *node
else
asgn_node, _operator, rhs_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"