Chef 13 Upgrade: Rubocop Changes for Word Array Literals (%w)

Featured image for sharing metadata for article
As part of an upgrade from Chef 12 to Chef 13, this is one of the posts in which I've been detailing the issues I've encountered, and how I've resolved them .

One recommended change with the new version of Rubocop is the error %w-literals should be delimited by [ and ].

For instance:

-arr = %w(this is an array)
+arr = %w[this is an array]

For most cases, you will be able to perform one of the following commands:

# use Rubocop's automagic autocorrect, if possible
rubocop --auto-correct
# or fall back to a search and replace
find . -iname "*.rb" -exec sed -i 's/%w(\([^)]*\))/%w[\1]/g' {} \;

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #chef-13-upgrade #chef-13-upgrade-rubocop #chef #rubocop #chef-13 #rubocop-0-49.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.