Sha256: 0d6c869afebc27cc55c9ee9a5039575e1cf8bf015cc9b5c308a9feb34fa4d0ba

Contents?: true

Size: 920 Bytes

Versions: 27

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

PuppetLint.new_check(:manifest_whitespace_two_empty_lines) do
  def check
    tokens.select { |token| token.type == :NEWLINE }.each do |token|
      prev_newline = token.prev_token_of(:NEWLINE)
      next unless prev_newline

      prev_newline = prev_newline.prev_token_of(:NEWLINE)
      next unless prev_newline

      good_to_go = true
      tokens.index(prev_newline).upto(tokens.index(token)).each do |between_token_idx|
        unless %i[NEWLINE WHITESPACE INDENT].include?(tokens[between_token_idx].type)
          good_to_go = false
          break
        end
      end
      next unless good_to_go

      notify(
        :error,
        message: 'there should be no two consecutive empty lines',
        line: token.line,
        column: token.column,
        token: token,
      )
    end
  end

  def fix(problem)
    token = problem[:token]
    remove_token(token)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
puppet-lint-manifest_whitespace-check-0.3.0 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.9 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.8 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.7 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.6 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.5 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.4 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.3 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.2 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.1 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.2.0 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.1.17 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.1.16 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.1.15 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.1.14 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.1.13 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.1.12 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.1.11 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.1.10 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb
puppet-lint-manifest_whitespace-check-0.1.9 lib/puppet-lint/plugins/check_manifest_whitespace_empty_lines.rb