Class: ThemeCheck::TemplateLength
- Inherits:
-
LiquidCheck
- Object
- Check
- LiquidCheck
- ThemeCheck::TemplateLength
- Defined in:
- lib/theme_check/checks/template_length.rb
Constant Summary
Constants inherited from Check
Check::CATEGORIES, Check::SEVERITIES
Instance Attribute Summary
Attributes inherited from Check
Instance Method Summary collapse
-
#initialize(max_length: 200) ⇒ TemplateLength
constructor
A new instance of TemplateLength.
- #on_document(node) ⇒ Object
Methods inherited from LiquidCheck
Methods included from ChecksTracking
Methods included from ParsingHelpers
Methods inherited from Check
all, category, #category, #code_name, doc, #doc, #ignore!, #ignored?, severity, #severity, #to_s, #unignore!
Methods included from JsonHelpers
Constructor Details
#initialize(max_length: 200) ⇒ TemplateLength
Returns a new instance of TemplateLength.
7 8 9 |
# File 'lib/theme_check/checks/template_length.rb', line 7 def initialize(max_length: 200) @max_length = max_length end |
Instance Method Details
#on_document(node) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/theme_check/checks/template_length.rb', line 11 def on_document(node) lines = node.template.source.count("\n") if lines > @max_length add_offense("Template has too many lines [#{lines}/#{@max_length}]", template: node.template) end end |