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

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 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.

Categories:

Tags:

Other posts you may be interested in:

Interactions with this post

This post has had 0 WebMention interactions, as of Sun, 24 Mar 2019 13:54:27 +0000.

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