Class: RuboCop::Cop::Chef::ChefDeprecations::VerifyPropertyUsesFileExpansion
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefDeprecations::VerifyPropertyUsesFileExpansion
- Includes:
- RuboCop::Chef::CookbookHelpers
- Defined in:
- lib/rubocop/cop/chef/deprecation/verify_property_file_expansion.rb
Overview
In Chef Infra Client 13 the “file” variable for use within the verify property was replaced with the “path” variable.
Constant Summary collapse
- MSG =
"Use the 'path' variable in the verify property and not the 'file' variable which was removed in Chef Infra Client 13.".freeze
Instance Method Summary collapse
Methods included from RuboCop::Chef::CookbookHelpers
#match_property_in_resource?, #match_resource_type?, #method_arg_ast_to_string, #resource_block_name_if_string
Instance Method Details
#autocorrect(node) ⇒ Object
46 47 48 49 50 |
# File 'lib/rubocop/cop/chef/deprecation/verify_property_file_expansion.rb', line 46 def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.expression, node.loc.expression.source.gsub('%{file}', '%{path}')) end end |
#on_block(node) ⇒ Object
40 41 42 43 44 |
# File 'lib/rubocop/cop/chef/deprecation/verify_property_file_expansion.rb', line 40 def on_block(node) match_property_in_resource?(nil, 'verify', node) do |verify| add_offense(verify, location: :expression, message: MSG, severity: :refactor) if verify.source.match?(/%{file}/) end end |