class HamlLint::Linter::MultilineScript
Checks scripts spread over multiple lines.
Constants
- SPLIT_OPERATORS
List of operators that can split a script into two lines that we want to alert on.
Public Instance Methods
visit_script(node)
click to toggle source
# File lib/haml_lint/linter/multiline_script.rb, line 25 def visit_script(node) check(node) end
visit_silent_script(node)
click to toggle source
# File lib/haml_lint/linter/multiline_script.rb, line 29 def visit_silent_script(node) check(node) end
Private Instance Methods
check(node)
click to toggle source
# File lib/haml_lint/linter/multiline_script.rb, line 35 def check(node) # Condition occurs when scripts do not contain nested content, e.g. # # - if condition || <-- no children; its sibling is a continuation # - other_condition # # ...whereas when it contains nested content it's not a multiline script: # # - begin <-- has children # some_helper # - rescue # An error occurred return unless node.children.empty? operator = node.script[/\s+(\S+)\z/, 1] if SPLIT_OPERATORS.include?(operator) record_lint(node, "Script with trailing operator `#{operator}` should be " \ 'merged with the script on the following line') end end