Class: HamlLint::Linter::InstanceVariables
- Inherits:
-
HamlLint::Linter
- Object
- HamlLint::Linter
- HamlLint::Linter::InstanceVariables
- Includes:
- HamlLint::LinterRegistry
- Defined in:
- lib/haml_lint/linter/instance_variables.rb
Overview
Checks for the presence of instance variables
Instance Attribute Summary
Attributes inherited from HamlLint::Linter
Instance Method Summary collapse
-
#visit_root(node) ⇒ true, false
Enables the linter if the tree is for the right file type.
-
#visit_script(node) ⇒ void
(also: #visit_silent_script)
Checks for instance variables in script nodes when the linter is enabled.
-
#visit_tag(node) ⇒ void
Checks for instance variables in tag nodes when the linter is enabled.
Methods included from HamlLint::LinterRegistry
extract_linters_from, included
Methods inherited from HamlLint::Linter
#initialize, #name, #run, #run_or_raise, supports_autocorrect?, #supports_autocorrect?
Methods included from HamlVisitor
Constructor Details
This class inherits a constructor from HamlLint::Linter
Instance Method Details
#visit_root(node) ⇒ true, false
Enables the linter if the tree is for the right file type.
12 13 14 |
# File 'lib/haml_lint/linter/instance_variables.rb', line 12 def visit_root(node) @enabled = matcher.match(File.basename(node.file)) ? true : false end |
#visit_script(node) ⇒ void Also known as: visit_silent_script
This method returns an undefined value.
Checks for instance variables in script nodes when the linter is enabled.
20 21 22 23 24 25 26 |
# File 'lib/haml_lint/linter/instance_variables.rb', line 20 def visit_script(node) return unless enabled? if node.parsed_script.contains_instance_variables? record_lint(node, "Avoid using instance variables in #{file_types} views") end end |
#visit_tag(node) ⇒ void
This method returns an undefined value.
Checks for instance variables in tag nodes when the linter is enabled.
39 40 41 42 43 44 45 46 |
# File 'lib/haml_lint/linter/instance_variables.rb', line 39 def visit_tag(node) return unless enabled? visit_script(node) || if node.parsed_attributes.contains_instance_variables? record_lint(node, "Avoid using instance variables in #{file_types} views") end end |