Class: HamlLint::Linter::ConsecutiveComments

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

Overview

Checks for multiple lines of code comments that can be condensed.

Constant Summary collapse

COMMENT_DETECTOR =
->(child) { child.type == :haml_comment }

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

Methods included from HamlVisitor

#visit, #visit_children

Constructor Details

This class inherits a constructor from HamlLint::Linter

Instance Method Details

#visit_root(node) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/haml_lint/linter/consecutive_comments.rb', line 8

def visit_root(node)
  HamlLint::Utils.for_consecutive_items(
    node.children,
    COMMENT_DETECTOR,
  ) do |group|
    record_lint(group.first,
                "#{group.count} consecutive comments can be merged into one")
  end
end