Skip to main content

LazyEvalNodeAttributeDefaults

The department is: LazyEvalNodeAttributeDefaults

The full name of the cop is: Chef/Correctness/LazyEvalNodeAttributeDefaults

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYesAll Versions

When setting a node attribute as the default value for a custom resource property, wrap the node attribute in lazy {} so that its value is available when the resource executes.

Examples

incorrect

property :Something, String, default: node['hostname']

correct

property :Something, String, default: lazy { node['hostname'] }

Configurable attributes

NameDefault valueConfigurable values
Version Added6.6.0String
Include
  • **/libraries/*.rb
  • **/resources/*.rb
Array

Thank you for your feedback!

×









Search Results