class HamlLint::Linter::ConsecutiveSilentScripts
Checks for multiple consecutive silent script markers that could be condensed into a :ruby filter block.
Constants
- SILENT_SCRIPT_DETECTOR
Public Instance Methods
visit_silent_script(node)
click to toggle source
# File lib/haml_lint/linter/consecutive_silent_scripts.rb, line 13 def visit_silent_script(node) return if previously_reported?(node) HamlLint::Utils.for_consecutive_items( possible_group(node), SILENT_SCRIPT_DETECTOR, config['max_consecutive'] + 1, ) do |group| record_lint(group.first, "#{group.count} consecutive Ruby scripts can be merged " \ 'into a single `:ruby` filter') end end
Private Instance Methods
possible_group(node)
click to toggle source
# File lib/haml_lint/linter/consecutive_silent_scripts.rb, line 29 def possible_group(node) node.subsequents.unshift(node) end
previously_reported?(node)
click to toggle source
# File lib/haml_lint/linter/consecutive_silent_scripts.rb, line 33 def previously_reported?(node) reported_nodes.include?(node) end
reported_nodes()
click to toggle source
# File lib/haml_lint/linter/consecutive_silent_scripts.rb, line 37 def reported_nodes @reported_nodes ||= [] end