Sha256: b1ea015c49441b694752cb57ea74aca071cbae52e084e33526a76072b17dfde8

Contents?: true

Size: 1.02 KB

Versions: 25

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module PlatformosCheck
  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 on_inline_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 platformos-check-enable", node:)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
platformos-check-0.4.14 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.13 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.12 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.11 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.10 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.9 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.8 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.7 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.6 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.5 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.4 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.3 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.2 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.1 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.4.0 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.3.3 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.3.1 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.3.0 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.2.2 lib/platformos_check/checks/missing_enable_comment.rb
platformos-check-0.2.1 lib/platformos_check/checks/missing_enable_comment.rb