Class: RuboCop::Cop::Chef::ChefModernize::Definitions
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefModernize::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, commmon 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.'.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
#on_block(node) ⇒ Object
28 29 30 |
# File 'lib/rubocop/cop/chef/modernize/definitions.rb', line 28 def on_block(node) add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.respond_to?(:method_name) && node.method_name == :define end |