Sha256: 576716d09b070d1014fcfaa754cfda067b8de83ad62b8e07aee70a8effef7837
Contents?: true
Size: 1019 Bytes
Versions: 1
Compression:
Stored size: 1019 Bytes
Contents
module SlimLint # Searches for more than an allowed number of consecutive control code # statements that could be condensed into a :ruby filter. class Linter::ConsecutiveControlStatements < Linter include LinterRegistry on [:multi] do |sexp| Utils.for_consecutive_items(sexp, method(:code_sexp?), config['max_consecutive'] + 1) do |group| report_lint(group.first, "#{group.count} consecutive control statements can be " \ 'merged into a single `ruby:` filter') end end private # Returns whether the given Sexp is a :code abstraction. # # @param sexp [SlimLint::Sexp] # @return [Boolean] def code_sexp?(sexp) # TODO: Switch this with a built-in method on the {Sexp} object itself sexp.is_a?(Sexp) && sexp.match?([:slim, :control]) end def newline_sexp?(sexp) sexp.is_a?(Sexp) && sexp.first == :newline end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slim_lint-0.2.0 | lib/slim_lint/linter/consecutive_control_statements.rb |