Sha256: 94b27f75750c179fecd1ec9ecd68decaae5f6db02b8afabcdbc9f1babcdec8cd

Contents?: true

Size: 768 Bytes

Versions: 25

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  # Report Liquid syntax errors
  class SyntaxError < LiquidCheck
    severity :error
    category :liquid
    doc docs_url(__FILE__)

    def on_document(node)
      node.template.warnings.each do |warning|
        add_exception_as_offense(warning, template: node.template)
      end
    end

    def on_error(exception)
      add_exception_as_offense(exception, template: theme[exception.template_name])
    end

    private

    def add_exception_as_offense(exception, template:)
      add_offense(
        exception.to_s(false).sub(/ in ".*"$/, ''),
        line_number: exception.line_number,
        markup: exception.markup_context&.sub(/^in "(.*)"$/, '\1'),
        template: template,
      )
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
theme-check-1.6.1 lib/theme_check/checks/syntax_error.rb
theme-check-1.6.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.5.2 lib/theme_check/checks/syntax_error.rb
theme-check-1.5.1 lib/theme_check/checks/syntax_error.rb
theme-check-1.5.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.4.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.3.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.2.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.1.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.0.0 lib/theme_check/checks/syntax_error.rb
theme-check-0.10.2 lib/theme_check/checks/syntax_error.rb
theme-check-0.10.1 lib/theme_check/checks/syntax_error.rb
theme-check-0.10.0 lib/theme_check/checks/syntax_error.rb
theme-check-0.9.1 lib/theme_check/checks/syntax_error.rb
theme-check-0.9.0 lib/theme_check/checks/syntax_error.rb
theme-check-0.8.3 lib/theme_check/checks/syntax_error.rb
theme-check-0.8.2 lib/theme_check/checks/syntax_error.rb
theme-check-0.8.1 lib/theme_check/checks/syntax_error.rb
theme-check-0.8.0 lib/theme_check/checks/syntax_error.rb
theme-check-0.7.3 lib/theme_check/checks/syntax_error.rb