Class: PlatformosCheck::ConvertIncludeToRender
- Inherits:
-
LiquidCheck
- Object
- Check
- LiquidCheck
- PlatformosCheck::ConvertIncludeToRender
- Defined in:
- lib/platformos_check/checks/convert_include_to_render.rb
Overview
Recommends replacing ‘include` for `render`
Constant Summary collapse
- RENDER_INCOMPATIBLE_TAGS =
%w[break include].freeze
Constants inherited from Check
PlatformosCheck::Check::CATEGORIES, PlatformosCheck::Check::SEVERITIES, PlatformosCheck::Check::SEVERITY_VALUES
Instance Attribute Summary
Attributes inherited from Check
#ignored_patterns, #offenses, #options, #platformos_app
Instance Method Summary collapse
-
#initialize ⇒ ConvertIncludeToRender
constructor
A new instance of ConvertIncludeToRender.
- #on_include(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 ⇒ ConvertIncludeToRender
Returns a new instance of ConvertIncludeToRender.
12 13 14 |
# File 'lib/platformos_check/checks/convert_include_to_render.rb', line 12 def initialize @processed_files = {} end |
Instance Method Details
#on_include(node) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/platformos_check/checks/convert_include_to_render.rb', line 16 def on_include(node) return if allowed_usecase?(node) add_offense("`include` is deprecated - convert it to `render`", node:) do |corrector| match = node.markup.match(/(?<include>include\s*)/) corrector.replace(node, node.markup.sub(match[:include], 'render '), node.start_index...node.end_index) end end |