Class: ThemeCheck::SchemaJsonFormat
- Inherits:
-
LiquidCheck
- Object
- Check
- LiquidCheck
- ThemeCheck::SchemaJsonFormat
- Defined in:
- lib/theme_check/checks/schema_json_format.rb
Constant Summary
Constants inherited from Check
Check::CATEGORIES, Check::SEVERITIES, Check::SEVERITY_VALUES
Instance Attribute Summary
Attributes inherited from Check
#ignored_patterns, #offenses, #options, #theme
Instance Method Summary collapse
-
#initialize(start_level: 0, indent: ' ') ⇒ SchemaJsonFormat
constructor
A new instance of SchemaJsonFormat.
- #on_schema(node) ⇒ Object
Methods included from ChecksTracking
Methods included from ParsingHelpers
Methods inherited from Check
#==, #add_offense, all, can_disable, #can_disable?, categories, #categories, category, #code_name, doc, #doc, docs_url, #ignore!, #ignored?, #severity, severity, #severity=, #severity_value, severity_value, single_file, #single_file?, #to_s, #whole_theme?
Methods included from JsonHelpers
#format_json_parse_error, #pretty_json
Constructor Details
#initialize(start_level: 0, indent: ' ') ⇒ SchemaJsonFormat
Returns a new instance of SchemaJsonFormat.
8 9 10 11 12 13 |
# File 'lib/theme_check/checks/schema_json_format.rb', line 8 def initialize(start_level: 0, indent: ' ') @pretty_json_opts = { indent: indent, start_level: start_level, } end |
Instance Method Details
#on_schema(node) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/theme_check/checks/schema_json_format.rb', line 15 def on_schema(node) schema = node.inner_json return if schema.nil? pretty_schema = pretty_json(schema, **@pretty_json_opts) if pretty_schema != node.inner_markup add_offense( "JSON formatting could be improved", node: node, ) do |corrector| corrector.replace_inner_json(node, schema, **@pretty_json_opts) end end end |