Skip to main content

OhaiAttributeToString

The department is: OhaiAttributeToString

The full name of the cop is: Chef/RedundantCode/OhaiAttributeToString

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYesAll Versions

Many Ohai node attributes are already strings and do not 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

    Was this page helpful?

    ×









    Search Results