bbatsov/rubocop

View on GitHub
lib/rubocop/cop/variable_force.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class VariableForce has 28 methods (exceeds 20 allowed). Consider refactoring.
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

Severity: Minor
Found in lib/rubocop/cop/variable_force.rb - About 3 hrs to fix

    Method mark_assignments_as_referenced_in_loop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    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)
    Severity: Minor
    Found in lib/rubocop/cop/variable_force.rb - About 45 mins to fix

    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

          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
    Severity: Minor
    Found in lib/rubocop/cop/variable_force.rb - About 25 mins to fix

    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

    There are no issues that match your filters.

    Category
    Status