Class: HamlLint::Linter::MultilinePipe

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

Overview

Checks for uses of the multiline pipe character.

Constant Summary collapse

MESSAGE =
"Don't use the `|` character to split up lines. " \
'Wrap on commas or extract code into helper.'

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_plain(node) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/haml_lint/linter/multiline_pipe.rb', line 23

def visit_plain(node)
  line = line_text_for_node(node)

  # Plain text nodes are allowed to consist of a single pipe
  return if line.strip == '|'

  record_lint(node, MESSAGE) if line.match(MULTILINE_PIPE_REGEX)
end

#visit_script(node) ⇒ Object



15
16
17
# File 'lib/haml_lint/linter/multiline_pipe.rb', line 15

def visit_script(node)
  check(node)
end

#visit_silent_script(node) ⇒ Object



19
20
21
# File 'lib/haml_lint/linter/multiline_pipe.rb', line 19

def visit_silent_script(node)
  check(node)
end

#visit_tag(node) ⇒ Object



11
12
13
# File 'lib/haml_lint/linter/multiline_pipe.rb', line 11

def visit_tag(node)
  check(node)
end