Skip to main content

Chef/Modernize/RespondToInMetadata

Cookstyle cops page

The Cookstyle cops department: Chef/Modernize

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYes12.15+

It is not longer necessary respond_to?(:foo) or defined?(foo) in metadata. This was used to support new metadata methods in Chef 11 and early versions of Chef 12.

Examples

incorrect

chef_version '>= 13' if respond_to?(:chef_version)
chef_version '>= 13' if defined?(chef_version)
chef_version '>= 13' unless defined?(Ridley::Chef::Cookbook::Metadata)
if defined(chef_version)
  chef_version '>= 13'
end

correct

chef_version '>= 13'

Configurable attributes

NameDefault valueConfigurable values
Version Added5.2.0String
Include
  • **/metadata.rb
Array

Thank you for your feedback!

×










Search Results