Sha256: 410b4c4ae3ee3807fb8fcfd1c5383066105a6265cf93ef1a30279797853cdab5

Contents?: true

Size: 725 Bytes

Versions: 25

Compression:

Stored size: 725 Bytes

Contents

# frozen_string_literal: true

module PlatformosCheck
  class ParseJsonFormat < LiquidCheck
    severity :style
    category :liquid
    doc docs_url(__FILE__)

    def initialize(start_level: 0, indent: '  ')
      @pretty_json_opts = {
        indent:,
        start_level:
      }
    end

    def on_parse_json(node)
      parse_json = node.inner_json
      return if parse_json.nil?

      pretty_parse_json = pretty_json(parse_json, **@pretty_json_opts)
      return unless pretty_parse_json != node.inner_markup

      add_offense(
        "JSON formatting could be improved",
        node:
      ) do |corrector|
        corrector.replace_inner_json(node, parse_json, **@pretty_json_opts)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
platformos-check-0.2.0 lib/platformos_check/checks/parse_json_format.rb
platformos-check-0.1.0 lib/platformos_check/checks/parse_json_format.rb
platformos-check-0.0.3 lib/platformos_check/checks/parse_json_format.rb
platformos-check-0.0.2 lib/platformos_check/checks/parse_json_format.rb
platformos-check-0.0.1 lib/platformos_check/checks/parse_json_format.rb