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 06 March 2018, and last updated on 03 April 2018.