Chef/Modernize/DefaultActionFromInitialize
The Cookstyle cops department: Chef/Modernize
Enabled by default | Supports autocorrection | Target Chef Version |
---|---|---|
Enabled | Yes | All Versions |
The default actions can now be specified using the default_action
helper instead of using the @action variable in the resource provider initialize method. In general we recommend against writing HWRPs, but if HWRPs are necessary you should utilize as much of the resource DSL as possible.
correct
default_action :create
Examples
incorrect
def initialize(*args)
super
@action = :create
end
### incorrect
```ruby
def initialize(*args)
super
@default_action = :create
end
Configurable attributes
Name | Default value | Configurable values |
---|---|---|
Version Added | 5.10.0 | String |
Include |
| Array |