Sha256: 0715ee776fd3df9502ebd5e45151834f0ed0a3b84e4c2a46b0ae90bccecd99f6

Contents?: true

Size: 924 Bytes

Versions: 30

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  class MissingEnableComment < LiquidCheck
    severity :error
    doc docs_url(__FILE__)

    # Don't allow this check to be disabled with a comment,
    # as we need to be able to check for disabled checks.
    can_disable false

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

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

    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
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
theme-check-1.1.0 lib/theme_check/checks/missing_enable_comment.rb
theme-check-1.0.0 lib/theme_check/checks/missing_enable_comment.rb
theme-check-0.10.2 lib/theme_check/checks/missing_enable_comment.rb
theme-check-0.10.1 lib/theme_check/checks/missing_enable_comment.rb
theme-check-0.10.0 lib/theme_check/checks/missing_enable_comment.rb
theme-check-0.9.1 lib/theme_check/checks/missing_enable_comment.rb
theme-check-0.9.0 lib/theme_check/checks/missing_enable_comment.rb
theme-check-0.8.3 lib/theme_check/checks/missing_enable_comment.rb
theme-check-0.8.2 lib/theme_check/checks/missing_enable_comment.rb
theme-check-0.8.1 lib/theme_check/checks/missing_enable_comment.rb