Class: RuboCop::Cop::Chef::ChefCorrectness::PropertyWithRequiredAndDefault
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefCorrectness::PropertyWithRequiredAndDefault
- Defined in:
- lib/rubocop/cop/chef/correctness/property_with_default_and_required.rb
Overview
When using properties in a custom resource you shouldn’t set a property to required and then provide a default value. If a property is required the user will always pass in a value and the default will never be used. In Chef Infra Client 13+ this became an error.
Constant Summary collapse
- MSG =
'Resource property should not be both required and have a default value. This will fail on Chef Infra Client 13+'.freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
37 38 39 40 41 |
# File 'lib/rubocop/cop/chef/correctness/property_with_default_and_required.rb', line 37 def on_send(node) if required_property?(node) && property_has_default?(node) add_offense(node, location: :expression, message: MSG, severity: :refactor) end end |