Class: PlatformosCheck::RequiredLayoutObject

Inherits:
LiquidCheck show all
Defined in:
lib/platformos_check/checks/required_layout_object.rb

Overview

Reports missing content_for_layout in layouts

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

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

Methods included from JsonHelpers

#format_json_parse_error, #pretty_json

Constructor Details

#initializeRequiredLayoutObject

Returns a new instance of RequiredLayoutObject.



10
11
12
# File 'lib/platformos_check/checks/required_layout_object.rb', line 10

def initialize
  @content_for_layout_found = false
end

Instance Method Details

#after_document(node) ⇒ Object



24
25
26
27
28
# File 'lib/platformos_check/checks/required_layout_object.rb', line 24

def after_document(node)
  return unless node.app_file.layout?

  add_missing_object_offense("content_for_layout", "</body>") unless @content_for_layout_found
end

#on_document(node) ⇒ Object



14
15
16
# File 'lib/platformos_check/checks/required_layout_object.rb', line 14

def on_document(node)
  @layout_platformos_app_node = node if node.app_file.layout?
end

#on_variable(node) ⇒ Object



18
19
20
21
22
# File 'lib/platformos_check/checks/required_layout_object.rb', line 18

def on_variable(node)
  return unless node.value.name.is_a?(Liquid::VariableLookup)

  @content_for_layout_found ||= node.value.name.name == "content_for_layout"
end