Refactoring code by gem 'Rubocop'