# Cookstyle 6.2.5 released with 2 new Chef cops!

**URL:** <https://discourse.chef.io/t/cookstyle-6-2-5-released-with-2-new-chef-cops/16886>\
**Category:** Chef Release Announcements\
**Created:** [April 3, 2020, 11:10pm UTC](https://discourse.chef.io/t/cookstyle-6-2-5-released-with-2-new-chef-cops/16886 "2020-04-03T23:10:54Z")\
**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:** [April 3, 2020, 11:10pm UTC](https://discourse.chef.io/t/cookstyle-6-2-5-released-with-2-new-chef-cops/16886/1 "2020-04-03T23:10:54Z")

</div>

Hey everyone,

It's time for the weekly release of Cookstyle. This release brings an updated Rubocop engine, improvements for prepping cookbooks for new Chef Infra Client releases, and new cops.

### 2 New Cops

#### ChefRedundantCode/UseCreateIfMissing

The `ChefRedundantCode/UseCreateIfMissing` cop detects file, cookbook\_file, template, and remote\_file resources that contain a not\_if conditional check used to check that the file they manage is already present on disk. These complex conditionals can be removed by changing the action from `:create` to `:create_if_missing`.

Overly complex conditional check:

```ruby
file '/etc/some/config' do
  content 'value = true'
  only_if { ::File.exist?('/etc/some/config') }
end

```

:create\_if\_missing action usage:

```ruby
file '/etc/some/config' do
  content 'value = true'
  action :create_if_missing
end

```

`Enabled by default`: True

`Autocorrects`: Yes

#### ChefStyle/NegatingOnlyIf

The `ChefStyle/NegatingOnlyIf` cop detects resources that use an only\_if to run Ruby code that is then negated using Ruby's logical NOT operator (!). This conditional will be autocorrected to use not\_if without the operator instead.

only\_if with negated ruby:

```ruby
package 'legacy-sysv-deps' do
  only_if { !is_something_true? }
end

```

not\_if without the negated ruby:

```ruby
package 'legacy-sysv-deps' do
  not_if { is_something_true? }
end

```

`Enabled by default`: True

`Autocorrects`: Yes

### RuboCop 0.81

The RuboCop engine that powers Cookstyle has been updated from 0.80.1 to 0.81.0 which includes a large number of fixes for bugs encountered during cookbook testing. This release also includes support for new Ruby syntax, introduced in Ruby 2.7, which will ship in Chef Infra Client 16.

### Other Changes

- The `ChefCorrectness/IncorrectLibraryInjection` no longer incorrectly autocorrects libraries that send to the `Chef::DSL::Resource` class.
- `TargetChefVersion` support in the .rubocop.yml config has been added to five of the `ChefDeprecation` cops. This will make it easier to move from legacy versions of Chef Infra Client without jumping right to the latest releases.

Enjoy,  
Tim
