Class: ThemeCheck::LiquidCheck

Inherits:
Check
  • Object
show all
Extended by:
ChecksTracking
Includes:
ParsingHelpers
Defined in:
lib/theme_check/liquid_check.rb

Constant Summary collapse

TAG =
/#{Liquid::TagStart}.*?#{Liquid::TagEnd}/om
VARIABLE =
/#{Liquid::VariableStart}.*?#{Liquid::VariableEnd}/om
START_OR_END_QUOTE =
/(^['"])|(['"]$)/
QUOTED_LIQUID_ATTRIBUTE =
%r{
  '(?:#{TAG}|#{VARIABLE}|[^'])*'| # any combination of tag/variable or non straight quote inside straight quotes
  "(?:#{TAG}|#{VARIABLE}|[^"])*"  # any combination of tag/variable or non double quotes inside double quotes
}omix
ATTR =
/[a-z0-9-]+/i
HTML_ATTRIBUTE =
/#{ATTR}(?:=#{QUOTED_LIQUID_ATTRIBUTE})?/omix
HTML_ATTRIBUTES =
/(?:#{HTML_ATTRIBUTE}|\s)*/omix

Constants inherited from Check

Check::CATEGORIES, Check::SEVERITIES

Instance Attribute Summary

Attributes inherited from Check

#offenses, #options, #theme

Instance Method Summary collapse

Methods included from ChecksTracking

inherited

Methods included from ParsingHelpers

#outside_of_strings

Methods inherited from Check

all, can_disable, #can_disable?, categories, #categories, category, #code_name, #doc, doc, docs_url, #ignore!, #ignored?, #severity, severity, #to_s, #unignore!

Methods included from JsonHelpers

#format_json_parse_error

Instance Method Details

#add_offense(message, node: nil, template: node&.template, markup: nil, line_number: nil, &block) ⇒ Object



20
21
22
# File 'lib/theme_check/liquid_check.rb', line 20

def add_offense(message, node: nil, template: node&.template, markup: nil, line_number: nil, &block)
  offenses << Offense.new(check: self, message: message, template: template, node: node, markup: markup, line_number: line_number, correction: block)
end