# Cookstyle 5.21 released with 4 new Chef cops!

**URL:** <https://discourse.chef.io/t/cookstyle-5-21-released-with-4-new-chef-cops/16709>\
**Category:** Chef Release Announcements\
**Created:** [February 19, 2020, 9:26pm UTC](https://discourse.chef.io/t/cookstyle-5-21-released-with-4-new-chef-cops/16709 "2020-02-19T21:26:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tas50](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/tas50/32/941_2.png) [@tas50](https://discourse.chef.io/u/tas50)\
**Post date:** [February 19, 2020, 9:26pm UTC](https://discourse.chef.io/t/cookstyle-5-21-released-with-4-new-chef-cops/16709/1 "2020-02-19T21:26:42Z")

</div>

Hey folks,

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

The `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 `plaform_family`.

#### ChefModernize/SimplifyAptPpaSetup

The `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 `ppa:webupd8team/atom`.

#### ChefRedundantCode/StringPropertyWithNilDefault

The `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

The `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/IncludingYumDNFCompatRecipe` will now remove any inline conditionals around the `include_recipe` statement during autocorrection so that it does not leave behind invalid Ruby.
- `ChefDeprecations/WindowsTaskChangeAction` will no longer fail when the action value is not a String type value.
- `ChefSharing/InvalidLicenseString` will not autocorrect `apache v2` to `Apache-2.0`.
- `Layout/EndAlignment` and `Layout/DefEndAlignment` now have autocorrection enabled to eliminate the need for manually fixing indentation in cookbooks.
- `ChefStyle/UsePlatformHelpers` now detects and autocorrects `node['platform'].eql?()` usage.
- `Style/ModuleFunction` cop has been disabled because this caused library helpers to fail to load.
- All metadata cops now properly autocorrect legacy metadata that included HEREDOCs.
- The `TargetRubyVersion` is 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.

Enjoy,  
Tim
