Class: Simplabs::Excellent::Checks::Rails::InstanceVarInPartialCheck
- Defined in:
- lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
Overview
This check reports partials that use instance variables. Using instance variables in partials couples the partial to the controller action or template that includes the partial and that has to define the instance variable.
Applies to
-
partials
Instance Attribute Summary
Attributes inherited from Base
#interesting_files, #interesting_nodes, #warnings
Instance Method Summary collapse
-
#evaluate(context) ⇒ Object
:nodoc:.
-
#initialize ⇒ InstanceVarInPartialCheck
constructor
:nodoc:.
Methods inherited from Base
#add_warning, #evaluate_node, #warnings_for
Constructor Details
#initialize ⇒ InstanceVarInPartialCheck
:nodoc:
19 20 21 22 23 |
# File 'lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb', line 19 def initialize #:nodoc: super @interesting_nodes = [:ivar] @interesting_files = [/^_.*\.erb$/] end |
Instance Method Details
#evaluate(context) ⇒ Object
:nodoc:
25 26 27 |
# File 'lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb', line 25 def evaluate(context) #:nodoc: add_warning(context, 'Instance variable {{variable}} used in partial.', { :variable => context.full_name }) end |