Cookstyle 5.21 is now available on Rubygems. This release includes 4 new Chef cops as well as a large number of improvements to existing cops.
4 New Cops
ChefStyle/UnnecessaryOSCheck cop checks cookbooks that use
node['os'] to check the operating system of a node, when they could instead use the
platform_family?() helper. All values of
os from Ohai match one-to-one with
platform_family values, except for
linux which has no single equivalent
ChefModernize/SimplifyAptPpaSetup cop detects
apt_repository resources that setup Ubuntu PPAs by using their full URL. For example,
http://ppa.launchpad.net/webupd8team/atom/ubuntu can be simplified to just
ChefRedundantCode/StringPropertyWithNilDefault cop detects String type resource properties that set their default value to
nil. All String type properties default to
nil so this does not need to be set.
ChefRedundantCode/PropertySplatRegex cop detects String type resource properties that validate their input with a regex of
/.*/. This regex will match on any String value and is not necessary.
Other fixes and changes
ChefDeprecations/IncludingYumDNFCompatRecipewill now remove any inline conditionals around the
include_recipestatement during autocorrection so that it does not leave behind invalid Ruby.
ChefDeprecations/WindowsTaskChangeActionwill no longer fail when the action value is not a String type value.
ChefSharing/InvalidLicenseStringwill not autocorrect
Layout/DefEndAlignmentnow have autocorrection enabled to eliminate the need for manually fixing indentation in cookbooks.
ChefStyle/UsePlatformHelpersnow detects and autocorrects
Style/ModuleFunctioncop has been disabled because this caused library helpers to fail to load.
- All metadata cops now properly autocorrect legacy metadata that included HEREDOCs.
TargetRubyVersionis now set to 2.3 to match the version of Ruby that shipped in Chef Infra Client 12. This config value is used to enable/disable cops and autocorrection that may break Ruby code in these older Chef Infra Client releases. If you are on a later release of Chef Infra Client, you can set this value to Ruby 2.6 to enable additional cops and autocorrection.