Class: ThemeCheck::DeprecatedFilter

Inherits:
LiquidCheck show all
Defined in:
lib/theme_check/checks/deprecated_filter.rb

Constant Summary

Constants inherited from Check

Check::CATEGORIES, Check::SEVERITIES, Check::SEVERITY_VALUES

Instance Attribute Summary

Attributes inherited from Check

#ignored_patterns, #offenses, #options, #theme

Instance Method Summary collapse

Methods included from ChecksTracking

#inherited

Methods included from ParsingHelpers

#outside_of_strings

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_theme?

Methods included from JsonHelpers

#format_json_parse_error

Instance Method Details

#on_variable(node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/theme_check/checks/deprecated_filter.rb', line 8

def on_variable(node)
  used_filters = node.value.filters.map { |name, *_rest| name }
  used_filters.each do |filter|
    alternatives = ShopifyLiquid::DeprecatedFilter.alternatives(filter)
    next unless alternatives

    alternatives = alternatives.map { |alt| "`#{alt}`" }
    add_offense(
      "Deprecated filter `#{filter}`, consider using an alternative: #{alternatives.join(', ')}",
      node: node,
    )
  end
end