Sha256: e2ca6208b23b6a8a139f0a862a5f50aac2d8a9fe8259a80c228de54cfcdd3e2a

Contents?: true

Size: 849 Bytes

Versions: 25

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

PuppetLint.new_check(:manifest_whitespace_inherits_name_single_space_before) do
  def check
    tokens.select { |token| token.type == :INHERITS }.each do |inherits_token|
      name_token = inherits_token.next_token_of(%i[NAME FUNCTION_NAME])
      next unless name_token

      next_token = inherits_token.next_token
      next unless tokens.index(name_token) != tokens.index(inherits_token) + 2 ||
                  !is_single_space(next_token)

      notify(
        :error,
        message: 'there should be a single space between the inherits statement and the name',
        line: next_token.line,
        column: next_token.column,
        token: next_token,
      )
    end
  end

  def fix(problem)
    raise PuppetLint::NoFix if problem[:token].type != :WHITESPACE

    problem[:token].value = ' '
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

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