Class: RubyLint::Analysis::UndefinedVariables
- Defined in:
- lib/ruby-lint/analysis/undefined_variables.rb
Overview
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 UndefinedMethods instead.
Constant Summary
- VARIABLE_TYPES =
Hash containing the various variable types to add errors for whenever they are used but not defined.
{ :gvar => 'global variable', :ivar => 'instance variable', :cvar => 'class variable' }
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Attributes inherited from Iterator
#arity_cache, #arity_cache Hash containing the amount of arguments for
Instance Method Summary collapse
-
#on_const(node) ⇒ Object
Handles regular constants as well as constant paths.
Methods inherited from Base
#add_message, #after_initialize, analyze?, #current_scope, #error, #info, #previous_scope, register, #set_current_scope, #set_previous_scope, #warning
Methods included from MethodEvaluation
Methods inherited from Iterator
#execute_callback, #initialize, #iterate, #skip_child_nodes!
Constructor Details
This class inherits a constructor from RubyLint::Iterator
Instance Method Details
#on_const(node) ⇒ Object
Handles regular constants as well as constant paths.
40 41 42 43 44 45 46 |
# 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 |