Class: HamlLint::Linter::MultilineScript

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

Overview

Checks scripts spread over multiple lines.

Constant Summary collapse

SPLIT_OPERATORS =

List of operators that can split a script into two lines that we want to alert on.

%w[
  || or && and
  ||= &&=
  ^ << >> | &
  <<= >>= |= &=
  + - * / ** %
  += -= *= /= **= %=
  < <= <=> >= >
  = == === != =~ !~
  .. ...
  ? :
  not
  if unless while until
  begin
].to_set

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

autocorrect_priority, autocorrect_safe?, #initialize, #name, ruby_parser, #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

#after_visit_root(node) ⇒ Object



37
38
39
40
41
42
# File 'lib/haml_lint/linter/multiline_script.rb', line 37

def after_visit_root(node)
  super
  return if merges.empty?

  apply_autocorrect(merged_source)
end

#visit_script(node) ⇒ Object



29
30
31
# File 'lib/haml_lint/linter/multiline_script.rb', line 29

def visit_script(node)
  check(node)
end

#visit_silent_script(node) ⇒ Object



33
34
35
# File 'lib/haml_lint/linter/multiline_script.rb', line 33

def visit_silent_script(node)
  check(node)
end