Skip to main content

Chef/Style/UsePlatformHelpers

Cookstyle cops page

The Cookstyle cops department: Chef/Style

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYesAll Versions

Use the platform?() and platform_family?() helpers instead of node[‘platform] == ‘foo’ and node[‘platform_family’] == ‘bar’. These helpers are easier to read and can accept multiple platform arguments, which greatly simplifies complex platform logic.

Examples

incorrect

node['platform'] == 'ubuntu'
node['platform_family'] == 'debian'
node['platform'] != 'ubuntu'
node['platform_family'] != 'debian'
%w(rhel suse).include?(node['platform_family'])
node['platform'].eql?('ubuntu')

correct

platform?('ubuntu')
!platform?('ubuntu')
platform_family?('debian')
!platform_family?('debian')
platform_family?('rhel', 'suse')

Configurable attributes

NameDefault valueConfigurable values
Version Added5.6.0String
Include
    Array

    Thank you for your feedback!

    ×










    Search Results