Sha256: ad473fd5238204adb492b87f2c5f075adcddb2f553ac290ed709c6667b597cb1

Contents?: true

Size: 850 Bytes

Versions: 10

Compression:

Stored size: 850 Bytes

Contents

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

    def initialize
      @in_assign = false
      @in_capture = false
    end

    def on_variable(node)
      return unless node.value.name.is_a?(Liquid::VariableLookup)
      return unless node.value.name.name == "content_for_header"

      if @in_assign || @in_capture || node.filters.any?
        add_offense(
          "Do not rely on the content of `content_for_header`",
          node: node,
        )
      end
    end

    def on_assign(_node)
      @in_assign = true
    end

    def after_assign(_node)
      @in_assign = false
    end

    def on_capture(_node)
      @in_capture = true
    end

    def after_capture(_node)
      @in_capture = false
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
theme-check-1.15.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.14.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.13.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.12.1 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.12.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.11.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.10.3 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.10.2 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.10.1 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.10.0 lib/theme_check/checks/content_for_header_modification.rb