Sha256: 8276d32171990ca224f9ac98db36654ec2349cbdd0c645cdab80390591380640

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

PuppetLint.new_check(:resource_reference_with_unquoted_title) do
  def check
    resource_indexes.each do |resource|
      resource[:param_tokens].select { |param_token|
        ['require', 'subscribe', 'notify', 'before', 'consume', 'export'].include? param_token.value
      }.each do |param_token|
        value_token = param_token.next_code_token
        check = value_token.next_token
        until resource[:param_tokens].include? check or not resource[:tokens].include? check or check.nil?
          case value_token.next_token.type
          when :CLASSREF
            begin
              if value_token.next_token.next_token.type == :LBRACK
                check_token = value_token.next_token.next_token.next_token
                if check_token.type == :NAME
                  notify :error, {
                    :message => 'unquoted title in resource reference',
                    :line    => check_token.line,
                    :column  => check_token.column,
                    :token   => check_token,
                  }
                end
              end
              value_token = value_token.next_token
              check = value_token.next_token
            end
          else
            value_token = value_token.next_token
            check = value_token.next_token
          end
        end
      end
    end
  end

  def fix(problem)
    problem[:token].type = :SSTRING
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-lint-resource_reference_syntax-1.2.0 lib/puppet-lint/plugins/resource_reference_with_unquoted_title.rb
puppet-lint-resource_reference_syntax-1.1.0 lib/puppet-lint/plugins/resource_reference_with_unquoted_title.rb