Chef/Style/UnnecessaryOSCheck
The Cookstyle cops department: Chef/Style
| Enabled by default | Supports autocorrection | Target Chef Version |
|---|---|---|
| Enabled | Yes | All Versions |
Use the platform_family?() helpers instead of node[‘os] == ‘foo’ for platform_families that match one-to-one with OS values. These helpers are easier to read and can accept multiple platform arguments, which greatly simplifies complex platform logic. All values of os from Ohai match one-to-one with platform_family values except for linux, which has no single equivalent platform_family.
Examples
incorrect
node['os'] == 'darwin'
node['os'] == 'windows'
node['os'].eql?('aix')
%w(netbsd openbsd freebsd).include?(node['os'])
correct
platform_family?('mac_os_x')
platform_family?('windows')
platform_family?('aix')
platform_family?('netbsd', 'openbsd', 'freebsd)
Configurable attributes
| Name | Default value | Configurable values |
|---|---|---|
| Version Added | 5.21.0 | String |
| Include | Array |