Class: HamlLint::Linter::TrailingWhitespace

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

Overview

Checks for trailing whitespace.

Defined Under Namespace

Classes: DummyNode

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, #run_or_raise, supports_autocorrect?, #supports_autocorrect?

Methods included from HamlVisitor

#visit, #visit_children

Constructor Details

This class inherits a constructor from HamlLint::Linter

Instance Method Details

#visit_root(root) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/haml_lint/linter/trailing_whitespace.rb', line 10

def visit_root(root)
  document.source_lines.each_with_index do |line, index|
    next unless line =~ /\s+$/

    node = root.node_for_line(index + 1)
    unless node.disabled?(self)
      record_lint DummyNode.new(index + 1), 'Line contains trailing whitespace'
    end
  end
end