Sha256: dc46dcb6aaf776f8656da7376699f2068452a4dcefd7882c069a9003d5525a8d

Contents?: true

Size: 779 Bytes

Versions: 19

Compression:

Stored size: 779 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(:flat_control_statement?),
                                  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

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
slim_lint-0.15.1 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.15.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.14.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.13.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.12.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.11.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.10.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.9.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.8.3 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.8.2 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.8.1 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.8.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.7.2 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.7.1 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.7.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.6.1 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.6.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.5.0 lib/slim_lint/linter/consecutive_control_statements.rb
slim_lint-0.4.0 lib/slim_lint/linter/consecutive_control_statements.rb