Class: PlatformosCheck::IncludeInRender
- Inherits:
-
LiquidCheck
- Object
- Check
- LiquidCheck
- PlatformosCheck::IncludeInRender
- Defined in:
- lib/platformos_check/checks/include_in_render.rb
Overview
Recommends replacing ‘include` for `render`
Constant Summary
Constants inherited from Check
Check::CATEGORIES, Check::SEVERITIES, Check::SEVERITY_VALUES
Instance Attribute Summary
Attributes inherited from Check
#ignored_patterns, #offenses, #options, #platformos_app
Instance Method Summary collapse
-
#initialize ⇒ IncludeInRender
constructor
A new instance of IncludeInRender.
- #on_render(node) ⇒ Object
Methods included from ChecksTracking
Methods included from ParsingHelpers
Methods inherited from Check
#==, #add_offense, all, can_disable, #can_disable?, categories, #categories, category, #code_name, doc, #doc, docs_url, #ignore!, #ignored?, #severity, severity, #severity=, #severity_value, severity_value, single_file, #single_file?, #to_s, #whole_platformos_app?
Methods included from JsonHelpers
#format_json_parse_error, #pretty_json
Constructor Details
#initialize ⇒ IncludeInRender
Returns a new instance of IncludeInRender.
10 11 12 |
# File 'lib/platformos_check/checks/include_in_render.rb', line 10 def initialize @processed_files = {} end |
Instance Method Details
#on_render(node) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/platformos_check/checks/include_in_render.rb', line 14 def on_render(node) path = node.value.template_name_expr return unless include_tag_in_render?(root_node_for_render(path)) add_offense("`render` context does not allow to use `include`, either remove all includes from `#{app_file_for_path(path).relative_path}` or change `render` to `include`", node:) end |