Skip to main content

OhaiAttributeToString

All Cookstyle Cops


The department is: Chef/RedundantCode

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 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
Exclude
  • **/metadata.rb
  • **/Berksfile
Array

Was this page helpful?









Search Results