Sha256: b46f76e980c1d343a1d13e58744349ec2d6307358f32ae85888d09efc97796bc

Contents?: true

Size: 782 Bytes

Versions: 18

Compression:

Stored size: 782 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.theme_file.warnings.each do |warning|
        add_exception_as_offense(warning, theme_file: node.theme_file)
      end
    end

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

    private

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
theme-check-1.15.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.14.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.13.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.12.1 lib/theme_check/checks/syntax_error.rb
theme-check-1.12.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.11.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.10.3 lib/theme_check/checks/syntax_error.rb
theme-check-1.10.2 lib/theme_check/checks/syntax_error.rb
theme-check-1.10.1 lib/theme_check/checks/syntax_error.rb
theme-check-1.10.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.9.2 lib/theme_check/checks/syntax_error.rb
theme-check-1.9.1 lib/theme_check/checks/syntax_error.rb
theme-check-1.9.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.8.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.7.2 lib/theme_check/checks/syntax_error.rb
theme-check-1.7.1 lib/theme_check/checks/syntax_error.rb
theme-check-1.7.0 lib/theme_check/checks/syntax_error.rb
theme-check-1.6.2 lib/theme_check/checks/syntax_error.rb