Class: HamlLint::Linter::ViewLength

Inherits:
HamlLint::Linter show all
Includes:
HamlLint::LinterRegistry
Defined in:
lib/haml_lint/linter/view_length.rb

Overview

Detects overly long views.

Defined Under Namespace

Classes: DummyNode

Constant Summary collapse

MSG =
'View template is too long [%d/%d]'

Instance Attribute Summary

Attributes inherited from HamlLint::Linter

#lints

Instance Method Summary collapse

Methods included from HamlLint::LinterRegistry

extract_linters_from, included

Methods inherited from HamlLint::Linter

#initialize, #name, #run

Methods included from HamlVisitor

#visit, #visit_children

Constructor Details

This class inherits a constructor from HamlLint::Linter

Instance Method Details

#visit_root(root) ⇒ Object


12
13
14
15
16
17
18
19
20
# File 'lib/haml_lint/linter/view_length.rb', line 12

def visit_root(root)
  max = config['max']
  line_count = document.source_lines.count
  node = root.children.first

  if line_count > max && !node.disabled?(self)
    record_lint(DummyNode.new(0), format(MSG, line_count, max))
  end
end