Class: RuboCop::Cop::Chef::Modernize::Definitions
- Includes:
- RuboCop::Chef::CookbookHelpers
- Defined in:
- lib/rubocop/cop/chef/modernize/definitions.rb
Overview
In 2016 with Chef Infra Client 12.5 Custom Resources were introduced as a way of writing reusable resource code that could be shipped in cookbooks. Custom Resources offer many advantages of legacy Definitions including unit testing with ChefSpec, input validation, actions, common properties like not_if/only_if, and resource reporting.
Constant Summary collapse
- MSG =
'Legacy Chef Infra definitions should be rewritten as custom resources to take full advantage of the Chef Infra feature set.'
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
Methods inherited from Base
Instance Method Details
#on_block(node) ⇒ Object
29 30 31 |
# File 'lib/rubocop/cop/chef/modernize/definitions.rb', line 29 def on_block(node) add_offense(node, severity: :refactor) if node.respond_to?(:method_name) && node.method?(:define) end |