Sha256: 8ecd688b759f375e900e16d4edf837078ff26f7f02c9a9db9d19ee2b65d29310
Contents?: true
Size: 1.09 KB
Versions: 13
Compression:
Stored size: 1.09 KB
Contents
# encoding: utf-8 module RuboCop module Cop class VariableForce # This class represents each reference of a variable. class Reference include Locatable VARIABLE_REFERENCE_TYPES = ( [VARIABLE_REFERENCE_TYPE] + OPERATOR_ASSIGNMENT_TYPES + [ZERO_ARITY_SUPER_TYPE] ).freeze attr_reader :node, :scope def initialize(node, scope) unless VARIABLE_REFERENCE_TYPES.include?(node.type) fail ArgumentError, "Node type must be any of #{VARIABLE_REFERENCE_TYPES}, " \ "passed #{node.type}" end @node = node @scope = scope end # There's an implicit variable reference by the zero-arity `super`: # # def some_method(foo) # super # end # # In this case, the variable `foo` is not explicitly referenced, # but it can be considered used implicitly by the `super`. def explicit? @node.type != ZERO_ARITY_SUPER_TYPE end end end end end
Version data entries
13 entries across 13 versions & 2 rubygems