Class: ThemeCheck::MissingEnableComment

Inherits:
LiquidCheck show all
Defined in:
lib/theme_check/checks/missing_enable_comment.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

#after_document(node) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/theme_check/checks/missing_enable_comment.rb', line 19

def after_document(node)
  checks_missing_end_index = @disabled_checks.checks_missing_end_index
  return if checks_missing_end_index.empty?

  message = if checks_missing_end_index.any? { |name| name == :all }
    "All checks were"
  else
    checks_missing_end_index.join(', ') + " " + (checks_missing_end_index.size == 1 ? "was" : "were")
  end

  add_offense("#{message} disabled but not re-enabled with theme-check-enable", node: node)
end

#on_comment(node) ⇒ Object



15
16
17
# File 'lib/theme_check/checks/missing_enable_comment.rb', line 15

def on_comment(node)
  @disabled_checks.update(node)
end

#on_document(_node) ⇒ Object



11
12
13
# File 'lib/theme_check/checks/missing_enable_comment.rb', line 11

def on_document(_node)
  @disabled_checks = DisabledChecks.new
end