class RubyLint::Analysis::UndefinedVariables
The UndefinedVariables
class checks for the use of undefined variables (such as instance variables and constants). The order of definition and use of a variable does not matter.
This analysis class does not check for undefined local variables. Ruby treats these as method calls and as result they are handled by {RubyLint::Analysis::UndefinedMethods} instead.
Constants
- VARIABLE_TYPES
Hash containing the various variable types to add errors for whenever they are used but not defined.
@return [Hash]
Public Instance Methods
on_const(node)
click to toggle source
Handles regular constants as well as constant paths.
@param [RubyLint::AST::Node] node
# File lib/ruby-lint/analysis/undefined_variables.rb, line 40 def on_const(node) path = ConstantPath.new(node) variable = path.resolve(current_scope) name = path.to_s error("undefined constant #{name}", node) unless variable end