Sha256: 94945bd0f50d1602866237e4cb20100ffc98396211ff18c56d4188b942952735

Contents?: true

Size: 741 Bytes

Versions: 10

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  # Report Liquid syntax errors
  class SyntaxError < LiquidCheck
    severity :error
    category :liquid

    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

10 entries across 10 versions & 1 rubygems

Version Path
theme-check-0.4.0 lib/theme_check/checks/syntax_error.rb
theme-check-0.3.3 lib/theme_check/checks/syntax_error.rb
theme-check-0.3.2 lib/theme_check/checks/syntax_error.rb
theme-check-0.3.1 lib/theme_check/checks/syntax_error.rb
theme-check-0.3.0 lib/theme_check/checks/syntax_error.rb
theme-check-0.2.2 lib/theme_check/checks/syntax_error.rb
theme-check-0.2.0 lib/theme_check/checks/syntax_error.rb
theme-check-0.1.2 lib/theme_check/checks/syntax_error.rb
theme-check-0.1.1 lib/theme_check/checks/syntax_error.rb
theme-check-0.1.0 lib/theme_check/checks/syntax_error.rb