Skip to main content

Chef/Correctness/LazyEvalNodeAttributeDefaults

Cookstyle cops page

The Cookstyle cops department: Chef/Correctness

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