[ci skip] Add missing utf-8 encoding comments
Fix minor rubocop warnings
Prefer find over detect
Prefer reduce over inject
Use default rubocop CollectionMethods settings
Don't shadow an outer variable inside a block