Class: ThemeCheck::MissingTemplate

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

Overview

Reports missing include/render/section template

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_include(node) ⇒ Object Also known as: on_render



10
11
12
13
14
15
16
17
# File 'lib/theme_check/checks/missing_template.rb', line 10

def on_include(node)
  template = node.value.template_name_expr
  if template.is_a?(String)
    unless theme["snippets/#{template}"]
      add_offense("'snippets/#{template}.liquid' is not found", node: node)
    end
  end
end

#on_section(node) ⇒ Object



20
21
22
23
24
25
# File 'lib/theme_check/checks/missing_template.rb', line 20

def on_section(node)
  template = node.value.section_name
  unless theme["sections/#{template}"]
    add_offense("'sections/#{template}.liquid' is not found", node: node)
  end
end