Skip to main content

SetOrReturnInResources

The department is: SetOrReturnInResources

The full name of the cop is: Chef/Modernize/SetOrReturnInResources

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNoAll Versions

set_or_return within a method should not be used to define property in a resource. Instead use the property method which properly validates and defines properties in a way that works with reporting and documentation functionality in Chef Infra Client

Examples

incorrect

 def severity(arg = nil)
   set_or_return(
     :severity, arg,
     :kind_of => String,
     :default => nil
   )
 end

correct

property :severity, String

Configurable attributes

NameDefault valueConfigurable values
Version Added5.2.0String
Include
  • **/resources/*.rb
  • **/libraries/*.rb
Array

Thank you for your feedback!

×









Search Results