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

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

Instance Attribute Summary

Attributes inherited from HamlLint::Linter

#lints, #parser

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


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

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