class RuboCop::Cop::Chef::Deprecations::VerifyPropertyUsesFileExpansion

In Chef Infra Client 13 the “file” variable for use within the verify property was replaced with the “path” variable.

@example

#### incorrect
file '/etc/nginx.conf' do
  verify 'nginx -t -c %{file}'
end

#### correct
file '/etc/nginx.conf' do
  verify 'nginx -t -c %{path}'
end

Constants

MSG

Public Instance Methods

on_block(node) click to toggle source
# File lib/rubocop/cop/chef/deprecation/verify_property_file_expansion.rb, line 45
def on_block(node)
  match_property_in_resource?(nil, 'verify', node) do |verify|
    return unless verify.source.match?(/%{file}/)
    add_offense(verify, severity: :warning) do |corrector|
      corrector.replace(verify.loc.expression, verify.loc.expression.source.gsub('%{file}', '%{path}'))
    end
  end
end