Skip to main content

Chef/RedundantCode/OhaiAttributeToString

Cookstyle cops page

The Cookstyle cops department: Chef/RedundantCode

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYesAll Versions

Many Ohai node attributes are already strings and don’t need to be cast to strings again

Examples

incorrect

node['platform'].to_s
node['platform_family'].to_s
node['platform_version'].to_s
node['fqdn'].to_s
node['hostname'].to_s
node['os'].to_s
node['name'].to_s

correct

node['platform']
node['platform_family']
node['platform_version']
node['fqdn']
node['hostname']
node['os']
node['name']

Configurable attributes

NameDefault valueConfigurable values
Version Added6.10.0String
Include
    Array

    Thank you for your feedback!

    ×









    Search Results