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

Instance Attribute Summary

Attributes inherited from Check

#offenses, #options, #theme

Instance Method Summary collapse

Methods inherited from LiquidCheck

#add_offense

Methods included from ChecksTracking

#inherited

Methods included from ParsingHelpers

#outside_of_strings

Methods inherited from Check

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

Methods included from JsonHelpers

#format_json_parse_error

Instance Method Details

#after_document(node) ⇒ Object



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

def after_document(node)
  return if @disabled_checks.full_document_disabled?
  return unless @disabled_checks.any?

  message = if @disabled_checks.all_disabled?
    "All checks were"
  else
    @disabled_checks.all.join(', ') + " " + (@disabled_checks.all.size == 1 ? "was" : "were")
  end

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

#on_comment(node) ⇒ Object



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

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

#on_document(_node) ⇒ Object



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

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