Sha256: 1654bb8798960f0c3206bf99f6e391f35e30503da1e9f63bf43fcbaad33d991b

Contents?: true

Size: 738 Bytes

Versions: 5

Compression:

Stored size: 738 Bytes

Contents

# frozen_string_literal: true

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|
      max = config["max_consecutive"] + 1
      Utils.for_consecutive_items(sexp, method(:flat_control_statement?), max) do |group|
        report_lint(
          group.first,
          "#{group.count} consecutive control statements can be " \
          "merged into a single `ruby:` filter"
        )
      end
    end

    private

    def flat_control_statement?(sexp)
      sexp.match?([:slim, :control]) && sexp[3] == [:multi]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slim_lint_standard-0.0.2.2 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint_standard-0.0.2.1 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint_standard-0.0.2 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint_standard-0.0.1 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint_standard-0.0.0 lib/slim_lint/linter/consecutive_control_statements.rb