123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::Cop::VariableForce::Branch Private

Relationships & Source Files
Namespace Children
Modules:
Classes:
Defined in: lib/rubocop/cop/variable_force/branch.rb

Overview

Namespace for branch classes for each control structure.

Constant Summary

Class Method Summary

Class Method Details

.of(target_node, scope: nil)

[ GitHub ]

  
# File 'lib/rubocop/cop/variable_force/branch.rb', line 8

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]
    next unless klass

    branch = klass.new(node, scope)
    return branch if branch.branched?
  end

  nil
end