Sha256: 801105c8d0c3b7a662970ee05a7d6f9a53620f642bc9fdf806b933d3b08bb21f

Contents?: true

Size: 856 Bytes

Versions: 23

Compression:

Stored size: 856 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.value.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

23 entries across 23 versions & 1 rubygems

Version Path
theme-check-1.9.2 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.9.1 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.9.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.8.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.7.2 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.7.1 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.7.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.6.2 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.6.1 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.6.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.5.2 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.5.1 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.5.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.4.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.3.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.2.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.1.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-1.0.0 lib/theme_check/checks/content_for_header_modification.rb
theme-check-0.10.2 lib/theme_check/checks/content_for_header_modification.rb
theme-check-0.10.1 lib/theme_check/checks/content_for_header_modification.rb